//tickerData = document.getElementById("tickerData")
//alert(tickerData)
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()
{
	/*document.getElementById("tickerData").style.display = 'none'
	var tick_win;
	getTickerData('BSE')
	tick_win = window.open("../ticker_pop.aspx","DetailNews1","status=1,height=120,width=800,resizable=0,scrollbars=0,left=50,top=100")
	tick_win.focus();*/
	
	var id=document.getElementById("PlayImg");
	if (id.src.indexOf("pause.gif")!=-1)
	{
		id.src = "images/play.gif"
		document.getElementById("MarqueeId").stop();
		//id.alt = "Play";
		id.title="Play";
	}
	else
	{
		id.src="images/pause.gif";
		document.getElementById("MarqueeId").start();
		//id.alt = "Stop";
		id.title="Stop";
	}

}
function getTickerData(Exchg)
	{
		//alert("check");
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl ="TickerData.aspx?Exchg="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//document.write(requestUrl);
		if(XmlHttp)	
		{
					XmlHttp.onreadystatechange = function(){getDataResponseTicker(Exchg);};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
		}
	}

function getDataResponseTicker(Exchg)
{
//    if(XmlHttp.readyState == 1)
//    {
//    var MarqueeId = document.getElementById("MarqueeId1");
//    MarqueeId.innerHTML ="Ticker Loading.....";
//    }
	if(XmlHttp.readyState == 4)
	{
		if(XmlHttp.status == 200)
		{			
			var arrCol,Time,Code,CompName,ClPrice,DiffVal,DiffImg;
			var ExchgDet="",stkDet="";
            var browserName=navigator.appName; 
			if(browser.isIE )//&& browserName=="Opera") 
				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='TickerGreen'>+"
						}
						else if(DiffVal<0) 
						{
							clss = "<span class='TickerRed'>"
						}
						else 
						{
							clss = "<span class='TickerGreen'>"
						}
						if(i==0)
						{
							
							ExchgDet = arrCol[0] +" &nbsp; "+ CompName +"&nbsp;&nbsp;:&nbsp;&nbsp;"+ ClPrice  +"&nbsp;"+clss+"&nbsp;"+ DiffVal +"&nbsp;</span>&nbsp;&nbsp;&nbsp;";
						}	
						else
						{
						    stkDet += "<a href=javascript:getwin('Equities.aspx?id=41&cocode="+ arrCol[0] +"') class=TickerLink>" + CompName +"</a>&nbsp;&nbsp;:&nbsp; "+ ClPrice +"&nbsp;"+clss+"&nbsp;"+DiffVal +"</span> &nbsp;&nbsp;&nbsp;";
							//stkDet += "<a href='../CorporateInfo/CorpInfo.aspx?id=41&cocode="+ arrCol[0] +"' class=TickerLink>" + CompName +"</a>&nbsp;&nbsp;:&nbsp; "+ ClPrice +"&nbsp;"+clss+"&nbsp;"+DiffVal +"</span> &nbsp;&nbsp;&nbsp;";
							//stkDet += "<a href='#' class=TickerLink>" + CompName +"</a>&nbsp;&nbsp;:&nbsp; "+ ClPrice +"&nbsp;"+clss+"&nbsp;"+DiffVal +"</span> &nbsp;&nbsp;&nbsp;";
							
						}	
				}
				var browserName=navigator.appName; 
				if(browser.isIE)
					MarqueeId.innerHTML = "<marquee id='MarqueeId' onmouseover='javascript:OnmouseStop();' onmouseout='javascript:OnmouseStart();' trueSpeed scrollAmount='1' scrollDelay='35' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>";
//				else if(browserName=="Opera")				
//					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
					MarqueeId.innerHTML = ExchgDet + stkDet;	
				//alert(MarqueeId.innerHTML)
				document.body.style.cursor = "auto";
				ExchngTimeClock(Exchg);
		}
	}
}

function changeTicker(Exchg)
{
	if (Exchg == "BSE")
	{ 
	    document.getElementById("img_bse").src="Images/bse_on.gif";
	    document.getElementById("img_nse").src="Images/nse_off.gif";
//	    document.getElementById("Td_BSE").className="BNGOff"
//		document.getElementById("Td_NSE").className="BNPOn"
//		document.getElementById("BscId").className="BNGOffTab"
//		document.getElementById("NscId").className="BNPOnTab"		
		document.getElementById("BscId").style.cursor="pointer";
		document.getElementById("NscId").style.cursor="default";
		getTickerData('BSE');
	}
	else
	{
	    document.getElementById("img_bse").src="Images/bse_off.gif";
	    document.getElementById("img_nse").src="Images/nse_on.gif";
//		document.getElementById("Td_BSE").className="BNPOn"
//		document.getElementById("Td_NSE").className="BNGOff"
//		document.getElementById("BscId").className="BNPOnTab"
//		document.getElementById("NscId").className="BNGOffTab"
		document.getElementById("NscId").style.cursor="pointer";
		document.getElementById("BscId").style.cursor="default";
		getTickerData('NSE');
	}
}
function changeTickerpop(Exchg)
{
	if (Exchg == "BSE")
	{ 
		document.getElementById("AhrefBSE1").className="Ticksel"
		document.getElementById("AhrefNSE1").className="TickUnsel"
		getTickerData('BSE');
	}
	else
	{
		document.getElementById("AhrefBSE1").className="TickUnsel"
		document.getElementById("AhrefNSE1").className="Ticksel"
		getTickerData('NSE');
	}
}



