//----Quotes Class Library By Alex Mishel 2003 --------------------------------------------------------------------------
//---class quote---
function clsQuote()
{
	this.CCY1="";
	this.CCY2="";
	this.Bid=0;
	this.Ask=0;
	this.High=0;
	this.Low=0;
	this.Time="";
	this.Change="";
this.setQuote=function(pCcy1,pCcy2,pBid,pAsk,pHigh,pLow,pTime,pChange)
{
	this.CCY1=pCcy1;
	this.CCY2=pCcy2;
	this.Bid=pBid;
	this.Ask=pAsk;
	this.High=pHigh;
	this.Low=pLow;
	this.Time=pTime;
	this.Change=pChange;
}	
	this.toString=function (){return(this.CCY1+","+this.CCY2+","+this.Bid+","+this.Ask+","+this.High+","+this.Low+","+this.Time+","+this.Change);}		
	this.toXml=function ()
		{
			var res;
			res="<q>";
			res+="<CCY1>"+this.CCY1+"</CCY1>";
			res+="<CCY2>"+this.CCY2+"</CCY2>";
			res+="<Bid>"+this.Bid+"</Bid>";
			res+="<Ask>"+this.Ask+"</Ask>";
			res+="<High>"+this.High+"</High>";
			res+="<Low>"+this.Low+"</Low>";
			res+="<TTime>"+this.Time+"</TTime>";
			res+="<Change>"+this.Change+"</Change>";
			res+="</q>";
			return(res);			
		}
	this.fromString= function (QuoteString)
	{
		var qArr=QuoteString.split(",");
		this.CCY1=qArr[0];
		this.CCY2=qArr[1];
		this.Bid=qArr[2];
		this.Ask=qArr[3];
		this.High=qArr[4];
		this.Low=qArr[5];
		this.Time=qArr[6];
		this.Change=qArr[7];
	}	
	this.fromXml=function (XmlString)
	{
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc.async=false;
		xmldoc.loadXML(XmlString);
		var i,len,xmlel;
		xmlel = xmldoc.getElementsByTagName("q");		   
			   	this.CCY1 = xmlel[0].selectSingleNode("CCY1").text
			   	this.CCY2=xmlel[0].selectSingleNode("CCY2").text;
			   	this.Bid = xmlel[0].selectSingleNode("Bid").text;
				this.Ask = xmlel[0].selectSingleNode("Ask").text;
			    this.High = xmlel[0].selectSingleNode("High").text;
				this.Low = xmlel[0].selectSingleNode("Low").text;
				this.Time =xmlel[0].selectSingleNode("TTime").text;						
				this.Change=xmlel[0].selectSingleNode("Change").text;										
	}
}
//--class QuoteList---
function clsQuoteList()
{
	this.QList = new Array();
	this.Add=function (pQuote){this.QList[this.QList.length]=pQuote;}
	this.Count=function (){return(this.QList.length);}
	this.Clear=function (){this.QList=new Array();}
	this.Item=function (index){return(this.QList[index]);}
	this.Remove=function (index)
							{
							try{
							var i;
							for(i=index;i<this.Count-1;i++)this.QList[i]=this.QList[i+1];
							this.QList[this.Count-1]=null;
							return(res);
							}catch(ex){return(0);}
							}
	this.Find=function (pCCY)
						{
							var i;							
							for(i=0;i<this.Count()-1;i++)
							{
							if((this.Item(i).CCY1+"/"+this.Item(i).CCY2)==pCCY)return(this.Item(i));							
							}
							return(null);
						}
	this.toString=function ()
	{
	try{
		var i,res="";
		for(i=0;i<this.Count()-1;i++)res+=this.Item(i).toString()+"#";
		res+=this.Item(this.Count()-1).toString();
		return(res);
		}catch(ex){return("");}
	}							
	this.toXml=function ()
	{
	try{
		var i,res="<quotelist>";
		for(i=0;i<this.Count();i++)res+=this.Item(i).toXml();
		res+="</quotelist>";
		return(res);
		}catch(ex){return("");}
	}							
	this.fromString=function (QuoteString)
	{
		var str=QuoteString.split("#");
		var i;
		this.Clear();
		for(i=0;i<str.length;i++)
		{
			var q= new clsQuote();
			q.fromString(str[i]);
			this.Add(q);
		}
	}
	this.fromXml=function (XmlString)
	{
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc.async=false;
		xmldoc.loadXML(XmlString);
		var i,len,xmlel;
		xmlel = xmldoc.getElementsByTagName("q");
		len=xmlel.length;
		this.Clear();
		for(i=0;i<len;i++)
		{
			var q= new clsQuote();
			q.fromXml(xmlel[i].xml);
			this.Add(q);
		}		   
	}
}
//---class indice---
function clsIndice()
{
	this.Name="";
	this.Last=0;
	this.Change="";	
	this.Time="";
this.setQuote=function(pName,pLast,pChange,pTime)
{
	this.Name=pName;
	this.Last=pLast;
	this.Change=pChange;
	this.Time=pTime;
}	
	this.toString=function (){return(this.Name+","+this.Last+","+this.Change+","+this.Time);}		
	this.toXml=function ()
		{
			var res;
			res="<q>";
			res+="<Name>"+this.Name+"</Name>";
			res+="<Last>"+this.Last+"</Last>";
			res+="<Change>"+this.Change+"</Change>";
			res+="<TTime>"+this.Time+"</TTime>";
			res+="</q>";
			return(res);			
		}
	this.fromString= function (QuoteString)
	{
		var qArr=QuoteString.split(",");
		this.Name=qArr[0];
		this.Last=qArr[1];
		this.Change=qArr[2];
		this.Time=qArr[3];		
	}	
	this.fromXml=function (XmlString)
	{
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc.async=false;
		xmldoc.loadXML(XmlString);
		var i,len,xmlel;
		xmlel = xmldoc.getElementsByTagName("q");		   
			   	this.Name = xmlel[0].selectSingleNode("Name").text
			   	this.Last=xmlel[0].selectSingleNode("Last").text;
			   	this.Change = xmlel[0].selectSingleNode("Change").text;
				this.Time = xmlel[0].selectSingleNode("TTime").text;			    
	}
}
//--class IndicesList---
function clsIndicesList()
{
	this.IList = new Array();
	this.Add=function (pIndice){this.IList[this.IList.length]=pIndice;}
	this.Count=function (){return(this.IList.length);}
	this.Clear=function (){this.IList=new Array();}
	this.Item=function (index){return(this.IList[index]);}
	this.Remove=function (index)
							{
							try{
							var i;
							for(i=index;i<this.Count-1;i++)this.IList[i]=this.IList[i+1];
							this.IList[this.Count-1]=null;
							return(res);
							}catch(ex){return(0);}
							}
	this.Find=function (pName)
						{
							var i;							
							for(i=0;i<this.Count()-1;i++)
							{
							if(this.Item(i).Name==pName)return(this.Item(i));							
							}
							return(null);
						}
	this.toString=function ()
	{
	try{
		var i,res="";
		for(i=0;i<this.Count()-1;i++)res+=this.Item(i).toString()+"#";
		res+=this.Item(this.Count()-1).toString();
		return(res);
		}catch(ex){return("");}
	}							
	this.toXml=function ()
	{
	try{
		var i,res="<Indicelist>";
		for(i=0;i<this.Count();i++)res+=this.Item(i).toXml();
		res+="</Indicelist>";
		return(res);
		}catch(ex){return("");}
	}							
	this.fromString=function (IndiceString)
	{
		var str=IndiceString.split("#");
		var i;
		this.Clear();
		for(i=0;i<str.length;i++)
		{
			var q= new clsIndice();
			q.fromString(str[i]);
			this.Add(q);
		}
	}
	this.fromXml=function (XmlString)
	{
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM");
		xmldoc.async=false;
		xmldoc.loadXML(XmlString);
		var i,len,xmlel;
		xmlel = xmldoc.getElementsByTagName("q");
		len=xmlel.length;
		this.Clear();
		for(i=0;i<len;i++)
		{
			var q= new clsIndice();
			q.fromXml(xmlel[i].xml);
			this.Add(q);
		}		   
	}
}
var quotesCacheCounter = 0;
function getUTCString() {
        var d = new Date();
        var res = d.getUTCFullYear().toString() + d.getUTCMonth().toString() + d.getUTCDay().toString() + d.getUTCHours().toString() + d.getUTCMinutes().toString() + "" + quotesCacheCounter;
        quotesCacheCounter++;
        return res;
    }

