
var flag      = true;
var offTemp   = null;
var onTemp    = null;


idTemp = null;
idChetzTemp = null;
var infoImage = new Image();
infoImage.src = "/f/images/preim.gif";


// checking form fields
function isLegalFullPhone(str)
{
	var legal = 1;
	if(str != undefined && str !=""){
	  for (i=0; i<str.length; i++) {
	    ch = str.substring(i,i+1)
	    if (ch !="-" && ch !="0" && ch !="1" && ch !="2" && ch !="3" && ch !="4" && ch !="5" && ch !="6" && ch !="7" && ch !="8" && ch !="9") {
	      legal = 0
	      break
	    }
	  }
	  if (str.length > 11 || str.length < 7)
	     legal=0;
	}
	return legal
}
function setNewHomePage(site)
{	
	document.getElementById("home").style.behavior='url(#default#homepage)';
	if (site == 'yoetz')
		document.getElementById("home").setHomePage('http://yoetz.themarker.com');
	else
		document.getElementById("home").setHomePage('http://finance.themarker.com');	
}

/////////////////////////////////////////////////
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');
	str = str.replace(re, '%26');
	re = new RegExp('#','g');
	return str.replace(re, '%27');
}


function changeDropPremiumBgcolor(idName)
{
	if(idTemp!=null)
	{
		document.getElementById(idChetzTemp+"1").innerHTML= "";	
		
		document.getElementById(idTemp).className = "dropDownGreen";
		
		if(idTemp=="sms")
			document.getElementById("topGap").className = "dropDownGreen";
	}
	
	//document.getElementById(idName+"1").innerHTML= "<img src='/f/images/preimChetz.gif' align='middle'>";	
	
	document.getElementById(idName).className = "dropDownBlue";
	
	if(idName=="sms")
		document.getElementById("topGap").className = "dropDownBlue";
		
	idTemp=idName;	
	idChetzTemp = idName;
}


var timer = 0;
var tempSecCode = null;

function showDropPremium(titleName,secCode,evt)
{	
	
	evt = (evt) ? evt : ((window.event) ? window.event : "")
    if (evt) 
	{
	    if(!checkTelniri())
		{
			var sWidth = screen.width;
			document.getElementById("dropDown").style.display="";
			
			if(evt.clientY <70)
				document.getElementById("dropDown").style.top = evt.clientY + window.document.body.scrollTop;
		
			else{
				if((secCode == "0") || (secCode == "-1"))
					document.getElementById("dropDown").style.top = evt.clientY + window.document.body.scrollTop-62;
						
				else
					document.getElementById("dropDown").style.top = evt.clientY + window.document.body.scrollTop-80;
			}
		
			document.getElementById("dropDown").style.left = evt.clientX + window.document.body.scrollLeft-147;	
			document.getElementById("premumTitle").innerHTML= titleName;	
			
			/*if(secCode == "0"){
				document.getElementById("marketDiv").style.display="none";
			}
			
			else{
				document.getElementById("marketDiv").style.display="";
				//alert(secCode);
			} */
			
			tempSecCode = secCode;
		}
	}
}

function hideDropPremium()
{
	if(!checkTelniri())
		timer = window.setTimeout("hideDropPremium2()", 100); 
}

function hideDropPremium2()
{
	document.getElementById("dropDown").style.display= "none";
	
	if(idTemp != null){
		document.getElementById(idTemp).className = "dropDownGreen";
		document.getElementById(idTemp+"1").innerHTML= " ";	
	
		if(idTemp=="sms")
		document.getElementById("topGap").className = "dropDownGreen";
	}
}

function showDropPremiumDiv()
{
	window.clearTimeout(timer);
	document.getElementById("dropDown").style.display="inline";
}

function stockLink()
{
	url = 'http://www.themarker.com/klal.jhtml?stockid='+tempSecCode;
	window.open(url);	
//	location.href = url;
}
////////////////////////////////////////////////////////////////////////////////////////////////////

function arrowGif(val){
	if (val > 0){
	 return "<img src='/f/images/up.gif'>"; 
	}
	
	else if (val < 0){
	 return "<img src='/f/images/down.gif'>";
	}
	
	else{
			return "";
		}
}

function OpenPopUp()
	{ 
	window.open('../../site/market/popUpMsg.jhtml','update_popups','left=0,top=0,width=400,height=320,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=no');
	}
	

function FDiffColor(val,decimalPlace,percent){
	var valnum;
	var per ="";
	//valnum = cDbl(val)
	if (percent==1){ 
		per= "%";
	} 
	if (val > 0)
	{
		 return "<font color=green>"  + FixFormat( val,decimalPlace) + per+"</font>";
	}
	else
	{
		if (val < 0)
		{
			return  "<font color=red>"  + FixFormat( val,decimalPlace) + per + "</font>";
		}
		else
		{
			return "<font color=green>0.00"+per+"</font>";
		}
	}
}

// changing color of the value
// percent:1  -  add % to the value
function valDiffColor(val,percent){
	var valnum;
	var per ="";
	//valnum = cDbl(val)
	if (percent==1){ 
		per= "%";
	} 
	if (val > 0)
		return "<font color=green>"  + val + per+"</font>";
	else if (val < 0)
		return  "<font color=red>"  + val + per + "</font>";
	else
		return "<font color=green>0.00"+per+"</font>";
}

function FixFormat(num,decimalPlace)
{

		if (decimalPlace ==1)
			divNum = 10;
		if (decimalPlace ==2)
			divNum = 100;
		if (decimalPlace ==3)
			divNum = 1000;
		if (decimalPlace ==4)
			divNum = 10000;
		StringNum = num.toString();
		SplitNum = StringNum.split(".");
		if (SplitNum[1]){
		//----------------------------------------
			lenNum = SplitNum[1].length;
			DecimalNum = SplitNum[1].substr(0,decimalPlace);
			if (decimalPlace == 0) {
				if (decimalPlace < lenNum)
				{
					spl1 = SplitNum[1].substr(SplitNum[1].length-1,SplitNum[1].length);
					chkNum = "0."+spl1;
					chkNum = chkNum*1;
					if (chkNum>=0.5)
					{
						fn = SplitNum[0]+""+DecimalNum;
						if (num >= 0)
							fn = fn*1+1;
						else
							fn = fn*1-1;
						StringNum1 = fn.toString();						
						SplitNum = StringNum1.split(".");
						if(StringNum1.indexOf(".")==-1)
							DecimalNum = 0;
						else
							DecimalNum = SplitNum[1];
					}
				}
				//---------------------------------------
				OutPutNum = prefix(SplitNum[0]);
			}else{
				if (decimalPlace < lenNum)
				{
					spl1 = SplitNum[1].substr(decimalPlace,decimalPlace+1);
					chkNum = "0."+spl1;
					chkNum = chkNum*1;
					if (chkNum>=0.5)
					{
						fn = SplitNum[0]+""+DecimalNum;
						if (num >= 0)
							fn = fn*1+1;
						else
							fn = fn*1-1;
						fn = fn/divNum;
						StringNum1 = fn.toString();						
						SplitNum = StringNum1.split(".");
						if(StringNum1.indexOf(".")==-1)
							DecimalNum = 0;
						else
							DecimalNum = SplitNum[1];
					}
				}
				OutPutNum = prefix(SplitNum[0]) + "." + DecimalNum;
				if (decimalPlace == 2){
					DecimalNum = DecimalNum.toString();
					if(DecimalNum.length == 1){
						OutPutNum = OutPutNum + "0";
					} 
				}
			}
			num = OutPutNum; 
			
		}
		else{
			
			if (decimalPlace == 1){
				num = num + ".0"
			}
			if (decimalPlace == 2){
				num = num + ".00"
			}
			num = prefix(num);
		}		
		if (num =="0.0" || num ==".0" || num =="0" || num =="0.00" || num ==".00" ||num =="-9,999" || num =="-9,999.0" || num =="-9,999.00" || num =="9,999" || num =="9,999.0" || num =="9,999.00"){
			num = "-";
		}
		if (num.indexOf("-.") != -1)
		{
			num = "-";
		}	
		return num;
		
}

