

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;  //return true if  the browser is internetexplorer,else-false
var isDivOpen=0; //0=no 1=yes
var firstArc="";   //the id of the first article in list
var firstArcIndex=-1;
/* in all main pages */

//  when loading the page body call  the function initsectionCombo() /
function init()
{
	setTimeout('initsectionCombo()',100);
}	

//after chosing section in the drop down put the value in  input text  /
function selidd(val,valuetoshow,targethdn,targetshow,frm)
{
   eval("document."+frm+"."+targethdn+".value=val;");
  targetshow.innerHTML=valuetoshow+"&nbsp;";
  closeall();
}
	
/* first article page*/

//loadin loader gif before send article to friend or adding talkback
var loadingInterval;
function stopLoadingInterval(sendAddDiv,loaderDiv)
{ 
	
    if(document.getElementById(loaderDiv.id)!=null)
		document.getElementById(loaderDiv.id).style.display = 'none';
	if(document.getElementById(sendAddDiv.id)!=null )
		document.getElementById(sendAddDiv.id).style.display = 'block';
	
}
//loadin div  send article to friend or adding talkback after loading gif 
function loadingDiv(sendAddDiv,loaderDiv)
{ 
   if(document.getElementById(loaderDiv)!=null)
		document.getElementById(loaderDiv).style.display = 'block';	
	
	setTimeout("stopLoadingInterval(" + sendAddDiv + ","  + loaderDiv + ")",1000); 
}

//open div for new talkback or div for sending the article by a mail ("שלח לחבר")
function openDiv(divName,num,idSort,slug)
{	
	if(divName!=null && divName!="")
	{
		if(divName.style.display == "none")
		{
			if(num==1)
			{
				document.getElementById(divName.id).innerHTML = "<iframe id=add src=../objects/newTB.jhtml?msg_id=0&slug="+slug+"&idSort="+idSort+" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=100% height=100%></iframe>";				
			    if(document.getElementById("sendDiv")!=null)
				{
					loadingDiv("addDiv","loaderPurple");
					document.getElementById("sendDiv").style.display = "none";
			    }
			}
			else if (num==2)
			{
				document.getElementById(divName.id).innerHTML = "<iframe id=send src=../objects/sendArticle.jhtml?slug="+slug+"&emailSend=false frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=100% height=100%></iframe>";										
			    if(document.getElementById("addDiv")!=null)
				{
					document.getElementById("addDiv").style.display = "none";
					loadingDiv("sendDiv","loaderGreen");
				}
			}
			document.body.style.cursor="auto";
		}
		else
			divName.style.display = "none";	
	}
}

/* display the content of talkback */
function displayContent(msgId,count)
{
	  if (document.getElementById("tr"+msgId)) //if exist
	  {	
	    if (document.getElementById("tr"+msgId).style.display == "none")
		{
			 document.getElementById("tr"+count).style.display = "none";
			 document.getElementById("tr"+msgId).style.display = "block";
		}
		else
		{
		     document.getElementById("tr"+count).style.display = "block";
			 document.getElementById("tr"+msgId).style.display = "none";
		} 
	  }           
}

/* call getContent function  */	
function sendContent()
{
	top.getContent(document.body.innerHTML,'talkBackDiv');
}	
	
/* send html to the div*/	
function getContent(txt,divID)
{
	document.getElementById(divID).innerHTML = txt;
}
	
/* new talk back page newTB.jhtml */ 
// submit the form of  new talk back and check validation of feilds
function sbm()
{
	if(document.frm.tmsg_description.value == "")
	{
		alert("יש למלא את נושא ההודעה");
		document.frm.tmsg_description.focus();
		return false;
	}
	
	var stringToCheck=document.frm.tmsg_content.value;
	if(stringToCheck.indexOf(".")==0)
	{
		temp=" "+stringToCheck.substring(1, stringToCheck.length)
		document.frm.tmsg_content.value=temp;
	}
	document.frm.tmsg_content.value = checkString(document.frm.tmsg_content.value);
	document.frm.teditor_name.value = checkString(document.frm.teditor_name.value);
	document.frm.tmsg_description.value = checkString(document.frm.tmsg_description.value);
	if(InternetExplorer)
		loadGif('addDiv','loaderPurple');
	
		
	  
	return true;	
}
		
//chack validation of email. clears :;)(*&^%$#@!?<>||~{}[]\\/ from string.
function checkString(str)
{
			var re = new RegExp('[\]*&\\\\^\$#@<>|~\{\}\[/]','g');
			return str.replace(re, '');
}

/* page after submiting  TalkBack page - antisubmit.jhtml */

// close the div of the talkback 
function closeWindow()
{
   window.setTimeout("closeDiv()", 5500);
}
// close the div of the talkback 
function closeDiv()
{
  parent.document.getElementById("addDiv").style.display = "none";
}
//load the loader gif after for 1.5 seconds and after call showGif(). 
function loadGif(sendAddDiv,loaderDiv)
{
  if(parent.document.getElementById(sendAddDiv)!=null )
		parent.document.getElementById(sendAddDiv).style.display = 'none';
  if(parent.document.getElementById(loaderDiv)!=null)
		parent.document.getElementById(loaderDiv).style.display = 'block';	
  parent.window.setTimeout("showGif(" + sendAddDiv + ","  + loaderDiv + ")",1500);
}

function showGif(sendAddDiv,loaderDiv)
{
  if(parent.document.getElementById(loaderDiv.id)!=null)
		parent.document.getElementById(loaderDiv.id).style.display = 'none';
	if(parent.document.getElementById(sendAddDiv.id)!=null )
		parent.document.getElementById(sendAddDiv.id).style.display = 'block';
}


/* send article*/
//check validation of form for sending article by mail ("שלח לחבר")
 function IsLegalData(form)
{
	if (form.senderEmail.value=="")
	{
	    alert("כתובת השולח הינו שדה חובה")
	    form.senderEmail.focus();
		return false;
	}
	else if(!validEmail(form.senderEmail.value))
	{
	    alert("כתובת השולח שגויה")
	    form.senderEmail.focus();
		return false;
	}      
	if (form.recieverEmail.value=="")
	{
	    alert("כתובת הנמען הינו שדה חובה")
	    form.recieverEmail.focus();
		return false;
	}
	else if(!validEmail(form.recieverEmail.value))
	{
	    alert("כתובת הנמען שגויה")
	    form.recieverEmail.focus();
		return false;
	}
	if(InternetExplorer)
		loadGif("sendDiv","loaderGreen"); 

		    
}
//check validation of emails 
 function validEmail(email) 
{
	invalidChars = " /:,;"
	if (email == "") 
		return false
	for (i=0; i<invalidChars.length; i++) 
	{
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) 
		{
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) 
		return false
	if (email.indexOf("@",atPos+1) != -1) 
		return false
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) 
		return false
	if (periodPos+3 > email.length)	
		return false
   return true
 }

 /*  header object - headersections.jhtml */
 
//get distance from the parent object 
function getAbsolutePos2(oNode){
		var k = new Array(2);
 	 	var oCurrentNode=oNode;
		xpos = 0;
		ypos=0;
		while(oCurrentNode.tagName!="BODY"){
    		xpos+=oCurrentNode.offsetLeft;
			ypos+=oCurrentNode.offsetTop;
    		oCurrentNode=oCurrentNode.offsetParent;
   		}
		k[0] = xpos;
		k[1] = ypos;			
  		return k;
}

//place the links to articles sections according to the size of the window
function placeDiv(divID,sectionTD)
{
  var sWidth= screen.width;
  var divWidth = 205;  //the div of every div
   if(divWidth - window.event.clientX > 100)
       document.getElementById(divID).style.left = document.body.scrollLeft;
}
// function  validation of search article 
function checkSearch()
{
  if(document.arcSearch.searchStr.value == "" || document.arcSearch.searchStr.value.indexOf("חפש כתבת טלוויזיה")!=-1)
	{
		alert("יש להזין מילות מפתח");
		document.arcSearch.searchStr.focus();	
		return false;
	}
  if(document.arcSearch.searchStr.value.length < 3 || trimString(document.arcSearch.searchStr.value).length<3)
	{
		alert("חיפוש בארכיון חייב להכיל לפחות 3 אותיות");
		document.arcSearch.searchStr.focus();	
        return false;
	}
	return true;	
}