function setFixedUSD(obj) { 
    try {
        var lbl = document.getElementById("lblFixedUSD");
        var tr = lbl.getElementsByTagName("tr")[0];
        var result = tr.getElementsByTagName("td")[1];
        var change = tr.getElementsByTagName("td")[2];
        result.innerHTML = obj.result
        change.innerHTML = obj.change
    }
    catch(e){}
}
function callFixedUSD()
{
    try{
        var script = document.getElementById("fixedUsd");
        if (script != null) {
            document.getElementsByTagName("body")[0].removeChild(script);
        }
        script = document.createElement("script");
        script.id = "fixedUsd";
        //script.defer = true;
        script.src ="http://ratesams.iforex.com/scripts/inc/fixedrates.ashx?q=USD&callback=setFixedUSD&_=" + getUTCString();
        window.document.body.appendChild(script);
    }catch(e){}
}


(function(i) {
    var u = navigator.userAgent;
    var e = /*@cc_on!@*/false;
    var st = setTimeout;
    if (/webkit/i.test(u)) {
        st(function() {
            var dr = document.readyState;
            if (dr == "loaded" || dr == "complete") { i() } else { st(arguments.callee, 10); }
        }, 10);
    }
    else if ((/mozilla/i.test(u) && !/(compati)/.test(u)) || (/opera/i.test(u))) {
        document.addEventListener("DOMContentLoaded", i, false);
    } else if (e) {
        (
function() {
    var t = document.createElement('doc:rdy'); try {
        t.doScroll('left');
        i(); t = null;
    } catch (e) { st(arguments.callee, 0); }
})();
    } else { window.onload = i; }
})(
function() {
if (window.location.host.match(/^((www|local|qa)\.)?iforex\.co\.il$/)) {
    callFixedUSD();
}
});

