﻿// JScript File

var XmlHttp;

//Creating object of XMLHTTP For AJAX Method
function CreateXmlHttpCpro()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttpCpro = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttpCpro = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttpCpro = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttpCpro && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttpCpro = new XMLHttpRequest();
		}
	}
	

 function SchResult()
 {
 
		
	 var txtSchName = document.getElementById("ctl00_ContentPlaceHolder1_txtSchName");
	 if(txtSchName.value=="Enter Company Name")
	{ 
	alert("Please Enter some text");
	} 
	else
		{
 		var SearchResult = document.getElementById("ctl00_ContentPlaceHolder1_lbSchResult");	
 		document.getElementById("serchresultCpro").style.display="inline";		
 		document.getElementById("Go").disabled=false;
		CreateXmlHttpCpro();
		document.body.style.cursor = "progress";
		var requestUrl = "GetSchDataAjax.aspx?timeStamp="+ new Date().getTime() +"&txtSchName="+txtSchName.value;
	
		if(XmlHttpCpro)	{
					XmlHttpCpro.onreadystatechange = function(){fillSymbolResp(SearchResult)};
					XmlHttpCpro.open("GET", requestUrl,  true);
					XmlHttpCpro.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(XmlHttpCpro.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpCpro.status == 200)
		{		
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
			var strData = XmlHttpCpro.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";		
		}
	}
}

var tempX = 0;
 var tempY = 0;
 
 
 var IE = document.all?true:false
 
 if (!IE) document.captureEvents(Event.MOUSEMOVE)
 document.onmousemove = getMouseXY;
 
 function getMouseXY(e) 
 {
 	if(IE)
 	{
 	  //  tempX = event.clientX + screen.width/2 ;
 	 tempY = document.body.scrollTop+50;

 	}
 	else
 	{
 		tempX = e.pageX;
 	    tempY = e.pageY;
 	}
 	return true;
 }