function prefix(num){
	Newnum = "0";
	mark = "";
	StringNum = num.toString();
	SplitNum = StringNum.split(".");
	if (SplitNum[1]){
	 	num = SplitNum[0];
		decimalPart = "." + SplitNum[1];
	}else{
		decimalPart = "";
	}
	num = num.toString();
	if (num.substr(0,1) == "-"){
		mark = "-"
		if (num.length == 1){
			num = "";
		}else{
			num = num.substr(1);
		}
	}
	leng = num.length;
	numOfPrefix = Math.floor(leng / 3);
	if ((leng % 3) == 0){
		numOfPrefix = numOfPrefix - 1;
	}
	arrayObj = new Array();
	first = leng-3;
	len = 3;  
	for (i=0;i<numOfPrefix+1;i++){
		if (first < 0){
			len = 3+first;
			first = 0;
		}
		arrayObj[i] = num.substr(first,len);
		first = first - len;
	}
	num = "";
	for (i=numOfPrefix;i>=0;i--){
		if (i == 0){
			num = num + arrayObj[i];
		}else{
			num = num + arrayObj[i] + ",";
		}
	}
	num = mark + num + decimalPart;
	return num;
}

function mathFunc(num,operator,withNum)
{
		switch (operator) {
			case "/" :
				x = num/withNum;
				break;
			case "*" :
				x = num*withNum;
				break;
			case "-" :
				x = num-withNum;
				break;
			default :
				x = num
		}
		return  x;	
}
function dw(str){
document.write(str);
}

function bannerNew(noPosition,l1,l2,l3,posSrcs,positionStr){
	loc = document.location;
	locationStr = loc.toString();
    site = "AOnline";
	var now = new Date();
	var RND = now.getSeconds();
	var frameUrl = "http://dclk"
	if(checkKlal())
		l2 = "yoetz";
	frameUrl += ".themarker.com/html.ng/site="+site+"&adsize=" + posSrcs + "&" + (l1=="none"?"":"aolayer0="+l1+"&") + (l2=="none"?"":"aolayer1="+l2+"&") + (l3=="none"?"":"aolayer2="+l3+"&") + "adtype=hp&aopage_position=" + noPosition + "&Rnd=" + RND;	
	//frameUrl = "";  //problem in dclk
	document.write("<IFRAME " + positionStr + " MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=000000 SRC=\"" + frameUrl + "\"></IFRAME>");
	document.write('</div>');	
}

function bannerNewCreative(site,noPosition,l1,l2,l3,l4,posSrcs,positionStr){
var site = site;
var now = new Date();
var RND = now.getSeconds();
var frameUrl = "http://dclk"
frameUrl += ".themarker.com/html.ng/site="+site+"&adsize=" + posSrcs + "&" + (l1=="none"?"":"aolayer0="+l1+"&") + (l2=="none"?"":"aolayer1="+l2+"&") + (l3=="none"?"":"aolayer2="+l3+"&") + "adtype=hp&aopage_position=" + noPosition + "&Rnd=" + RND;
document.write("<IFRAME " + positionStr + " MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=000000 SRC=\"" + frameUrl + "\"></IFRAME>");
document.write('</div>');	
}

var userTypeBanner="";
var navBar="";
function banner(noPosition,aolayer0,aolayer1,aolayer2)
{
	position = new Array("","WIDTH=468 HEIGHT=60","WIDTH=124 HEIGHT=80","WIDTH=124 HEIGHT=80","WIDTH=109 HEIGHT=65","WIDTH=150 HEIGHT=154","WIDTH=124 HEIGHT=180","WIDTH=80 HEIGHT=31","WIDTH=245 HEIGHT=245","WIDTH=210 HEIGHT=210","WIDTH=124 HEIGHT=450","WIDTH=76 HEIGHT=34","WIDTH=76 HEIGHT=34","WIDTH=76 HEIGHT=34","WIDTH=150 HEIGHT=154","WIDTH=124 HEIGHT=31","WIDTH=124 HEIGHT=31","WIDTH=230 HEIGHT=30","WIDTH=152 HEIGHT=40","WIDTH=109 HEIGHT=109","WIDTH=485 HEIGHT=38","","WIDTH=124 HEIGHT=84","WIDTH=124 HEIGHT=48","WIDTH=124 HEIGHT=60","WIDTH=89 HEIGHT=17","WIDTH=761 HEIGHT=60","WIDTH=280 HEIGHT=60","WIDTH=468 HEIGHT=60","WIDTH=468 HEIGHT=60","","","","","","","WIDTH=760 HEIGHT=60","WIDTH=280 HEIGHT=60","WIDTH=280 HEIGHT=60");
	posSrcs = new Array(" ","adsize=468x60","adsize=124x80","adsize=124x80","adsize=109x65","adsize=150x154","adsize=124x180","adsize=80x31","adsize=245x245","adsize=210x210","adsize=124x450","adsize=76x34","adsize=76x34","adsize=76x34","adsize=150x154","adsize=124x31","adsize=124x31","adsize=230x30","adsize=152x40","adsize=109x109","adsize=485x38","","adsize=124x84","adsize=124x48","adsize=124x60","adsize=89x17","adsize=761x60","adsize=280x60","adsize=468x60","adsize=468x60","","","","","","","adsize=760x60","adsize=280x60","adsize=280x60");
	var now = new Date();
	var RND = now.getSeconds();
	var site;
	
	if(checkMsn()==1)
		site="aonline_msn";

	else
		site = "AOnline";
		
	document.write('<IFRAME ID=add' + noPosition + ' ' + position[noPosition] + ' MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR=000000 SRC="http://dclk.themarker.com/html.ng/site='+site+'&userType='+userTypeBanner+'&navBar='+navBar+'&' + posSrcs[noPosition] + '&aolayer0=' + aolayer0 + '&aolayer1=' + aolayer1 +'&aolayer2=' + aolayer2 + '&adtype=hp&aopage_position=' + noPosition + '&Rnd=' + RND +'"></IFRAME>');
}


var navBar="";

function chktag(val)
{
	if (val == "-")
		return 0;
	else
		return val;
}
function calculator(info) 
{
	var cal = window.open("/site/bonds/calculator.jhtml","downpop1","left=0,top=0,width=510,height=450,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=no");
}
function addTag(obj)
{
	str = obj.value;
	secAfter = str.replace("'", "''");
	obj.value = secAfter;
}
function getpass()  
{
	password=window.open("/site/gen/passwordMail.jhtml","password","height=320,width=300,top=0,left=0");
}
function wr(str)
{
	document.write(str);
}

