﻿// JScript File
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 url;
var containerid="contentarea";
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""


var browser = new Browser();
 var dragObj = new Object();
dragObj.zIndex = 0;
function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
var XmlHttp;

//Creating object of XMLHTTP For AJAX Method
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();
		}
		if (!XmlHttpFO && window.createRequest) 
        {
	        try 
	        {
		        XmlHttpFO = window.createRequest();
	        } 
	        catch (e)
	        {
		        XmlHttpFO=false;
	        }
        }
	}
	
	//For Getting Symbol Drop Down Contains
	
	 function Get_Symbol(optS)
 {var InstName="";
			var Symbol ="";
 		var OptionType = "";
 		var StrikePrice = "";
		//alert(optS);ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol
		if(optS=="Inn")
		{
	      InstName = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
	      Symbol = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
 		  OptionType = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_OptionType");
 		  StrikePrice = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_StrikePrice");
		}
		else
		{
		  InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType"); 
		 Symbol = document.getElementById("Symbol");
 		 OptionType = document.getElementById("OptionType");
 		 StrikePrice = document.getElementById("StrikePrice");                      
		}
		//alert(InstName);
	
 	

			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="PE";
				OptionType.options[1].text="PE";
				OptionType.options[2] = new Option();
				OptionType.options[2].value="CE";
				OptionType.options[2].text="CE";
				
			}
			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 Strick Price";
			}
			
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetSymbolAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value;
		//alert(requestUrl);
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){getSymbolResp(Symbol)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
		
 }
 
 //Called when response comes back from server Only For Symbol
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";	
					
					
					/*to clear expiry date*/
                    var ExpDt = document.getElementById("ExpiryDate");
                     ExpDt.length = 0;
                     ExpDt.options[0] = new Option(); 
					 ExpDt.options[0].value = "";
					 ExpDt.options[0].text = "Select Expiry Date";
					 document.body.style.cursor = "auto";
					
					
					
			}
			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";		
		}
	}
}

//End of Symbol Function///////////////////////////////////////////////////////////


function Get_ExpDateHome(optD)
 {
  var InstName='';
  var Symbol = "";
  var ExpiryDate =""; 
  //ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol
 if(optD=="Inn")
		{ //alert(document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType"));
	     InstName= document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
	    Symbol = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
        ExpiryDate =document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
		}
		else
		{
		  //alert(document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType"));
		  InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");
		   Symbol = document.getElementById("Symbol");
           ExpiryDate =document.getElementById("ExpiryDate");
		}
 		
 				
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetExpDateAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value;
		//alert(requestUrl)
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){getDateResp(ExpiryDate)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
		
 }
 
 //Called when response comes back from server Only For Symbol
function getDateRespHome(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; 	
				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 = "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";		
		}
	}
}

//For Getting Expiry Date


  function Get_ExpDate(optD)
  
 {
          var InstName='';
  var Symbol = "";
  var ExpiryDate =""; 
  //ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol
 if(optD=="Inn")
		{
	   InstName= document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
	    Symbol = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
        ExpiryDate = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
		}
		else
		{
		  InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");
		   Symbol = document.getElementById("Symbol");
           ExpiryDate = document.getElementById("ExpiryDate");
		}
 			//	alert(InstName.value);
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetExpDateAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value;
		//alert(requestUrl)
		if(XmlHttpFO)
			{
					XmlHttpFO.onreadystatechange = function(){getDateResp(ExpiryDate)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
			}
		
 }
 
 
 
 //Called when response comes back from server Only For Symbol
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; 	
				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 = "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";		
		}
	}
}

// End of Expiry Date Funtion////////////////////////////////////////////

//For Getting Strike Price 


function Get_StrikePricehom(optP)
 {  
       var InstName="";
       var Symbol ="";
 		var ExpiryDate = "";
 		var OptionType = "";
 		var StrikePrice = "";
     if(optP=="Inn")
		{
	     InstName = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
	     Symbol = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
 		 ExpiryDate = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
 		 OptionType = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_OptionType");
 		 StrikePrice = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_StrikePrice");
		}
		else
		{
		    InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");  
		    Symbol = document.getElementById("Symbol");
 		    ExpiryDate = document.getElementById("ExpiryDate");
 		    OptionType = document.getElementById("OptionType");
 		    StrikePrice = document.getElementById("StrikePrice");                     
		}
		

 		 
 		//alert(InstName.value)		
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetStrikePriceAjax.aspx?timeStamp="+ new Date().getTime() +"&InstName="+InstName.value +"&Symbol="+Symbol.value+"&ExpDate="+ExpiryDate.value+"&OptionType="+OptionType.value;

		
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){Get_StrikePriceResphom(StrikePrice)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
				
		
 }
 
 
 //Called when response comes back from server Only For Strike Price
