﻿//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 = "imagesnew/tic_pause.gif"
		document.getElementById("MarqueeId").stop();
		//id.alt = "Play";
		id.title="Play";
	}
	else
	{
		id.src="imagesnew/tic_play.gif";
		document.getElementById("MarqueeId").start();
		//id.alt = "Stop";
		id.title="Stop";
	}
/// <reference path="file:///C:\DOCUME~1\pasu\LOCALS~1\Temp\kkumqo8h.bmp" />

}
function getTickerDataInner(Exchg)
	{
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl ="/TickerDataInner.aspx?Exchg="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
		//document.write(requestUrl);
		if(XmlHttp)	
		{
					XmlHttp.onreadystatechange = function(){getDataResponseTicker1(Exchg);};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
		}
	}

	
	
	
	
function getDataResponseTicker1(Exchg)
{
	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 = "<span style='color:#373737'>" + arrCol[0] +"</span> &nbsp;<span style='color:#373737'> "+ CompName +"</span>&nbsp;&nbsp;:&nbsp;&nbsp;<span style='color:#373737'> "+ ClPrice +"</span>&nbsp;"+clss+"&nbsp;["+ DiffVal +"]&nbsp;</span>&nbsp;&nbsp;&nbsp;";
						}	
						else
						{
						
						    stkDet += "<a class='TickerinnerText' href='../CorporateInfo/Scripsearch.aspx?opt=1&id=401&cocode="+ arrCol[0] +"' > " + CompName +"</a>&nbsp;&nbsp;:&nbsp;<span style='color:#373737'>  "+ ClPrice +"</span>&nbsp;"+clss+"&nbsp;["+ DiffVal +"]</span> &nbsp;&nbsp;&nbsp;";
						
						    
						
							
						}	
						
				}
				var browserName=navigator.appName; 
				if(browser.isIE)
					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("td_bse3").className="tabon";
        document.getElementById("td_nse3").className="taboff";
        document.getElementById("td_bse3").style.cursor="default";
        document.getElementById("td_nse3").style.cursor="pointer";
         document.getElementById("BSE").className="more1";
         document.getElementById("NSE").className="morenew";
         
		getTickerDataInner('BSE');
		//LiveIndices1('BSE');
	}
	else
	{
	    document.getElementById("td_bse3").className="taboff";
            document.getElementById("td_nse3").className="tabon";
            document.getElementById("td_bse3").style.cursor="pointer";
            document.getElementById("td_nse3").style.cursor="default";
             document.getElementById("BSE").className="morenew";
             document.getElementById("NSE").className="more1";

		getTickerDataInner('NSE');
		//LiveIndices1('NSE');
		
	}
	

}



