//(c) Arkady Krishtul September, 2005
//Talkback control Javascript functions


function openWin(url,title,attrib) 
{
	wref=window.open(url,"_blank",attrib);
	wref.focus();
}

//opens page with URL in new window
function openInnewWindow(url,width,height,toolbar) 
{
	if(toolbar==1) 
	{
	
	openWin(url,'20+','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=no,width='+width+',height='+height)
	} 
	else 
	{
	openWin(url,'20+','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,movable=yes,resizable=no,width='+width+',height='+height)
	}
}

//shows inline frame containing talkback addition form
function showAdd(parent,article,appPath,width,height)
{  
	var spanObj = document.getElementById("AddTBSpan");
	var tdObj = document.getElementById("AddTalkbackTD");
	
	if (spanObj)
	{
		spanObj.innerHTML = "<iframe id='frameAddTalkback' src='" + appPath + "/TalkBacks/TalkBackAddPopUp.aspx?ParentId=" +parent+"&ArticleId="+ article + "' frameborder=0 width=" + width + " height=" + height + " marginwidth=0 marginheight=0  scrolling=no hspace=0 vspace=0></iframe>"
		spanObj.style.display = "block";
	}
	
	if(tdObj)
	{
		tdObj.style.display = "block";
	}
}

function hideAdd()
{  
   var spanObj = document.getElementById("AddTBSpan");
   var tdObj = document.getElementById("AddTalkbackTD");
   
   if (spanObj)
   {
		spanObj.innerHTML = "";
		spanObj.style.display = "none";
   }
   if(tdObj)
   {
		tdObj.style.display = "none";
   }
}


function openPopUp(parent,article,appPath,mode)
{
	openInnewWindow(appPath + '/TalkBacks/TalkBackAddPopUp.aspx?ParentId='+parent+'&ArticleId='+article+'&Mode='+mode,307,421,0)
}

function toggle(msg,img,appPath)
{ 
	var emptyImg =  appPath + '/TalkBacks/images/t.gif';
	var plusImage =  appPath + '/TalkBacks/images/plus.gif';
	var minusImage =  appPath + '/TalkBacks/images/minus.gif';
	
	if(document.getElementById(msg).style.display == "none")
	{	
		document.getElementById(msg).style.display = "block";   
		document.getElementById(msg).style.overflow = "visible"; 
		document.getElementById(msg).style.cursor = "hand";
		if(document.getElementById(img)!= null) {     
			if(document.getElementById(img).src.indexOf("t.gif") == -1)    	
				document.getElementById(img).src = minusImage.toLowerCase();    
				
		} 
	} 
	else
	{	document.getElementById(msg).style.display = "none";   
		 if(document.getElementById(img)!= null) 
		 {      
			if(document.getElementById(img).src.indexOf("t.gif") == -1)    	
				document.getElementById(img).src = plusImage.toLowerCase();    
		 } 
	}
} 


///////////////////////////////////////////////////

function ReloadOpenerAndClose()
{
	var OpenerUrl = ""; 

	if(window.opener != null)	//the page is opened as POPUP
	{
		OpenerUrl = window.opener.location.host + RedirectUrl;
		
		window.opener.location.reload(true);
		window.opener.location.href = "http://" + OpenerUrl;
		window.close();
	}
	else //the page is opened in IFRAME
	{
		if(window.parent != null)
		{	
			OpenerUrl = window.parent.location.host + RedirectUrl;
			window.parent.location.replace("http://" + OpenerUrl);
			window.parent.location.reload(true);					
		}
	}
}	
	
///////////////////////////////////////////////////

function ConfirmDelete()
{
	if (!confirm('!!האם ברצונך למחוק תגובה הזאת וכל התגובות שקשורות אליה?'))
		event.returnValue = false;
}

function ShowResults(pollId)
{
	 var sUrl = 'VotePopup.aspx?PollId=' + pollId;
	 sFeatures = "toolbar=0,width=500,height=400,directories=no,status=no,scrollbars=no,resizable=no,menubar=no";
	 var newWin = window.open(sUrl,"_blank",sFeatures);
	 newWin.focus();
	 event.returnValue = false;
}