function help(info)
{ 
	window.open("/site/gen/helpContent.jhtml?info=" + info,"downpop","left=0,top=0,width=490,height=400,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=yes");
} 

function OpenArt(link) 
{
	window.open(link + '.html',"","width=750,height=540,directories=yes,toolbar=yes,resizable=no,menubar=yes,location=yes,scrollbars=yes,status=yes,top=0,left=0 ");
}

function Ruler(colspan) 
{ 
	var Ruler;
	Ruler = "<tr><td colspan=" + colspan;
	Ruler = Ruler + " bgcolor='#E4E5D8'><img src='http://grm.aonline.co.il/site/images/nothing.gif' height=1 width=1></td></tr>";
	document.write (Ruler);
} 
function glossary(code)
{
	window.open("/site/gen/glossary.jhtml?code="+code,"downpop2","left=0,top=0,width=270,height=160,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=yes");
}
function OpenBursa(Link)
{
	window.open(Link,"AnalystNews","left=0,top=0,width=400,height=300,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes");
}

function formHandler(){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}


function trim (s)
{
var iLen = s.length;
var sOut = "";
var chr = "";

for (var i=0; i<iLen; i++)
{
chr = s.charAt (i); 
if (chr!=" ")
{
sOut = sOut + chr; 
}
}
return sOut; 
}

 
function midIt (currString, fromNum, countNum){
	splitString = currString.split("");
	newString = "";
	var i = (fromNum-1);
	for(i ; i <=(countNum+1); i++){
		newString = newString + splitString[i];
	}
	return(newString);
}

function cngGif(CurrOrder,pOrder)
	{
		if (pOrder == CurrOrder){
			document.write("<img src=/site/images/sortglow.gif border=0 width=30 height=9>");
		}else{
			document.write("<img src=/site/images/sort.gif border=0 width=30 height=9>");
		}
	}
function cngGif2(CurrOrder,pOrder)
{
	document.write("<img src=/f/images/ws/down.gif border=0 >");
	document.write("<img src='../../f/images/0.gif' width='14' border='0'>");
	document.write("<img src=/f/images/ws/up.gif border=0 >");
}
	
function AddImage(rate)
{ 
	if (! isNaN(rate)){ 
		StringNum = rate.toString();
	}
	
	if (rate.search("0.00") == -1){
		if (rate.search("-") == -1){
			document.write('<img src="/site/images/arrow_up.gif">');
		}else{
			document.write('<img src="/site/images/arrow_dawn.gif">');
		}
	}else{
		document.write('<img src="/site/images/no_arrow.gif" WIDTH="12" HEIGHT="11">');
	}
}

function trimStr(obj)
{
	str = obj.value;
	newStr = "";
	splStr = str.split(",");
	perfix = "";
	for(i=0;i<splStr.length;i++)
	{
		if(splStr[i].indexOf(" ") == 0)
		{
			splStr[i] = splStr[i].substr(1);
		}
		if(splStr[i].indexOf(" ",(splStr[i].length)-1) == (splStr[i].length)-1)
		{
			splStr[i] = splStr[i].substr(0,(splStr[i].length)-1);
		}
		newStr = newStr +perfix + splStr[i];
		perfix = ",";
	}
	obj.value = newStr;
}

function buildDate(dateStr)
	{
		time = "";
		day = "";
		month = "";
		splitTime = "";
		if(dateStr != "")
		{
			splitDate = dateStr.split(" ");
			if(splitDate[3])
				time = splitDate[3];
			if(splitDate[2])
				day = splitDate[2];
			if(splitDate[1])				
				month = replaceMonth(splitDate[1]);
			if(time != "")
				splitTime =  time.split(":");
			if(splitTime[1])
				newStr = day+"/"+month+" | "+ splitTime[0] +":"+splitTime[1];
			else
				newStr = day+"/"+month;
		}
		else
			newStr = "";
		document.write(newStr);
	}

function replaceMonth(month)
{
	mon = "";
	switch (month)
	{
		case "Jan" :
		{
			mon = "01";
			break;
		}
		case "Feb" :
		{
			mon = "02";
			break;
		}
		case "Mar" :
		{
			mon = "03";
			break;
		}
		case "Apr" :
		{
			mon = "04";
			break;
		}
		case "May" :
		{
			mon = "05";
			break;
		}
		case "Jun" :
		{
			mon = "06";
			break;
		}
		case "Jul" :
		{
			mon = "07";
			break;
		}
		case "Aug" :
		{
			mon = "08";
			break;
		}		
		case "Sep" :
		{
			mon = "09";
			break;
		}
		case "Oct" :
		{
			mon = "10";
			break;
		}
		case "Nov" :
		{
			mon = "11";
			break;
		}
		case "Dec" :
		{
			mon = "12";
			break;	
		}
		default :
			mon = "";		
	}
	return mon;
}

function go_search1() 
{
if (document.Search1.text.value=="")
{	
	alert(" הקלד טקסט לחיפוש");
	return;
}
else
	document.Search1.submit(); 
}

function submitToArchive(url){
	document.location.href=url+document.getElementById("searchText").value;
}

function OpenLink(Link)
{
window.open(Link,"AOnline","left=0,top=0,width=460,height=330,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=no");
}	

function replaceChar(str)
{
document.write(str.replace("-",":"));
}

function openGraphWin(Pname,width,height)
{
NewVin = window.open(Pname,"GraphWindow","width=" + width + ",height=" + height + ",top=0,left=0,screenX=150,screenY=150,status=no,toolbar=no,menubar=no,resizable=no,scrolling=no");
NewVin.focus();
}

function openNewGraphWin(Pname,width,height,str)
{
str=encodeHebrewString(str);
var graphTitle="&graphTitle="+str;
Pname=Pname+graphTitle;
NewVin = window.open(Pname,"GraphWindow","width=" + width + ",height=" + height + ",top=0,left=0,screenX=150,screenY=150,status=no,toolbar=no,menubar=no,resizable=no,scrolling=no");
NewVin.focus();
}

function gotolog(pAction)
{
	var topLocation = top.location;
	if(checkKlal())
	{
		var searchParam = topLocation.search;
		topLocation.href="/login.jhtml?action="+pAction+"&webType=40&backTo="+buildURLNew(topLocation);
	}
	else
		topLocation.href="/login.jhtml?action="+pAction+"&backTo="+buildURLNew(topLocation);
}

function gotoupdate(domain,siteBack)
{
	top.location.href=domain+"/ibo/register/update.jhtml?webType=20&backTo="+buildURLNew(siteBack);
}

function goToUpdateYoetzUser(domain,siteBack)
{
	top.location.href=domain+"/ibo/register/update.jhtml?webType=20&backTo="+buildURLNew(siteBack)+"&yoetz=yes";
}

function gotoMap()
{
top.location.href="/site/gen/map.jhtml?navBar=gen";
}	

function checkMsn()
{

	if(location.hostname=="aonline.msn.co.il"||location.search.indexOf("brand=msn")!=-1)
		return 1;
	else
		return 0;
}

