var bRA = location.href.indexOf("News.aspx")>-1||location.href.indexOf("Blog.aspx")>-1||location.href.indexOf("aspx/Pict")>-1;

function ReplySendPrint(type,item,visible, first,last){
	if(!first)first="";if(!last)last="";
	sHTML = "<div class=ReplySendPrint id=divRepSP>" + first
	if (visible==1) sHTML += "<span class=Link onclick='DisplayPost(false,"+item+")'><img src=/images/reply.gif> Post Comment</span>&nbsp; <span class=ReplySendPrintBorder>&nbsp;</span>  &nbsp; "
	 sHTML += "<span class=Link onclick='DisplaySend(false,"+item+")'><img src=/images/email.gif> Send to Friend</span>&nbsp; <span class=ReplySendPrintBorder>&nbsp;</span>  &nbsp; <a target=_blank href=/SendMail.aspx?print=print&type=" + type +"&item=" + item + "><img src=/images/print.gif> Print Version</a> &nbsp;</a>"+last+"</div><br>\
			  <div style=text-align:right;margin-top:15px;margin-bottom:15px;text-align:center><div  class=ReplyFloatWin id=divNew" + item +" align=right style=display:none;><div class=ReplyFormTitle><div>Post Comment</div></div>\
			  <div style=display:none;padding:15px id=spnNewReplySent"+item+">Thank you for sending your comments 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=''><img src=/images/replies/x.gif> Close</span><br>&nbsp;</div>\
			  <div id=divReplyWin" + item + "><div  style=padding:15px>\
			  Comments which include incitement, slander or foul language will not be published. Read the <a target=\"_blank\" href=\"/More/Page.aspx/CommentsGuide\">site's Guidelines for Comments</a>\
			  </div><table style='background-color:transparent;font-weight:bold;' cellspacing=5><tr><td>Name:</td><td><input type=text class=TextBox name=name id=NewReplyName"+item+" maxlength=20 size=16 value=\""+sUser+"\"></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>Subject:</td><td colspan=2><input type=text id=NewReplyTitle"+item+" maxlength=80 style=width:72% class=TextBox></td></tr><tr><td>Message:</td><td Colspan=2><textarea class=textbox name=content id=NewReplyContent" + item +" rows=6  style=width:95% onKeyUp=UpdateCount('spnNewCount" +item+"',this,900);></textarea><div style=font-weight:normal><span id=spnNewCount" +item+">900</span> chars.</div></td></tr><tr><td></td><td ><input class=ReplyButton type=button onClick='SendReply("+type+","+item+","+item+");' value=Submit></td><td align=left style=padding-left:40px><input class=ReplyButton type=button onClick='DisplayPost(false,"+item+");' value=Close></td></tr></table></div></div>\
			  <div class=ReplyFloatWin id=divSend" + item +" style=display:none><div class=ReplyFormTitle><div>Send to Friend</div></div><div style=padding:15px><form method=post name=fSend action=/SendMail.aspx?action=send onsubmit=\"return sendMail();\"><input type=hidden name=type value="+type+"><input type=hidden name=item value="+item+"><table style=background-color:transparent><tr><td>Send to Email:</td><td><input type=text name=eMail2></td></tr><tr><td>Sender Name:</td><td><input type=text name=Name1></td></tr><tr><td>Sender E-Mail:</td><td><input type=text name=eMail1></td></tr><tr><td>&nbsp;</td><td><input type=submit class=ReplyButton value=Send></td></tr></table></form></div></div>\
			  </div><br><br>"
	return sHTML;
}
function ReplySendPrint2(type,item,visible, first,last){
	if(!first)first="";if(!last)last="";
	sHTML = "<div class=ReplySendPrint id=divRepSP>" + first
	if (visible == 1) sHTML += "<span class=Link onclick='DisplayPost(false," + item + ")'><img src=/images/reply.gif> Post Comment</span>&nbsp; <span class=ReplySendPrintBorder>&nbsp;</span>  &nbsp; "
	 sHTML += "<span class=Link onclick='DisplaySend(false,"+item+")'><img src=/images/email.gif> Send to Friend</span>&nbsp;";
	 if (!noprint) sHTML += "<span class=ReplySendPrintBorder>&nbsp;</span>  &nbsp;  <a target=_blank href=/SendMail.aspx?print=print&type=" + type + "&item=" + item + "><img src=/images/print.gif> Print Version</a> &nbsp;</a>" + last + "</div><br>";
	
	sHTML +="<div style=text-align:right;margin-top:15px;margin-bottom:15px;text-align:center>\
	            <div  class=ReplyFloatWin id=divNew" + item +" align=right style=display:none;>\
	                 <div class=ReplyFormTitle>\
	                    <div>Post Comment</div>\
	                </div>\
			        <div style=display:none;padding:15px id=spnNewReplySent"+item+">Thank you for sending your comments 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=''>\
<img src=/images/replies/x.gif> Close</span><br>&nbsp;\
</div>\
<div id=divReplyWin" + item + ">\
<div  style=padding:15px>Comments which include incitement, slander or foul language will not be published.</div>\
<table style='background-color:transparent;font-weight:bold;' cellspacing=5>\
<tr><td>Name:</td>\
<td><input type=text class=TextBox name=name id=NewReplyName"+item+" maxlength=20 size=16 value=\""+sUser+"\"></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>Subject:</td><td colspan=2><input type=text id=NewReplyTitle"+item+" maxlength=80 style=width:72% class=TextBox></td></tr><tr><td>Message:</td><td Colspan=2><textarea class=textbox name=content id=NewReplyContent" + item +" rows=6  style=width:95% onKeyUp=UpdateCount('spnNewCount" +item+"',this,900);></textarea><div style=font-weight:normal><span id=spnNewCount" +item+">900</span> chars.</div></td></tr><tr><td></td><td ><input class=ReplyButton type=button onClick='SendReply("+type+","+item+","+item+");' value=Submit></td><td align=left style=padding-left:40px><input class=ReplyButton type=button onClick='DisplayPost(false,"+item+");' value=Close></td></tr></table>\
			  </div></div>\
			  <div class=ReplyFloatWin id=divSend" + item +" style=display:none><div class=ReplyFormTitle><div>Send to Friend</div></div><div style=padding:15px><form method=post name=fSend action=/SendMail.aspx?action=send onsubmit=\"return sendMail();\"><input type=hidden name=type value="+type+"><input type=hidden name=item value="+item+"><table style=background-color:transparent><tr><td>Send to Email:</td><td><input type=text name=eMail2></td></tr><tr><td>Sender Name:</td><td><input type=text name=Name1></td></tr><tr><td>Sender E-Mail:</td><td><input type=text name=eMail1></td></tr><tr><td>&nbsp;</td><td><input type=submit class=ReplyButton value=Send></td></tr></table></form></div></div>\
			  </div><br><br>"
	return sHTML;
}
function ReplySend(type, item, visible, first, last) {
    if (!first) first = ""; if (!last) last = "";
    sHTML = "<div class=ReplySendPrint id=divRepSP style='margin-top:0px;'><div style='padding-top:15px'>" + first
    if (visible == 1) sHTML += "<span class=Link onclick='DisplayPost2(false," + item + ")'><img src=/images/reply.gif> Post Comment</span>&nbsp; <span class=ReplySendPrintBorder>&nbsp;</span>  &nbsp; "
    sHTML += "<span class=Link onclick='DisplaySend2(false," + item + ")'><img src=/images/email.gif> Send to Friend</span>&nbsp;</div>";


    sHTML += "<div style=text-align:center;>\
	            <div  class=ReplyFloatWin id=divNew" + item + " align=right style=display:none;width:100%;margin-top: 10px;>\
	                 <div class='ReplyFormTitle' style='background:none;' >\
	                    <div style='background:none;border-bottom:2px solid #DD0423;color:#2F5876;font-size:11pt;'>Post Comment</div>\
	                </div>\
			        <div style=display:none;padding:15px id=spnNewReplySent" + item + ">Thank you for sending your comments 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=''>\
<img src=/images/replies/x.gif> Close</span><br>&nbsp;\
</div>\
<div id=divReplyWin" + item + ">\
<div  style=padding:15px>Comments which include incitement, slander or foul language will not be published.</div>\
<form name='f_replies' id='f_replies' action=''><input type='hidden' name='item' id='item' value='" + item + "' /><input type='hidden' name='type' id='type' value='" + type + "' /><table style='background-color:transparent;font-weight:bold;margin-left:18px;width:294px !important;' cellspacing=5>\
<tr><td>Name:<br><input type=text class=TextBox name=name id=NewReplyName" + item + " maxlength=20 size=16 value=\"" + sUser + "\"></td><td>City:<br><input type=text name=city id=NewReplyCity" + item + " maxlength=15 size=16 class=TextBox></td></tr>\
<tr><td colspan='2'>Subject:<br/><input type='text' id='NewReplyTitle" + item + "' name='title' maxlength=80 style=width:94% class=TextBox></td></tr>\
<tr><td colspan='2'>Message:<br /><textarea class=textbox name=content id=NewReplyContent" + item + " rows=6  cols=32 onKeyUp=UpdateCount('spnNewCount" + item + "',this,900);></textarea><div style=font-weight:normal><span id=spnNewCount" + item + ">900</span> chars.</div></td></tr>\
<tr><td colspan='2'><input class=ReplyButton type=button onClick='SendReply2(" + type + "," + item + "," + item + ");' value=Submit><input class=ReplyButton type=button onClick='DisplayPost(false," + item + ");' value=Close></td></tr></table></form>\
			  </div></div>\
			  <div class=ReplyFloatWin id=divSend" + item + " style=display:none;width:100%;margin-top: 10px;><div class=ReplyFormTitle style='background:none;'><div style='background:none;border-bottom:2px solid #DD0423;color:#2F5876;font-size:11pt;'>Send to Friend</div></div><div style=padding:15px><form method=post name=fSend action=/SendMail.aspx?action=send onsubmit=\"return sendMail();\"><input type=hidden name=type value=" + type + "><input type=hidden name=item value=" + item + "><table style=background-color:transparent;width:260px !important;><tr><td>Send to Email:</td><td><input type=text name=eMail2></td></tr><tr><td>Sender Name:</td><td><input type=text name=Name1></td></tr><tr><td>Sender E-Mail:</td><td><input type=text name=eMail1></td></tr><tr><td>&nbsp;</td><td><input type=submit class=ReplyButton value=Send></td></tr></table></form></div></div>\
			  </div><br><br>"
    return sHTML;
}


