var arrFAO		=  new Array('ALL Contracts','ALL Futures','ALL Options','NIFTY Futures','NIFTY Options','BANKNIFTY Futures','BANKNIFTY Options','CNXIT Futures','CNXIT Options','STOCK Futures','STOCK Options');
var arrFAOCode	=  new Array('','FUT','OPT','FUTIDX|NIFTY','OPTIDX|NIFTY','FUTIDX|BANKNIFTY','OPTIDX|BANKNIFTY','FUTIDX|CNXIT','OPTIDX|CNXIT','FUTSTK','OPTSTK');

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;
  }

  // Treat any other "Gecko" browser as NS 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}
var browser = new Browser();
var clockTimeoutID;

var XmlHttp;
//Creating object of XMLHTTP For AJAX Method
function GetQotUrl(code)
				{
				window.location="http://www.balajiequities.com/Balaji_Top.aspx?target=http://www.balajisec.cmlinks.com/Profile/CorpInfo.aspx|pnav=PI3_PI0~PageOpt=13~code="+ code +"";
				}
function CreateXmlHttp()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttp = new XMLHttpRequest();
		}
	}
	
//**** Function ExchngTimeClock Is used for to find out the market hours --- The ticker will automatically refresh only in market timings *****//			
function ExchngTimeClock(Exchg) {
	 var time = new Date()
	 var hour = time.getHours()
	 if (hour >= 10 && hour <= 20)
			  clockTimeoutID = setTimeout("getTickerData('"+ Exchg +"')",600000);
	}
	
//**** Function killClock Is used for killing clock timer  *****//
function killClock(){
	clearTimeout(clockTimeoutID);
	}		
	

//For Loading ticker from TickerData.aspx Using AJAX
function getTickerData(Exchg)
	{
	if (Exchg=="BSE")
	{
		document.getElementById("BSE").src = "../images/TickerBseOn.gif"
		document.getElementById("NSE").src = "../images/TickerNseOff.gif"
		document.getElementById("tdBSE").style.cursor = "default"
		document.getElementById("tdNSE").style.cursor = "hand"
		document.getElementById("tdMCX").style.cursor = "hand";
		document.getElementById("tdWIN").style.cursor = "hand"
		document.getElementById("MCX").src = "../images/TickerMcxOff.gif"
		document.getElementById("WIN").src = "../images/TickerwinOff.gif"
	}
	else if(Exchg=="NSE")
	{
		document.getElementById("BSE").src = "../images/TickerBseOff.gif"
		document.getElementById("NSE").src = "../images/TickerNseOn.gif"
		document.getElementById("tdBSE").style.cursor = "hand"
		document.getElementById("tdNSE").style.cursor = "default"
		document.getElementById("tdMCX").style.cursor = "hand";
		document.getElementById("tdWIN").style.cursor = "hand"
		document.getElementById("MCX").src = "../images/TickerMcxOff.gif"
		document.getElementById("WIN").src = "../images/TickerwinOff.gif"
	}
	else if(Exchg=="MCX")
	{
		document.getElementById("BSE").src = "../images/TickerBseOff.gif"
		document.getElementById("NSE").src = "../images/TickerNseOff.gif"
		document.getElementById("tdBSE").style.cursor = "hand"
		document.getElementById("tdNSE").style.cursor = "hand"
		document.getElementById("tdWIN").style.cursor = "hand"
		document.getElementById("tdMCX").style.cursor = "default";
		document.getElementById("MCX").src = "../images/TickerMcxOn.gif"
		document.getElementById("WIN").src = "../images/TickerwinOff.gif"
	}
	else if(Exchg=="WI")
	{
		document.getElementById("BSE").src = "../images/TickerBseOff.gif"
		document.getElementById("NSE").src = "../images/TickerNseOff.gif"
		document.getElementById("tdBSE").style.cursor = "hand"
		document.getElementById("tdNSE").style.cursor = "hand"
		document.getElementById("tdWIN").style.cursor = "default"
		document.getElementById("tdMCX").style.cursor = "hand";
		document.getElementById("MCX").src = "../images/TickerMcxOff.gif"
		document.getElementById("WIN").src = "../images/Tickerwinon.gif"
	}
	
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		document.getElementById("MarqueeId").innerHTML = " <img src='../images/loading1.gif'>";
		
		var requestUrl = "../TickerData.aspx?Exchg="+ Exchg +"&IpTrack="+ window.location.hostname +"&timeStamp="+new Date().getTime();		
		
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){getDataResponse(Exchg);};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
	}
	
	//Called when response comes back from server Only For Ticker