function checkTelniri()
{

	if(location.hostname.indexOf("talniri") != -1)
		return 1;
	else
		return 0;
}

function checkKlal()
{
	if(location.hostname.indexOf("yoetz") != -1)
		return 1;
	else
		return 0;
}

function wait()
{
	window.setInterval("load()", 360000);
}

function load()
{
		document.location.reload();
}

function getCurrency(currency)
{
	if(currency == 2)
		return "&euro;";
	else if(currency == 3)
		return "CHF";
	else if(currency == 7)
		return "p";
	else
		return "";
}

function checkString(str)
{
	str = str.replace(new RegExp('[~]','g'), "&quot;"); 
	str = str.replace(new RegExp('[*]','g'), "&rsquo;"); 
	str = str.replace(new RegExp('[#]','g'), "&#32;"); 
	str = str.replace("^", "");
	return str;
}

function glossary(code)
{
	window.open("/site/gen/glossary.jhtml?code="+code,"downpop2","left=0,top=0,width=270,height=160,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=yes");
}


function changeImage(val,objectId)
{
	if(val>=0)
	{
		if(objectId.src != "/f/images/bar_up.gif")
			objectId.src = "/f/images/bar_up.gif";
	}
	else if(val<0)
	{
		if(objectId.src != "/f/images/bar_down.gif")
			objectId.src = "/f/images/bar_down.gif";
	}
}

function FDiffColorLast(val,last)
{
	if (val > 0)
	{
		 return "<font class=greenStockes>"  + FixFormat(last,2) +"</font>";
	}
	else
	{
		if (val < 0)
			return  "<font class=redStockes>"  + FixFormat(last,2)  + "</font>";
		else 
			return "<font class=greenStockes>"  + FixFormat(last,2) +"</font>";
	}
}

function FDiffColorStockes(val,decimalPlace,percent){
	var valnum;
	var per ="";
	//valnum = cDbl(val)
	if (percent==1){ 
		per= "%";
	} 
	if (val > 0){
		 return "<font class=greenStockes>"  + FixFormatStockes( val,decimalPlace) + per+"</font>";
	}else{
		if (val < 0){
			return "<font class=redStockes>"  + FixFormatStockes( val,decimalPlace) + per+"</font>";
		}else{
			return "<font class=greenStockes>0.00"+per+"</font>";
		}
	}
}

function FixFormatStockes(num,decimalPlace)
{
		if (decimalPlace ==1)
			divNum = 10;
		if (decimalPlace ==2)
			divNum = 100;
		if (decimalPlace ==3)
			divNum = 1000;
		StringNum = num.toString();
		SplitNum = StringNum.split(".");
		if (SplitNum[1]){
		//----------------------------------------
			lenNum = SplitNum[1].length;
			DecimalNum = SplitNum[1].substr(0,decimalPlace);
			if (decimalPlace == 0) {
				if (decimalPlace < lenNum)
				{
					spl1 = SplitNum[1].substr(SplitNum[1].length-1,SplitNum[1].length);
					chkNum = "0."+spl1;
					chkNum = chkNum*1;
					if (chkNum>=0.5)
					{
						fn = SplitNum[0]+""+DecimalNum;
						fn = fn*1+1;
						StringNum1 = fn.toString();						
						SplitNum = StringNum1.split(".");
						if(StringNum1.indexOf(".")==-1)
							DecimalNum = 0;
						else
							DecimalNum = SplitNum[1];
					}
				}
				//---------------------------------------
				OutPutNum = prefixNoMark(SplitNum[0]);
			}else{
				if (decimalPlace < lenNum)
				{
					spl1 = SplitNum[1].substr(SplitNum[1].length-1,SplitNum[1].length);
					chkNum = "0."+spl1;
					chkNum = chkNum*1;
					if (chkNum>=0.5)
					{
						fn = SplitNum[0]+""+DecimalNum;
						fn = fn*1+1;
						fn = fn/divNum;
						StringNum1 = fn.toString();						
						SplitNum = StringNum1.split(".");
						if(StringNum1.indexOf(".")==-1)
							DecimalNum = 0;
						else
							DecimalNum = SplitNum[1];
					}
				}
				OutPutNum = prefixNoMark(SplitNum[0]) + "." + DecimalNum;
				if (decimalPlace == 2){
					DecimalNum = DecimalNum.toString();
					if(DecimalNum.length == 1){
						OutPutNum = OutPutNum + "0";
					} 
				}
			}
			num = OutPutNum; 
			
		}
		else{
			
			if (decimalPlace == 1){
				num = num + ".0"
			}
			if (decimalPlace == 2){
				num = num + ".00"
			}
			num = prefixNoMark(num);
		}		
		if (num =="0.0" || num ==".0" || num =="0" || num =="0.00" || num ==".00" ||num =="-9,999" || num =="-9,999.0" || num =="-9,999.00" || num =="9,999" || num =="9,999.0" || num =="9,999.00"){
			num = "-";
		}
		if (num.indexOf("-.") != -1)
		{
			num = "-";
		}	
		return num;
		
}

function prefixNoMark(num){
	Newnum = "0";
	mark = "";
	StringNum = num.toString();
	SplitNum = StringNum.split(".");
	if (SplitNum[1]){
	 	num = SplitNum[0];
		decimalPart = "." + SplitNum[1];
	}else{
		decimalPart = "";
	}
	num = num.toString();
	if (num.substr(0,1) == "-"){
		mark = ""
		if (num.length == 1){
			num = "";
		}else{
			num = num.substr(1);
		}
	}
	leng = num.length;
	numOfPrefix = Math.floor(leng / 3);
	if ((leng % 3) == 0){
		numOfPrefix = numOfPrefix - 1;
	}
	arrayObj = new Array();
	first = leng-3;
	len = 3;  
	for (i=0;i<numOfPrefix+1;i++){
		if (first < 0){
			len = 3+first;
			first = 0;
		}
		arrayObj[i] = num.substr(first,len);
		first = first - len;
	}
	num = "";
	for (i=numOfPrefix;i>=0;i--){
		if (i == 0){
			num = num + arrayObj[i];
		}else{
			num = num + arrayObj[i] + ",";
		}
	}
	num =  num + decimalPart;
	return num;
}

function numToString (time)
{
	var pTime = time/3600;
	var hour = parseInt(pTime);
	var minute = Math.round((pTime - hour) * 60);
    return hour + ":" + minute;
}

function byBaseRate(baseRate,limit,val)
{
	var change = limit-baseRate;
	if (change >= 0)
		 return "<font color=green>"  + val+"</font>";
	else
		return  "<font color=red>"  + val + "</font>";
}

