﻿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();
		}
	}
	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;
  }
}

var xmlHttpNews;
function CreateXmlHttp1()
	{
		try
		{
			xmlHttpNews = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlHttpNews = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				xmlHttpNews = null;
					
			}
		}
		if(!xmlHttpNews && typeof XMLHttpRequest != "undefined") 
		{
			xmlHttpNews = new XMLHttpRequest();
		}
	}
	var xmlHttpTicker;
function CreateXmlHttpTicker()
	{
		try
		{
			xmlHttpTicker = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlHttpTicker = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				xmlHttpTicker = null;
					
			}
		}
		if(!xmlHttpTicker && typeof XMLHttpRequest != "undefined") 
		{
			xmlHttpTicker = new XMLHttpRequest();
		}
	}

function HmNewsData(Secid,SubSecid,opt)
{
       var BusiNews=document.getElementById('Tr_BusiNews');
       var MktCtry=document.getElementById('Tr_MktCmtry');
       var HotNews=document.getElementById('Tr_HotNews');
      var browser=navigator.appName;
      var dis;
      if(browser=="Microsoft Internet Explorer")
      {
         dis="inline";
      }
      else
      {
        dis="table-row";
      }
   
    CreateXmlHttp1();
    document.body.style.cursor = "progress";
    var header=document.getElementById('Td_Header');
    if(opt=="BN")
    {
        header.innerHTML="BUSINESS NEWS";
        BusiNews.style.display="none";
        HotNews.style.display=dis;
        MktCtry.style.display=dis;
        HotNews.style.cursor="pointer";
        MktCtry.style.cursor="pointer";
    }
     else if(opt=="MC")
    {
        header.innerHTML="MARKET COMMENTARY";
        BusiNews.style.display=dis;
        HotNews.style.display=dis;
        BusiNews.style.cursor="pointer";
        HotNews.style.cursor="pointer";
        MktCtry.style.display="none";
    }
    else if(opt=="HN")
    {
        header.innerHTML="HOT NEWS";
        HotNews.style.display="none";
        BusiNews.style.display=dis;
        MktCtry.style.display=dis;
        BusiNews.style.cursor="pointer";
        MktCtry.style.cursor="pointer";
    }
    
    var Url="HmNewsData.aspx?Sec="+Secid+"&SubSec="+SubSecid;
    document.getElementById("Td_News").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=210px height=92px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
    if(xmlHttpNews)
    {
            xmlHttpNews.onreadystatechange=function(){GetResponseTxt()};
            xmlHttpNews.open("GET",Url,true);
            xmlHttpNews.send(null);
    }
}
function GetResponseTxt()
{

    if(xmlHttpNews.readyState==4)
    {
      if(xmlHttpNews.status==200)
      {
      
        document.getElementById("Td_News").innerHTML=xmlHttpNews.responseText;
        document.body.style.cursor = "auto";
      }
      else
      {
          document.getElementById("Td_News").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=210px height=92px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
      }
    }
}

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 changeTicker(Exchg)
 {
    var img_bse = document.getElementById("img_bse");
    var img_nse = document.getElementById("img_nse");
	if(Exchg=="BSE")
	{
	    img_bse.src="/images/tic_bseon.gif";
	    img_nse.src="/images/tic_nseoff.gif";
	    img_bse.style.cursor="default";
        img_nse.style.cursor="pointer";
        getTickerData('BSE');
	}
	else if(Exchg=="NSE")
	{
	    img_bse.src="/images/tic_bseoff.gif";
	    img_nse.src="/images/tic_nseon.gif";
	    img_bse.style.cursor="pointer";
        img_nse.style.cursor="default";
        getTickerData('NSE');	    
	}
	}

//Ticker Loading Image
function getTickerData(Exchg)
	{
	    CreateXmlHttpTicker();
	    var requestUrl = "/TickerData.aspx?Exchg="+Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();
	    if(xmlHttpTicker)	
		{
					xmlHttpTicker.onreadystatechange = function(){getDataResponseTicker();};
					xmlHttpTicker.open("GET", requestUrl,  true);
					xmlHttpTicker.send(null);
		}
   }
	
