//----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);
		}		   
	}
}