// build the table of the div drop down sections 
function initsectionCombo()
{
	var str = '<table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">'
	var links = new Array();
	links[0]=new Array("הכל","comp");
	for (counter = 1; counter < sections.length; counter++)
       { 
	  links[counter] =  new Array(sections[counter],sectionsLayers[counter]);
	}
	for(i=0;i<links.length;i++)
	{
		var cobj = links[i];
		str += '<tr><td height="17" bgcolor="#ffffff" style="font-size:12px;font-family:Arial;color:#000000;cursor:default"  onmouseover="this.style.backgroundColor=\'#e2f0cd\'" onmouseout="this.style.backgroundColor=\'#ffffff\'" onclick="selidd(\''+ cobj[1] +'\',this.innerHTML,\'sectionTools\',sectionToolsDiv,\'arcSearch\')" height="16" align="right">&nbsp;'+cobj[0]+'</td></tr>';
	}
	str += '</table>';
	document.getElementById("sectionDropDown").innerHTML = str;
}	
//arrow gifs
img01= new Image()
img01.src="../images/down_on.gif"; 
img02= new Image()
img02.src="../images/down_off.gif"; 

// left and right gifs of the headers
img03=new Image();
img03.src="../images/right_off2.gif"; 
img04=new Image();
img04.src="../images/right_on2.gif";

img05=new Image();
img05.src="../images/left_off2.gif";
img06=new Image();
img06.src="../images/left_on2.gif";

// mouse over link in header change background,arrow and open div 
function linkMouseOver(Num)
{
  if(InternetExplorer)
     placeDiv('div'+Num,'sction'+Num);
   document.getElementById('img'+Num).src=img01.src;
   document.getElementById('section'+Num).className = "selectedSection";
   document.getElementById('div'+Num).style.display='block';
   document.getElementById('sectionhref'+Num).className ="headerLinkOn";
   if(Num==1)
   	  document.getElementById('rightTd'+Num).src=img04.src;
   if(Num==9)
   	  document.getElementById('leftTd'+Num).src=img06.src;
   
     
}
/* mouse out of link in header change background,arrow and close div  */
function linkMouseOut(Num)
{
  document.getElementById('img'+Num).src=img02.src;
  document.getElementById('section'+Num).className = "regularSection";
  document.getElementById('div'+Num).style.display='none';
  document.getElementById('sectionhref'+Num).className ="headerLink";
   if(Num==1)
   	  document.getElementById('rightTd'+Num).src=img03.src;
   if(Num==9)
   	  document.getElementById('leftTd'+Num).src=img05.src;

}
//define 3 arrays of sections
var sections = new Array("חדשות","שוק ההון","אנליסטים","פוליטיקה","נדל\"ן ותשתיות", "הייטק ותקשורת","שיווק וצרכנות","סיכום שבועי","רכב","סקירות חיצוניות");
var sectionsLayers = new Array("comp","TvCapitalMarket","TvAnalystAdvice","TvPolitics","TvRealEstate","TvHitech","TvMarketing","TvWeekSum","TvCar","foreign");
var sectionsURL = new Array("/index2.jhtml","/capitalMarket","/analyst","/politics","/realEstate","/hitech","/market","/weekSummery","/car","/outerArc");
/* build the header sections  */
function showTheMarkerSections2(selectedSection,pageNo)
{
	for (counter = 1; counter < sections.length; counter++)
	{ 
		if(sectionsLayers[counter]==selectedSection) //if it's the selected section
			 document.write('<td style="cursor:pointer;" id=section' + counter + ' class=selectedSection2 >');
		else
		 	 document.write('<td style="cursor:pointer;" id=section'+ counter +  '  class=regularSection onmouseover=linkMouseOver(' + counter + ') onmouseout=linkMouseOut(' + counter + ')>');
		 document.write('      <table cellpadding=0 cellspacing=0 border=0>');
		 document.write('         <tr>');
		 
		 
		 if(counter==1) //if its the first section
		 {

		    	if(sectionsLayers[counter]==selectedSection)
				{
		 			document.write('    <td bgcolor="White" ><img id=rightTd' + counter + ' src="../images/right_mador.gif"></td>');
					document.write('    <td align=right style="padding-right:6px;"><img  src="/ibo/images/0.gif" border=0 width=6 id=img' + counter + '></td>');  
		        	document.write('    <td nowrap><a id=sectionhref' + counter + ' class=headerLinkSelected href=' + sectionsURL[counter] + '>' + sections[counter] + '</a></td>');
				}
			    else
				{
		 	        document.write('    <td bgcolor="White" ><img id=rightTd' + counter + ' src="../images/right_off2.gif"></td>');
					document.write('    <td align=right style="padding-right:6px;"><img  src="../images/down_off.gif" border=0 id=img' + counter + '></td>');  
			   		document.write('    <td nowrap><a id=sectionhref' + counter + ' class=headerLink href=' + sectionsURL[counter] + '>' + sections[counter] + '</a></td>');
 				}
             document.write('           <td width=11><img src="http://www.themarker.com/ibo/images/0.gif" width="11"></td>');	   
		 }
		 else if (counter==sections.length-1) //if it's the last section link
		 {
		   		if(sectionsLayers[counter]==selectedSection)
				{
		 			document.write('    <td align=right style="padding-right:6px;"><img  src="/ibo/images/0.gif" border=0 width=6 id=img' + counter + '></td>');  
					document.write('    <td nowrap><a id=sectionhref' + counter + ' class=headerLinkSelected href=' + sectionsURL[counter] + '>' + sections[counter] + '</a></td>');
				
				}
			    else
				{
		 	        document.write('    <td align=right style="padding-right:6px;"><img  src="../images/down_off.gif" border=0 id=img' + counter + '></td>');  
					document.write('    <td nowrap><a id=sectionhref' + counter + ' class=headerLink href=' + sectionsURL[counter] + '>' + sections[counter] + '</a></td>');
				}
            document.write('            <td width=10><img src="http://www.themarker.com/ibo/images/0.gif" width="10"></td>');	   
		    if(sectionsLayers[counter]==selectedSection)
				document.write('         <td bgcolor="White" ><img id=leftTd' + counter + ' src="../images/left_mador.gif"></td>');
		    else
				document.write('         <td bgcolor="White" ><img id=leftTd' + counter + ' src="../images/left_off2.gif"></td>');
		 }
		 else
		 {
		   		if(sectionsLayers[counter]==selectedSection)
				{
		 			document.write('    <td align=right style="padding-right:6px;"><img  src="/ibo/images/0.gif" border=0 width=6 id=img' + counter + '></td>');  
			        document.write('           <td nowrap><a id=sectionhref' + counter + ' class=headerLinkSelected href=' + sectionsURL[counter] + '>' + sections[counter] + '</a></td>');
			    }
			    else
				{
		 	        document.write('    <td align=right style="padding-right:6px;"><img  src="../images/down_off.gif" border=0 id=img' + counter + '></td>');  
					document.write('    <td nowrap><a id=sectionhref' + counter + ' class=headerLink href=' + sectionsURL[counter] + '>' + sections[counter] + '</a></td>');				
				}
             document.write('           <td width=14><img src="http://www.themarker.com/ibo/images/0.gif" width="14"></td>');	   
		 }
	 	document.write('          </tr>');	   
  		document.write('      </table>');
		if(counter==8 || counter==9)
	 		document.write('      <div id=div'+ counter +' style="display:none;z-index:100;position:absolute;border-left:1px solid #c0c2d7;border-right:1px solid #c0c2d7;border-bottom:1px solid #c0c2d7;border-top:1px solid #c0c2d7;;font-family:arial;font-size:12px;width:205px;"></div>');
		else
		    document.write('      <div id=div'+ counter +' style="display:none;z-index:100;position:absolute;border-left:1px solid #c0c2d7;border-right:1px solid #c0c2d7;border-bottom:1px solid #c0c2d7;font-family:arial;font-size:12px;width:205px;"></div>');	
        document.write("      <iframe id=talkBackIfarme" + counter + " src='../objects/fiveArticlesBySection.jhtml?bottomDiv=bottomDiv"  + counter +  "&divNum=div"  + counter +  "&sectionLayer=" + sectionsLayers[counter] +  "&sectionName="  + sections[counter]  + "&sectionsURL=" +  sectionsURL[counter] + "&pageNo=" + pageNo + "' frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style='overflow:visible; width:100%; display:block'></iframe>");			 
  	 	document.write('    </td>')
		if(counter!=sections.length-1)
			 document.write('<td width=1 bgcolor=#474a83><img src="http://www.themarker.com/ibo/images/0.gif" width="1"></td>');	
	}
}