function getDataResponse(Exchg)
{	
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{			
			var arrCol,Time,Code,CompName,ClPrice,DiffVal,DiffImg;
			var ExchgDet="",stkDet="";
			var MarqueeId = document.getElementById("MarqueeId");
			var Mq_Data = XmlHttp.responseText;
			
			if(Mq_Data != "")
			var arrRow = Mq_Data.split("|");
			if(Exchg=="MCX")
			{
				for(i=0; i<arrRow.length-1; i++)
				 {
					arrCol = arrRow[i].split("~");
					DiffVal  = arrCol[3];
						if(DiffVal>0) 
						{
							clss = "<span class='TickerBlue'>"
						}
						else if(DiffVal<0) 
						{
							clss = "<span class='TickerRed'>"
						}
						else 
						{
							clss = "<span class='TickerBlue'>"													
						}
					//stkDet += arrCol[0]+"&nbsp; <a target=_parent href=javascript:GetQotUrl("+arrCol[1]+"); class=GreyTickerLink>" + arrCol[1] +"</a>&nbsp; "+ arrCol[2]+" "+"&nbsp"+ clss +"["+ DiffVal+"%]</span>  &nbsp;&nbsp;&nbsp;";
					stkDet += arrCol[0]+"&nbsp; <a target=_top href='http://www.balajiequities.com/Balaji_Top.aspx?target=http://www.balajisec.cmlinks.com/Commodity/Commodity.aspx|pnav=PI7_PI2~id=1~Exchg=MCX~Symbol="+arrCol[1]+"~ExpDate="+arrCol[5]+"' class=GreyTickerLink>" + arrCol[1] +"</a>&nbsp; "+ arrCol[2]+" "+"&nbsp"+ clss +"["+ DiffVal+"]</span>  &nbsp;&nbsp;&nbsp;";
										
				}
			}
			else if(Exchg=="WI")
			{
				for(i=0; i<arrRow.length-1; i++)
				 {
					arrCol = arrRow[i].split("~");
					DiffVal  = arrCol[3];
						if(DiffVal>0) 
						{
							clss = "<span class='TickerBlue'>"
						}
						else if(DiffVal<0) 
						{
							clss = "<span class='TickerRed'>"
						}
						else 
						{
							clss = "<span class='TickerBlue'>"													
						}
					//stkDet += arrCol[0]+"&nbsp; <a target=_parent href=javascript:GetQotUrl("+arrCol[1]+"); class=GreyTickerLink>" + arrCol[1] +"</a>&nbsp; "+ arrCol[2]+" "+"&nbsp"+ clss +"["+ DiffVal+"%]</span>  &nbsp;&nbsp;&nbsp;";
					if(i==0)
					   ExchgDet = arrCol[0]+"&nbsp;&nbsp;<a target=_parent href='http://www.balajiequities.com/Balaji_Top.aspx?target=http://www.balajisec.cmlinks.com/OtherMarket/OtherMarketInfo.aspx|pnav=PI8_PI3' class=GreyTickerLink>" + arrCol[1] +"</a>&nbsp; "+ arrCol[2]+" "+"&nbsp"+ clss +"["+ DiffVal+"]</span>  &nbsp;&nbsp;&nbsp;";
					 else
					stkDet +="&nbsp;&nbsp;<a target=_top href='http://www.balajiequities.com/Balaji_Top.aspx?target=http://www.balajisec.cmlinks.com/OtherMarket/OtherMarketInfo.aspx|pnav=PI8_PI3' class=GreyTickerLink>" + arrCol[1] +"</a>&nbsp; "+ arrCol[2]+" "+"&nbsp"+ clss +"["+ DiffVal+"]</span>  &nbsp;&nbsp;&nbsp;";
										
				}
			}			
			else
			{ 
				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='TickerBlue'>"													
						}
						
						if(i==0)
							ExchgDet = arrCol[0] +" &nbsp; "+ CompName +"&nbsp; "+ ClPrice +"&nbsp;" + clss +"["+ DiffVal+"]</span> &nbsp;&nbsp;&nbsp;";
						else 
							//stkDet +="<a target=_parent href=javascript:GetQotUrl("+arrCol[0]+"); class=GreyTickerLink>" + CompName +"</a>&nbsp; "+ ClPrice +" "+"&nbsp"+ clss +"["+ DiffVal+"]</span>  &nbsp;&nbsp;&nbsp;";
							stkDet +="<a target=_top href='http://www.balajiequities.com/Balaji_Top.aspx?target=http://www.balajisec.cmlinks.com/Profile/CorpInfo.aspx|pnav=PI3_PI0~PageOpt=13~code="+arrCol[0]+"' class=GreyTickerLink>" + CompName +"</a>&nbsp; "+ ClPrice +" "+"&nbsp"+ clss +"["+ DiffVal+"]</span>  &nbsp;&nbsp;&nbsp;";
				}
							
			}
				if(browser.isIE)
					MarqueeId.innerHTML = "<marquee onmouseover='this.stop();' id='marq' onmouseout='this.start();' trueSpeed scrollAmount='1' scrollDelay='35' direction='left' loop='repeat' width='100%'>" + ExchgDet + stkDet + "</marquee>";
				else
					MarqueeId.innerHTML = ExchgDet + stkDet;	
				document.body.style.cursor = "auto";
				ExchngTimeClock(Exchg);
		}
		else
			MarqueeId.innerHTML = "<img src='../images/loading1.gif'>";
	}
}