function getDataResponseTicker()
{
	if(xmlHttpTicker.readyState == 4)
	{
		if(xmlHttpTicker.status == 200)
		{			
			var SpnHomeTicker = document.getElementById("SpnHomeTicker");
			SpnHomeTicker.innerHTML=xmlHttpTicker.responseText;
			document.body.style.cursor = "auto";
				
		}
	}
}


function SpeedTicker(opt,MarqueeId)
{
	if(opt == "PLUS")	
	{
	    var imgsrc=document.getElementById("StopImg").src;
	    if(imgsrc.indexOf("/images/itic_play.gif")>=0)
	    {
	         document.getElementById(MarqueeId).stop();
	    }
	    else
	    {
	   	    document.getElementById(MarqueeId).start();
		    document.getElementById(MarqueeId).setAttribute('scrollAmount',parseInt(document.getElementById(MarqueeId).getAttribute('scrollAmount'))+1);this.alt='  +'+ document.getElementById(MarqueeId).getAttribute('scrollAmount');
		  
            document.getElementById("ImgP").title=' «« +'+document.getElementById(MarqueeId).getAttribute('scrollAmount');	
            document.getElementById("ImgM").title='««-'+ document.getElementById(MarqueeId).getAttribute('scrollAmount');	
        }
    }
		
	if(opt == "STOP")
	{
            if(document.getElementById("StopImg").src.indexOf("itic_play")>=0)
              {
                document.getElementById('StopImg').src='/images/itic_stop.gif';
                document.getElementById(MarqueeId).start();
              }
              else
               {
                document.getElementById('StopImg').src='/images/itic_play.gif';
                document.getElementById(MarqueeId).stop();
              }
	}	
	if(opt == "MINUS")
	{

      if(document.getElementById('marqHome').getAttribute('scrollAmount')>1)
      {
      document.getElementById('marqHome').setAttribute('scrollAmount',parseInt(document.getElementById('marqHome').getAttribute('scrollAmount'))-1); this.alt='  -'+ document.getElementById('marqHome').getAttribute('scrollAmount');
      document.getElementById("ImgP").title=' «« +'+ document.getElementById('marqHome').getAttribute('scrollAmount');	
      document.getElementById("ImgM").title='««-'+ document.getElementById('marqHome').getAttribute('scrollAmount');	
      }
	}
}


/* For Home World Indices */
var XmlHttpWorldIndicies;
function CreateXmlHttp2()
	{
	
		try
		{
			XmlHttpWorldIndicies = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpWorldIndicies = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpWorldIndicies = null;
					
			}
		}
		if(!XmlHttpWorldIndicies && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpWorldIndicies = new XMLHttpRequest();
		}
	}

function ChangeWorldIndices(opt)
{
       var Url="";
       var WorldIndicies=document.getElementById('Tr_WorldIndices');
       var CurrPrice=document.getElementById('Tr_CurrPrice');
       var Bullion=document.getElementById('Tr_Bullion');

      var browser=navigator.appName;
      var dis;
      if(browser=="Microsoft Internet Explorer")
      {
         dis="inline";
      }
      else
      {
        dis="table-row";
      }
   
    CreateXmlHttp2();
    document.body.style.cursor = "progress";
    var header=document.getElementById('Td_WIHeader');
    if(opt=="WI")
    {
        header.innerHTML="WORLD INDICES";
        WorldIndicies.style.display="none";
        WorldIndicies.style.cursor="default";
        CurrPrice.style.display=dis;
        Bullion.style.display=dis;
        CurrPrice.style.cursor="pointer";
        Bullion.style.cursor="pointer";
        Url="HmWorld-Indicies.aspx";
    }
     else if(opt=="CP")
    {
        header.innerHTML="CURRENCY PRICE";
        WorldIndicies.style.display=dis;
        Bullion.style.display=dis;
        Bullion.style.cursor="pointer";
        WorldIndicies.style.cursor="pointer";
        CurrPrice.style.cursor="default";
        CurrPrice.style.display="none";
        Url="Currency_Price.aspx";
    }
    else if(opt=="BIL")
    {
        header.innerHTML="BULLION";
        Bullion.style.display="none";
        Bullion.style.cursor="default";
        CurrPrice.style.display=dis;
        WorldIndicies.style.display=dis;
        CurrPrice.style.cursor="pointer";
        WorldIndicies.style.cursor="pointer";
        Url="Bullion.aspx";
    }
    document.getElementById("Td_World_Indices").innerHTML ="<table cellpadding=0 cellspacing=0 border=0 width=220px height=92px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
    if(XmlHttpWorldIndicies)
    {
            XmlHttpWorldIndicies.onreadystatechange=function(){GetWIResponseTxt()};
            XmlHttpWorldIndicies.open("GET",Url,true);
            XmlHttpWorldIndicies.send(null);
    }
    
  
}
function GetWIResponseTxt()
{
    
    if(XmlHttpWorldIndicies.readyState==4)
    {
      if(XmlHttpWorldIndicies.status==200)
      {
       
        document.getElementById("Td_World_Indices").innerHTML=XmlHttpWorldIndicies.responseText;
        document.body.style.cursor = "auto";
      }
      else
      {
          document.getElementById("Td_World_Indices").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=210px height=92px><tr><td align=center class=NoData><img src=/images/loading.gif></td></tr></table>";
      }
    }
}