//get distance width and height from the parent objetct
function getAbsolute(oNode)
{
		var k = new Array(2);
 	 	var oCurrentNode=oNode;
   		xpos=-19;
		ypos=0;
   		while(oCurrentNode.tagName!="BODY")
		{
    		xpos+=oCurrentNode.offsetLeft;
			ypos+=oCurrentNode.offsetTop;
    		oCurrentNode=oCurrentNode.offsetParent;
   		}
		ypos = ypos + 20;
		xpos = xpos + 19;
		k[0] = xpos;
		k[1] = ypos;			
  		return k;
}
var selopen = false;
var selid;
// close section drop down
function closeall()
{
   if(selopen)
   {
     selid.style.display='none';
	 selopen=false
   }
}
/* after pressing the arrow of the sections dropdown , open it's div   */
function dropDown(x,obj,foc)
{	
	  if(selopen)
	  		closeall()
	  else
	  {
	    var curobj = obj;
	  	var obj1 = x;
	 	curobj.style.left = getAbsolute(obj1)[0];
	 	curobj.style.top = getAbsolute(obj1)[1];
		 
		if(selopen){curobj.style.display = 'none';}
	 	else{curobj.style.display = '';}
		 	selid = obj;
		selopen = !selopen;
	 }
	//document.all.focusTd
	document.getElementById("focusTd").focus();
}
//loading the content of the page body into the parent div
function sendContent2(divName)
{
	parent.document.getElementById(divName).innerHTML=document.body.innerHTML;
}		

/* first article - firstArticle.jhtml */
//open the div of the related links of an article 
function openRelatedLinks()
{
  if(document.getElementById("relatedLinks")!=null)
  {
     document.getElementById("relatedLinks").style.display = "block";
	 document.getElementById("closeLinks").style.display = "block";
  }
}
//open the div of the related links of an article
function closeRelatedLinks()
{
 if(document.getElementById("relatedLinks")!=null)
  {
     document.getElementById("relatedLinks").style.display = "none";
	 document.getElementById("closeLinks").style.display = "none";
  }
}
//open talkbacks' div if there are more then 3
function openAllTB(tbNum)
{
  for (i=4;i<=tbNum;i++)
  {
	  document.getElementById("tr"+i).style.display = "block";
	  document.getElementById("trWhite"+i).style.display = "block";
  }

  document.getElementById("trMore").style.display="none";
  document.getElementById("trLess").style.display="block";
}
//close talkbacks' div and leave the 3 first 
function closeTB(tbNum)
{
  for (i=tbNum;i>=4;i--)
  {
    
	  document.getElementById("tr"+i).style.display = "none";
	  document.getElementById("trWhite"+i).style.display = "none";
  }
  document.getElementById("trMore").style.display="block";
  document.getElementById("trLess").style.display="none";
}

/* article list  - articleList.jhtml */

var objhttp;
var objhttp2;
var articles  = new Array();
var article1,article2,article3,article4,article5,article6,article7,article8,article9,article10;
var articles2  = new Array();
var arc1,arc2,arc3;
var ArcForPage=10;  //number of articles for each page
var pagesCount=0;  //number of pages of 10 articles in each 
var arcCount;

//check which browser  
if (window.XMLHttpRequest) 
{ // if it's browsers: Mozilla, Safari, ...
	objhttp = new XMLHttpRequest();
	objhttp2 = new XMLHttpRequest();
    if (objhttp.overrideMimeType) 
    	objhttp.overrideMimeType('text/xml');
	if (objhttp2.overrideMimeType) 
    	objhttp2.overrideMimeType('text/xml');	
} 
else if (window.ActiveXObject) 
{ // IE
	try 
	{
    	objhttp = new ActiveXObject("Msxml2.XMLHTTP");
		objhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
    } 
	catch (e) 
	{
	    try
		{
    	    objhttp = new ActiveXObject("Microsoft.XMLHTTP");
			objhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
        } 
		catch (e) {}
    }
 }	
//send parameters to articleList.jhtml and get the string response  from this file 
function getArcList(section,from)
{		
	try
	{			
		var parameters = "sectionLayer="+section + "&startIndex="+from;		
		objhttp.open ("POST", "../objects/articleList.jhtml", true);
		objhttp.onreadystatechange=function callGetResult(){getResults(section,from);};				
		objhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;");				
		objhttp.send(parameters);			
	}
	catch(e){}	
}

//get search Article  results
function getResults(section,from)
{	
	
	var repId,author,headline,specialImage,callout,extendedCallout,smsHeadline,effectiveDate,tbCount;
	if ((objhttp.readyState==4) && (objhttp.status == 200)) //if all data has loaded without errors
	{			
		var respText = objhttp.responseText;//get response text	

		if(respText != "")//if there is response text
		{			
			respText = trimString(respText);
			var ar = respText.split("!!!");			
			var len = ar.length;
			arcCount = 	ar[0];
			countPages(arcCount); //at the moment pageCount is going to be maximum 5

			if (len > 1)  //if there are articles
			{																
				for (var i =1 ; i <len ; i++)
				{								
					if (trimString(ar[i]) == "")
						continue;		
					arc = ar[i].split("@@@");				
					repId = arc[0];
					author = arc[1];
					headline = arc[2];
					specialImage = arc[3];
					callout = arc[4];
					extendedCallout=arc[5];
					smsHeadline = arc[6];
					effectiveDate = arc[7];		
					tbCount = arc[8];
		
					buildArcObj(i,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);
				}
				showPagesNum(section,from,"pageCountUpDiv");			
				writeTableAfterOrder();
				showPagesNum(section,from,"pageCountBottomDiv");
					
			}		
			
		}	
	}
	
}
//create an objest of Article and insert it into the array
function buildArcObj(index,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount)
{
   eval("article" + index + " = new Article(repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);");
   eval("articles[index] = article" + index + ";");
}