function rediecturl(code)
{
window.parent.location="http://www.balajiequities.com/Balaji_Top.aspx?target=http://www.balajisec.cmlinks.com/Profile/CorpInfo.aspx|pnav=PI3_PI0~PageOpt=13~code="+ code +"";
}


function GetNews(secid,subsecid,sno)
{
	var url= "../PopUpNews.aspx?secid=" + secid + "&subsecid=" + subsecid + "&sno=" + sno 
	window.open(url,"","status =no, height =390, width =550px, resizable = 0,scrollbars=1,left=200,top=200" )
}

function Reckoner(url)
{
	window.open(url,"","status =no, height =175, width =550px, resizable = 0,scrollbars=1,left=200,top=200" )
}

//javascript for showing Market Information in home page

function ShowMktInfo(id)
{
	var intraday = document.getElementById("td_intraday");
	var td_intraday = document.getElementById("td_intradayhead");
	
	var gl = document.getElementById("td_gl");	
	var td_gl = document.getElementById("td_glhead");
	
	var FII = document.getElementById("td_FII");
	var td_FII = document.getElementById("td_FIIhead");
	
	var MktSummary = document.getElementById("td_MktSummary");
	var td_MktSummary = document.getElementById("td_MktSummaryhead");	
	
	var MktQuotes = document.getElementById("td_MktQuote");
	var td_MktQuotes = document.getElementById("td_MktQuotehead");
	
	
	if(id=="intraday")
	{	
		MktQuotes.style.display="none";    
		intraday.style.display="inline";
		gl.style.display="none";
		MktSummary.style.display="none";
		FII.style.display="none";
		td_gl.style.cursor="hand"
		td_intraday.style.cursor="default"
		td_MktSummary.style.cursor="hand"
		td_FII.style.cursor="hand";
		td_MktQuotes.style.cursor="hand";
	}
	else if(id=="GL")
	{	
		MktQuotes.style.display="none";   
		intraday.style.display="none";
		gl.style.display="inline";
		MktSummary.style.display="none";
		FII.style.display="none";
		td_intraday.style.cursor="hand"
		td_gl.style.cursor="default"		
		td_MktSummary.style.cursor="hand"
		td_FII.style.cursor="hand";
		td_MktQuotes.style.cursor="hand";
	}
	else if(id=="MktSummary")
	{
		MktQuotes.style.display="none";
	  	MktSummary.style.display="inline";
		intraday.style.display="none";
		FII.style.display="none";
		gl.style.display="none";	
	    td_gl.style.cursor="hand"	
		td_MktSummary.style.cursor="default"	    
	    td_intraday.style.cursor="hand"
	    td_FII.style.cursor="hand";
	    td_MktQuotes.style.cursor="hand";
	}
	else if(id=="FII")
	{	
	    MktQuotes.style.display="none";   
		MktSummary.style.display="none";
		intraday.style.display="none";
		gl.style.display="none";
		FII.style.display="inline";	
	    td_gl.style.cursor="hand"	
		td_MktSummary.style.cursor="hand"	    
	    td_intraday.style.cursor="hand"
	    td_FII.style.cursor="default";
	    td_MktQuotes.style.cursor="hand";
	}	
	else if(id=="MktQuotes")
	{	
	    MktQuotes.style.display="inline";   
		MktSummary.style.display="none";
		intraday.style.display="none";
		gl.style.display="none";
		FII.style.display="none";	
	    td_gl.style.cursor="hand"	
		td_MktSummary.style.cursor="hand"	    
	    td_intraday.style.cursor="hand"
	    td_FII.style.cursor="hand";
	    td_MktQuotes.style.cursor="default";
	}	
	
	
}