var XmlHttpGainLose;
function CreateXmlHttp3()
	{
	
		try
		{
			XmlHttpGainLose = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpGainLose = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpGainLose = null;
					
			}
		}
		if(!XmlHttpGainLose && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpGainLose = new XMLHttpRequest();
		}
	}


function ChangeGainLose(Exchg,GainLose,Opt)
{

         var browser=navigator.appName;
          var dis;
          if(browser=="Microsoft Internet Explorer")
          {
             
             dis="inline";
          }
          else
          {
            dis="table-row";
          }



       var GainLoseHdr=document.getElementById("Td_GainLoseHdr");
       var TrStocks=document.getElementById("Tr_Stocks");
       var TrMF=document.getElementById("Tr_MF");
       var TrComm=document.getElementById("Tr_Comm");
       var HidExchg=document.getElementById("Hid_Exchg");
       var HidComExchg=document.getElementById("Hid_CommExchg");
       var HidComOpt=document.getElementById("Hid_CommOpt");
       var HidOpt=document.getElementById("Hid_Opt");
       var TdGain=document.getElementById("Td_Gain");
       var TdLose=document.getElementById("Td_Lose");
       var TrGainLoseTab=document.getElementById("Tr_GainLoseTab");
       var TrCommGainLoseTab=document.getElementById("Tr_CommGainLoseTab");
       var TdBSENSE=document.getElementById("Td_BSENSE");
       var TdMCXNCDEX=document.getElementById("Td_MCXNCDEX");
       var TdCommGain=document.getElementById("Td_CommGain");
       var TdCommLose=document.getElementById("Td_CommLose");
       
       var TdBSE=document.getElementById("Td_BSE");
       var TdNSE=document.getElementById("Td_NSE");
       var TdMCX=document.getElementById("Td_MCX");
       var TdNCDEX=document.getElementById("Td_NCDEX");
       var Td_GLData=document.getElementById("Td_GLData");
      
       
        TrGainLoseTab.style.display="none";
        TrCommGainLoseTab.style.display="none";
        TdBSENSE.style.display="none";
        TdMCXNCDEX.style.display="none";
       
       if(Exchg=="BSE")
       {
        HidExchg.value="BSE";
        TdBSE.className="TabOn HmWhiteTxt";
        TdNSE.className="TabOff HmWhiteNB";
       }
       else if(Exchg=="NSE")
       {
        HidExchg.value="NSE";
        TdNSE.className="TabOn HmWhiteTxt";
        TdBSE.className="TabOff HmWhiteNB";
       }
      else if(Exchg=="MCX")
       {
        HidComExchg.value="MCX";
        TdMCX.className="TabOn HmWhiteTxt";
        TdNCDEX.className="TabOff HmWhiteNB";
       }
      else if(Exchg=="NCDEX")
       {
        HidComExchg.value="NCDEX";
        TdNCDEX.className="TabOn HmWhiteTxt";
        TdMCX.className="TabOff HmWhiteNB";
       }
        
       if(GainLose=="GAIN")
       {
           TrGainLoseTab.style.display=dis;
           TdBSENSE.style.display=dis;
           HidOpt.value="GAIN";
	       TdGain.className="GTabOn";
           TdLose.className="GTabOff"
           Url="HmGainLoseData.aspx?Exchg="+Exchg+"&Opt="+GainLose;
       }
       else if(GainLose=="LOSE")
       {
           TrGainLoseTab.style.display=dis;
           TdBSENSE.style.display=dis;
           HidOpt.value="LOSE";
           TdGain.className="GTabOff";
           TdLose.className="GTabOn"
           Url="HmGainLoseData.aspx?Exchg="+Exchg+"&Opt="+GainLose;
       }
       else if(GainLose=="TOPG")
       {
           TdMCXNCDEX.style.display=dis; 
           TrCommGainLoseTab.style.display=dis; 
           HidComOpt.value="TOPG";
           TdCommGain.className="GTabOn";
           TdCommLose.className="GTabOff"
           Url="CommGainLose.aspx?Exchg="+Exchg+"&Opt="+GainLose;
       }
        else if(GainLose=="TOPL")
       {
           TdMCXNCDEX.style.display=dis; 
           TrCommGainLoseTab.style.display=dis;
           HidComOpt.value="TOPL";
           TdCommGain.className="GTabOff";
           TdCommLose.className="GTabOn"
           Url="CommGainLose.aspx?Exchg="+Exchg+"&Opt="+GainLose;
          
       }
       else if(GainLose=="MF1")
       {
            Url="MF-Fund-Perf.aspx"; 
       }
       
       if(Opt=="ST")
       {
            GainLoseHdr.style.width="140px";
            GainLoseHdr.innerHTML="STOCKS";
            TrStocks.style.display="none";
            TrStocks.style.cursor="default";
            TrMF.style.display=dis;
            TrComm.style.display=dis;
            TrMF.style.cursor="pointer";
            TrComm.style.cursor="pointer";
            Td_GLData.style.height="77px";
            document.getElementById("Td_GainLose").innerHTML ="<table cellpadding=0 cellspacing=0 border=0 width=220px height=77px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
       }
       else if(Opt=="MF")
       {
            GainLoseHdr.innerHTML="MUTUAL FUND";
            TrMF.style.display="none";
            TrMF.style.cursor="default";
            TrComm.style.display=dis;
            TrStocks.style.display=dis;
            TrComm.style.cursor="pointer";
            TrStocks.style.cursor="pointer";
            Td_GLData.style.height="92px";
            document.getElementById("Td_GainLose").innerHTML ="<table cellpadding=0 cellspacing=0 border=0 width=220px height=92px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
       }
       else if(Opt=="CO")
       {
            TdMCXNCDEX.style.width="85px";
            GainLoseHdr.style.width="115px";
            GainLoseHdr.innerHTML="COMMODITY";
            TrComm.style.display="none";
            TrComm.style.cursor="default";
            TrMF.style.display=dis;
            TrStocks.style.display=dis;
            TrMF.style.cursor="pointer";
            TrStocks.style.cursor="pointer";
            Td_GLData.style.height="77px";
            document.getElementById("Td_GainLose").innerHTML ="<table cellpadding=0 cellspacing=0 border=0 width=220px height=77px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
        }
       
       CreateXmlHttp3();
      
       if(XmlHttpGainLose)
        {
                XmlHttpGainLose.onreadystatechange=function(){GetGainLoseResponseTxt(Opt)};
                XmlHttpGainLose.open("GET",Url,true);
                XmlHttpGainLose.send(null);
        }
            
  
}
function GetGainLoseResponseTxt(Opt)
{

    if(XmlHttpGainLose.readyState==4)
    {
      if(XmlHttpGainLose.status==200)
      {      
        document.getElementById("Td_GainLose").innerHTML=XmlHttpGainLose.responseText;
        document.body.style.cursor = "auto";
      }
      else
      {
         if(Opt=="MF")
          document.getElementById("Td_GainLose").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=210px height=92px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
          else
          document.getElementById("Td_GainLose").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 width=210px height=77px><tr><td align=center><img src=/images/loading.gif></td></tr></table>";
      }
    }
}


