﻿var change = false;
var iLastPosition, iLastState = -1;

function VPlayPause(id) 
{
	
	var MP = document.getElementById('Player0');
	if(is_FF){
		if(MP.playState==3)
			MP.controls.pause();
		else
			{MP.controls.play();}
		}
		else
		if (MP.PlayState==3) MP.controls.Pause(); else  MP.controls.Play();
}
function VStop(id)
{
	var MP = document.getElementById('Player'+id);
	if(is_FF) MP.controls.stop();
	 else MP.controls.Stop();
}

function CheckFFWMP() {
	var is_WMP;
	try{
	for ( var i in navigator.plugins ) {
		var n = navigator.plugins[i].name; //alert(n);
		if ( n != null && n.indexOf("Windows Media") >= 0 && n.indexOf("Microsoft") == 0 )
			return true;
	}
	return false;}
	catch(e){return false;}
}

var iVolume = 100;
var currWinEmbedState=false;
function getScriptHtml(id)
{
var url = 'http://www.israelnationalnews.com/exp.aspx/'+id;
return "&lt;script type=\"text/javascript\" src= \"" + url + "\"> </script>";
}

function AddZero(time) { if (time>10) return time; else return "0"+time}
function PaseTime(time){
	return Math.floor(AddZero(time/60)) + ":" + AddZero(Math.floor(time-(Math.floor(time/60))*60))
}
function UpdateMP(id) {
	try{
	MP = document.getElementById('Player'+id);

	var iCurrState = MP.playState;
	var iCurrPosition = MP.controls.currentPosition;
	if (!!MP.currentMedia) {
	    var iCurrDuration = MP.currentMedia.duration;
	}
	if (iLastState != iCurrState) {
	    if (iCurrState == 1 || iCurrState == 10 || iCurrState == 8) {
	        if (iLastPosition + 1.2 > iCurrDuration) {
	            change = true;
	        }
	    }

	}
	iLastState = iCurrState;
	iLastPosition = iCurrPosition;

	ReplaceUrl(0);


	if(MP.playState==2||MP.playState==3)
		{
		    iPos = Math.floor((iCurrPosition / iCurrDuration) * 100 + 0.999999999) + 1
		
		for (i=iPos;i<101;i++)	document.getElementById('pos'+id+'-'+ i).style.backgroundColor ='white';
		for (i=1;i<iPos;i++) document.getElementById('pos'+id+'-' + i).style.backgroundColor ='#4A80A6';
		MP.style.width='319px';MP.style.height='304px';
	} ;
	if (MP.playState == 3) x = "pause"; else x = "play";
	
	document.getElementById("VPlay"+id).firstChild.src="/images/tv/"+x+".gif";
	document.getElementById("VMarker"+id).innerHTML = MP.controls.currentPositionString;
	document.getElementById("VLen"+id).innerHTML = MP.currentMedia.durationString;
	}catch(e){}
}

function ChangePos(id,value)
{
    if (isInfo) return false;
 	MP =document.getElementById("Player"+id); 
 	MP.controls.currentPosition=MP.currentMedia.duration*(value/100); 
 	UpdateMP(id); 
}

function ChangeVolume(id,value) {if (value>49) return false;
iVolume=value*2
 document.getElementById('Player'+id).settings.volume=iVolume;
 for (i=value;i<50;i++)
	document.getElementById('volume'+id+'-' + i).style.backgroundColor ='';
 for (i=1;i<value;i++)
	document.getElementById('volume'+id+'-' + i).style.backgroundColor ='#4A80A6';
}
function FullScreen(id)
{	MP =document.getElementById("Player"+id);
	if (MP.playState == 3 || MP.playState == 2 || MP.playState == 6) 
		MP.fullScreen = true;
}


function IsLoad(id)
{	//if(navigator.userAgent.indexOf("MSIE")==-1) return false;
	var ps = document.getElementById('Player'+id).playState;
	if(ps<=2||ps==10) {document.getElementById('videoout').style.visibility='hidden'; document.getElementById('divLoading'+id).style.display="none";} else {
	if(ps==9||ps==6||ps==7) {document.getElementById('divLoading'+id).style.display="";  document.getElementById('divLoading'+id).innerHTML = 'Loading...'; document.getElementById('Player0').style.visibility='';}
	else {
	 document.getElementById('divLoading'+id).style.display="none"; document.getElementById('videoout').style.visibility='visible';}}
}