//write the article list
function  writeTableAfterOrder()
{
   firstArcIndex=-1; 
   var str="";
   if(firstArc!="")
    isDivOpen=1;
   str+="<table><tr><td height=4></td></tr></table>";
   for (i=1;i<articles.length;i++)
		{  
			if(articles[i].arcId==firstArc)
			{
				isDivOpen=0;
				firstArcIndex=i;
			}
			
			if(i==1 && isDivOpen==0)  //if it's the first article and the first div isn't open
				str+="<table border=0 bordercolor=Fuchsia id=table" + i + "  bordercolor=Blue  bgcolor=#d3d6eb  border=0 cellpadding=0 cellspacing=0 dir=rtl width=275 height=80 >"
			else
				str+="<table border=0 bordercolor=Fuchsia id=table" + i + " style=\"cursor:pointer;\" bordercolor=Blue background=\"../images/bg_mover_off.gif\" style=\"background-repeat : repeat-x;\"  border=0 cellpadding=0 cellspacing=0 dir=rtl width=275 height=84 onclick=\"logArticle('" + articles[i].arcId + "','credit','" +  articles[i].effectiveDate  + "','" +  articles[i].headline  + "','" +  articles[i].author  + "');changeArticle('" + articles[i].arcId + "','" + articles[i].extendedCallout + "');placeFirst(" + i + ");\" onmouseover=\"tableOnMouseOver('table" + i + "','td" + i + "');\" onmouseout=\"tableOnMouseOut('table" + i + "','td" + i + "');\"  >";
            str+="   <tr>";
			str+="	    <td valign=top align=right  style=\"padding-right:5px;padding-top:5px;\"><img src=\"http://www.themarker.com" + articles[i].specialImage + "\" width=124 height=70 alt=\"" + replaceChars(articles[i].headline) + "\"></td>";
			str+="	    <td align=right valign=top style=\"padding-right:10px;padding-left:10px;padding-top:3px;\" width=173>";
			str+="	        <table border=0 bordercolor=Fuchsia cellpadding=0 cellspacing=0 align=right width=100%  >";
			if(i==1 && isDivOpen==0) //if it's the first article and the first div isn't open
				str+="		   <tr><td  align=right class=blackTitle id=td" + i + ">" + replaceChars(articles[i].headline)  + "</td></tr>";
			else
			    str+="         <tr><td  align=right class=regularTitle id=td" + i + ">" + replaceChars(articles[i].headline)  + "</td></tr>";   
			str+="			   <tr><td valign=top align=right class=greenDateOrFilmTime dir=rtl style=\"padding-top:3px;\">" +  articles[i].effectiveDate + "  | " + articles[i].smsHeadline + "</td></tr>";
			str+=" 			   <tr>";
			str+="					<td height=10 valign=top align=right >";
			str+="						<table border=0 cellpadding=0 cellspacing=0 dir=rtl>";
			str+="                            <tr>";
			str+="								<td align=right>";
			if(articles[i].tbCount!="none") //if there are any talkbacks
			{
		     str+="                                   <img src='../tv/images/talkb.gif' height=10 width=11></td>";
             str+="                             <td align=right class=greyTalkBack style=\"padding-right:3px;\">" + articles[i].tbCount + " תגובות ";
			}															
									 
			str+="</td></tr></table></td></tr></table></td></tr></table>";
			if(i==1 ) 
			 str+="<img src=http://www.themarker.com/ibo/images/0.gif width=1 height=5>";
			else
			 str+="<img src=http://www.themarker.com/ibo/images/0.gif width=1 height=1>";
		}	
		
    if(firstArcIndex==1)
	{
		 isDivOpen=0;
		 document.getElementById("firstArcInList").innerHTML='<iframe id="firstArcInList1" src="../objects/firstArticleInList.jhtml?ElementId=' + firstArc + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="display:block;overflow:hidden;"></iframe>';
		 document.getElementById("firstArticleInList").style.display="none"; //dont show the div
		 document.getElementById("arcListDiv2").innerHTML=str;	
	 }	
	else if(firstArcIndex>1)	//if the article was found and need to be place first
	{
	
		isDivOpen=0;
		document.getElementById("firstArcInList").innerHTML='<iframe id="firstArcInList2" src="../objects/firstArticleInList.jhtml?ElementId=' + firstArc + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="display:block;overflow:hidden;"></iframe>';
		document.getElementById("firstArticleInList").style.display="none"; //dont show the div	
		placeFirst(firstArcIndex); //order the articles again and place article in the top
	}
	
	else if (firstArc=="") //if it's the first time we are in the page without param ElementId
	{
	  isDivOpen=1;
	  firstArc=articles[1].arcId;  
      document.getElementById("arcListDiv2").innerHTML=str;		
	  
	 } 
	else //if the article wasnt found in the 10 articles
	{  
	  isDivOpen=1;
	   if(document.getElementById("firstArcInList")!=null)
	   {
	   	
		document.getElementById("firstArcInList").innerHTML='<iframe id="firstArcInList3" src="../objects/firstArticleInList.jhtml?ElementId=' + firstArc + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="display:block;overflow:hidden;"></iframe>';
		document.getElementById("firstArticleInList").style.display="block"; // show the div	
	   }	
		document.getElementById("arcListDiv2").innerHTML=str;		
	}

}

 
//constructor for article 
function Article(arcId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount)
{
  this.arcId=arcId;
  this.headline=headline;
  this.author=author;
  this.effectiveDate=effectiveDate;
  this.extendedCallout=extendedCallout;   //the video film
  this.specialImage=specialImage;
  this.callout=callout;   //the sub headline
  this.smsHeadline=smsHeadline;  //the time of the video film 
  this.tbCount=tbCount;  //number of talkbacks
  
} 
//replace chars 
function replaceChars(str)
{
	while(str.indexOf("~")!=-1)
		str =str.replace("~","\"");
	while(str.indexOf("*")!=-1)	
		str =str.replace("*","\'");
	return str;
}

//place the clicked article in the first place of the array
function placeFirst(index)
{

  if (index!=0)
  {
	  var tmp = articles[index];  //if it's the first article don't do anything
	 
	  for (i=index;i>=2;i--)
	    articles[i]= articles[i-1];
    articles[1]=tmp;
	writeTableAfterOrder();
  }
}

// change table background when mouse over  
function tableOnMouseOver(tableID,tdID)
{ 
  document.getElementById(tableID).className="tableMouseOver";
  document.getElementById(tdID).className="blackTitle";
}
//change table background when mouse out 
function tableOnMouseOut(tableID,tdID)
{ 
 document.getElementById(tableID).className = "tableMouseOut";
 document.getElementById(tdID).className="regularTitle";
}


//trim string function to delete spaces at a beginnig and the end of the string
function trimString(str)
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
//write the numbers of pages links
function showPagesNum(section,from,divName)
{ 
   if(pagesCount>5)
   	 pagesCount=5;  //at the moment pagesCount is 5 maximum
   var nextpage=from+ArcForPage;
   var previouspage=from-ArcForPage;
   var str="";
   var fromArc=0;
   var currPage;
   str= "<table  border=0 bordercolor=Fuchsia dir=rtl width=100% align=center><tr><td align=left style=\"padding-top:4px;\">";
		if(Math.floor(from/ArcForPage)+1 !=pagesCount) 
		   str+="<span onclick=movePage(" + nextpage + ",'"  + section  + "') class=orangeLink style=\"cursor:pointer;\" > <img src='../images/next_on.gif' border=0 style=\"cursor:pointer;\"> לכתבות הבאות</span>";
		else
		   str+="<span class=grey11><img src='../images/next_off.gif' border=0> לכתבות הבאות</span>";   
		 str+="</td><td align=center dir=ltr valign=top >";
		 for(i=1;i<=pagesCount;i++)
		 {
					fromArc = (i-1 )* ArcForPage + 1;
			     	if(i == Math.floor(from/ArcForPage)+1)//if its the current page
						str+="&nbsp;<span class=unPressedPage>" + i  + "</span>&nbsp;";
					else
				
					str+="&nbsp;<span style=\"cursor:pointer;\" class=pressedPage onclick=movePage(" + fromArc +  ",'" + section  + "')>"  + i + "</span>&nbsp;" ;
		 }	  
 		 str+="</td><td align=right style=\"padding-top:4px;\" >"; 	
		if(Math.floor(from/ArcForPage)+1 !=1) 
		 	str+="<span onclick=movePage(" + previouspage + ",'"  + section  + "') class=orangeLink style=\"cursor:pointer;\" > לכתבות הקודמות <img src='../images/back_on.gif' border=0 style=\"cursor:pointer;\"> </span>";
		else
		   str+="<span class=grey11>לכתבות הקודמות <img src='../images/back_off.gif' border=0> </span>";   
   		str+="</td></tr></table>";
   		document.getElementById(divName).innerHTML=str;
}

//write pages links for the next/prevvious articles
function showPagesNumArchive(section,from,divName,searchStr)
{ 
 
  if(pagesCount>1)
  {
 
	  var nextpage=from+ArcForPage;
	  var previouspage=from-ArcForPage;
	  var searchStr = encodeHebrewString(searchStr);
	  var str="";
	  var fromArc=0;
	  var currPage;
	  str= "<table  border=0 bordercolor=Fuchsia dir=rtl align=center><tr><td  align=left style=\"padding-top:4px;\" >";
	 if(Math.floor(from/ArcForPage)+1 !=pagesCount) 
		   str+="<a href=javascript:movePage2(" + nextpage + ",'"  + section  + "','" + searchStr + "') class=orangeLink > <img src='../images/next_on.gif' border=0 > לכתבות הבאות</a>";
	 else
		str+="<span class=grey11><img src='../images/next_off.gif' border=0>  לכתבות הבאות  </span>";   
	 
	 str+="</td><td align=center dir=ltr valign=top>";
	 for(i=1;i<=pagesCount;i++)
	 {
				fromArc = (i-1 )* ArcForPage + 1;
		     	if(i == Math.floor(from/ArcForPage)+1)//if its the current page
					str+="&nbsp;<span class=unPressedPage>" + i  + "</span>&nbsp;";
				else
			
				str+="&nbsp;<a class=pressedPage href=javascript:movePage2(" + fromArc +  ",'" + section  + "','" + searchStr + "')   >"  + i + "</a>&nbsp;" ;
	 }	  
	 str+="</td><td align=right style=\"padding-top:4px;\" >"; 	
	if(Math.floor(from/ArcForPage)+1 !=1) 
	 	str+="<td><a   class=orangeLink href=javascript:movePage2(" + previouspage + ",'"  + section  + "','" + searchStr + "')>   לכתבות הקודמות  <img src='../images/back_on.gif' border=0  ></a></td>";
  	else
		str+="<span class=grey11>  לכתבות הקודמות   <img src='../images/back_off.gif' border=0>  </span>";   
  	str+="</td></tr></table>";
  	document.getElementById(divName).innerHTML=str;
 }

}




//count the number of  pages showing 10 articles for each page
function countPages(arcCount2)
{
  pagesCount=Math.floor(arcCount2/ArcForPage)   // number of result/10
  
  if( arcCount2 % ArcForPage !=0)  //if the remainder doesnt equal 0
    pagesCount++;
}

/* article list */

//after pressing the page link for the next/previous page
function movePage(index,section)
{
		 isDivOpen=1;
		 getArcList(section,index);
         document.getElementById("arcListDiv").scrollTop=0;
}