function UpdateCount(id,obj,count)
{
	str = obj.value;
	strlen = str.length;
	var div = document.getElementById(id)
	div.innerHTML= count - strlen
	if ((count - strlen) < 20) div.style.color = "red";
	else  div.style.color = "";
	if (strlen>count) obj.value = obj.value.substring(0,count);
}

var sRepliesHTML = "";
var iReplies = 0;
var bPosted, sLastTitle;
function SendReply(type,item,div)
{
    if (bPosted && sLastTitle==document.getElementById("NewReplyTitle"+div).value) {return false;}
	bPosted = true;
	sLastTitle = document.getElementById("NewReplyTitle"+div).value;
	oXH = GetXH();
	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 SendReply2(type,item) {
    var str = $("#f_replies").serialize();
    $.post("/PostReply.aspx?type=" + type + "&item=" + item, str, function(data) {
        if (data == 'good') {
            document.getElementById("spnNewReplySent" + item).style.display = '';
            document.getElementById("divReplyWin" + item).style.display = 'none';
        } else {
            alert(data);
        }
    });
}
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);
}
var iViewed=0;
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";
		iViewed++;
		if (Math.floor((iViewed-1)/2)==((iViewed-1)/2)||iViewed==0) ExectueJS("http://info.inn.co.il/infoonenew.php?zones=77&site=1&ids=divRepAd"+id+"&_"+new Date().getTime())
		else document.getElementById("divRepAd"+id).style.display="none";
		
		}
	else
	{	div.style.display = "none";div2.style.display="";}
}