function sky_ad_newSite(sky_layer)
{
	var sWidth = document.body.clientWidth;
		var x = 0;
		if (checkMsn() == 0)
			document.write("<div id=\"bigAdd\" style=\"display:none;position: absolute; height: 450; width: 100; left: " + x + "; top: 45;\">");
	
		else
			document.write("<div id=\"bigAdd\" style=\"display:none;position: absolute; height: 450; width: 100; left: " + x + "; top: 292;\">");
		
		if(checkTelniri())
			bannerNew(43,'telniri',sky_layer,'none','100x450','WIDTH=100 HEIGHT=450');
		else if(checkKlal())
			bannerNew(43,'yoetz',sky_layer,'none','100x450','WIDTH=100 HEIGHT=450');
		else
			bannerNew(43,'none',sky_layer,'none','100x450','WIDTH=100 HEIGHT=450');
		document.write("</div>");
	if (sWidth >= 1020) 
		document.getElementById("bigAdd").style.display="inline";
}
function onresizeManager(){
	setBigPicPos();
	if(checkMsn()==1)
		performResize();
			
}
function setBigPicPos(){
	var bigPicX
	var aboutPosX
	if(document.body.clientWidth > 1024)
	{
		bigPicX = 0;
		document.getElementById("bigAdd").style.display = "inline";
		document.getElementById("rightBanner").style.display = "inline";
	}
	else{
		document.getElementById("bigAdd").style.display = "none";
		document.getElementById("rightBanner").style.display = "none";
	}
}

function OpenDeals(code,dnum,high,low,last,diff)
{
	window2=window.open("/site/comp/dailyTrades.jhtml?secCode=" + code  + "&dealsNum="+ dnum + "&dailyHigh=" + high + "&dailyLow=" + low + "&lastrate=" + last + "&Lastdiff=" + diff,"window2","left=0,top=0,width=500,height=300,resizable=yes,scrollbars=yes,Expires=YES");
}
	

	
document.write("<div id='dropDown' onmouseover='showDropPremiumDiv()' onmouseout='hideDropPremium()' style='display:none;position:absolute;'>");
document.write("	<table cellpadding='0' cellspacing='0' width='145'  dir='ltr' >");
document.write("		<tr>");
document.write("			<td>");
document.write("				<table cellpadding='0' cellspacing='0' width='100%' dir='rtl'>");
document.write("					<tr>");
document.write("						<td height='1' width='3'><img src='/site/images/0.gif' ></td>");
document.write("						<td height='1' width='97' bgcolor='#738A90'></td>");
document.write("					</tr>");
document.write("				</table>");
document.write("			</td>");
document.write("		</tr>");
document.write("		<tr>");
document.write("			<td>");
document.write("				<table cellpadding='0' cellspacing='0' width='145' dir='rtl' style='border-left-color: #738A90; border-left-style: solid; border-left-width: 1px;'>");
document.write("					<tr>");
document.write("						<td height='3' width='2' bgcolor='#D8D8D8'></td>");
document.write("						<td height='3' width='1' bgcolor='#134BA0' ></td>");
document.write("						<td id='premumTitle' height='15' class='dropDownTitle' align=center dir='ltr' style='line-height:1;'></td>");
document.write("					</tr>");
document.write("				</table>");
document.write("			</td>");
document.write("		</tr>");
document.write("		<tr>");
document.write("			<td>");
document.write("				<table cellpadding='0' cellspacing='0' width='100%' dir='rtl' style='border-left-color: #738A90; border-left-style: solid; border-left-width: 1px;'>");
document.write("					<tr>");
document.write("						<td height='3' width='2'><img src='/site/images/0.gif' ></td>");
document.write("						<td height='3' width='1' bgcolor='#738A90'></td>");
document.write("						<td id='topGap' height='3' width='97' class='dropDownGreen'></td>");
document.write("					</tr>");
document.write("					<tr>");
document.write("						<td height='3' width='2' bgcolor='#D8D8D8'></td>");
document.write("						<td height='3' width='1' bgcolor='#738A90' ></td>");
document.write("						<td id='sms' height='15' class='dropDownGreen' style='border-bottom-color: #738A90; border-bottom-style: solid; border-bottom-width: 1px;' onmouseover=changeDropPremiumBgcolor('sms') onmouseout=changeDropPremiumBgcolor('sms')>&nbsp;&nbsp;<a href='http://finance.themarker.com/sms' class='dropDownHrefBlack' style='text-decoration : none;cursor:hand;' target='_top'>SMS</a><span id='sms1'></span></td>");
document.write("					</tr>");
document.write("					<tr>");
document.write("						<td height='3' width='2' bgcolor='#D8D8D8'></td>");
document.write("						<td height='3' width='1' bgcolor='#738A90' ></td>");
document.write("						<td id='alerts' height='18' class='dropDownGreen' style='border-bottom-color: #738A90; border-bottom-style: solid; border-bottom-width: 1px;' onmouseover=changeDropPremiumBgcolor('alerts') onmouseout=changeDropPremiumBgcolor('alerts')>&nbsp;&nbsp;<a href='http://www.themarker.com/alerts' class='dropDownHrefBlack' style='text-decoration : none;cursor:hand;' target='_top'>Alerts</a><span id='alerts1'></span></td>");
document.write("					</tr>");
document.write("					<tr>");
document.write("						<td height='3' width='2' bgcolor='#D8D8D8'></td>");
document.write("						<td height='3' width='1' bgcolor='#738A90' ></td>");
document.write("						<td id='realTime' height='18' class='dropDownGreen'  style='border-bottom-color: #738A90; border-bottom-style: solid; border-bottom-width: 1px;' onmouseover=changeDropPremiumBgcolor('realTime') onmouseout=changeDropPremiumBgcolor('realTime')>&nbsp;&nbsp;<a href='http://www.themarker.com/tmc/bill/services.jhtml?mode=index&type=aonline' class='dropDownHrefBlack' style='text-decoration : none;cursor:hand;' target='_top'>זמן אמת</a><span id='realTime1'></span></td>");
document.write("					</tr>");
/*document.write("					<tr id='marketDiv' >");
document.write("			 			<td colspan='3'>");
document.write("							<table cellpadding='0' cellspacing='0' width='100%' dir='rtl' style='border-bottom-color: #738A90; border-bottom-style: solid; border-bottom-width: 1px;'>");
document.write("								<tr>");
document.write("									<td height='3' width='2' bgcolor='#D8D8D8' ></td>");
document.write("									<td height='3' width='1' bgcolor='#738A90' ></td>");
document.write("									<td id='sMarket' height='18' class='dropDownGreen'   onmouseover=changeDropPremiumBgcolor('sMarket') onmouseout=changeDropPremiumBgcolor('sMarket')>&nbsp;&nbsp;<a onclick=stockLink() class='dropDownHrefBlack' style='text-decoration : none;cursor:hand;' target='_blank'><img src='/f/images/chart.gif' border='0'>מסחר במניה</a><span id='sMarket1'></span></td>");
document.write("								</tr>");
document.write("							</table>");
document.write("						</td'>");
document.write("					</tr>"); */
document.write("					<tr>");
document.write("						<td height='3' width='2' bgcolor='#D8D8D8'></td>");
document.write("						<td height='3' width='1' bgcolor='#738A90' ></td>");
document.write("						<td id='easyforex' height='18' class='dropDownGreen'  onmouseover=changeDropPremiumBgcolor('easyforex') onmouseout=changeDropPremiumBgcolor('easyforex')>&nbsp;&nbsp;<a href='http://finance.themarker.com/f/gen/logGeneral.jhtml?pageType=40&url=http://www.easy-forex.com/Gateway.aspx?gid=694' class='dropDownHrefBlack' style='text-decoration : none;cursor:hand;' target='_blank'>שערים רציפים <font color='#025FA9' style='FONT-SIZE:11px;'><b>Easy Forex</b></font></a><span id='easyforex1'></span></td>");
document.write("					</tr>");
document.write("				</table>");
document.write("			</td>");
document.write("		</tr>");
document.write("		<tr>");
document.write("			<td>");
document.write("				<table cellpadding='0' cellspacing='0' width='100%' dir='rtl'>");
document.write("					<tr>");
document.write("						<td height='1' width='3' bgcolor='#D8D8D8'></td>");
document.write("						<td height='1' width='97' bgcolor='#738A90'></td>");
document.write("					</tr>");
document.write("				</table>");
document.write("			</td>");
document.write("		</tr>");
document.write("		<tr>");
document.write("			<td>");
document.write("				<table cellpadding='0' cellspacing='0' width='100%' border='0' border='yellow' >");
document.write("					<tr>");
document.write("						<td height='3'><img src='/site/images/0.gif' ></td>");
document.write("						<td width='97' bgcolor='#D8D8D8' height='3'></td>");
document.write("					</tr>");
document.write("				</table>");
document.write("			</td>");
document.write("		</tr>");
document.write("	</table>");
document.write("</div>");