// chang article video clip and content of first article
function changeArticle(slug,clipURL)
{
  firstArc=slug;
	document.getElementById("firstArticleInList").style.display="none"; //dont show the div		
   if (InternetExplorer)
    {
		firstArticleIframe.location="../objects/firstArticle.jhtml?ElementId="+slug;
		if(isCastTvPlayer(clipURL))
		{
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO style="overflow:auto;"></iframe>';				       
		}
		else 
		{	
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="../objects/default.jhtml?clipURL=' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO></iframe>';				       			       
			//var ifChildFrame = top.document.getElementById("tvScreenIframe");		
			//var oChildFrameDoc = (ifChildFrame.contentDocument) ?ifChildFrame.contentDocument : ifChildFrame.contentWindow.document;
			//oChildFrameDoc.parentWindow.Player.controls.stop(); 	
			//oChildFrameDoc.parentWindow.Player.url = clipURL;																	
			//oChildFrameDoc.parentWindow.Player.controls.play();
		}
		document.getElementById("arcListDiv").scrollTop=0;  //go to the top of the articles list (to the first article)	
	}
	else
	{
		document.getElementById("firstArcDiv").innerHTML='<iframe id="firstArticleIframe" src="../objects/firstArticle.jhtml?ElementId=' + slug  + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="overflow:hidden;display:block"></iframe>';
		if(isCastTvPlayer(clipURL))
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO style="overflow:auto;"></iframe>';				       
     	else
	   		document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="../objects/default.jhtml?clipURL=' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO></iframe>';				       
	    document.getElementById("arcListDiv").scrollTop=0;  //go to the top of the articles list (to the first article)	
    }
}
//log article page - counts the pressed article
function logArticle(id,leadingSection,effectiveDate,headline,author)
{
	leadingSection = escape(leadingSection);
	effectiveDate = escape(effectiveDate);
	headline = encodeHebrewString(headline);
	author = encodeHebrewString(author);
	document.getElementById("logger").innerHTML = "<iframe src=/scripts/logger.jhtml?id="+id+"&leadingSection="+leadingSection+"&headline="+headline+"&effectiveDate="+effectiveDate+"&author="+author+" border=0 width=0 height=0></iframe>";
}

// change special characters
function encodeHebrewString(str)
{
	var re = new RegExp('%','g');
	str = str.replace(re, '%25');
	re = new RegExp('~','g');
	str = str.replace(re, '%22');
	re = new RegExp(' ','g');
	str = str.replace(re, '%20');
	re = new RegExp('"','g');
	str = str.replace(re, '%22');
	re = new RegExp('\'`','g');
	str = str.replace(re, '%5C');
	re = new RegExp('<','g');
	str = str.replace(re, '%3C');
	re = new RegExp('>','g');
	str = str.replace(re, '%3E');
	re = new RegExp(';','g');
	str = str.replace(re, '%3B');
	re = new RegExp(':','g');
	str = str.replace(re, '%3A');
	re = new RegExp('#','g');
	return str.replace(re, '%27');
}

/* archive list page  */

//after pressing the page link for the next/previous page
function movePage2(index,section,searchStr)
{
		 
		 getArchiveList(section,searchStr,index);
         document.getElementById("arcListDiv").scrollTop=0;
}

function getArchiveList(section,searchStr,from)
{		
	try
	{			
		var parameters = "sectionTools="+section + "&searchStr=" + buildURL(searchStr)  +  "&startIndex="+from;	
		objhttp.open ("POST", "../objects/archiveList.jhtml", true);
		objhttp.onreadystatechange=function callGetResult2(){getResults2(section,from,searchStr);};				
		objhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;");				
		objhttp.send(parameters);			
	}
	catch(e){}	
}

//get search results in a string 
function getResults2(section,from,searchStr)
{	

	var repId,author,headline,specialImage,callout,extendedCallout,smsHeadline,effectiveDate,tbCount;
	if ((objhttp.readyState==4) && (objhttp.status == 200)) //if all data has loaded without errors
	{			

		var respText = objhttp.responseText;//get response text	
		 
		if(respText != "")//if there is response text
		{			

			respText = trimString(respText);
			var ar = respText.split("!!!");			
			var len = ar.length;

			arcCount = 	ar[0];
			countPages(arcCount);
			   if (len > 1)  //if there are articles
				{																

					for (var i =1; i <len; i++)
					{								
						if (trimString(ar[i]) == "")
							continue;		
	
						arc = ar[i].split("@@@");				
						repId = arc[0];
						author = arc[1];
						headline = arc[2];
						specialImage = arc[3];
						callout = arc[4];
						extendedCallout=arc[5];
						smsHeadline = arc[6];
						effectiveDate = arc[7];		
						tbCount = arc[8];	
	
						buildArcObj(i,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);
					}	
					document.getElementById("resultNum").innerHTML= searchStr + "&nbsp;[&nbsp;" + arcCount + "&nbsp;כתבות&nbsp;]";	
					showPagesNumArchive(section,from,"pageCountUpDiv",searchStr);			
					writeTableAfterOrder();
					showPagesNumArchive(section,from,"pageCountBottomDiv",searchStr);
			countPages(arcCount);
			}		
		}	
	}
}


//script for encoding string to utf-8
function utf8(wide) 
{
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) 
{
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s)
 {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}

function buildURL(fld)
{
	if (fld == "") return false;
	var encodedField = "";
	var s = fld;
	if (typeof encodeURIComponent == "function")
	{
		// Use JavaScript built-in function
		// IE 5.5+ and Netscape 6+ and Mozilla
		encodedField = encodeURIComponent(s);
	}
	else 
	{
		// Need to mimic the JavaScript version
		// Netscape 4 and IE 4 and IE 5.0
		encodedField = encodeURIComponentNew(s);
	}
	return encodeURIComponentNew(fld);
}


/*  tv searchword results */
//send parameters to archiveList.jhtml and get the string response  from this file 
function getArchiveList2(section,searchStr,from)
{		
	try
	{			
		var parameters = "sectionTools="+section + "&searchStr=" + buildURL(searchStr)  +  "&startIndex="+from;	
		objhttp.open ("POST", "../objects/archiveList.jhtml", true);
		objhttp.onreadystatechange=function callGetResult3(){getResults3(section,from,searchStr);};				
		objhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;");				
		objhttp.send(parameters);			
	}
	catch(e){}	
}

/*get tag search results*/
function getResults3(section,from,searchStr)
{	

	var repId,author,headline,specialImage,callout,extendedCallout,smsHeadline,effectiveDate,tbCount;
	if ((objhttp.readyState==4) && (objhttp.status == 200)) //if all data has loaded without errors
	{			
		var respText = objhttp.responseText;//get response text	
		 
		if(respText != "")//if there is response text
		{			
			respText = trimString(respText);
			var ar = respText.split("!!!");			
			var len = ar.length;
			arcCount = 	ar[0];
		    countPages(arcCount);
			    if (len > 1)  //if there are articles
				{																
								
					for (var i =1; i <len; i++)
					{								
						if (trimString(ar[i]) == "")
							continue;		
	
						arc = ar[i].split("@@@");				
						repId = arc[0];
						author = arc[1];
						headline = arc[2];
						specialImage = arc[3];
						callout = arc[4];
						extendedCallout=arc[5];
						smsHeadline = arc[6];
						effectiveDate = arc[7];		
						tbCount = arc[8];	
	
						
						buildArcObj(i,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);
						
					 }	
					 document.getElementById("resultNum").innerHTML= "<span class=searchStr>"  +  searchStr + "</span><span class=resultNum>&nbsp;[&nbsp;<b>" + arcCount + "</b>&nbsp;כתבות&nbsp;]</span>";	
					 showPagesNumArchive2(section,from,"pageCountUpDiv",searchStr);			
					 writeTableResults(searchStr,section);
					 //showPagesNumArchive2(section,from,"pageCountBottomDiv",searchStr);
				 }
			     else
			   		document.getElementById("noResultsDiv").style.display='block';
		}
	}	
}