function DisplayPost(isMessage,div)
{	
	div = document.getElementById("divNew"+div);
	if (div.style.display == "none" || isMessage)
	{	div.style.display = ""; if (isMessage){ document.getElementById("divRepSP").scrollIntoView(); } }
	else
		div.style.display = "none";
}
function DisplaySend(isMessage,div)
{	
	div = document.getElementById("divSend"+div);
	if (div.style.display == "none" || isMessage)
	{	div.style.display = ""; if (isMessage){ document.getElementById("divRepSP").scrollIntoView(); } }
	else
		div.style.display = "none";
}
function DisplayPost2(isMessage,div)
{	
//	div = document.getElementById("divNew"+div);
//	if (div.style.display == "none" || isMessage)
//	{	div.style.display = ""; if (isMessage){ document.getElementById("divRepSP").scrollIntoView(); } }
//	else
//		div.style.display = "none";
    if ($("#divSend" + div + ":visible")) $("#divSend" + div).hide("slow");
    $("#divNew" + div).toggle("slow");
}
function DisplaySend2(isMessage,div)
{	
//	div = document.getElementById("divSend"+div);
//	if (div.style.display == "none" || isMessage)
//	{	div.style.display = ""; if (isMessage){ document.getElementById("divRepSP").scrollIntoView(); } }
//	else
//	    div.style.display = "none";
    if ($("#divNew" + div + ":visible")) $("#divNew" + div).hide("slow");
	$("#divSend" + div).toggle("slow");
}