function rateChangeColor(val,decimalPlace,percent){
	var valnum;
	var per ="";
	//valnum = cDbl(val)
	if (percent==1){ 
		per= "%";
	} 
	if (val > 0){
		 return "<font color=#20AA04>+"  + FixFormat( val,decimalPlace) + per+"</font>";
	}else{
		if (val < 0){
			return "<font color=#F30000>"  + FixFormat( val,decimalPlace) + per+"</font>";
		}else{
			return "<font color=#20AA04><img src=/f/images/0.gif width=5px height=1px>0.00"+per+"</font>";
		}
	}
}
function rateChangeImage(val,decimalPlace,percent){
	var valnum;
	var per ="";
	//valnum = cDbl(val)
	if (percent==1){ 
		per= "%";
	} 
	if (val > 0){
		 return "<font color=#59BD00>+"  + FixFormat( val,decimalPlace) + per+"</font>";
	}else{
		if (val < 0){
			return "<font color=#F50000>"  + FixFormat( val,decimalPlace) + per+"</font>";
		}else{
			return "<font color=#59BD00>0.00"+per+"</font>";
		}
	}
}
function getImage(val)
{
	if(val>0)
		return "<img src=/f/images/ratesBox/upArrow.gif>";
	else if(val<0)
		return "<img src=/f/images/ratesBox/downArrow.gif>";
	else
		return "<img src=/f/images/ratesBox/upArrow.gif>";
}
		function IsLegalDigits(str)
		{
		  var legal = 1;
		  for (i=0; i<str.length; i++) {
		    ch = str.substring(i,i+1)
		    if (ch !="0" && ch !="1" && ch !="2" && ch !="3" && ch !="4" && ch !="5" && ch !="6" && ch !="7" && ch !="8" && ch !="9") {
		      legal = 0
		      break
		    }
		  }
		  return legal
		}
		
		function getAuthentication(mobilePhone,dpsId)
		{
			var xml = new ActiveXObject("Microsoft.XMLDOM");
			xml.async = false;
			xml.load("/xsql/sms/authentication.xsql?dpsId="+dpsId+"&phone="+mobilePhone);
			if (xml != null && xml.documentElement != null)
			{
				var st = xml.selectSingleNode("//ACTIVE");
				if (st == null)
					return 0;
				else
				{
					var value = st.text;
					if (value == "1")
						return 1;
					else
						return 0;
				}
		
			}
			else
			{
				alert("אירעה שגיאה. נא נסה שנית.");
				return 2;
			}
		}
		function handleEnter (field, event) {
				var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
				if (keyCode == 13) {
					var i;
					for (i = 0; i < field.form.elements.length; i++)
						if (field == field.form.elements[i])
							break;
					i = (i + 1) % field.form.elements.length;
					field.form.elements[i].focus();
					return false;
				} 
				else
				return true;
			} 
			
//search
var selopenSearch = false;
var selidSearch;
var targetShow;
function initComComboSearch()
{
			var str = '<table cellpadding="0" cellspacing="0" align="center" width="75">'
			var links = new Array();
			links[0] = new Array('תמצית חברה','1');
			links[1] = new Array('דוחות פיננסיים','5');
			links[2] = new Array('נתוני מסחר','3');
			links[3] = new Array('חדשות בחברות','6');
			links[4] = new Array('בעלי עניין','40');
			links[5] = new Array('הודעות בורסה','32');
			links[6] = new Array('גרף מניה','2');
			links[7] = new Array('פורום ההודעות','52');
			links[8] = new Array('ניתוח ענפי','4');
			links[9] = new Array('פרופיל קרן','7');
			links[10] = new Array('גרף קרן','8');
			links[11] = new Array('פרופיל מנהל','9');
			links[12] = new Array('פרטי אג"ח','10');
			links[13] = new Array('יחס שווי','27');
			links[14] = new Array('יעילות ניהול','28');
			for(i=0;i<links.length;i++){
				var cobj = links[i];
				str += '<tr><td bgcolor="#ffffff" nowrap style="font-size:12px;font-family:Arial;color:#000000;cursor:default" onclick="seliddSearch(\''+ cobj[1]+'\',this.innerHTML)" onmouseover="this.style.backgroundColor=\'#D1FA80\'" onmouseout="this.style.backgroundColor=\'#ffffff\'" height="16" align="right">&nbsp;'+cobj[0]+'</td></tr>';
			}
			str += '</table>';
			comDropDown.innerHTML = str;
			if (links.length<6){
				comDropDown.style.height = links.length * 16;
			}
			else comDropDown.style.height=6*16;
		}	
			
function dropDownSearch(x,obj,foc)
{	
	  if(selopenSearch)
	  		closeallSearch();
	  else
	  {
	  	var curobj = obj;
	  	var obj1 = x;
	 	curobj.style.left = getAbsoluteSearch(obj1)[0];
	 	curobj.style.top = getAbsoluteSearch(obj1)[1];
		if(selopenSearch){curobj.style.display = 'none';}
	 	else{curobj.style.display = '';}
		 	selidSearch = obj;
		  	selopenSearch = !selopenSearch;
		 }
	
			targetShow = 'comDiv';
	}
	
	function getAbsoluteSearch(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;
	}
	
	function closeallSearch()
	{
	if(selopenSearch)
	{
		selidSearch.style.display='none';
		selopenSearch=false;
	}
	}
	
	function seliddSearch(val,valuetoshow)
	{
		eval(targetShow+".innerHTML=valuetoshow");
		document.chsFund.typePap.value=val;
		closeallSearch();
	}
function changeBack()
{
	//chsFund.namesymbol[0].checked =true;
}
function clearTxt()
{
	document.chsFund.val.value="";
	document.chsFund.val.className="txt_search";
}