//write the articles list after seacrh
function writeTableResults(searchStr,sectionTools)
{
  var str="";
    str+="<table border=0 bordercolor=blue width=760 cellpadding=0 cellspacing=0 align=center dir=rtl>";
	str+="	<tr><td height=11 colspan=10></td></tr>"
	str+="	<tr>";
   for (i=1;i<articles.length;i++)
		{  
			
			str+="<td width=124 valign=top align=left>";		
			str+="<table border=0 bordercolor=Fuchsia id=table" + i + " style=\"cursor:pointer;\" bordercolor=Blue   border=0 cellpadding=0 cellspacing=0 dir=rtl width=100%  onclick=\"logArticle('" + articles[i].arcId + "','credit','" +  articles[i].effectiveDate  + "','" +  articles[i].headline  + "','" +  articles[i].author  + "');changeArticle2('" + articles[i].arcId + "','" + articles[i].extendedCallout + "','" + searchStr + "','" + sectionTools + "');\"  onmouseover=\"changeFontSpecial('td" + i + "');\" onmouseout=\"changeFontRegular('td" + i + "');\" >";
            str+="       <tr><td valign=top align=right><img src=\"http://www.themarker.com" + articles[i].specialImage + "\" width=124 height=70 alt=\"" + replaceChars(articles[i].headline) + "\"></td></tr>";
			str+="       <tr><td height=5></td></tr>";
			str+="		 <tr><td valign=top  align=right class=regularTitle id=td" + i + ">" + replaceChars(articles[i].headline)  + "</td></tr>";
			str+="		 <tr><td valign=top align=right class=greenDateOrFilmTime dir=rtl style=\"padding-top:3px;\">" +  articles[i].effectiveDate + "  | " + articles[i].smsHeadline + "</td></tr>";
			str+=" 		 <tr>";
			str+="			<td height=10 valign=top align=right >";
			str+="				<table border=0 cellpadding=0 cellspacing=0 dir=rtl>";
			str+="                 <tr>";
			str+="						<td align=right>";
			if(articles[i].tbCount!="none")
			{
		     str+="                          <img src='../tv/images/talkb.gif' height=10 width=11></td>";
             str+="                      <td align=right class=greyTalkBack style=\"padding-right:3px;\">" + articles[i].tbCount + " תגובות ";
			}															
									 
			str+="                      </td>";
			str+="                   </tr>";
			str+="                </table>";
			str+="             </td>";
            str+="         </tr>";
			str+=" </table>";
			
			if(i==5) //break line afe
			 str+="</td></tr><tr><td height=27 colspan=10></td></tr>";
			else if(i==articles.length-1) 
			  str+="</td></tr>";
			else
			 str+="</td><td width=35></td>";
			
		}	
	str+="<tr><td height=63 colspan=10></td></tr>"	
	str+="</table>";
 document.getElementById("arcListDiv2").innerHTML=str;
}

/*  tv archive list    */
//write the numbers of pages link for nex/previous articles
function showPagesNumArchive2(section,from,divName,searchStr)
{ 
  if(pagesCount>1)
  {
	  var nextpage=from+ArcForPage;
	  var previouspage=from-ArcForPage;
	  var searchStr = encodeHebrewString(searchStr);
	  var str="";
	  var fromArc=0;
	  var currPage;
	  str= "<table border=0 bordercolor=Fuchsia width=300 cellpadding=0 cellspacing=0 align=center><tr><td align=left style=\"padding-top:4px;\" >";
	
	 if(Math.floor(from/ArcForPage)+1 !=pagesCount) 
	 	str+="<a  class=orangeLink href=javascript:movePage3(" + nextpage + ",'"  + section  + "','" + searchStr + "')> <img src='../images/next_on.gif' border=0 style=\"cursor:pointer;\"> לכתבות הבאות</a>";
	 else
	   str+="<span class=grey11><img src='../images/next_off.gif' border=0 style=\"cursor:pointer;\"> לכתבות הבאות</span>";  
	 str+="</td><td align=center dir=ltr valign=top  >";
	 for(i=1;i<=pagesCount;i++)
	 {
	 			
				fromArc = (i-1 )* ArcForPage + 1;
		     	if(i == Math.floor(from/ArcForPage)+1)//if its the current page
					str+="&nbsp;<span class=unPressedPage>" + i  + "</span>&nbsp;";
				else
			
				str+="&nbsp;<a  class=pressedPage href=javascript:movePage3(" + fromArc +  ",'" + section  + "','" + searchStr + "')>"  + i + "</a>&nbsp;" ;
	 }	  
	 str+="</td><td align=right style=\"padding-top:4px;\" >"; 	
	if(Math.floor(from/ArcForPage)+1 !=1) 
	   str+="<a class=orangeLink href=javascript:movePage3(" + previouspage + ",'"  + section  + "','" + searchStr + "')> לכתבות הקודמות <img src='../images/back_on.gif' border=0>  </a>";
    else
	   str+="<span class=grey11>לכתבות הקודמות<img src='../images/back_off.gif' border=0>  </span>";
		
  	str+="</td></tr></table>";
	document.getElementById(divName).innerHTML=str;
 }

}
//after presing next/previous page showing articles list
function movePage3(index,section,searchStr)
{
  	 	 getArchiveList2(section,searchStr,index);
         document.getElementById("arcListDiv").scrollTop=0;
}
//after pressing an article , show her
function changeArticle2(slug,clipURL,searchStr,sectionTools)
{
   location.href="/tvArchive.jhtml?searchStr=" + searchStr + "&ElementId=" + slug + "&sectionTools=" + sectionTools;

}
//after pressing enter in search field 
function checkEvent2()
{
   if (event.keyCode == 13)
   {
       event.returnValue = false;
       event.cancel = true;
      if(checkSearch2())
	     document.arcSearch2.submit();		
	}
}
//check validation of the search word 
function checkSearch2()
{
  if(document.arcSearch2.searchStr.value == "" ||document.arcSearch2.searchStr.value.indexOf("חפש כתבת טלוויזיה")!=-1)
	{
		alert("יש להזין מילות מפתח");
		document.arcSearch2.searchStr.focus();	
		return false;
	}
 if(document.arcSearch2.searchStr.value.length < 3 || trimString(document.arcSearch2.searchStr.value).length<3)
	{
		alert("חיפוש בארכיון חייב להכיל לפחות 3 אותיות");
		document.arcSearch2.searchStr.focus();	
        return false;
	}
	return true;	
}	
//building the sections  drop down 
function initsectionCombo2()
{
			var str = '<table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">'
			var links = new Array();
			links[0]=new Array("הכל","comp");
			for (counter = 1; counter < sections.length; counter++)
			  links[counter] =  new Array(sections[counter],sectionsLayers[counter]);

			for(i=0;i<links.length;i++)
			{
				var cobj = links[i];
				str += '<tr><td height="17" bgcolor="#ffffff" style="font-size:12px;font-family:Arial;color:#000000;cursor:default"  onmouseover="this.style.backgroundColor=\'#e2f0cd\'" onmouseout="this.style.backgroundColor=\'#ffffff\'" onclick="selidd(\''+ cobj[1] +'\',this.innerHTML,\'sectionTools\',sectionToolsDiv2,\'arcSearch2\')" height="16" align="right">&nbsp;'+cobj[0]+'</td></tr>';
			}
			str += '</table>';
			document.getElementById("sectionDropDown2").innerHTML = str;
}
//when loading the results page  initsectionCombo2
function init2()
{
	setTimeout('initsectionCombo2()',100);
}				
//turn  off the first article in list if other artice was selected (from a link-email,send article,themarker hp,investorguide)		
function setFirstArc(slug)
{
   firstArc=slug;
}		

/* five articles by section  */

//mouse over the td
function tdStyleOn(hrefNum,tdNum)
{
  if(hrefNum.indexOf("tdMoreArc5b")!=-1 || hrefNum.indexOf("tdMoreArcFirst")!=-1)
  	  document.getElementById(hrefNum).className="tdMoreArcOn";
  else
	  document.getElementById(hrefNum).className="blueNewVideoOn";
 		 document.getElementById(tdNum).style.backgroundColor="#57598f";


}

//mouse out the td
function tdStyleOff(hrefNum,tdNum)
{
  document.getElementById(tdNum).style.backgroundColor="white";
  if(hrefNum.indexOf("tdMoreArc5b")!=-1 || hrefNum.indexOf("tdMoreArcFirst")!=-1)
  	document.getElementById(hrefNum).className="greenNewVideo12";
  else
  	document.getElementById(hrefNum).className="blueNewVideo";

}

//send parameters to articleList.jhtml and get the string response  from this file 
function getNewArticleList(section)
{		

	try
	{			

			var parameters = "sectionLayer=" + section + "&amount=9" ;	
			objhttp.open ("POST", "../objects/articleList.jhtml", true);
			objhttp.onreadystatechange=function callGetResult4(){getNewArcResult(section);};				
			objhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;");				
			objhttp.send(parameters);		
	}	

	catch(e){}	
}
//send parameters to articleList.jhtml and get the string response  from this file 
 function getNewForeignList(section)
 {
   try
	{			

			var parameters = "sectionLayer=" + section + "&amount=3" ;	
			objhttp2.open ("POST", "../objects/articleList2.jhtml", true);
			objhttp2.onreadystatechange=function callGetResult5(){getNewForeignResult(section);};				
			objhttp2.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;");				
			objhttp2.send(parameters);		
	}	

	catch(e){}	

 }