function ShowQuotesInfo(id)
{		
	var MktQuotes = document.getElementById("td_MktQuote");
	var td_MktQuotes = document.getElementById("td_MktQuotehead");	
	
	td_MktQuotes.style.cursor="hand"
	MktQuotes.style.display="inline";
}


function ShowPage(page)
{
	var frame = document.getElementById("mid-frame");
	var ig_a = document.location.search.substring(1);
	if(ig_a.indexOf("PageName=")!= -1)
	{
		var ig_b = ig_a.split("PageName=");
		for(var ig_c=0; ig_c<ig_b.length; ig_c++)
		{
			var ig_d = ig_b[ig_c].indexOf(".aspx")
			if(ig_d!=-1)
				frame.src = "../"+ig_b[ig_c];
		}
	}
}
function A2ZIndex(Exchg,Index,Group,id,Option){
	var A2ZIndexId = document.getElementById("A2ZIndex");
	if(A2ZIndexId.innerHTML==""){
		var A2Z="",A2ZClass ="";
			for(i=65; i<=90; i++)
			{
				var Alpha = String.fromCharCode(i);
				A2ZClass = (Index==Alpha) ? "IndexLinkSel" : "IndexLink";
				A2Z += "<a href='MktInner.aspx?id="+id+"&Exchng="+ Exchg +"&Index="+ Alpha +"&Group="+Group+"&opt="+Option+"' class="+ A2ZClass +" >"+ Alpha +"</a>";
			}
			A2ZClass = (Index=="0-9") ? "IndexLinkSel" : "IndexLink";	
			A2ZIndexId.innerHTML = A2Z + "<a href='marketinfo.aspx?id="+id+"&Exchng="+ Exchg +"&Index=0-9&Group="+Group+"&opt="+Option+"' class="+ A2ZClass +" >0-9</a>";
	}
	else
		A2ZIndexId.innerHTML = "";
				
	}
	/*for search company*/

	
