// Clock VARs Start
var myMonths=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
 
var timeArray = [];
var currTop = timeLeft = currWidth = 0;
var h, m, s, commNo;
// Clock VARs End
// Browser params - Start
isNav = isIE = isIE55 = false;
browser = navigator.appName;
browserVer = navigator.appVersion;
if (browser == "Netscape") isNav = true;
else if (browser == "Microsoft Internet Explorer") isIE = true;
if (isIE){
   if (browserVer.indexOf("MSIE 5.5") != -1) isIE55 = true;
   document.write("<body>");currWidth = getWidth();document.write("</body>");
}
else currWidth = getWidth();
// Browser params - End
function titleView(title)
{
document.title = title;
//alert(document.title);
}


function paramContrassID(contrassID)
{
	return contrassID;
}
function paramSubContrassID(subContrassID)
{
	return subContrassID;
}
function paramObjectLink(objectLink)
{
	return objectLink;
}
function paramArtWriter(artWriter)
{
	return artWriter;
}
function paramObjectSubHeader(objectSubHeader)
{
	return objectSubHeader;
}
function paramObjectHeader(objectHeader)
{
	return objectHeader;
}
function paramObjectArtTitle(artTitle)
{
	return artTitle;
}

/*Survey Admin*/
function checkSurvey()
{

 if(document.surveyInsert.SURVEY_QUESTION.value == "")
    {
	 alert("יש להוסיף שאלה לסקר");
	 document.surveyInsert.SURVEY_QUESTION.focus();
	 return false;
	}

 if(document.surveyInsert.QUESTION_BACKGROUND.value == "")
    {
	 alert("יש להוסיף צבע רקע לשאלה");
	 document.surveyInsert.selectColor.focus();
	 return false;
	}

 if(document.surveyInsert.STATUS.value == "")
    {
	 alert("יש להוסיף סטוטס לסקר");
	 return false;
	}

 if(document.surveyInsert.OPTION_1_DESC.value == "")
    {
	 alert("יש להוסיף תשובה");
	 document.surveyInsert.OPTION_1_DESC.focus();
	 return false;
	}

 if(document.surveyInsert.OPTION_2_DESC.value == "")
    {
	 alert("יש להוסיף תשובה");
	 document.surveyInsert.OPTION_2_DESC.focus();
	 return false;
	}			
}

function setSurvey(form,statusParam)
{
 if(form == 0)
   {
     var sel_idx =  document.surveyInsert.selectStatus.selectedIndex;
     document.surveyInsert.STATUS.value = sel_idx;
   }
 else
   {
     var sel_idx = eval("document.survey"+form+".selectStatus.selectedIndex");
     eval("document.survey"+form+".STATUS.value = sel_idx");
   }  
}


function setColorSurvey(form,select)
{
 var r = new Array();
  for (var i = 0; i < select.options.length; i++)
    if (select.options[i].selected)
      r[r.length] = select.options[i].value;
 if(form == 0)
   {
     document.surveyInsert.QUESTION_BACKGROUND.value = r;
   }
 else
   {
     eval("document.survey"+form+".QUESTION_BACKGROUND.value = r");
   }  
}

/*Rosner talkback - display or not*/
function displayTalkBack(talkB)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(talkB).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[talkB].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[talkB].style;
		style2.display = style2.display? "":"block";
	}
}



function getWidth(){
   if (isIE) return document.body.clientWidth;
	else return window.innerWidth;
}
if (document.layers){
	window.captureEvents(Event.RESIZE);
	window.onresize = handeleResize;
}
function handeleResize(){
   location.reload(); return false;
}
function pageInit(pageNum, commNum){
   commNo = commNum;
   if (pageNum == 1){
      currTop = 167;
      timeLeft = currWidth/2 + 135;
      if (document.layers){
         tickersLength = msgTexts.length;
         navInsertTicker(tickerCounter);
      }
	  if (commNum == 2)
		  window.onresize = positionMonopol;
   }
   else if (pageNum == 2){
      currTop = 111;
      timeLeft = currWidth/2 + 148;
   }
   else{
      currTop = 111;
      timeLeft = currWidth/2 + 147;
   }
   if (document.layers){
      if (document.layers.isTime) digiTime();
   }
   else{
      if (document.all.isTime) digiTime();
   }
}