/*
function checkType(valTest)
{
//alert(valTest);
	if(valTest=='symbol')
	{
		//alert("in if");
		document.all.lPos.style.display = "none" ;
		document.all.gPos.style.display = "none" ;
		document.all.bPos.style.display = "inline" ;
		document.chsFund.val.value ='שם מניה או סימול';
		document.chsFund.namesymbol[1].checked = true;
	}
	else
	{
		document.chsFund.namesymbol[0].checked = true;
		document.chsFund.namesymbol[1].checked = false;
		//alert("else");
	}
}
*/

function moveTag()
{
	if(document.chsFund.val.value =="")
	{
		alert("יש להזין מילה לחיפוש");
		document.chsFund.val.focus();
		return false;
	}

	if( document.chsFund.typePap.value == "")
	{
		alert("יש לבחור סוג לחיפוש");
		return false;
	}

	a = document.chsFund.val.value;
	b = a.split("'");
	str = "";
	for(i=0;i<b.length;i++)
	{
		if ((b[i] != "") && (b[i] != null))
		{			
			str = str.concat(b[i]);			
		}		
	}
	document.chsFund.val.value = str;
}
function hidBut(val)
{
	if(val=='symbol')
	{
		document.all.lPos.style.display = "none" ;
		document.all.gPos.style.display = "none" ;
		document.all.bPos.style.display = "inline" ;
		document.chsFund.val.value ='שם מניה או סימול';
		closeallSearch();
	}
	else 
	{
		document.all.lPos.style.display = "inline" ;
		document.all.gPos.style.display = "inline" ;
		document.all.bPos.style.display = "none" ;
		document.chsFund.val.value ='';
	}
}


	     
function buildRows(curNames,curChange,curRates,curSecCodes,curSecRefs,isInTmFrm,tableId)
{
	var row;
	row = '';
	var trg='';
	var evenRow=true;
	if (isInTmFrm =='true')//themarker article feature
		trg='target="_top"';
	else if(checkKlal())
		trg='target="_top"';
	row =row + '<table cellpadding="0"  cellspacing="0" width="100%" id="'+tableId+'">';
	for(var i=0;i<curSecCodes.length;i++)
	{
		if(curNames[i] != undefined)
		{
			if(evenRow)
			{
				row =row + '<tr class=evenBackground align=right>';
				evenRow=false;
			}
			else
			{
				row =row + '<tr class=oddBackground align=right>';
				evenRow=true;
			}
			row =row + '	<td width="67">';
			row =row + '		<table border="0" bordercolor="Fuchsia" cellpadding="0"  cellspacing="0" height="19">';
			row =row + '		<tr>';
			row =row + '			<td height="19" width="20"></td>';
			row =row + '			<td width="13" class="lineStyle">'+arrowGif(curChange[i])+'</td>';
			row =row + '			<td width="32" dir="ltr" align="right" class="lineStyle">'+FDiffColor(curChange[i],2,0)+'</td>';
			row =row + '			<td width="11"></td>';					
			row =row + '		</tr>';
			row =row + '		</table>';
			row =row + '	</td>';
			row =row + '	<td bgcolor="White" width="1"></td>';
			row =row + '	<td width="71">';
			row =row + '		<table cellpadding="0"  cellspacing="0" height="19">';
			row =row + '		<tr>';
			row =row + '			<td width="62" align="right" class="lineStyle">'+curRates[i]+'</td>';
			row =row + '			<td width="9"></td>';
			row =row + '		</tr>';
			row =row + '		</table>';
			row =row + '	</td>';
			row =row + '	<td bgcolor="White" width="1"></td>';
			row =row + '	<td width="140" align=right id="securityName'+i+'" style="padding-right:4px;"><a '+trg+'href="'+curSecRefs[i]+'"><font class="lineStyle"><u>'+curNames[i]+'</font></u></a></td>';
			row =row + '</tr>';
		}
	}
	row =row + '</table>';
	return row;
}

function buildQuotesRows(curNames,curChange,curSecCodes,curSecRefs)
{
	var row;
	row = '';
	var evenRow=true;
	for(var i=0;i<curSecCodes.length;i++)
	{
		if(evenRow)
		{
			row =row + '<tr class=evenBackground align=right>';
			evenRow=false;
		}
		else
		{
			row =row + '<tr class=oddBackground align=right>';
			evenRow=true;
		}
		row =row + '	<td width="60">';
		row =row + '		<table border="0" bordercolor="Fuchsia" cellpadding="0"  cellspacing="0" height="19">';
		row =row + '		<tr>';
		row =row + '			<td width="13" class="lineStyle" align="right">'+arrowGif(curChange[i])+'</td>';
		row =row + '			<td  height="19" width="45" dir="ltr" align="right" class="rateFont">'+FDiffColor(curChange[i],2,1)+'</td>';
		row =row + '			<td width="2"></td>';					
		row =row + '		</tr>';
		row =row + '		</table>';
		row =row + '	</td>';
		row =row + '	<td width="60" align=right class="quoteLineStyle"><a target="_top" href="'+curSecRefs[i]+'"><font color=blue style="YES; font-family: Arial, Helvetica, sans-serif; font-size: 11;">'+curNames[i]+'</font></a>&nbsp;&nbsp;</td>';
		row =row + '</tr>';
	}
	return row;
}

function buildCommRows(curDomain,curElementIds,curOrigins,curSections,curHeadlines,curDates,curAuthors,target)
{
	var row='';
	for(var i=0;i<curElementIds.length;i++)
	{
		row = row + '<tr><td align=right valign=top dir="rtl">';
		row = row + '<a href="http://'+curDomain+'/tmc/article.jhtml?ElementId='+curElementIds[i]+'&origin='+curOrigins[i]+'&section='+curSections[i]+'&layer=hp&layer3='+curSections[i]+'" target='+target+' class="t12Head" dir="rtl"><font color=#00164B>'+curHeadlines[i]+'</font></a>';
		row = row + '</td>';
		row = row + '</tr>';
		row = row + '<tr>';
		row = row + '<td align=right valign=top>';
			row = row + '<table border="0" cellpadding="0" cellspacing="0" dir="rtl">';
							row = row + '<tr><td>';
								row = row + '<span class="newstyle" dir="ltr" align="right" valign="middle">'+replaceChars(curDates[i])+'</span>';									
								row = row + '<span class="authorNew">';	
									row = row + '&nbsp;'+curAuthors[i]+'</span>';
								row = row + '</td>';
							row = row + '</tr>';
			row = row + '</table></td></tr>';
		row = row + '<tr><td><img src="/f/images/0.gif" border="0"  width="1" height="5"></td></tr>';
		row = row + '<tr><td><img src="/f/images/0.gif" border="0"  width="1" height="5"></td></tr>';
	}
	return row;
}

function buildNewsRows(curDomain,curElementIds,curOrigins,curSections,curHeadlines,curDates)
{
	var row='';
	for(var i=0;i<curElementIds.length;i++)
	{
		row = row + '<tr><td align=right valign=top dir="rtl">';
		row = row + '<a href="http://'+curDomain+'/tmc/article.jhtml?ElementId='+curElementIds[i]+'&origin='+curOrigins[i]+'&section='+curSections[i]+'&layer=hp&layer2=headarticle&layer3='+curSections[i]+'" target="_top" class="t12Head" dir="rtl"><font color=#00164B>'+curHeadlines[i]+'</font></a>';
		row = row + '</td>';
		row = row + '</tr>';
		row = row + '<tr><td><img src="/f/images/0.gif" border="0"  width="1" height="2"></td></tr>';
		row = row + '<tr>';
		row = row + '<td dir="ltr" align="right" valign="bottom" class="dateNews">';
								row = row + '<font class="newstyle">'+replaceChars(curDates[i])+'</font>';									
		row = row + '</td>';
		row = row + '</tr>';
		row = row + '<tr><td><img src="/f/images/0.gif" border="0"  width="1" height="2"></td></tr>';
	}
	return row;
}