function SearchQuote()
	{
	
		
		var SrchQuote = document.getElementById("txt_Symbol").value;
		var PageId = document.getElementById("DD_Options").value;	
		
		if(SrchQuote =="" || SrchQuote=="Enter Company Name")
		{
			alert("Please enter company name ..!!!");
			return false;
		}
		
		else
		{
					var strReplaceAll =SrchQuote;
					var intIndexOfMatch = strReplaceAll.indexOf( "'" );
					while (intIndexOfMatch != -1)
					{
						strReplaceAll = strReplaceAll.replace( "'", "" )
						intIndexOfMatch = strReplaceAll.indexOf( "'" );
						
					}
					var StrUrl = "CompSearch.aspx?schtxt="+strReplaceAll+"&id="+PageId;
					window.location = StrUrl;
		}
				
   }
   
function Event(e,id)
{
		if(e.keyCode==13)	
		{
			//var Scripid = document.getElementById(id);
			var boolval = SearchQuote();
			if(boolval)
			return true;
			else
			return false;
		}	
}

function EnterScript1(e,id)
{
	if(e.keyCode==13)	
	{
		var Scripid = document.getElementById(id);
		Scripid.click();
	}
}


function Compempty2()
{
	if (document.getElementById("txt_Symbol").value=="Company Name")
	{
  		document.getElementById("txt_Symbol").value="";
	}
}

function Compfill2()
{
	var getquote=document.getElementById("txt_Symbol").value;
	if (getquote=="")
	{
		document.getElementById("txt_Symbol").value="Company Name";
	}
}

function Compempty()
{
	if (document.getElementById("txt_Symbol").value=="Enter Company Name")
	{
  		document.getElementById("txt_Symbol").value="";
	}
}

function Compfill()
{
	var getquote=document.getElementById("txt_Symbol").value;
	if (getquote=="")
	{
		document.getElementById("txt_Symbol").value="Enter Company Name";
	}
}





function Compempty1()
{
	if (document.getElementById("txt_Quote2").value=="Change Company")
	{
  		document.getElementById("txt_Quote2").value="";
	}
}

function Compfill1()
{
	var getquote=document.getElementById("txt_Quote2").value;
	if (getquote=="")
	{
		document.getElementById("txt_Quote2").value="Change Company";
	}
}

function CompValidate()
{					
		var SrchQuote = document.getElementById("txt_Quote2").value;
	//	var PageId = document.getElementById("DD_Options").value;
		if(SrchQuote =="" || SrchQuote=="Enter Company Name...!!!" || SrchQuote=="Change Company")
		{
			alert("Please enter company name ..!!!");
			return false;
		}
		else 
		{
				var strReplaceAll =SrchQuote;
				var intIndexOfMatch = strReplaceAll.indexOf( "'" );
				while (intIndexOfMatch != -1)
				{
					strReplaceAll = strReplaceAll.replace( "'", "" )
					intIndexOfMatch = strReplaceAll.indexOf( "'" );
					
				}
				var StrUrl = "../Profile/CompSearch.aspx?id=13&schtxt="+strReplaceAll;
				//var StrUrl = "../Profile/CompSearch.aspx?schtxt="+strReplaceAll+"&id=13";						
				window.location=StrUrl;
		}		
}


//Get the A-Z			
				function ShowA2ZIndexAll(redUrl_)
				{
				 var A2ZIndexId = document.getElementById("A2ZIndex");
					if(A2ZIndexId.innerHTML==""){
						var A2Z="";
							for(i=65; i<=90; i++)
								A2Z += "<a class=Menulink1 href='"+ redUrl_ +"&var="+ String.fromCharCode(i) +"'><span class=skybluebold    id = spn"+String.fromCharCode(i)+">"+ String.fromCharCode(i) +"</span>&nbsp;&nbsp;</a> ";
								A2Z += "<a class=Menulink1 href='"+ redUrl_ +"&var='><span class=skybluebold  id = spn>ALL</span></a>";
								
								A2ZIndexId.innerHTML = A2Z;
					}
					else
						A2ZIndexId.innerHTML = "";			
				}
				
				function CloseSecForth(co_code)
{
	document.getElementById('B'+co_code).style.display = 'inline';
	document.getElementById('E'+co_code).style.display = 'none';
	document.getElementById("Disp_Co_codeF").value = "";
	
}