function AddReply(id,title,name,city,date,content)
{
	var onclick = "DisplayReply(" + id + ")"
	if (content == "")
	{	title += " (N\"C)"; onclick = "";}
	content = content.replace(/\n/g,"<br>")
	sRepliesHTML += "<Div class=ReplyTitle id=divReplyTitle"+id+"><span style=float:left;height:20px;font-weight:bold>" + iReplies + ".&nbsp;&nbsp; </span><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=right><img src=/images/replies/right.gif></div><div style=margin-bottom:9px><span style=font-weight:bold;>" + iReplies + ". </span><Span class=RepliesLink onClick=" + onclick + ">" + title + "</span></div><div class=ReplyContent>" + content + "<div  style='padding-top:15px;padding-bottom:10px;color:gray'>" + name + ", " + city + " (" + date + ")</div>"
	if (bRA) sRepliesHTML+="<div style='text-align:center'><div class=divRepAd id=divRepAd"+id+"></div></div>"
	sRepliesHTML += "<div class=ReplyCommands><span class=link style=float:right OnClick=DisplayReply(" + id + ")><img src=/images/replies/x.gif> Close</span><span class='Link' onclick=DisplayPost(1," + iDiv + ")><img src=/images/replies/reply.gif> Reply</span></div></div><img src=/images/replies/left.gif></div>";
	iReplies--;
}

function CheckReply()
{
	if (document.reply.title.value == "")
	{ alert("Title is missing"); return false;}
}

function sendMail()
{
	var s = "";
	if (document.fSend.Name1.value == "")
		s += "Name is missing\n";
	if (document.fSend.Name2.value == "")
		s += "Name is missing\n";
	if (!checkEmail(document.fSend.eMail1.value) || !checkEmail(document.fSend.eMail2.value))
		s += "Email missing\n";
		
	if (s != "")
	{	alert(s); return false;	}
}

function WriteReplies(type,id,iDiv)
{
	if (!iDiv || iDiv==0) div = "Replies";
	else div = "Replies" + iDiv;
		if(!!sLinkData) sRepliesHTML = "<a href="+sLinkData.replace("New","")+"RepliesList.aspx?type="+type+"&item="+id+">Manage</a>" + sRepliesHTML
		document.getElementById(div).innerHTML = ("<div class=RepliesTitle><div>Talkback &nbsp; <span> " + mReplies + " Comments</span></div></div><div><span class=RepliesLink style=float:right;padding-right:2px;text-decoration:underline onClick=\"PrintReplies(" + type + "," + id + ")\">View All Comments</span></div>\
	<input type=hidden name=NewReplyType value=" + type + "><input type=hidden id=NewReplyItem value=" + id + "><br><br><Div align=left>" + sRepliesHTML + "</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+',right='+l+',top='+t+',scrollbars=yes';
	var x = window.open(url,'',props)
}