function buildRatesBarRows(curSecCodes,curNames,curLasts,curDiffs)
{
	var row='';
	for(var i=0;i<curSecCodes.length;i++)
	{
		row = row + '<a href="/f/quote.jhtml?secCode='+curSecCodes[i]+'&sType=ta&navBar=comp" class="linkNoLine_11" target="_top" onmouseover="tickerStatus(\'stop\')" onmouseout="tickerStatus(\'start\')">'+curNames[i]+'</a>&nbsp;'+curLasts[i]+'&nbsp;|&nbsp;<span dir="ltr">'+curDiffs[i]+'</span>&nbsp;&nbsp;';
	}
	return row;
}

function replaceChars(str)
{
str=str.replace("-",":");
str=str.replace("/",".");
str=str.replace("/",".");
return str;
}

function getImageByValue(val)
{
	if(val>=0)
		return "<img src=/f/images/bar_up.gif>";
	else if(val<0)
		return "<img src=/f/images/bar_down.gif>";
}
var openDailyClicked = false;//prevent clicking repitedly on the link
var openDailyFirstClick = true;//prevent repositioning after the first click
function openDailyTrades(code,high,low,last,time,option)
{
	if(!openDailyClicked)
	{
		openDailyClicked = true;
		if(openDailyFirstClick)
		{
			if (option = "true"){
				positionDivByRef("loadingGif","optionDealsLinkPage",0,0);
				positionDivByRef("dailyTradesDiv","optionDealsLinkPage",0,0);
			} else {
				positionDivByRef("loadingGif","companyAnalysis",0,-508);
				positionDivByRef("dailyTradesDiv","companyAnalysis",0,-508);
			}
		}
		if(document.getElementById("loadingGif") != undefined)
			document.getElementById("loadingGif").style.display= "inline";
		if(document.getElementById("dailyTradesDiv") != undefined)
			document.getElementById("dailyTradesDiv").style.display= "inline";
		if(document.getElementById("dailyTradesIframe") != undefined)
			document.getElementById("dailyTradesIframe").src = "/f/comp/dailyTrades.jhtml?secCode=" + code  + "&dailyHigh=" + high + "&dailyLow=" + low + "&lastrate=" + last + "&time=" + time + "&option=" + option ;
	}
}
// get position of object in a page
function getAbsolutePos(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;
}

// sending html code to div 
function openDealsManager(code,divId)
{
	sendToDiv(code,divId);
	if(document.getElementById(divId)!= undefined)
	{
		if(document.getElementById("loadingGif") != undefined)
			document.getElementById("loadingGif").style.display= "none"; 
		document.getElementById(divId).style.height = dailyTradesDivHeight; 
		if(document.getElementById("loadingGif") != undefined)
			document.getElementById("loadingGif").style.height = dailyTradesDivHeight; 
		if(document.getElementById("dailyTradesInnerTable") != undefined)
			document.getElementById("dailyTradesInnerTable").style.height = dailyTradesDivHeight-45; 
		document.getElementById(divId).style.display = "inline";
		if(document.getElementById("handle") != undefined)
			Drag.init(document.getElementById("handle"),document.getElementById(divId)); 
		openDailyClicked = false;
		openDailyFirstClick=false;
	}
	
}


// sending html code to div 
function sendToDiv(code,divId)
{
	if(document.getElementById(divId)!= undefined)
		document.getElementById(divId).innerHTML = code;
}
// position div by reference div
function positionDivByRef(divId,refId,topDiff,leftDiff)
{
	if(document.getElementById(refId) != undefined)
	{
		var pos=getAbsolutePos(document.getElementById(refId));
		document.getElementById(divId).style.top = pos[1]+topDiff;
		document.getElementById(divId).style.left = pos[0]+leftDiff;
	}
}

function openCloseDiv(divId)
{
	if(document.getElementById(divId)!= undefined)
	{
		if(document.getElementById(divId).style.display == "inline")
		{
			document.getElementById(divId).style.display = "none";
			openDailyClicked = false;
		}
		else
		{
			document.getElementById(divId).style.display = "inline";
			openDailyClicked = true;
		}
	}
}

function onmouseOverTag(isIn,elm)
{
	if (isIn == true)//in
		elm.className='tagBack';					
	else//out
		elm.className='';		
}

function onmouseOverTagText(isIn,elm)
{
	if (isIn == true)//in
		elm.className='tagsTextOver';					
	else//out
		elm.className='tagsText';			
}	
//////////// real time update //////////////////////
// changing backroundcolor of a row and calling timeout to change back the color
function changeRowBackroundColorManager(row)
{
	var currentClass = row.className;
	row.className="realTimeUpdateBackroundColor";
	window.setTimeout(function () { changeRowBackroundColor(row,currentClass); }, 5000);

}

function changeObjBackroundColorManager(obj)
{
	var currentBg = obj.style.backgroundColor;
	obj.style.backgroundColor="#A4FFFE";
	window.setTimeout(function () { changeObjBackroundColor(obj,currentBg); }, 5000);

}

function changeRowBackroundColor(row,currentClass)
{
	row.className=currentClass;
}

function changeObjBackroundColor(obj,currentBg)
{
	obj.style.backgroundColor=currentBg;
}

// Returns true if valueToSearch is contained in the array targetArray
function contains(targetArray, valueToSearch) {
	for(var j=0;j<targetArray.length;j++)
		if(targetArray[j]==valueToSearch)
			return true;
	return false;
}

/**************************************/
/*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 buildURLNew(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 encodedField;
}


function disableEnter (event)
{
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13)
		return false;
} 

/*
recieves 3 strings that represent r,g,b
return string of color in hex
*/
function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}

/*
recieves integer for r/g/b
return string of r/g/b in hex
*/
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}
/*
recieves string that consists from r,g,b
returns color in hex
*/
function rgbToHexString(rgbColor)
{
 if(rgbColor!=null)
 {
	 var rgbColorArray = rgbColor.split(",");
	 var colorHex=RGBtoHex(rgbColorArray[0],rgbColorArray[1],rgbColorArray[2]);
	 return colorHex;
 }
 else
  return RGBtoHex(0,0,0);
}

function replaceAllChars(str)
{
	str = str.replace(new RegExp('[~]','g'), "\""); 
	str = str.replace(new RegExp('[*]','g'), "'"); 
	str = str.replace(new RegExp('[#]','g'), "&#32;"); 
	str = str.replace("^", "");
	return str;
}

function replaceAllStrChars(str , repWhat , repWith)
{
	var idx ;

	idx = str.indexOf(repWhat) ;

	while (idx != -1){
		str = str.replace(repWhat,repWith);
		idx = str.indexOf(repWhat) ;
	}

	return str;
}