function fA (id) {if(!toPlay){return;} if (aVI[id] && aVI[id].Url) {document.getElementById('Player'+id).URL='mms://media.israelnn.com/inntv-eng/'+aVI[id].Url; aVI[id].AdIn=true;document.getElementById('divVideoAd'+id).innerHTML=aVI[id].HTML;}
	else {document.getElementById("Player"+id).URL = Elements[id][2]; aVI[id].AdIn = false;}}

function onDone()
{
		  try {
		    if (document.getElementById('Player0').playState==8) 
		      if (iActive<(aList.length-1)) 
		        window.setTimeout("RemoveVideo(iActive)",1000);} 
		  catch(e){}
}
function ReplaceUrl(id) 
{
 try {IsLoad(id) } catch(e) {}
var playstate=document.getElementById("Player"+id).playState;
	if ((playstate==8||(playstate==1&&change))&&isInfo)
	{change=false;
		document.getElementById("Img").innerHTML = aVI[id].Img;
		aVI[id].AdIn = false;
		isInfo = false;
		if(sCountry=="IL") whatNeedPlay= whatNeedPlay.replace("msmedia","media");
		document.getElementById("Player"+id).URL = whatNeedPlay
		setTimeout("try {document.getElementById('Player"+id+"').controls.Play()} catch(e) {document.getElementById('Player"+id+"').controls.play();}",1000);
	}
	else {
	    try {
	        if (playstate == 8 || (playstate == 1 && change)) {
	            change = false;
	            if (iActive < (aList.length - 1))
	                window.setTimeout("RemoveVideo(iActive)", 1000);
	        }
	    }
	    catch (e) { alert(e); }

	}
}