/*get tag results*/
function getNewArcResult(section)
{	
	var repId,author,headline,specialImage,callout,extendedCallout,smsHeadline,effectiveDate,tbCount;
	if ((objhttp.readyState==4) && (objhttp.status == 200)) //if all data has loaded without errors
	{			
		var respText = objhttp.responseText;//get response text	
		 
		if(respText != "")//if there is response text
		{			
			respText = trimString(respText);
			var ar = respText.split("!!!");			
			var len = ar.length;

			    if (len > 1)  //if there are articles
				{																
					for (var i =1; i <len; i++)
					{								
						if (trimString(ar[i]) == "")
							continue;		
	
						arc = ar[i].split("@@@");				
						repId = arc[0];
						author = arc[1];
						headline = arc[2];
						specialImage = arc[3];
						callout = arc[4];
						extendedCallout=arc[5];
						smsHeadline = arc[6];
						effectiveDate = arc[7];		
						tbCount = arc[8];	

						buildArcObj(i,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);
					 }	
					 	writeTableNewArticleResults(section);
				 }
				 
		}
	}	
}
/*get tag search results*/
function getNewForeignResult(section)
{	

	var repId,author,headline,specialImage,callout,extendedCallout,smsHeadline,effectiveDate,tbCount;
	
	if ((objhttp2.readyState==4) && (objhttp2.status == 200) ) //if all data has loaded without errors
	{			
		var respText = objhttp2.responseText;//get response text	
		 
		if(respText != "")//if there is response text
		{	
			respText = trimString(respText);
			var ar = respText.split("!!!");			
			var len = ar.length;

			    if (len > 1)  //if there are articles
				{															
					for (var i =1; i <len; i++)
					{								
						if (trimString(ar[i]) == "")
							continue;		
	
						arc = ar[i].split("@@@");				
						repId = arc[0];
						author = arc[1];
						headline = arc[2];
						specialImage = arc[3];
						callout = arc[4];
						extendedCallout=arc[5];
						smsHeadline = arc[6];
						effectiveDate = arc[7];		
						tbCount = arc[8];	
						buildArcObj2(i,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);
					 }	
					    writeTableNewArticleResults2(section);
				 }
				 
		}
	}	
}
//write the articles list after seacrh
function writeTableNewArticleResults(section)
{
  var str="";
    str+="<table border=0 bordercolor=blue cellpadding=0 cellspacing=0 dir=rtl>";
	str+="	<tr>";
        for (i=1;i<articles.length;i++)
		{  
			str+="<td width=124 valign=top align=left>";		
			str+="<table border=0 bordercolor=Fuchsia id=table" + i + " style=\"cursor:pointer;\" bordercolor=Blue   border=0 cellpadding=0 cellspacing=0 dir=rtl width=100%  onclick=\"logArticle('" + articles[i].arcId + "','credit','" +  articles[i].effectiveDate  + "','" +  articles[i].headline  + "','" +  articles[i].author  + "');changeArticle3('" + articles[i].arcId + "');\" onmouseover=\"changeFontSpecial('td" + i + "');\" onmouseout=\"changeFontRegular('td" + i + "');\"   >";
            str+="       <tr><td valign=top align=right><img src=\"http://www.themarker.com" + articles[i].specialImage + "\" width=124 height=70 alt=\"" + replaceChars(articles[i].headline) + "\"></td></tr>";
			str+="       <tr><td height=5></td></tr>";
			str+="		 <tr><td valign=top  align=right class=regularTitle  id=td" + i + ">" + replaceChars(articles[i].headline)  + "</td></tr>";
			str+="		 <tr><td valign=top align=right class=greenDateOrFilmTime dir=rtl style=\"padding-top:3px;\">" +  articles[i].effectiveDate + "  | " + articles[i].smsHeadline + "</td></tr>";
		    str+=" </table>";
			
			if(i%3==0 && i!=articles.length-1) //break line after 3 articles
			 str+="</td></tr><tr><td height=44 colspan=10></td></tr>";
			else if(i==articles.length-1) 
			  str+="</td></tr>";
			else
			 str+="</td><td width=46></td>";
			
		}	
      str+="</table>";
 		document.getElementById("arcListDiv1").innerHTML=str;
	    	
}

//write the articles list after seacrh
function writeTableNewArticleResults2(section)
{
  var str="";
    str+="<table border=0 bordercolor=blue cellpadding=0 cellspacing=0 dir=rtl>";
	str+="	<tr>";
        for (i=1;i<articles2.length;i++)
		{ 
			str+="<td width=124 valign=top align=left>";		
			str+="<table border=0 bordercolor=Fuchsia id=table" + i + " style=\"cursor:pointer;\" bordercolor=Blue   border=0 cellpadding=0 cellspacing=0 dir=rtl width=100%  onclick=\"logArticle('" + articles2[i].arcId + "','credit','" +  articles2[i].effectiveDate  + "','" +  articles2[i].headline  + "','" +  articles2[i].author  + "');changeArticle3('" + articles2[i].arcId + "');\" onmouseover=\"changeFontSpecial('tdb" + i + "');\" onmouseout=\"changeFontRegular('tdb" + i + "');\"  >";
            str+="       <tr><td valign=top align=right><img src=\"http://www.themarker.com" + articles2[i].specialImage + "\" width=124 height=70 alt=\"" + replaceChars(articles2[i].headline) + "\"></td></tr>";
			str+="       <tr><td height=5></td></tr>";
			str+="		 <tr><td valign=top  align=right class=regularTitle id=tdb" + i + ">" + replaceChars(articles2[i].headline)  + "</td></tr>";
			str+="		 <tr><td valign=top align=right class=greenDateOrFilmTime dir=rtl style=\"padding-top:3px;\">" +  articles2[i].effectiveDate + "  | " + articles2[i].smsHeadline + "</td></tr>";
		    str+=" </table>";
			
			 if(i==articles2.length-1) 
			  str+="</td></tr>";
			else
			 str+="</td><td width=46></td>";
			
		}	
      str+="</table>";

 	document.getElementById("arcListDiv2").innerHTML=str;	    	
}
function buildArcObj2(index,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount)
{
   eval("arc" + index + " = new Article(repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);");
   eval("articles2[index] = arc" + index + ";");
}

//after pressing an article , show her
function changeArticle3(slug)
{
   location.href="../index2.jhtml?ElementId=" + slug;

}

function changeFontSpecial(tdId)
{
  document.getElementById(tdId).className="blackTitle";
}

function changeFontRegular(tdId)
{
  document.getElementById(tdId).className="regularTitle";
}


function AddButMouseOver()
{
  addBut.src="../images/talkb_on.gif"
  addBut2.className="sendGreenUnderLine";
}

function AddButMouseOut()
{
  addBut.src="../images/talkb.gif"
  addBut2.className="sendGreen";
}

function sendButMouseOver()
{
  sendBut.src="../images/send_green.gif"
  sendBut2.className="sendGreenUnderLine";
}

function sendButMouseOut()
{
  sendBut.src="../images/send3.gif"
  sendBut2.className="sendGreen";
}


function FrequentVideoOver(num,alink)
{
  document.getElementById(num).className ="popularArticlesTitleOn" ;
  document.getElementById(alink).className="articlesLinksOn";
}

function FrequentVideoOut(num,alink)
{
   document.getElementById(num).className ="popularArticlesTitle "; 
   document.getElementById(alink).className="articlesLinks";
}


/* functions for article list iframe in tv home (index.jhtml)  */
//get articles from targeters from articleListHome.jhtml
function getArcListHome()
{		
	
		var parameters = "";		
		objhttp.open ("POST", "../objects/articleListHome.jhtml", true);
		objhttp.onreadystatechange=function callGetResultHome(){getResultsHome();};				
		objhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;");				
		objhttp.send(parameters);			
	
}