function positionMonopol()
{
	if(document.getElementById("monopolDiv")!= undefined)	
		document.getElementById("monopolDiv").style.display = 'none';		
}


function PopUpWin(mypage, myname, w, h, scroll){
   var winl = (screen.width)* 27/100;
 	var wint =(screen.height) * 18/100;
 	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
 	win = window.open(mypage, myname, winprops);
 	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}
function chkSearch(word){
   if (word == "")return false;
   else return true;
}
// Clock functions Start 
//Clock Function
function digiTime(){
   if (!document.layers && !document.all)	return
   h = timeArray[0]; m = timeArray[1]; s = timeArray[2];
   if (s < 59) s = parseInt(s) + 1;
   else{
      s = 0;
      if (m < 59) m = parseInt(m) + 1;
      else{
         m = 0;
         if (h < 24) h = parseInt(h) + 1;
         else h = 1;
      }
   }
   timeArray[0] = h;
   timeArray[1] = m;
   timeArray[2] = s;
	var strH = strM = strS = "";
   if (h < 10) strH = "0" + h; else strH = h;
   if (m < 10) strM = "0" + m; else strM = m;
   if (s < 10) strS = "0" + s; else strS = s;
   if (strH.length == 3) strH = strH.substring(1, strH.length);
   if (strM.length == 3) strM = strM.substring(1, strM.length);
   if (strS.length == 3) strS = strS.substring(1, strS.length);
	digclock = '<span class="t11AquaBlue">' +  strH + ":" + strM + '</span>';//":" + strS + 
	if (document.layers){
      document.layers.isTime.top = parseInt(currTop);
      document.layers.isTime.left = parseInt(timeLeft);
      document.layers.isTime.document.open();
      document.layers.isTime.document.write(digclock);
		document.layers.isTime.document.close();
      document.layers.isTime.visibility = "show";
   }
   else if (document.all)
		isTime.innerHTML = digclock;
   setTimeout("digiTime()",1000)
}
//Insert server's time into array
function startTime(time){
   timeArray[0] = time.substring(0, time.indexOf(":"));
   timeArray[1] = time.substring(time.indexOf(":")+1, time.lastIndexOf(":"));
   timeArray[2] = time.substring(time.lastIndexOf(":")+1, time.length);
}
// Clock functions End
function PopUp(mypage, myname, w, h, scroll,t,l){
   var winL, winT;
   var a = arguments;
   if (a.length > 5){
      if (!document.layers){
         this.t = event.screenY + 30;
         this.l = event.screenX - w - 10;
      }
      if (a.length == 6){
         winT = t;
         winL = (screen.width) * 235/1000;
      }
      else{
         winT = t;
         winL = l;
      }
   }
   else{
      winL = (screen.width) * 235/1000;
      winT = (screen.height) * 40/100;
   }
   winprops = 'height='+h+',width='+w+',top='+winT+',left='+winL+',scrollbars='+scroll+',resizable';
   win = window.open(mypage, myname, winprops);
   if (parseInt(navigator.appVersion) >= 4)
      win.window.focus();
}
function pageArch(pID){
   if (pID == 45 ||pID == 47){
      if (document.all)
         document.all.wait.style.visibility="hidden";
   }
 }
 
