﻿// JScript File

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();
		}
	}
	


 function SchResult()
 {
 

		
	 var txtSchName = document.getElementById("txtSchName");
	
	 if(txtSchName.value=="Enter Company Name")
	{ 
	alert("Please Enter some text");
	} 
	else
		{
 		var SearchResult = document.getElementById("lbSchResult");	
 		//alert(SearchResult)
 		document.getElementById("serchresult").style.display="inline";		
 		document.getElementById("Go").disabled=false;
		CreateXmlHttpNew();
		document.body.style.cursor = "progress";
		var requestUrl = "GetSchDataAjax.aspx?timeStamp="+ new Date().getTime() +"&txtSchName="+txtSchName.value;
	    //alert(requestUrl)
		if(XmlHttpFO)	{
					XmlHttpFO.onreadystatechange = function(){fillSymbolResp(SearchResult)};
					XmlHttpFO.open("GET", requestUrl,  true);
					XmlHttpFO.send(null);
				}
				}
		
 }
 
 //Called when response comes back from server Only For Symbol
function fillSymbolResp(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 = "No Data Found";			
			}
			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 open_win(url)
   {
   window.open(url,'welcome','width=505,height=350,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes');
   }