function VideoElement() {
	var ElementId=0,sVideoURL='',iVideoImage=0,sCurrVideoCode=0,sVideoTitle='';
	Elements = new Array();
	var id =Elements.length;
	aVI[0] = new Array();
	if(id==0)
	    {aVI[id].AdIn = true;isInfo=true;}
	else
		{aVI[id].AdIn = false;isInfo=false;}
	Elements[id] = [ElementId,1,sVideoURL,iVideoImage,sCurrVideoCode];
	iShowV[id] =false;
	sPlayer = ''//<div style=color:white;><a style=color:white href='+sVideoURL+'>Click to start video</a> in external player';

	if (navigator.userAgent.indexOf("Firefox") > -1 &&!is_FF &&navigator.platform=='Win32')
	//Firefox without addon
	{sPlayer  = "<div style=color:white>Please Install Windows Media Player plugin for Firefox.<br><a target=_blank href=http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx style=color:white>Click here to install</a></div>";toPlay=false;}
	
	else if (navigator.userAgent.indexOf("Firefox") > -1 && is_FF) 
	//Firefox with addon
	{sPlayer = '<object style="z-index:10;" id=Player'+id+' width="319" height="242"  type="application/x-ms-wmp"><PARAM NAME="stretchToFit" VALUE="true" /><PARAM NAME="autoStart" VALUE="true" /><PARAM name="uiMode" value="none" /></OBJECT>'; document.getElementById("dvMP").innerHTML = sPlayer; }
	if (navigator.userAgent.indexOf("MSIE") > -1) 
	//Internet Explorer
	{sPlayer =  '<object id=Player'+id+' classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 width="319" height="304"><PARAM NAME="enableContextMenu" VALUE="false"><PARAM NAME="stretchToFit" VALUE="false"><param name=url value=""><PARAM NAME="transparentatStart" VALUE="true"><PARAM NAME="autoStart" VALUE="true"></OBJECT>'}
	

	if (sPlayer == "") location.href='Linux.aspx';

	sBG = "";
	if (iVideoImage>0) sBG = "background-image:url(/static/pictures/resized/319-239/"+Math.floor(iVideoImage/1000)+"/"+iVideoImage+".jpg)";
	if (sPlayer != "") {
	sHTML = '<div class="VideoIn" dir="ltr" unselectable="on">';
	if(sVideoTitle)
	{
	sHTML +='<div class="VideoTitle">'+sVideoTitle+'</div>';
	}
	sHTML +='<div class="VideoLoadingOut"><span style="display:none" id="divLoading'+id+'"></span></div><div id="videoout" style="width:319px;height:239px;direction:ltr;overflow:hidden;position:absolute;left:11px;top:32px;'+sBG+'">'+sPlayer+'</div><div class="VideoAdContainer" style=""><span style="float:left;font-size:12pt;color:#3e5469;text-decoration:none;font-weight:bold;">Arutz 7 Video</span><div class="VideoAd" style="float:right;" id="divVideoAd'+id+'"></div></div><br /><div style="width:302px; font-size:1px; position:absolute; top: 305px; left:21px; border: solid 1px #426E84"><span id="pos'+id+'-0" style="display:none"></span>';

	for(i=1;i<101;i++)
	{
		sHTML += "<span onClick='ChangePos("+id+"," + i + ");'  id=pos"+id+"-" + i + " style='display:-moz-inline-box;display:inline-block;width:3px;height:8px;background-color:white;'> </span>";
	}
	sHTML += '</div><br /><span class="VMarker" id="VMarker'+id+'">1</span><span class=VLen id=VLen'+id+'>2</span>\
	<div class="VPlay" id="VPlay'+id+'" onclick="VPlayPause('+id+');"><img src=/images/invideo2/aplay.png /></div>\
	<span class="VStop" onclick="VStop('+id+');">&nbsp;</span>\
	<span class="VMute" onclick="document.getElementById(\'Player'+id+'\').settings.mute=document.getElementById(\'Player'+id+'\').settings.mute==true?false:true;">&nbsp;</span>\
	<span class="VFS"   onclick="FullScreen('+id+')"></span>\
	<span class="VMinus" onclick="ChangeVolume('+id+',iVolume/2-4)">&nbsp;</span>\
	<span class="VPlus" onclick="ChangeVolume('+id+',iVolume/2+4)">&nbsp;</span>\
	<div class="VVol">';

	for(i=1;i<50;i++)
		sHTML += "<span onClick='ChangeVolume("+id+"," + i + ");' style='' id=volume"+id+"-" + i + ">&nbsp; </Span>";

	sHTML +='</div>';
	
	div = document.createElement("div");
	div.align='center';
	div.innerHTML = sHTML;
	document.getElementById('dvMP').innerHTML="";
	document.getElementById('dvMP').appendChild(div);

	//document.getElementById('Player'+id).playStateChange = IsLoad;
	if(toPlay){
	   
	   //document.getElementById('Player'+id).URL = sVideoURL;

	   IsLoad(id);
	   try 
	      {window.setInterval(function() {UpdateMP(id);},100); ChangeVolume(id,33);}
	   catch(e){}
	   s= "<SCRI"+"PT FOR=Player"+id+" event=PlayStateChange>ReplaceUrl("+id+")</SCRIPT><script FOR=Player"+id+" event=Click>if (aVI["+id+"].AdIn) {x = window.open(aVI["+id+"].Link); if (!x) location.href=aVI["+id+"].Link}</script>";
	   document.write(s);
	   document.getElementById("Player"+id).stretchToFit = false;
	}}setTimeout("ChangeVolume(0,12);",1000);	

}


function switchBtmWindow(id,toOpen)
{
    toOpen = !currWinEmbedState;
    var styleDisplayValue;
    var btn= document.getElementById('btn_embedvideo');
    var imgsrc = "newbtn ";
    if(toOpen)
        {imgsrc+='on';styleDisplayValue='block';}
    else
        {imgsrc+='';styleDisplayValue='none';}
    document.getElementById('a7_embedWin_'+id).style.display=styleDisplayValue;
    btn.className=imgsrc;
    showCurrUrl(id,Elements[id][4]);
    currWinEmbedState= !currWinEmbedState;
}
var currVideoId;
var currEmbedLast=false;
function updateEmbedSrc(isLast)
{
    var newcolor;
    if(!isLast){isLast=currVideoId;newcolor='#FFFFFF';}
    else {isLast='last';newcolor='#fbf075';}
    document.getElementById('UrlViewBox0').value=getScriptHtml(isLast).replace(/&lt;/,'<').replace(/&gt;/,'>');

document.getElementById('UrlViewBox0').style.backgroundColor=newcolor;
//setTimeout("document.getElementById('UrlViewBox0').style.backgroundColor='';",100);
}
function showCurrUrl(playerid)
{
    currEmbedLast=false;
    updateEmbedSrc(false);
    var classn='player_btn ';
    document.getElementById('btn_currvideo_0').className=classn+'on';
    document.getElementById('btn_lastvideo_0').className=classn;
}

