
//-------------------------------------------------------------------------------------
// Derivatives Get Quotes Select Starts here
var InstIndex="";
var SymbIndex="";
var ExpIndex ="";
var TypeIndex="";
var StrikeIndex="";

var ExpiryDate="";
var OptionType="";
var InstrumentTypeVal="";
var SymbolVal="";
var StrikeVal="";
var InstName="";

function dateConvert(strDate){
	//strDate = "21/01/2006"
	var strMon=0;
	monthArr = new Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
	strMon = strDate.substring(3,5);
	if(strMon.substring(0,1)==0)strMon=strMon.substring(1,2);
	return strDate.substring(0,2) + "-" + monthArr[strMon] + "-" + strDate.substring(6) 	
}
function CreateXmlHttpNew()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpFO = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpFO = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpFO = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpFO && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpFO = new XMLHttpRequest();
		}
	}
function Get_Symbol(Obj)
 {

 		InstName = document.getElementById(Obj);
 		
 		//var InstName = document.getElementById("<%=InstrumentType.ClientID%>");
 		//var InstName = document.getElementById("_ctl1_InstrumentType");
 		var Symbol = document.getElementById("Symbol");
 		var OptionType = document.getElementById("OptionType");
 		var StrikePrice = document.getElementById("StrikePrice");
			if(InstName.value=="OPTIDX")
			{
				OptionType.options[1] = new Option();
				OptionType.options[1].value="PE";
				OptionType.options[1].text="PE";
				OptionType.options[2] = new Option();
				OptionType.options[2].value="CE";
				OptionType.options[2].text="CE";
			}
			else if(InstName.value=="OPTSTK")
			{
				OptionType.options[1] = new Option();
				OptionType.options[1].value="PA";
				OptionType.options[1].text="PA";
				OptionType.options[2] = new Option();
				OptionType.options[2].value="CA";
				OptionType.options[2].text="CA";
			}
			else
			{
				OptionType.length = 0;
				OptionType.options[0] = new Option();
				OptionType.options[0].value="";
				OptionType.options[0].text="Select Option Type";
				
				StrikePrice.length = 0;
				StrikePrice.options[0] = new Option();
				StrikePrice.options[0].value="";
				StrikePrice.options[0].text="Select Price";
			}
		
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "FO_Symbol.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value;
		
		//document.writeln(requestUrl);
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){getSymbolResp(Symbol)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
		
 }
 function getSymbolResp(ig_)
{

	// To make sure receiving response data from server is completed
	if(XmlHttpFO.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpFO.status == 200)
		{
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
			var strData = XmlHttpFO.responseText
			//alert(strData)
			if(strData != "") {	
			    
				var arrSchm = strData.split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) {	
								
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					
					ig_.options[i] = new Option();
					
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
				
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Symbol not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}
function Get_ExpDate()
 {
 		//var InstName = document.getElementById("PutCallRatio11_InstrumentType");
 		var Symbol = document.getElementById("Symbol");
 		var ExpiryDate = document.getElementById("ExpiryDate");
 		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "FO_ExpDate.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value;
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){getDateResp(ExpiryDate)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
 }
 function getDateResp(ig_)
{

	// To make sure receiving response data from server is completed
	if(XmlHttpFO.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpFO.status == 200)
		{
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
			var strData = XmlHttpFO.responseText
			if(strData != "") {	
				var arrSchm = strData.split("|");
				ig_.length = 0;
				//******
				ig_.options[0] = new Option();
					ig_.options[0].value = "0";
					ig_.options[0].text = "Select Expiry Date"; 	
				//*****************
				for(i=1; i<arrSchm.length; i++) {	
					var strSchm = arrSchm[i-1];
					var arrSchmCode = strSchm.split("~");
					ig_.options[i] = new Option();
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Date not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}
function Get_StrikePrice()
 {
 		//var InstName = document.getElementById("PutCallRatio11_InstrumentType");
 		var Symbol = document.getElementById("Symbol");
 		var ExpiryDate = document.getElementById("ExpiryDate");
 		var OptionType = document.getElementById("OptionType");
 		var StrikePrice = document.getElementById("StrikePrice"); 
 		//alert(ExpiryDate.value)		
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "Strike_Price.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value+"&ExpDate="+ExpiryDate.value+"&OptionType="+OptionType.value;
	
		
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){Get_StrikePriceResp(StrikePrice)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
				
		
 }
 
 function Get_StrikePriceResp(ig_)
{


	// To make sure receiving response data from server is completed
	if(XmlHttpFO.readyState == 4)
	{
	//alert(XmlHttpFO.status)
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpFO.status == 200)
		{
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
			var strData = XmlHttpFO.responseText;
			//alert(strData)
			if(strData != "") {	
			    
				var arrPrice = strData.split("|");
				ig_.length = 0; 
				//*************	
				ig_.options[0] = new Option();
				ig_.options[0].value = "0";
				ig_.options[0].text = "Select Strike Price";
				//************					
				for(i=1; i<arrPrice.length-1; i++) {	
								
					var strPrice = arrPrice[i];
					var arrPriceCode = strPrice.split("~");
					
					ig_.options[i] = new Option();
					
					ig_.options[i].value = arrPriceCode[0];
					ig_.options[i].text = arrPriceCode[1];
				}
				
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Price not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}
function fillSymbol()
{
 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");
 
if((InstType.options[InstType.selectedIndex].value)=="FUTIDX") {
	Symbol.options.length =4;
	Symbol.options[0].value ="";
	Symbol.options[0].text ="Select Symbol";
	Symbol.selectedIndex=0;

	Symbol.options[1].value ="NIFTY";
	Symbol.options[1].text  ="NIFTY";
	Symbol.options[2].value ="CNXIT";
	Symbol.options[2].text  ="CNXIT";
	Symbol.options[3].value ="BANKNIFTY";
	Symbol.options[3].text  ="BANKNIFTY";

	ExpDate.options.length =4;
	ExpDate.selectedIndex=0;

	for (i=1;i<=3;i++){
		ExpDate.options[i].value = e[i];
		ExpDate.options[i].text = dateConvert(e[i]);
	}

	OptType.options.length =1;
	OptType.options[0].value ="";
	OptType.options[0].text ="Select Option Type";
	OptType.selectedIndex=0;

	StkPrice.options.length =1;
	StkPrice.options[0].value ="";
	StkPrice.options[0].text ="Select Strike Price";
	StkPrice.selectedIndex=0;
 }
 else if((InstType.options[InstType.selectedIndex].value)=="FUTSTK")
 {
   val=1;
   for (i=1;i<s.length;i++)
	 {
  	    //code to identify if symbol starts with NSE
  	    if(s[i].indexOf("NSE",0)==-1)val++;
      }

	 // Symbol.options.length =s.length;
  	 Symbol.options.length = val;
	 Symbol.options[0].value = "";
	 Symbol.options[0].text = "Select Symbol";
	 Symbol.selectedIndex=0;

	 /*for (i=1;i<s.length;i++)
	 	 {
	 	 Symbol.options[i].value = s[i];
	 	 Symbol.options[i].text = s[i];

     }*/
    val=1;
    for (i=1;i<s.length;i++)
	  {
	  	   //code to identify if symbol starts with NSE
	  	   if(s[i].indexOf("NSE",0)==-1){
	  		 Symbol.options[val].value = s[i];
	  		 Symbol.options[val].text  = s[i];
	  		 val++;
	  	   }

	   }
  	 ExpDate.options.length =4;
	 ExpDate.selectedIndex=0;


	for (i=1;i<=3;i++){
		ExpDate.options[i].value = e[i];
		ExpDate.options[i].text = dateConvert(e[i]);
	}

	OptType.options.length =1;
	OptType.options[0].value ="";
	OptType.options[0].text ="Select Option Type";
	OptType.selectedIndex=0;

	StkPrice.options.length =1;
	StkPrice.options[0].value ="";
	StkPrice.options[0].text ="Select Strike Price";
	StkPrice.selectedIndex=0;

 }
 else if((InstType.options[InstType.selectedIndex].value)=="FUTINT")
 {
	//length has to only symbols which belongs to FUTINT
	var len =1;
	for (i=1;i<s.length;i++){
		//code to identify if symbol starts with NSE
  		if(s[i].indexOf("NSE",0)!=-1){
  		len++;
  		}
 }

	 Symbol.options.length =len;
 	 Symbol.options[0].value ="";
 	 Symbol.options[0].text ="Select Symbol";
 	 Symbol.selectedIndex=0;

     len=1;
 	 for (i=1;i<s.length;i++){
 	 	//code to identify if symbol starts with NSE
 	 	if(s[i].indexOf("NSE",0)!=-1){
 	 	 Symbol.options[len].value = s[i];
 	 	 Symbol.options[len].text  = s[i];
 	 	 len++;
 	 	 }
      }

	ExpDate.options.length =e.length;
	ExpDate.selectedIndex=0;

	for (i=1;i<e.length;i++) {
		ExpDate.options[i].value = e[i];
		ExpDate.options[i].text = dateConvert(e[i]);
	}

 OptType.options.length =1;
 OptType.options[0].value ="";
 OptType.options[0].text ="Select Option Type";
 OptType.selectedIndex=0;

 StkPrice.options.length =1;
 StkPrice.options[0].value ="";
 StkPrice.options[0].text ="Select Strike Price";
 StkPrice.selectedIndex=0;

 }
 else if((InstType.options[InstType.selectedIndex].value)=="OPTIDX")
 {
	Symbol.options.length =4;
	Symbol.options[0].value ="";
	Symbol.options[0].text ="Select Symbol";
	Symbol.selectedIndex=0;

	Symbol.options[1].value ="NIFTY";
	Symbol.options[1].text ="NIFTY";
	Symbol.options[2].value ="CNXIT";
	Symbol.options[2].text ="CNXIT";
	Symbol.options[3].value ="BANKNIFTY";
	Symbol.options[3].text ="BANKNIFTY";

	ExpDate.options.length =4;
	ExpDate.selectedIndex=0;

	for (i=1;i<=3;i++){
		ExpDate.options[i].value = e[i];
		ExpDate.options[i].text = dateConvert(e[i]);
	}

	 OptType.options.length =3;
	 OptType.options[0].value ="";
	 OptType.options[0].text ="Select Option Type";
	 OptType.options[1].value ="PE";
	 OptType.options[1].text ="PE";
	 OptType.options[2].value ="CE";
	 OptType.options[2].text ="CE";

	 /*OptType.options[3].value ="PE";
	 OptType.options[3].text ="PE";
	 OptType.options[4].value ="CE";
	 OptType.options[4].text ="CE";*/
	 }
 else
 {
	val=1;
    for (i=1;i<s.length;i++) {
  	  	//code to identify if symbol starts with NSE
	    if(s[i].indexOf("NSE",0)==-1){
  	  	val++;
  	}

 }
	Symbol.options.length =val;
	Symbol.options[0].value ="";
	Symbol.options[0].text ="Select Symbol";
	Symbol.selectedIndex=0;
	
	/*for (i=1;i<s.length;i++) {
	 Symbol.options[i].value = s[i];
	 Symbol.options[i].text = s[i];
	}*/

	val=1;
    for (i=1;i<s.length;i++) {
  	  	//code to identify if symbol starts with NSE
  	 	if(s[i].indexOf("NSE",0)==-1){
  	  	 	Symbol.options[val].value = s[i];
  	  	 	Symbol.options[val].text = s[i];
  	  	 	val++;
  	  	}

	}

	ExpDate.options.length =4;
	ExpDate.selectedIndex=0;

	for (i=1;i<=3;i++)  {
		ExpDate.options[i].value = e[i];
		ExpDate.options[i].text = dateConvert(e[i]);
	}

	OptType.options.length =3;
	OptType.options[0].value ="";
	OptType.options[0].text  ="Select Option Type";
	OptType.options[1].value ="PA";
	OptType.options[1].text  ="PA";
	OptType.options[2].value ="CA";
	OptType.options[2].text  ="CA";

	 /*OptType.options[3].value ="PE";
	 OptType.options[3].text ="PE";
	 OptType.options[4].value ="CE";
	 OptType.options[4].text ="CE";*/
 }
fillStrikePrice();
}

function populate()
{
 var InstName = document.getElementById("PutCallRatio_InstrumentType");
 var Symbol   = document.getElementById("Symbol");
 var ExpDate  = document.getElementById("ExpiryDate");
 var OptType  = document.getElementById("OptionType");
 var StkPrice = document.getElementById("StrikePrice");
 
 // Code to dynamically populate the drop downs
 	Symbol.options.length =s.length;
 	ExpDate.options.length = e.length;
 	StkPrice.options.length=1;
 // works in browsers which support HTML 4.0
 // OptType.disabled=true;

 	InstName.selectedIndex=0;
 	Symbol.selectedIndex=0;
 	ExpDate.selectedIndex=0;
 	OptType.selectedIndex=0;
 	StkPrice.selectedIndex=0;
 	
 for (i=1;i<s.length;i++) {
 	Symbol.options[i].value = s[i];
 	Symbol.options[i].text = s[i];
 }

 for (i=1;i<e.length;i++) {
	ExpDate.options[i].value = e[i];
	ExpDate.options[i].text = dateConvert(e[i]);
 }
}


function fillStrikePrice()
{
	var InstType = InstName;//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;
	
 	SymbolVal=Symbol.options[Symbol.selectedIndex].value;
	SymbIndex=Symbol.selectedIndex;
	 
	ExpiryDate=ExpDate.options[ExpDate.selectedIndex].value;
	ExpIndex =ExpDate.selectedIndex;

	if(InstrumentTypeVal=="FUTIDX"||InstrumentTypeVal=="FUTSTK"||InstrumentTypeVal=="FUTINT") {
		OptionType="-";
		TypeIndex=0;
	}
	else{
		OptionType=OptType.options[OptType.selectedIndex].value;
		TypeIndex=OptType.selectedIndex;
	}

	if(InstIndex!=0) {
		if(SymbIndex!=0) {
			if(ExpIndex!=0) {
				if(TypeIndex!=0 && (InstrumentTypeVal!="FUTIDX"||InstrumentTypeVal!="FUTSTK"||InstrumentTypeVal!="FUTINT")) {
					unique_key = InstrumentTypeVal+SymbolVal+ExpiryDate+OptionType
					if(!populateStrikePrice(unique_key)) {
						alert("No Strike Price Is Available For The Selected Combination...Try Again");
						StkPrice.options.length =1;
						StkPrice.options[0].value ="";
						StkPrice.options[0].text ="Select Strike Price";
						StkPrice.selectedIndex=0;
					}
				}
				else if(TypeIndex==0 && (InstrumentTypeVal=="FUTIDX"||InstrumentTypeVal=="FUTSTK"||InstrumentTypeVal!="FUTINT")) {
					unique_key=InstrumentTypeVal+SymbolVal+ExpiryDate+OptionType;
				}
			}
		}
	}
}

function populateStrikePrice(unique_key)
{
	var InstType = InstName;//instname document.getElementById("InstrumentType");
	var Symbol   = document.getElementById("Symbol");
	var ExpDate  = document.getElementById("ExpiryDate");
	var OptType  = document.getElementById("OptionType");
	var StkPrice = document.getElementById("StrikePrice");
	
	avail_flag=false;
	// since zero element text is SelectStrikePrice and we need to fill from first element
	// hence counter =1
	StkPrice.options.length =1;
	StkPrice.options[0].value ="";
 	StkPrice.options[0].text ="Select Strike Price";
	StkPrice.selectedIndex=0;
	counter=1;
	
	
	for (i=1;i<u.length;i++) {
	 	 if(u[i].indexOf(unique_key) != -1) {
	 		avail_flag=true;
	 		StkPrice.options.length = counter + 1;
 			StkPrice.options[counter].value = u[i].substring(unique_key.length,u[i].length),u[i].substring(unique_key.length,u[i].length);
			StkPrice.options[counter].text = u[i].substring(unique_key.length,u[i].length),u[i].substring(unique_key.length,u[i].length);
			counter++;
		 }
	}
	return (!avail_flag)?false:true
}

 function finalcheck(unique_key)
 {
	avail_flag=false;
	for (i=1;i<u.length;i++) {
		if(u[i].indexOf(unique_key) != -1) {
		 	 avail_flag=true;
			 break;
		 }
	}
	return (!avail_flag)?false:true
 }
function ValidateForm()
{
	var InstType = InstName;// document.getElementById("_ctl0_InstrumentType");
	var Symbol   = document.getElementById("Symbol");
	var ExpDate  = document.getElementById("ExpiryDate");
	var OptType  = document.getElementById("OptionType");
	var StkPrice = document.getElementById("StrikePrice"); 
	var Opt;
	var SPrice;
		if(InstType.value=="")
		{
			alert("Please select the Instrument Type before you proceed")
			return false;
		}
		else if((InstType.value=="OPTIDX")||(InstType.value=="OPTSTK"))
		{
			if(Symbol.value=="Select Symbol")	
			{
			alert("Please select Symbol before you proceed")
			return false;
			}
			else if(OptType.value=="")
			{
			alert("Please select Option Type before you proceed")
			return false;
			}
			else if(StkPrice.value=="Select Price")
			{
			alert("Please select Price before you proceed")
			return false;
			}
		}
		else 
		{
			if(Symbol.value=="Select Symbol")	
			{
			alert("Please select Symbol before you proceed")
			return false;
			}
		}
		if(OptType.value=="") {Opt = "XX"} else {Opt = OptType.value};
		if(StkPrice.value=="") {SPrice = "0"} else {SPrice = StkPrice.value};
		var url="InstType="+InstType.value+"&Symbol="+Symbol.value+"&ExpDate="+ExpDate.value+"&OptType="+Opt+"&StkPrice="+SPrice+"";
		
	getFOQuotes(url);
}
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/loading7.gif";

		CreateXmlHttp();
		document.body.style.cursor = "progress";
		var requestUrl = "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/loading7.gif";
			//document.getElementById("LoadingID").innerHTML = "<img src='../CommonImgs/loading7.gif'>";
	}
}
 function validate1(Flag,InstType,Symbol,ExpDate,OptType,StkPrice)
 {
		//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
		if(Flag=="N")
		{
		var InstType = document.getElementById("ctl05_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;
									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;
		}
	}
	else
	{
	
		InstrumentTypeVal=InstType; 		
		 if(InstrumentTypeVal!="") 
			{
			
			SymbolVal=Symbol;
			if(SymbolVal!="") 
				{
				
				ExpiryDate=ExpDate;
				if(ExpiryDate!="") 
					{
						
						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;
			 						

			 							if(OptionType!="") 
			 							{
			 									StrikePriceVal=StkPrice;
			 									
												if(StrikePriceVal !="") 
													{
														
														//unique_key=InstrumentTypeVal+SymbolVal+ExpiryDate+OptionType+StrikePriceVal;
															//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
															//	}
																
													}
											
										}
									
								}
					    }
				
			      }
			
		      }
		
	}
 }