function checkFormHerald()
{

	e=document.InsertHeraldUser.EMAIL.value;
	if (document.InsertHeraldUser.FULL_NAME.value == '')
 	{   
    	alert("You have not filled in the name field");
		document.InsertHeraldUser.FULL_NAME.focus();
    	return false;
   	}
	if (document.InsertHeraldUser.ADDRESS.value == '')
    {
       alert("You have not filled in the address field");
	   document.InsertHeraldUser.ADDRESS.focus();
       return false;
    }
	
	if (document.InsertHeraldUser.PHONE.value == '')
    {
       alert("You have not filled in the phone field");
	   document.InsertHeraldUser.PHONE.focus();
       return false;
    }   
	
 	if (document.InsertHeraldUser.EMAIL.value=='')
   	{
    	document.InsertHeraldUser.EMAIL.focus();
    	alert("You have not filled in the Email field");
    	return false;
   }
   ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0) 
		{ 
			document.InsertHeraldUser.EMAIL.focus();
			alert("The email address is not valid.");
			return false;
		}	
	} 
	if (document.InsertHeraldUser.EMAIL.value.indexOf("@") == -1)
	{
	   	document.InsertHeraldUser.EMAIL.focus();
    	alert("The email address is not valid.");
	    return false;
	}
 	if (document.InsertHeraldUser.EMAIL.value.indexOf(".") == -1)
 	{
   		document.InsertHeraldUser.EMAIL.focus();
    	alert("The email address is not valid.");
    	return false;
   	}     
	
	
} 

function checkFormGreetingCard(checkNL)
{	
	e=document.sendCard.EMAIL.value;
	
	if (document.sendCard.SENDER_NAME.value == '')
 	{   
    	alert("You have not filled in the sender name field");
		document.sendCard.SENDER_NAME.focus();
    	return false;
   	}
	if (document.sendCard.SENDER_EMAIL.value == '')
 	{   
    	alert("You have not filled in the sender email field");
		document.sendCard.SENDER_EMAIL.focus();
    	return false;
   	}
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0) 
		{ 
			document.sendCard.SENDER_EMAIL.focus();
			alert("The email address is not valid.");
			return false;
		}	
		
	} 
if (document.sendCard.SENDER_EMAIL.value.indexOf("@") == -1)
 {
   document.sendCard.SENDER_EMAIL.focus();
    alert("The email address is not valid.");
    return false;
   }
 if (document.sendCard.SENDER_EMAIL.value.indexOf(".") == -1)
 {
   document.sendCard.SENDER_EMAIL.focus();
    alert("The email address is not valid.");
    return false;
   } 

 	if (document.sendCard.NAME.value == '')
 	{   
    	alert("You have not filled in the name field");
		document.sendCard.NAME.focus();
    	return false;
   	}
	
	
 if (document.sendCard.EMAIL.value=='')
   {
    document.sendCard.EMAIL.focus();
    alert("You have not filled in the Email field");
    return false;
   }
   ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0) 
		{ 
			document.sendCard.EMAIL.focus();
			alert("The email address is not valid.");
			return false;
		}	
		
	} 
if (document.sendCard.EMAIL.value.indexOf("@") == -1)
 {
   document.sendCard.EMAIL.focus();
    alert("The email address is not valid.");
    return false;
   }
 if (document.sendCard.EMAIL.value.indexOf(".") == -1)
 {
   document.sendCard.EMAIL.focus();
    alert("The email address is not valid.");
    return false;
   } 
     
	var i;
	var chk=0;

	for (i=0;i<document.sendCard.CARD.length;i++){ 
		if (document.sendCard.CARD[i].checked==true) 
			chk=1;
	}
	
	if (chk == 0)
	{			
		alert("Please select one of the donuts cards");
		return false;
	}

} 



function paramContrassID(contrassID)
{return contrassID;}
function paramSubContrassID(subContrassID)
{return subContrassID;}
function paramObjectLink(objectLink)
{return objectLink;}
function paramArtWriter(artWriter)
{return artWriter;}
function paramObjectSubHeader(objectSubHeader)
{return objectSubHeader;}
function paramObjectHeader(objectHeader)
{return objectHeader;}

// -----------  philantrophy --------------- 
function openPhilanthropyContent(contentUrl)
{
		if(document.getElementById("philanthropyDiv") != undefined)
			document.getElementById("philanthropyDiv").style.display= "inline";
		if(document.getElementById("philanthropyIframe") != undefined)
			document.getElementById("philanthropyIframe").src = contentUrl;
}

// sending html code to div 
function sendToDiv(code,divId)
{
	if(document.getElementById(divId)!= undefined)
		document.getElementById(divId).innerHTML = code;
}