function showLastUrl(playerid)
{
    currEmbedLast=true;
    updateEmbedSrc(true);
    var classn='player_btn ';
    document.getElementById('btn_currvideo_0').className=classn;
    document.getElementById('btn_lastvideo_0').className=classn+'on';
}
function Video(id,title,url,desc,image,visible)
{	this.id = id; this.title=title;this.desc=desc;this.url=url;this.visible=visible;this.image=image;this.inlist = false;}

function AddVideo(video)
{
	for (i==aList.length;i>iActive;i--)
		aList[i]=aList[i-1];
	aList[iActive] = video;
	SelectPlay(iActive);
	ReloadList();
}



///////////////////////////////////////////////////////////////////////
/////////////TV Code///////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
function InsertVideo(video)
{
	aList[aList.length] = video;
	ReloadList();
}

function DrawPlaylistTd(video,id)
{
	var td = document.createElement("div");
	td.className = "Video";
	td.innerHTML ="";
	sX = "<span class=spnButtonX onClick=RemoveVideo("+id+")><img src=/images/tv/x.gif></span>";
	if (iActive==id) { td.className = "Video"; td.innerHTML += "<div class=ActiveVideo>" + sX + "Now Playing</div>"}
	else if ((iActive+1)==id) td.innerHTML += "<div>" + sX + "Next Video</div>";
	else td.innerHTML += "<div>" + sX +"&nbsp;</div>";
	try{
	var currtitle=video.title;
	}catch(e){currtitle="";return td;}
	currtitle=currtitle.replace(/\"/g,"&qout;");
	td.innerHTML += "<img onclick='SelectPlay("+id+")' title=\"" + currtitle + "\" width=100 height=100 src=/static/pictures/resized/100-100/" + Math.floor(video.image/1000) + "/" +video.image + ".jpg>";
	return td;
}

function DrawTd(video,click, insClick)
{
	var td = document.createElement("div");
	var tdin = document.createElement("div");
	var tdiv = document.createElement("div");
	var divImg = document.createElement("div");
	var spanDesc = document.createElement("div");
	var divButtons = document.createElement("div");
	var spnAdd = document.createElement("span");
	var spnView =  document.createElement("span");
	tdin.className = "SecondVideo";
	td.className="SecondVideoOut";
	tdiv.className="SecondVideoIn";
	//td.onmousemove = function(){this.childNodes[2].style.visibility="";}
	//td.onmouseout = function(){this.childNodes[2].style.visibility="hidden";}
	divImg.innerHTML = "<img width=100 height=100 src=/static/pictures/resized/100-100/" + Math.floor(video.image/1000) + "/" +video.image + ".jpg><br>"
	divImg.onclick=click;
	spanDesc.innerHTML = video.title
	spanDesc.className = "Text";
	spnAdd.onclick = insClick;
	spnAdd.innerHTML ="Add"
	spnAdd.className="ViewAddDivAdd"
	spnView.onclick = click;
	spnView.innerHTML ="View"
	spnView.align="left"
	//divButtons.style.visibility = "hidden"
	divButtons.className="ViewAddDiv"
	divButtons.appendChild(spnAdd);
	divButtons.appendChild(spnView)
	tdiv.appendChild(divImg);
	tdiv.appendChild(spanDesc);
	tdiv.appendChild(divButtons);
	tdin.appendChild(tdiv);
	td.appendChild(tdin);
	return td;
}
function RemoveVideo(id)
{
	for (i=id;i<aList.length-1;i++)
		aList[i] = aList[i+1];
	aList.length--;
	if (id==iActive && iActive!=aList.length) SelectPlay(iActive);
	if (iActive>id)iActive--;
	if (aList.length==0) document.getElementById("Player0").controls.stop()
	ReloadList();
}

function ReloadList()
{
	var table = document.getElementById("tbContent");
	table.removeChild(table.firstChild);
	table.id = "tbContent";
	var tr = document.createElement("div");
	var i=0;
	for (i=0;i<aList.length;i++)
		{tr.appendChild(DrawPlaylistTd(aList[i],i));}
	table.appendChild(tr);
	tbl = document.getElementById("tblContent");
	try {tbl.removeChild(document.getElementById("tbContent"))} catch(e) {}
	tbl.appendChild(table);
}
var movedir;
var tomove=false;

function startmove(where)
{
    movedir=where;
    tomove=true;
    move(false);
}

function stopmove()
{
tomove=false;
}
function move(isClickEvent)
{

    if(!tomove){return;}
    var leng=5;

    var where=movedir;
    var obj = document.getElementById('tblContent');
    var currheight=obj.clientHeight;
    var height=318;
    var currposition=obj.style.top;
   currposition= currposition.substring(0,currposition.length-2)
    if(where=='u')
    {
        currposition= currposition-leng;
        if(currposition<(currheight-318+20)*-1 && obj.clientHeight!=0)
        { return;}
    }
    else if(where=='d')
    {
        currposition= currposition*1+leng;
        if(currposition>0){tomove=false;return;}
    }
    obj.style.top=currposition+"px";
    //if(!isClickEvent)
    setTimeout("move()",30);
}
function SelectPlay(id)
{
	iActive=id;

	/*document.getElementById("dvMP").innerHTML = */GetObjectHTML(aList[id].url);
	document.getElementById("dvContent").innerHTML = "<b>" + aList[id].title + "</b><br>" + aList[id].desc; //+ "<br><a href=/TV/?act=one&id=" + aList[id].id + ">קישור קבוע</a>"
	currVideoId=aList[id].id;
	updateEmbedSrc(currEmbedLast);
	ReloadList();
}

function GetObjectHTML(file)
{
	// החלפה_של_100_למהירות_הנדרשת.
	sURL =   file.replace(/\-[0-9]{3}\./g,'-'+iConnectionSpeed+'.');
	document.getElementById("aDown").href = sVideoDwnLink + sURL.replace("inntv","");
	var player = document.getElementById('Player0');
	
	whatNeedPlay = sVideoLink + sURL;
	if(!aVI[0].AdIn)
	{
	    player.URL=sVideoLink + sURL;
        VPlayPause(0);
    }
	//return GetMPObjectHTML(sVideoLink + sURL);
 }
 
function GetMPObjectHTML(url)
{
	if (navigator.userAgent.indexOf("MSIE") > -1)
		return '<OBJECT id=Player0 classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6  width="328" height="314"><PARAM NAME="autoStart" VALUE="true"><PARAM NAME="stretchToFit" VALUE="true"><PARAM NAME="URL" VALUE="' + url + '"></OBJECT>'
	else
		return '<EMBED ID="Player0" NAME="Player0" width="325" height="314" TYPE="application/x-mplayer2"  SRC="' + url + '"  WIDTH="400" HEIGHT="324"  AutoStart="1"  AutoSize="0" ShowStatusBar="1"  TransparentAtStart="1">'
}
function FullScreen()
{
var MediaPlayer = document.getElementById('Player0');
	if (MediaPlayer.playState == 3 || MediaPlayer.playState == 2) 
		MediaPlayer.fullScreen = true;
}

function AjaxReload(params)
{
	var scriptElem = document.createElement('script');
	scriptElem.setAttribute('src',"GetVideos.aspx?"+params);
	scriptElem.setAttribute('type','text/javascript');
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
}

function WriteDwnCell(video,id) { return DrawTd(video,function(){AddVideo(video);},function(){InsertVideo(video);});}
function WriteAll()
{
	var table = document.createElement("div");
	tr = document.createElement("div");
	var i2;
	if(Videos.length==0){SelectPage(currpage-1);return;}
	for (i2=0;i2<Videos.length;i2++)
	{
		tr.appendChild(WriteDwnCell(Videos[i2],i2));
		if (Math.floor((i2+1)/5)==(i2+1)/5)
		{
		    //table.appendChild(tr);
		   	//tr = document.createElement("tr");
		}
	}
	table.appendChild(tr);
	tbl = document.getElementById("tblAll");
	try {tbl.removeChild(tbl.childNodes[0]);} catch(e) {}
	tbl.appendChild(table);
	AjaxReload("act=cat&cat="+aCats[currcat][0]+"&page="+(currpage*1+1) +"&arrname=44");
}
var Videos44 = new Array();
function updateNextState()
{
    document.getElementById('prevspn').className="spnnextprev";
    document.getElementById('nextspn').className="spnnextprev";

    if(currpage!=0)
    {document.getElementById('prevspn').className+=" isActive";}
    if(Videos44.length!=0)
    {document.getElementById('nextspn').className+=" isActive";}
}
var aSpeeds = [100,300]
function UpdateSpeed(id,notplay)
{
	iConnectionSpeed = aSpeeds[id];
	for (i=0;i<2;i++){
	var cname="";
	if(i==id){cname="clicked";}
		document.getElementById("spnSpeed"+i).className = cname;
	}
	var scriptElem = document.createElement('script'); // עדכון
	var d = new Date()
	scriptElem.setAttribute('src',"Cookie.aspx?speed=" + id + "&time=" + d);
	scriptElem.setAttribute('type','text/javascript');
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
	if (!notplay) SelectPlay(iActive);
}

function UpdateCats() {
sHTML = "";
for (i=0;i<aCats.length;i++)
	sHTML += '<span id=spnCat'+i+' class=Category onclick=SelectCat('+i+') style=""><span class="leftTabImg">&nbsp;</span><span class="catname"><span>' + aCats[i][1] + '</span></span><span class="rightTabImg">&nbsp;</span></span>';


document.getElementById("divCats").innerHTML = sHTML;
}

function SelectCat(id)
{
	AjaxReload("act=cat&cat=" + aCats[id][0] + "&_sDate=" + new Date());
	for (i=0;i<aCats.length;i++)
			document.getElementById("spnCat"+i).className = "Category";
	
	document.getElementById("spnCat"+id).className += " Selected";
currpage=0;currcat=id;
}
function SelectPage(pageid,tonotstart)
{
document.getElementById('nextspn').style.display='';
document.getElementById('prevspn').style.display='';

	if(pageid=='n'){pageid=++currpage;}
	if(pageid=='p'){pageid=--currpage;}
	if(pageid<0){pageid=0;}
	AjaxReload("act=cat&arye=0&cat=" + aCats[currcat][0] +"&page=" + pageid + "&_sDate=" + new Date());
	for (i=0;i<aCats.length;i++)
			document.getElementById("spnCat"+i).className = "Category";
	document.getElementById("spnCat"+currcat).className = "Selected Category";
	currpage=pageid;
}
function Onload() {
	url="http://194.90.181.246/ads_array_selector_en_new.php?file=tv&zones_list=" + sZones + "&ids_list=" + sIDs
	var scriptElem = document.createElement('script');
	scriptElem.setAttribute('src',url);
	document.getElementsByTagName('head')[0].appendChild(scriptElem);
	
	}
		
	


// כל עוד עובדים בשיטה של 20 תגובות בעמוד, העתק בשינויים קלים של
// Replies.js


function ReplySendPrint(type,item,visible, first,last){
	sHTML = "<div><div  id=divNew" + item +" align=left>\
			  <div style=display:none;padding:15px id=spnNewReplySent"+item+">Thank you for sending your talkbacks to our news forum.<br><br><span class=link style=float:left OnClick=DisplayPost(false,"+item+");document.getElementById('spnNewReplySent"+item+"').style.display='none';document.getElementById('divReplyWin"+item+"').style.display=''></span><br>&nbsp;</div>\
			  <div style='width:280px;position:relative;left:-14px' id=divReplyWin" + item + ">Comments which include incitement, slander or foul language will not be published.<br><br><table style='background-color:transparent;font-weight:bold;width:280px'  cellspacing=5><tr><td>Name:</td><td><input type=text class=TextBox name=name id=NewReplyName"+item+" maxlength=20 size=16 ></td></tr><Tr><td>City:</td><td><input type=text name=city id=NewReplyCity" +item+" maxlength=15 size=16 class=TextBox></td></tr>\
			  <tr><td>Title:</td><td colspan=2 style=padding-right:20px><input type=text id=NewReplyTitle"+item+" maxlength=60 style=width:79% class=TextBox></td></tr><tr><td>Message:</td><td Colspan=2 style=padding-right:10px><textarea class=textbox name=content id=NewReplyContent" + item +" rows=6  style=width:95%></textarea></td></tr><tr><td></td><td ><input class=ReplyButton type=button onClick='SendReply("+type+","+item+","+item+");' value=Send></td><td align=left style=padding-left:40></td></tr></table></div></div></div>"
	return sHTML;
}

var sRepliesHTML = "";
var iReplies = 0;
var currpage=0;
var currcat = 0;
function SendReply(type,item,div)
{
	try {var oXH = new ActiveXObject('MSXML2.XMLHTTP');}
	catch(e) {var oXH = new XMLHttpRequest();}
	oXH.open("POST","/PostReply.aspx?type="+type+"&item="+item,true);
	// Post Data
	oXH.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	oXH.onreadystatechange = function(){SendCheckState(oXH,div)};
	sPostData = "title=" + escape(document.getElementById("NewReplyTitle"+div).value)+ "&content=" + escape(document.getElementById("NewReplyContent"+div).value)+"&name="
	sPostData += escape(document.getElementById("NewReplyName"+div).value)+"&city=" + escape(document.getElementById("NewReplyCity"+div).value);
	oXH.send(sPostData);
}

function SendCheckState(oXH,div)
{
	if (oXH.readyState != 4) 
		return false;
	if (oXH.status == 200) 
	{	document.getElementById("spnNewReplySent" + div).style.display='';
		document.getElementById("divReplyWin" + div).style.display='none';
		oXH = null;}
	else
	    alert('Error: ' + oXH.responseText);
}

function DisplayReply(id)
{
	
	div = document.getElementById("divReply" + id);
	div2 = document.getElementById("divReplyTitle" + id);
	if (div.style.display == "none")
	{	div.style.display = "";div2.style.display="none";}
	else
	{	div.style.display = "none";div2.style.display="";}
}
function DisplayPost(isMessage,div)
{	
	div = document.getElementById("divNew"+div);
	div.style.display = "";
}

function AddReply(id,title,name,city,date,content)
{
	iReplies ++
	var onclick = "DisplayReply(" + id + ")"
	if (content == "")
	{ title += " (N\"C)"; onclick = ""; }
	content = content.replace(/\n/g,"<br>")
	sRepliesHTML += "<Div class=ReplyTitle id=divReplyTitle"+id+"><Span class=RepliesLink onClick=" + onclick + ">" + title + "</span><div class=RepliesNameDate>" + name + ", " + city + " (" + date + ")</div></Div>\
	<Div id=divReply" + id + " class=\"RepliesBody\" style=display:none><div align=left><img src=/images/replies/left.gif></div><div style=margin-bottom:9px><Span class=RepliesLink onClick=" + onclick + ">" + title + "</span></div><div class=ReplyContent>" + content + "<div  style='padding-top:15px;padding-bottom:10;color:gray'>" + name + ", " + city + " (" + date + ")</div><div class=ReplyCommands><span class=link style=\"float:left;cursor:pointer;\" OnClick=DisplayReply(" + id + ")><img src=/images/replies/x.gif> Close</span><span class='Link' onclick=DisplayPost(1,0)><img src=/images/replies/reply.gif> Reply</span></div></div><img src=/images/replies/right.gif></div>"
}

function CheckReply()
{
	if (document.reply.title.value == "")
	{ alert("Title is missing"); return false; }
}

function WriteReplies(type, id)
{
	 div = "Replies";
	document.getElementById(div).innerHTML = ("<Div  class=Pdng10><div><span class=RepliesLink style=float:right;padding-right:17px onClick=\"PrintReplies(" + type + "," + id + ")\">Read All Talkbacks</span></div>\
	<input type=hidden name=NewReplyType value=" + type + "><input type=hidden id=NewReplyItem value=" + id + "><br><br><Div>" + sRepliesHTML + "</Div></div>");
}

function PrintReplies(type,id) {
	url = "/PrintReplies.aspx?type=" + type + "&id=" + id 
	w=465;h=420;
	l=(screen.width - w)/2;t=(screen.availHeight - h)/2;props = 'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=yes';
	var x = window.open(url,'',props)
}