function CloseSecToday(co_code)
{
	document.getElementById('BT'+co_code).style.display = 'inline';
	document.getElementById('ET'+co_code).style.display = 'none';
	document.getElementById("Disp_Co_codeT").value = "";
	
}

function GetMoreToday(co_code,M)
{

	document.getElementById('BT'+co_code).style.display = 'none';
	document.getElementById('ET'+co_code).style.display = 'inline';
		
	if (document.getElementById("Disp_Co_codeT").value != "")
	{
		document.getElementById('BT'+document.getElementById("Disp_Co_codeT").value).style.display ='inline';
		document.getElementById('ET'+document.getElementById("Disp_Co_codeT").value).style.display ='none';
	
	}
	document.getElementById("Disp_Co_codeT").value = co_code;	

}
function GetMoreForth(co_code,M)
{

	document.getElementById('B'+co_code).style.display = 'none';
	document.getElementById('E'+co_code).style.display = 'inline';
		
	if (document.getElementById("Disp_Co_codeF").value!= "")
	{
		document.getElementById('B'+document.getElementById("Disp_Co_codeF").value).style.display ='inline';
		document.getElementById('E'+document.getElementById("Disp_Co_codeF").value).style.display ='none';
	}
	document.getElementById("Disp_Co_codeF").value = co_code;	

}

//For Commodity ExpDate Using AJAX
function GetExpDate(Exchg,Symbol)
	{
	   
		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "ExpDateData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&Exchg="+ Exchg +"&Symbol="+Symbol;
		//alert(requestUrl);
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){getDateResp()};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
	}
	
	//for Commdity
//GET Quotes Commodity
function fillSymbol(Exchg)
	{
		var arrSymbol;
		var Symbol = document.getElementById("Symbol");
		cnt=1;
		if(Exchg!=''){
			if(Exchg=='MCX'){
				arrSymbol     = arrM_Symbol;
				arrSymbolText = arrM_CommName;
			}
			else if(Exchg=='NCDEX'){
				arrSymbol	  = arrN_Symbol;
				arrSymbolText = arrN_CommName;
			}
			Symbol.length = 0;
			Symbol.options[0] = new Option();
			Symbol.options[0].value = "";
			Symbol.options[0].text = "Select  Symbol";
		
			for(var i=0; i < arrSymbol.length; i++)
			{
					Symbol.options[cnt] = new Option(); 
					Symbol.options[cnt].value = arrSymbol[i];
					Symbol.options[cnt].text = arrSymbolText[i];
					cnt = cnt + 1;
					
			}
		}	
  }
  
  //Called when response comes back from server Only For ExpDateData