function Get_StrikePriceResphom(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; 	
				
				for(i=0; 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 Get_StrikePrice(optP)
 {
  var InstName ="";
      var Symbol = "";
 		var ExpiryDate = "";
 		var OptionType = "";
 		var StrikePrice = ""; 
     if(optP=="Inn")
		{
	     InstName = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
	     Symbol = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
 		 ExpiryDate = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
 		 OptionType = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_OptionType");
 		 StrikePrice = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_StrikePrice");   
		}
		else
		{
		  InstName = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");  
		   Symbol = document.getElementById("Symbol");
 		 ExpiryDate = document.getElementById("ExpiryDate");
 		 OptionType = document.getElementById("OptionType");
 		 StrikePrice = document.getElementById("StrikePrice");                      
		}
		

 		
 		//alert(InstName.value)		
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetStrikePriceAjax.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);
				}
				
		
 }
 
 
 //Called when response comes back from server Only For Strike Price
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; 	
				
				for(i=0; 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";		
		}
	}
}
 
 // End of Strike Price funtion ///////////////////////////////////////////////
 
 
 function ValidateFormHome(opt)
{

//var UserId= document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_inp_hid1").value;
var InstType ="";
	var Symbol   ="";
	var ExpDate  ="";
	var OptType  ="";
	var StkPrice ="";
 if(opt=="Inn")
 {
    InstType = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
 	 Symbol   = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
	 ExpDate  = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
	 OptType  = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_OptionType");
	 StkPrice = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_StrikePrice");
 }
else
{
  InstType = document.getElementById("ctl00_ContentPlaceHolder1_DervQuotesCtrl1_InstrumentType");
 	 Symbol   = document.getElementById("Symbol");
	 ExpDate  = document.getElementById("ExpiryDate");
	 OptType  = document.getElementById("OptionType");
	 StkPrice = document.getElementById("StrikePrice");
 
}

	
		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;
			}
		}
		var url="InstType="+InstType.value+"&Symbol="+Symbol.value+"&ExpDate="+ExpDate.value+"&OptType="+OptType.value+"&StkPrice="+StkPrice.value+"&Home=True&id=1&UserId=";
		
		var strUrlDer="GetQuotes.aspx?"+url;
		 var newWindow = window.open(strUrlDer, '_parent'); 
			
            newWindow.focus(); 
            return false; 

}
 
 //For GetQiote Button Click
function ValidateForm(opt)
{
    var InstType ="";
	var Symbol   ="";
	var ExpDate  ="";
	var OptType  ="";
	var StkPrice ="";

 if(opt=="Inn")
 {
     InstType = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
 	 Symbol   = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
	 ExpDate  = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
	 OptType  = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_OptionType");
	 StkPrice = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_StrikePrice");
 }
 else
{
     InstType = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_InstrumentType");
 	 Symbol   = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_Symbol");
	 ExpDate  = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_ExpiryDate");
	 OptType  = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_OptionType");
	 StkPrice = document.getElementById("ctl00_ContentPlaceHolder1_GetQuotesCtrl1_StrikePrice");                
}	//alert(StkPrice.value);
if(InstType.value=="")
{
    alert("Please select the Instrument Type before you proceed")
	InstType.focus();
	return false;
}
else if((InstType.value=="OPTIDX")||(InstType.value=="OPTSTK"))
{
	if(Symbol.value=="Select Symbol")	
	{
     alert("Please select Symbol before you proceed")
	 Symbol.focus();
	 return false;
	}
	else if(OptType.value=="")
	{
	 alert("Please select Option Type before you proceed")
	 OptType.focus();
	 return false;
	}
	else if(StkPrice.value=="")
	{
alert(StkPrice.value);
	 alert("Please select Strike Price before you proceed")
	 StkPrice.focus();
	 return false;
	}
}
else 
{
	if(Symbol.value=="Select Symbol")	
    {
	alert("Please select Symbol before you proceed")
	Symbol.focus();
	return false;
	}
}

  var strUrl="InstType="+InstType.value+"&Symbol="+Symbol.value+"&ExpDate="+ExpDate.value+"&OptType="+OptType.value+"&StkPrice="+StkPrice.value+"";

		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		
		var requestUrl = "AjaxGetQuoteData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ strUrl;

		if(XmlHttpFO)
		{
		 	XmlHttpFO.onreadystatechange = function(){getFODataResp()};
			XmlHttpFO.open("GET", requestUrl,  true);
			XmlHttpFO.send(null);
		}
}
 

function onload()
{
  getFOQuotes(document.getElementById("ctl00_ContentPlaceHolder1_txtHiddenUrl").value);
}

 //For Loading Data from FOQuotesData.aspx Using AJAX
function getFOQuotes(strUrl)
	{		
		//var FOQuotesTbl = document.getElementById("FOQuotesTbl");
		//if(FOQuotesTbl.style.display=="none")FOQuotesTbl.style.display = "inline";
		
		// Put Chart Page 
		//document.FOPChartImg.src="GetQuoteChart.aspx?"+ strUrl;

		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "AjaxGetQuoteData.aspx?IpTrack="+ window.location.hostname +"&timeStamp="+ new Date().getTime() +"&"+ strUrl;

		if(XmlHttpFO)	{
		
					XmlHttpFO.onreadystatechange = function(){getFODataResp()};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
		
	}
	
//Called when response comes back from server Only For FO Quotes Data Response
function getFODataResp()
{

	// 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)
		{
	    	var SNDate = document.getElementById("showQuotes");
			var strData = XmlHttpFO.responseText;
			
			if(strData != "")
			 {	
			    var arrSchm = strData.split("~");
			      
				    
				    SNDate.innerHTML =arrSchm[0];
				   QuotesChart(arrSchm[1]);
			   
			}
		
		document.body.style.cursor = "auto";
				
		}
		else
			document.getElementById("showQuotes").src = " ../App_Themes/Images/ajax-loader.gif";
			//document.getElementById("LoadingID").innerHTML = "<img src='../CommonImgs/loading7.gif'>";
	}
}


function QuotesChart(Url)
{
//alert(Url)
		 var RequestUrl =Url;// "../Equity/MarketChartAjax.aspx?Exchg=NSE";
	    var so = new SWFObject("../amline/amline.swf", "BSENSEline", "235", "150", "8", "#deecb7");
	    so.addVariable("path", "../amline/");
	    so.addParam("wmode","opaque");
	    so.addVariable("settings_file", encodeURIComponent("../amline/BSENSEline_settings.xml")); 
	    so.addVariable("data_file", encodeURIComponent(RequestUrl + "&TimeStamp="+new Date().getTime()));
	    so.write("QuotesCharts");
	    	
		
}

