//GET Quotes Commodity
function CreateXmlHttpnew()
	{
		try
		{
			XmlHttpnew = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpnew = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpnew = null;
					
			}
		}
		if(!XmlHttpnew && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpnew = new XMLHttpRequest();
		}
	}

//Home page Ticker

var XmlHttpnew
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);
	}


// For Commodity Ticker Data
function TickerDataCom(ex,typ)
{ 
//alert("t");
CreateXmlHttpnew();


var DDL2=document.getElementById("_ctl0_ContentPlaceHolder1_TickerComm1_Ddl_FS").value;
//alert(DDL2);

	var url="../Commodity/TickerComData.aspx?sid=" + Math.random() + "&typ="+typ+"&Exchg="+ex
	//alert(url);
//}

/*else
{
	var url="tickerds.aspx?sid=" + Math.random() + "&typ=S&Exchg="+DDL2.value
	alert(url);
}*/
//alert(url);
XmlHttpnew.onreadystatechange = function(){LoadTickerData()};
XmlHttpnew.open("GET", url , true)
XmlHttpnew.send(null)
} 
function LoadTickerData() 
{ 	
	if (XmlHttpnew.readyState==4 || XmlHttpnew.readyState=="complete")
	{ 
		//alert("1");
		//var winwidth = window.screen.availWidth;
		//alert(winwidth);
		//window.resizeto(1,winwidth);
		document.getElementById("_ctl0_ContentPlaceHolder1_TickerComm1_TD1").innerHTML=XmlHttpnew.responseText 
		
				
	} 
}
//----ticker---

function changeselection(exchng)
	{
	//alert(document.getElementById("FS"))	
	    
	    ChangeValue(exchng,document.getElementById("_ctl0_ContentPlaceHolder1_TickerComm1_Ddl_FS").value);
	   	if(exchng=="NCDEX")
	   	{
		  	document.getElementById("FS").value="NCDEX";
	   	}
	   	else
	   	{
			document.getElementById("FS").value="MCX";
	   	}
	}
	
	function ChangeValue(val,typ)
{
//alert(val)
//alert(typ)
	var Opt = document.getElementById("FS").value;
//	alert(Opt);
	if(val == 'NCDEX')
		{
		    document.getElementById("tops").className="BNPOn"
		    document.getElementById("TPRM1").className="BNPOnTab";
		    document.getElementById("bops").className="BNGOff";
	        document.getElementById("TPRM2").className="BNGOffTab";
		    document.getElementById("bops").style.cursor="pointer";
		    document.getElementById("tops").style.cursor="default";
		 }
		 else if(val=="MCX")
		 {
		    document.getElementById("tops").className="BNGOff"
		    document.getElementById("TPRM1").className="BNGOffTab";
		    document.getElementById("bops").className="BNPOn";
	        document.getElementById("TPRM2").className="BNPOnTab";
		    document.getElementById("tops").style.cursor="pointer";
		    document.getElementById("bops").style.cursor="default";
		 }
	
	if(typ == 'F')
	{
		
		
		if(val == 'NCDEX')
		{
			TickerDataCom('NCDEX','F');
		}
		else
		{
			TickerDataCom('MCX','F');
		}
	}
	else if(typ =='S')
	{
//		document.getElementById("TPRM1").style.cursor="pointer";
//		document.getElementById("TPRM1").className="";
//		document.getElementById("TPRM2").style.cursor="default";
	
		if(val =='NCDEX')
		{
			TickerDataCom('NCDEX','S');
		}
		else
		{
			TickerDataCom('MCX','S');
		}
	}
	//TickerDataCom(val,typ);
}

			


