

function chktag(val)
{
	if (val == "-")
		return 0;
	else
		return val;
}
function calculator(info) 
{
	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 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 "-";
		}
	}
}

function FixFormat(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 = prefix(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 = 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 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(){
alert("in");
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 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 = 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)
{
strLocation = top.location.toString();
if (strLocation.search("htm") == -1)		
	top.location.href="/login.jhtml?action="+pAction+"&backTo="+buildURLNew(top.location)+"/";
else
	top.location.href="/login.jhtml?action="+pAction+"&backTo="+buildURLNew(top.location);
}

function goToUpdateYoetzUser(domain,siteBack)
{
	top.location.href=domain+"/ibo/register/update.jhtml?backTo="+buildURLNew(siteBack)+"&webType=20&yoetz=yes";
}

							
						

function gotoMap()
{
top.location.href="/site/gen/map.jhtml?navBar=gen";
}	

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"?"":"layer="+l1+"&") + (l2=="none"?"":"layer2="+l2+"&") + (l3=="none"?"":"layer3="+l3+"&") + (l4=="none"?"":"layer4="+l4+"&") + "adtype=hp&page_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>');	
}

function checkPoalim()
{
	if(location.hostname=="poalim.aonline.co.il" || location.search.indexOf("brand=poalim")!=-1)
		return 1;
	return 0;
}

function wait()
{
	window.setInterval("load()", 360000);
}

function load()
{
		document.location.reload();
}

function dw(str){
document.write(str);
}

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 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>";
		}
	}
}

/**************************************/
/*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 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');
}