function openCloseDiv(divId)
{
	if(document.getElementById(divId)!= undefined)
	{
		if(document.getElementById(divId).style.display == "inline")
			document.getElementById(divId).style.display = "none";
		else
			document.getElementById(divId).style.display = "inline";
	}
}

// Tags Row Scripts .
function replaceCharsBack(str)
{	
	while(str.indexOf("+")!=-1)
		str =str.replace("+"," ");
	while(str.indexOf("~")!=-1)
		str =str.replace("~","\"");
	while(str.indexOf("*")!=-1) 
		str =str.replace("*","\'");	
	while(str.indexOf("^")!=-1) 
		str =str.replace("^","&");
	return str;
}

function createTagsDiv()
{
	var tagsDiv=document.createElement("DIV");
	tagsDiv.id="moreTags";
	tagsDiv.className="moreTagsDiv";				
	document.body.appendChild(tagsDiv);
	
	return (tagsDiv);
}
function hideTagsDiv(e)
{	
	var tagsDiv = document.getElementById("moreTags");
	
	// check if event triggered inside the the Tagsdiv.
	var is_X_OK = (((e.clientX+document.body.scrollLeft) > (parseInt(tagsDiv.style.left)+2)) && ((e.clientX + document.body.scrollLeft)< (parseInt(tagsDiv.style.left) + parseInt(tagsDiv.style.width))-2));
	var is_Y_OK = (((e.clientY+ document.body.scrollTop) > (parseInt(tagsDiv.style.top)+2)) && ((e.clientY + document.body.scrollTop)< (parseInt(tagsDiv.style.top) + parseInt(tagsDiv.style.height)-2)))
	
	if (! (is_X_OK && is_Y_OK)) 
		document.getElementById("moreTags").style.display="none";		
}

function setTagsDivSizeAndPos(posX,posY,site,tags)
{
	var tagsDiv = document.getElementById("moreTags");
	var numOfTags = tags.length;
	var longestTag = tags[0].length;
		// Find out the longest Tag.
	for (i=0;i<tags.length-1;i++)	
	{
		if (tags[i].length > longestTag)
			longestTag = tags[i].length;
	}
		// Set Height and Width
	tagsDiv.style.width =(longestTag * 9)+25;	
	tagsDiv.style.height=(numOfTags * 14);
	
	// Set Position 		
	if (site=='hasen')
		tagsDiv.style.left= (posX-5) + document.body.scrollLeft;
	else 			
		tagsDiv.style.left= (posX - parseInt(tagsDiv.style.width) + 5)+ document.body.scrollLeft ;
		
	tagsDiv.style.top = posY-5 + document.body.scrollTop;
	
}
function showMoreTags(tags,site,event)
{
	var tagsDiv = document.getElementById("moreTags");
	var content = "";
	
	if (tagsDiv==null)
	{
		tagsDiv=createTagsDiv();			
	}
	
	setTagsDivSizeAndPos(event.clientX,event.clientY,site,tags);	
	
	content+="<table width=\"100%\" height=\"100%\" id=\"moreTagsTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" onmouseout=\"hideTagsDiv(event)\">";				
	for (tag=0 ; tag < tags.length ; tag++)
	{
		content+="<tr><td><a class=\"tagsText\" onmouseover=\"this.className='tagBack tagsTextOver'\" onmouseout=\"this.className='tagsText'\" href=\"/" + site + "/pages/tags/index.jhtml?tag=" + tags[tag] + "\" target=\"_blank\"><span class=\"tagsText\" style=\"display:block;width:100%;cursor:pointer;text-align:center;\" onmouseover=\"this.className='tagBack tagsTextOver'\" onmouseout=\"this.className='tagsText'\" width=\"100%\">&nbsp;"+ replaceCharsBack(tags[tag]) + "&nbsp;</a></span></td></tr>";		
	}		
	content+="</table>";
	
	tagsDiv.innerHTML= content;	
			
	tagsDiv.style.display="block";
}