function getDateResp()
{


	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{
			var ExpDate   = document.getElementById("ExpDate");
			var strData = XmlHttp.responseText
			if(strData != "") {	
				var arrExpDate = strData.split("|");
				ExpDate.length = 0; 	
				for(i=0; i<arrExpDate.length-1; i++) {	
					var strDate = arrExpDate[i];
					var arrExpDateCode = strDate.split("~");
					ExpDate.options[i] = new Option();
					ExpDate.options[i].value = arrExpDateCode[0];
					ExpDate.options[i].text = arrExpDateCode[1];
				}
			}
			else {
					ExpDate.length = 0;
					ExpDate.options[0] = new Option(); 
					ExpDate.options[0].value = "";
					ExpDate.options[0].text = "No Exp Date";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ExpDate.length = 0;
					ExpDate.options[0] = new Option(); 
					ExpDate.options[0].value = "";
					ExpDate.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}

//Function For Derivative Summary
function redUrl_FandO(ig_,ig_a,ig_b){
		var in_="",s_="";
		var qr_Str = ig_a.split("|");
		in_ = "&InstName="+ qr_Str[0]
		if(qr_Str.length==2)
			s_ = "&Symbol="+ qr_Str[1]
			//alert(ig_+ig_b+in_+s_);
		document.location = ig_+ig_b+in_+s_;
}

function OptChange_FandO(ig_,ig_a){
		var Index = document.getElementById(ig_);
		Index.length = 0;
		for(var i=0; i < arrFAO.length; i++)
		{
			Index.options[i] = new Option(); 
			Index.options[i].value = arrFAOCode[i];
			Index.options[i].text = arrFAO[i];
			if(ig_a==arrFAOCode[i])
				Index.options[i].selected = true;
		}
}

//For Loading ticker from FoGetQuotesData.aspx Using AJAX
function getFOQuotes(strUrl)
	{
		var FOQuotesTbl = document.getElementById("FOQuotesTbl");
		if(FOQuotesTbl.style.display=="none")FOQuotesTbl.style.display = "inline";
		document.FOPChartImg.src="FOpriceChart.aspx?"+ strUrl;
		document.getElementById("LoadingID").src = "../images/loading1.gif";

		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "../Derivatives/FOQuotesData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ strUrl;
		
		
		if(XmlHttp)	{
					XmlHttp.onreadystatechange = function(){getFODataResp()};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
	}
	
	
	function getFODataResp()
{


	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{
			var FO_QuoteData = XmlHttp.responseText;
		
			if(FO_QuoteData != "") {
				var arrRow = FO_QuoteData.split("|");
				for(i=0; i<arrRow.length-1; i++)
				 {
					if((i!='14')&&(i!='15'))
						document.getElementById("FO"+i).innerHTML = arrRow[i];
				 }
				document.getElementById("LoadingID").src = "../images/spacer.gif";
				document.body.style.cursor = "auto";
			}	
		}
		else
			document.getElementById("LoadingID").src = "../images/loading1.gif";
			//document.getElementById("LoadingID").innerHTML = "<img src='../CommonImgs/loading7.gif'>";
	}
}


function validate1()
 {
		//final check ..required since any change during final submission will
		// unnecessarily invoke the server side program.... only the combinations
		//available needs to be checked at the server end...
		// wrong combinations will increase unwarranted calls to controller servlet
		var InstType = document.getElementById("InstrumentType");
		var Symbol   = document.getElementById("Symbol");
		var ExpDate  = document.getElementById("ExpiryDate");
		var OptType  = document.getElementById("OptionType");
		var StkPrice = document.getElementById("StrikePrice"); 

		 InstrumentTypeVal=InstType.options[InstType.selectedIndex].value;
		 InstIndex=InstType.selectedIndex;
		 if(InstIndex!=0) {
			SymbolVal=Symbol.options[Symbol.selectedIndex].value;
			SymbIndex=Symbol.selectedIndex;
			
			if(SymbIndex!=0) {
				ExpiryDate=ExpDate.options[ExpDate.selectedIndex].value;
				ExpIndex =ExpDate.selectedIndex;
				
				if(ExpIndex!=0) {
					if(InstrumentTypeVal=="FUTIDX"||InstrumentTypeVal=="FUTSTK"||InstrumentTypeVal=="FUTINT") {
			 				OptionType="-";
			 				TypeIndex=0;
			 				StrikePriceVal="-";
			 				StrikeIndex=0;

			 				if(SymbolVal.match(/&/g))
			 				SymbolVal=SymbolVal.replace("&","%26");
			 				unique_key=InstrumentTypeVal+SymbolVal+ExpiryDate+OptionType+StrikePriceVal;
							urlText = "InstType="+ InstrumentTypeVal +"&Symbol="+ SymbolVal +"&ExpDate="+ ExpiryDate +"&OptType=XX&StkPrice=0"
							
							//document.frmGetQuotes.action = "fogetquotes.asp?opt=2&"+ urlText
							getFOQuotes(urlText);
			 				return true; // to me made true
					}
					else{
			 				OptionType=OptType.options[OptType.selectedIndex].value;
			 				TypeIndex=OptType.selectedIndex;

			 				if(TypeIndex!=0) {
			 					StrikePriceVal=StkPrice.options[StkPrice.selectedIndex].value;
								StrikeIndex=StkPrice.selectedIndex;

								if(StrikeIndex !=0) {
									unique_key=InstrumentTypeVal+SymbolVal+ExpiryDate+OptionType+StrikePriceVal;
									//alert(unique_key);
									if(finalcheck(unique_key)) {
										if(SymbolVal.match(/&/g))
			 		 						SymbolVal=SymbolVal.replace("&","%26");
					 						urlText = "InstType="+ InstrumentTypeVal +"&Symbol="+ SymbolVal +"&ExpDate="+ ExpiryDate +"&OptType="+ OptionType +"&StkPrice="+ StrikePriceVal						 
											//document.frmGetQuotes.action = "fogetquotes.asp?opt=2&"+ urlText
											getFOQuotes(urlText);
											return true; // to return true
									}
									else{
									alert("No Strike Price Is Available For The Selected Combination...Try Again");
 									return false;
 									}
								}
								else {
						 			alert("Please Select Strike Price Before You Proceed");
	 	 							return false;
								}
							}
							else {
			 					alert("Please Select Option Type Before You Proceed");
	 	 						return false;
							}

						}
					}
				else {
						alert("Please Select Expiry Date Before You Proceed");
	 					return false;
				}
			}
			else {
		 			alert("Please Select The Symbol Before You Proceed");
					return false;
			}
		}
		else {
				alert("Please Select The Instrument Type Before You Proceed");
				return false;
		}
 }
 function popup()
 {
 var wind_new;
	wind_new=window.open("http://www.balajisec.cmlinks.com/branchpopup.aspx","","status =no, height =390, width =600px, resizable = 0,scrollbars=1,left=200,top=200" )
	wind_new.focus();
 }


function TabChange(EXCHG)
	{		
					if(EXCHG=="BSE")
					{		
                    document.getElementById("BSE").src = "../images/TickerBseOn.gif"
		            document.getElementById("NSE").src = "../images/TickerNseOff.gif"
					alert(EXCHG);
					document.getElementById(tdBSE).style.cursor="hand";
					document.getElementById(tdNSE).style.cursor="default";
					document.location="MktInner.aspx?EXCHG=BSE&pnav=<%=PanelId%>&PageOpt=<%=option%>&Group1=BSE";
					}
						
								
					if(EXCHG=="NSE")
					{	
					
                    document.getElementById("BSE").src = "../images/TickerBseOff.gif"
		            document.getElementById("NSE").src = "../images/TickerNseOn.gif"
					alert(EXCHG);	
					document.getElementById(tdBSE).style.cursor="default";
					document.getElementById(tdNSE).style.cursor="hand";
					
					document.location="MktInner.aspx?EXCHG=NSE&pnav=<%=PanelId%>&PageOpt=<%=option%>&Group1=NIFTY";	
					
					}
				
			
		  }
			
function showdivident(code,i)
{
     var win= document.getElementById("cm_window");     
     win.style.top =(360+i)+"px";     
    // alert(win.style.top)
     document.getElementById("cm_window").style.display='inline';
	 var NewsUrl = "../ShowDivident.aspx?code="+ code;	
	 var ajax = new Ajax.Updater('NewsId',NewsUrl);
}	

//added for showing divident data on home page
function showdividentdata(code)
{ 
	alert(document.getElementById("cm_windowdivident"));
     var win= document.getElementById("cm_windowdivident");   
     document.getElementById("cm_windowdivident").style.display='inline';
	 var dataUrl = "../ShowDivident.aspx?code="+ code;		
     var ajax = new Ajax.Updater('dividentId',dataUrl);
}	