function getResultsHome()
{	
	
	var repId,author,headline,specialImage,callout,extendedCallout,smsHeadline,effectiveDate,tbCount;
	if ((objhttp.readyState==4) && (objhttp.status == 200)) //if all data has loaded without errors
	{			
		var respText = objhttp.responseText;//get response text	

		if(respText != "")//if there is response text
		{			
			respText = trimString(respText);
			var ar = respText.split("!!!");			
			var len = ar.length;
			arcCount = 	ar[0];
			countPages(arcCount); //at the moment pageCount is going to be maximum 5

			if (len > 1)  //if there are articles
			{																
				for (var i =1 ; i <len ; i++)
				{								
					if (trimString(ar[i]) == "")
						continue;		
					arc = ar[i].split("@@@");				
					repId = arc[0];
					author = arc[1];
					headline = arc[2];
					specialImage = arc[3];
					callout = arc[4];
					extendedCallout=arc[5];
					smsHeadline = arc[6];
					effectiveDate = arc[7];		
					tbCount = arc[8];
		          
					buildArcObj(i,repId,headline,author,effectiveDate,extendedCallout,specialImage,callout,smsHeadline,tbCount);
				}
				//showPagesNum(section,from,"pageCountUpDiv");			
				writeTableAfterOrderHome();
				//showPagesNum(section,from,"pageCountBottomDiv");
					
			}		
			
		}	
	}
	
}

function  writeTableAfterOrderHome()
{
   firstArcIndex=-1; 
   var str="";
   if(firstArc!="")
    isDivOpen=1;
   str+="<table><tr><td height=4></td></tr></table>";
   for (i=1;i<articles.length;i++)
		{  
			if(articles[i].arcId==firstArc)
			{
				isDivOpen=0;
				firstArcIndex=i;
			}
			
			if(i==1 && isDivOpen==0)  //if it's the first article and the first div isn't open
				str+="<table border=0 bordercolor=Fuchsia id=table" + i + "  bordercolor=Blue  bgcolor=#d3d6eb  border=0 cellpadding=0 cellspacing=0 dir=rtl width=275 height=80 >"
			else
				str+="<table border=0 bordercolor=Fuchsia id=table" + i + " style=\"cursor:pointer;\" bordercolor=Blue background=\"../images/bg_mover_off.gif\" style=\"background-repeat : repeat-x;\"  border=0 cellpadding=0 cellspacing=0 dir=rtl width=275 height=84 onclick=\"logArticle('" + articles[i].arcId + "','credit','" +  articles[i].effectiveDate  + "','" +  articles[i].headline  + "','" +  articles[i].author  + "');changeArticleHome('" + articles[i].arcId + "','" + articles[i].extendedCallout + "');placeFirstHome(" + i + ");\" onmouseover=\"tableOnMouseOver('table" + i + "','td" + i + "');\" onmouseout=\"tableOnMouseOut('table" + i + "','td" + i + "');\"  >";
            str+="   <tr>";
			str+="	    <td valign=top align=right  style=\"padding-right:5px;padding-top:5px;\"><img src=\"http://www.themarker.com" + articles[i].specialImage + "\" width=124 height=70 alt=\"" + replaceChars(articles[i].headline) + "\"></td>";
			str+="	    <td align=right valign=top style=\"padding-right:10px;padding-left:10px;padding-top:3px;\" width=173>";
			str+="	        <table border=0 bordercolor=Fuchsia cellpadding=0 cellspacing=0 align=right width=100%  >";
			if(i==1 && isDivOpen==0) //if it's the first article and the first div isn't open
				str+="		   <tr><td  align=right class=blackTitle id=td" + i + ">" + replaceChars(articles[i].headline)  + "</td></tr>";
			else
			    str+="         <tr><td  align=right class=regularTitle id=td" + i + ">" + replaceChars(articles[i].headline)  + "</td></tr>";   
			str+="			   <tr><td valign=top align=right class=greenDateOrFilmTime dir=rtl style=\"padding-top:3px;\">" +  articles[i].effectiveDate + "  | " + articles[i].smsHeadline + "</td></tr>";
			str+=" 			   <tr>";
			str+="					<td height=10 valign=top align=right >";
			str+="						<table border=0 cellpadding=0 cellspacing=0 dir=rtl>";
			str+="                            <tr>";
			str+="								<td align=right>";
			if(articles[i].tbCount!="none") //if there are any talkbacks
			{
		     str+="                                   <img src='../tv/images/talkb.gif' height=10 width=11></td>";
             str+="                             <td align=right class=greyTalkBack style=\"padding-right:3px;\">" + articles[i].tbCount + " תגובות ";
			}															
									 
			str+="</td></tr></table></td></tr></table></td></tr></table>";
			if(i==1 ) 
			 str+="<img src=http://www.themarker.com/ibo/images/0.gif width=1 height=5>";
			else
			 str+="<img src=http://www.themarker.com/ibo/images/0.gif width=1 height=1>";
		}	
		
    if(firstArcIndex==1)
	{
		 isDivOpen=0;
		 document.getElementById("firstArcInList").innerHTML='<iframe id="firstArcInList1" src="../objects/firstArticleInListHome.jhtml?ElementId=' + firstArc + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="display:block;overflow:hidden;"></iframe>';
		 document.getElementById("firstArticleInList").style.display="none"; //dont show the div
		 document.getElementById("arcListDiv2").innerHTML=str;	
	 }	
	else if(firstArcIndex>1)	//if the article was found and need to be place first
	{
	
		isDivOpen=0;
		document.getElementById("firstArcInList").innerHTML='<iframe id="firstArcInList2" src="../objects/firstArticleInListHome.jhtml?ElementId=' + firstArc + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="display:block;overflow:hidden;"></iframe>';
		document.getElementById("firstArticleInList").style.display="none"; //dont show the div	
		placeFirstHome(firstArcIndex); //order the articles again and place article in the top
	}
	
	else if (firstArc=="") //if it's the first time we are in the page without param ElementId
	{
	  isDivOpen=1;
	  firstArc=articles[1].arcId;  
      document.getElementById("arcListDiv2").innerHTML=str;		
	  
	 } 
	else //if the article wasnt found in the 10 articles
	{  
	  isDivOpen=1;
	   if(document.getElementById("firstArcInList")!=null)
	   {
	   	
		document.getElementById("firstArcInList").innerHTML='<iframe id="firstArcInList3" src="../objects/firstArticleInListHome.jhtml?ElementId=' + firstArc + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="display:block;overflow:hidden;"></iframe>';
		document.getElementById("firstArticleInList").style.display="block"; // show the div	
	   }	
		document.getElementById("arcListDiv2").innerHTML=str;		
	}

}

// chang article video clip and content of first article
function changeArticleHome(slug,clipURL)
{
  
  firstArc=slug;
	document.getElementById("firstArticleInList").style.display="none"; //dont show the div		
   if (InternetExplorer)
    {
		firstArticleIframe.location="../objects/firstArticleHome.jhtml?ElementId="+slug; 
		if(isCastTvPlayer(clipURL))
		{
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO style="overflow:auto;"></iframe>';				       
		}
		else
		{
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="../objects/default.jhtml?clipURL=' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO></iframe>';				       
			//var ifChildFrame = top.document.getElementById("tvScreenIframe");		
			//var oChildFrameDoc = (ifChildFrame.contentDocument) ?ifChildFrame.contentDocument : ifChildFrame.contentWindow.document;
			//oChildFrameDoc.parentWindow.Player.controls.stop(); 	
			//oChildFrameDoc.parentWindow.Player.url = clipURL;																	
			//oChildFrameDoc.parentWindow.Player.controls.play(); 			       
		}
        document.getElementById("arcListDiv").scrollTop=0;  //go to the top of the articles list (to the first article)	
	}
	else
	{
		document.getElementById("firstArcDiv").innerHTML='<iframe id="firstArticleIframe" src="../objects/firstArticleHome.jhtml?ElementId=' + slug  + '" frameborder=0 scrolling=no marginheight=0 marginwidth=0 width=0 height=0 style="overflow:hidden;display:block"></iframe>';
		if(isCastTvPlayer(clipURL))
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO style="overflow:auto;"></iframe>';				       
        else
			document.getElementById("tvScreenDiv").innerHTML='<iframe id="tvScreenIframe"  src="../objects/default.jhtml?clipURL=' + clipURL  + '"  width="443" height="388"  marginwidth=0 marginheight=0  topmargin=0 leftmargin=0 FRAMEBORDER=0 SCROLLING=NO></iframe>';				       
		document.getElementById("arcListDiv").scrollTop=0;  //go to the top of the articles list (to the first article)	
    }
}

function placeFirstHome(index)
{
  if (index!=0)
  {
	  var tmp = articles[index];  //if it's the first article don't do anything
	 
	  for (i=index;i>=2;i--)
	    articles[i]= articles[i-1];
    articles[1]=tmp;
	writeTableAfterOrderHome();
  }
}
function isCastTvPlayer(clipURL)
{
	return (clipURL.indexOf("cast-tv"))==-1?false:true;
}