

function CreateXmlHttp()
	{
		try
		{
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;
					
			}
		}
		if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttp = new XMLHttpRequest();
		}
	}

//Home page Ticker

var xmlHttp
var browser = new Browser();

function Browser() {
  var ua, s, i;
  this.isIE    = false;
  this.isNS    = false;
  this.version = null;
  ua = navigator.userAgent;
  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

function ExchngTimeClock(Exchg) {
	 var time = new Date() 
	 var hour = time.getHours()
	 if (hour >= 10 && hour <= 20)
		  clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"')",600000);
	}
function StartTicker()
{
	window.close();
	window.opener.document.getElementById("tickerData").style.display='inline';
}	
function startstop()
{
	
    var id=document.getElementById("StopImg");
    if(document.getElementById('MarqueeId').scrollAmount==0)
    {
        
        id.src = "images/stop.gif"
        document.getElementById('MarqueeId').scrollAmount=1;
    }
    else
    {
    
     id.src = "images/play.gif"
     document.getElementById('MarqueeId').scrollAmount=0;
        
    }

}
function startstopinner()
{
	
    var id=document.getElementById("StopImg");
    if(document.getElementById('MarqueeId').scrollAmount==0)
    {
        
        id.src = "../images/stop.gif"
        document.getElementById('MarqueeId').scrollAmount=1;
    }
    else
    {
    
     id.src = "../images/play.gif"
     document.getElementById('MarqueeId').scrollAmount=0;
        
    }

}
function getTickerDataInner(Exchg)
	{
//	alert(Exchg);

		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl ="../TickerData.aspx?Exchg="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//document.write(requestUrl);
//		alert(requestUrl);
		if(XmlHttp)	
		{
			XmlHttp.onreadystatechange = function(){getDataResponseTicker(Exchg);};
			XmlHttp.open("GET", requestUrl,  true);
			XmlHttp.send(null);
		}
	}

function getTickerData(Exchg)
	{
//	alert(Exchg);

		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl ="TickerData.aspx?Exchg="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//document.write(requestUrl);
//		alert(requestUrl);
		if(XmlHttp)	
		{
			XmlHttp.onreadystatechange = function(){getDataResponseTicker(Exchg);};
			XmlHttp.open("GET", requestUrl,  true);
			XmlHttp.send(null);
		}
	}

function getDataResponseTicker(Exchg)
{
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			var arrCol,Time,Code,CompName,ClPrice,DiffVal,DiffImg;
			var ExchgDet="",stkDet="";
			if(browser.isIE)
				var MarqueeId = document.getElementById("MarqueeId1");
			else
				var MarqueeId = document.getElementById("MarqueeId");
			var Mq_Data = XmlHttp.responseText;
			//alert(Mq_Data);
			if(Mq_Data != "")
			var arrRow = Mq_Data.split("|");
				for(i=0; i<arrRow.length-1; i++)
				 {
					arrCol = arrRow[i].split("~");
						CompName = arrCol[1];
						ClPrice  = arrCol[2];
						DiffVal  = arrCol[3];
						if(DiffVal>0) 
						{
							clss = "<span class='TickerBlue'>+"
						}
						else if(DiffVal<0) 
						{
							clss = "<span class='TickerRed'>"
						}
						else 
						{
							clss = "<span class='TickerBlack'>"
						}
						if(i==0)
						{
							ExchgDet = arrCol[0] +" &nbsp; "+ CompName +"&nbsp;&nbsp;"+ ClPrice  + " [" + clss + DiffVal +"</span>] &nbsp;&nbsp;&nbsp;";
							//ExchgDet = arrCol[0] +" &nbsp; "+ CompName +"&nbsp;&nbsp;"+ ClPrice  + " &nbsp;&nbsp;" + clss + DiffVal +"]</span> &nbsp;&nbsp;&nbsp;";
						}	
						else
						{
							stkDet += "<a href='../corporateInfo/ScripSearch.aspx?opt=1&id=401&cocode="+ arrCol[0] +"' class=TickerText>" + CompName +"</a>&nbsp; "+ ClPrice +" ["+ clss +DiffVal +"</span>] &nbsp;&nbsp;&nbsp;";
//stkDet += "<a href='#="+ arrCol[0] +"' class=TickerText>" + CompName +"</a>&nbsp; "+ ClPrice +" ["+ clss +DiffVal +"</span>] &nbsp;&nbsp;&nbsp;";
							//stkDet += "<a href='../corporateInfo/CorpInfo.aspx?opt=1&id=10&cocode="+ arrCol[0] +"' class=TickerLink>" + CompName +"</a>&nbsp; "+ ClPrice +" &nbsp;&nbsp;"+ clss + DiffVal +"]</span> &nbsp;&nbsp;&nbsp;";
						}	
				}
				if(browser.isIE)
				{
					//alert("iefsd");
					MarqueeId.innerHTML = "<marquee id='MarqueeId' onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='35' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>";
					
					}
				else
				{
					
				//alert("eeee");
				MarqueeId.innerHTML =ExchgDet + stkDet;
				
//				    MarqueeId.innerHTML = ExchgDet + stkDet;	
//					//$('MarqueeId').update(ExchgDet + stkDet);
//					//$('MarqueeId').update("<marquee id='MarqueeId' onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='35' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>");
//					//MarqueeId.innerHTML = "<marquee id='MarqueeId' onmouseover='this.stop();' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='35' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>";
//					//alert(MarqueeId.innerHTML);
					}			
				document.body.style.cursor = "auto";
				ExchngTimeClock(Exchg);
		}
		
	}
}


