	
//KeyId : the value of the selected item of the combo 
//ActionId : It is used to retrive different data on from the different tables
	
var glbVar = '';

//Global Variable for User Dependent Function
var glbUFirstName= '';
var glbUMiddleName= '';
var glbULastName= '';
var glbUAddress= '';
var glbUDOb= '';
var glbUPlaceOB= '';
var glbUGender= '';
var glbUBloodGroup= '';
var glbURelationship= '';
var glbUCanPlaceOrder= '';
var glbUMaxOrdAmnt= '';
var glbUContact1= '';
var glbUContact2= '';
var glbUCountry= '';
var glbUState= '';
var glbUCity= '';
var glbUPostCode= '';
var glbUContactPerson= '';
var glbUContactPersonPhone= '';
var glbUBloodRelation= '';
var glbUNomineePerson= '';

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
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();
	}
}

//Called when we are selecting the state
function GetDataOnSelected(objCmb,objCmbChild,Actionid) 
	{
	
		glbVar = document.getElementById(objCmbChild);
		var abc = objCmb.options[objCmb.selectedIndex].value;
		var KeyId=abc.replace(/&/g,"*");
		var strPage = "XmlAjexSupport.aspx?Key=" + KeyId + "&ActionId="+Actionid ;
		CreateXmlHttp();		
		// If browser supports XMLHTTPRequest object
		if(XmlHttp)
		{		
			//Setting the event handler for the response
			XmlHttp.onreadystatechange = HandleResponse2;
			//Initializes the request object with GET (METHOD of posting), 
			//Request URL and sets the request as asynchronous.
			XmlHttp.open("GET", strPage,  true);
			//Sends the request to server
			XmlHttp.send(null);	
						
		}
	}
	
	//Called when response comes back from server
	function HandleResponse2()
	{
		// 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)
			{	
				ClearAndSetCityListItems(XmlHttp.responseXML.documentElement);
			}
			else
			{
				alert("There was a problem retrieving data from the server." );
			}
		}
	}

	//Clears the contents of city combo box and adds the cities of currently selected state
	function ClearAndSetCityListItems(countryNode)
	{
		var stateList = glbVar;
		for (var count = stateList.options.length-1; count >-1; count--)
		{
			stateList.options[count] = null;
		}
		var stateNodes = countryNode.getElementsByTagName('Location');
		var stateNodesId = countryNode.getElementsByTagName('LocationId');
		var textValue; 
		var cityValue;
		var optionItem;
		stateList.options[0] = new Option('--Select One--', '');
		//Add new states list to the state combo box.
		for (var count = 0; count < stateNodes.length; count++)
		{
			textValue = GetInnerText(stateNodes[count]);
   			cityValue = GetInnerText(stateNodesId[count]);
			optionItem = new Option( textValue, cityValue,  false, false);
			stateList.options[stateList.length] = optionItem;
		}
	}	
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}

/////////
//Called when we are selecting a dependent
function GetData1(KeyId,ActionId,objUserFname,objUserMname) 
	{
		glbUFirstName = document.getElementById(objUserFname);
		glbUMiddleName= document.getElementById(objUserMname);
		var strPage = "XmlAjexSupport.aspx?Key=" + KeyId + "&ActionId="+ActionId  	
		CreateXmlHttp();		
		// If browser supports XMLHTTPRequest object
		if(XmlHttp)
		{
			//Setting the event handler for the response
			XmlHttp.onreadystatechange = HandleResponse3;
			//Initializes the request object with GET (METHOD of posting), 
			//Request URL and sets the request as asynchronous.
			XmlHttp.open("GET", strPage,  true);			
			//Sends the request to server
			XmlHttp.send(null);		
		}
	}

	//Called when response comes back from server
	function HandleResponse3()
	{
	//alert(glbVar);
		
		// 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)
			{	
				GetDependentListItems(XmlHttp.responseXML.documentElement);
			}
			else
			{
				alert("There was a problem retrieving data from the server." );
			}
		}
	}

	
	function GetDependentListItems(countryNode)
	{
		//alert(countryNode);
		var UFname = glbUFirstName;
		var UMname = glbUMiddleName;
		var stateNodes = countryNode.getElementsByTagName('FirstName');
		var stateNodesId = countryNode.getElementsByTagName('LastName');				
		var textValue; 
		var cityValue;
		var optionItem;
		//stateList.options[0] = new Option('--Select One--', '');
		//Add new states list to the state combo box.
		for (var count = 0; count < stateNodes.length; count++)
		{
   			UFname.value = GetInnerText(stateNodes[count]);
   			UMname.value = GetInnerText(stateNodesId[count]);   			
		}
	}

/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////

//******************* This is First function will be called on Cobmo Change
function GetData(KeyId,ActionId)
{
var randomnumber=Math.floor(Math.random()*1001);
		var strPage1 = "XmlAjexSupport.aspx?Key=" + KeyId + "&ActionId="+ActionId+"&Random="+randomnumber;  
		var strXML1 = getXMLData(strPage1);	
		if (strXML1 == "")	
		 {		  
		  alert("The product/service selected by you is not deliverable/serviceable in the recipient's city selected by you.")		  
		 }	
		 else
		 {		 
						var xmlDoc1 = loadXMLstring(strXML1)
						//var x = xmlDoc1.childNodes[0].childNodes;				
						var y=new Array();	
						y[0]=xmlDoc1.getElementsByTagName('FirstName')[0].firstChild.data;								
						//alert("inside XML="+xmlDoc1.getElementsByTagName('networkcity')[0].firstChild.data);
						//alert("inside XML1="+xmlDoc1.getElementsByTagName('FirstName')[0].firstChild.data);	
						if((xmlDoc1.getElementsByTagName('MiddleName')[0].firstChild)!=null)
						{						
						y[1]=xmlDoc1.getElementsByTagName('MiddleName')[0].firstChild.data;								
						}
						else
						{
						y[1]='';
						}
						y[2]=xmlDoc1.getElementsByTagName('LastName')[0].firstChild.data;
						//alert(xmlDoc1.getElementsByTagName('DOB')[0]);
						if((xmlDoc1.getElementsByTagName('DOB')[0])!=null)
						{						
						y[3]=xmlDoc1.getElementsByTagName('DOB')[0].firstChild.data;		
						}
						else
						{
						y[3]='';
						}					
						if((xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild)!=null)
						{						
						y[4]=xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild.data;				
						}
						else
						{
						y[4]='';
						}										
						y[5]=xmlDoc1.getElementsByTagName('Address')[0].firstChild.data;				
						y[6]=xmlDoc1.getElementsByTagName('State')[0].firstChild.data;				
						y[7]=xmlDoc1.getElementsByTagName('City')[0].firstChild.data;
						if((xmlDoc1.getElementsByTagName('Postcode')[0].firstChild)!=null)
						{						
						y[8]=xmlDoc1.getElementsByTagName('Postcode')[0].firstChild.data;				
						}
						else
						{
						y[8]='';
						}
						y[9]=xmlDoc1.getElementsByTagName('Country')[0].firstChild.data;
						y[10]=xmlDoc1.getElementsByTagName('PhoneNumber')[0].firstChild.data;				
						if((xmlDoc1.getElementsByTagName('AlternateContactNumber')[0].firstChild)!=null)
						{						
						y[11]=xmlDoc1.getElementsByTagName('AlternateContactNumber')[0].firstChild.data;				
						}
						else
						{
						y[11]='';
						}
						if((xmlDoc1.getElementsByTagName('ContactPersonName')[0].firstChild)!=null)
						{						
						y[12]=xmlDoc1.getElementsByTagName('ContactPersonName')[0].firstChild.data;				
						}
						else
						{
						y[12]='';
						}	
						if((xmlDoc1.getElementsByTagName('ContactPersonPhoneNo')[0].firstChild)!=null)
						{						
						y[13]=xmlDoc1.getElementsByTagName('ContactPersonPhoneNo')[0].firstChild.data;				
						}
						else
						{
						y[13]='';
						}
						if((xmlDoc1.getElementsByTagName('RelationShip')[0].firstChild)!=null)
						{						
						y[14]=xmlDoc1.getElementsByTagName('RelationShip')[0].firstChild.data;				
						}
						else
						{
						y[14]='';
						}
						if((xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild)!=null)
						{						
						y[15]=xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild.data;				
						}
						else
						{
						y[15]='--Select One--';
						}
						if((xmlDoc1.getElementsByTagName('PlaceOB')[0].firstChild)!=null)
						{						
						y[16]=xmlDoc1.getElementsByTagName('PlaceOB')[0].firstChild.data;				
						}
						else
						{
						y[16]='';
						}
						if((xmlDoc1.getElementsByTagName('Gender')[0].firstChild)!=null)
						{						
						y[17]=xmlDoc1.getElementsByTagName('Gender')[0].firstChild.data;
										
						}
						else
						{
						y[17]='--Select One--';
						}
						alert("called6");		
						if((xmlDoc1.getElementsByTagName('MaxOrderAmt')[0].firstChild)!=null)
						{						
						y[18]=xmlDoc1.getElementsByTagName('MaxOrderAmt')[0].firstChild.data;				
						}
						else
						{
						y[18]='';
						}
						// new area map code by rahul
						if(xmlDoc1.getElementsByTagName('Area')[0]!=null)
						{
							if((xmlDoc1.getElementsByTagName('Area')[0].firstChild)!=null)
							{						
							y[19]=xmlDoc1.getElementsByTagName('Area')[0].firstChild.data;				
							}
							else
							{
							y[19]='';
							}
						}
						else
							{
								y[19]='Other Area';
							}
							
						//alert(xmlDoc1.getElementsByTagName('BranchID')[0]);	
						if(xmlDoc1.getElementsByTagName('BranchID')[0]!=null)
						{
						
							if((xmlDoc1.getElementsByTagName('BranchID')[0].firstChild)!=null)
							{						
							y[20]=xmlDoc1.getElementsByTagName('BranchID')[0].firstChild.data;				
							}
							else if((xmlDoc1.getElementsByTagName('BranchID')[0].firstChild)==0)
							{
							y[20]='';
							}
							else 
							{
							y[20]='';
							}
						}
						else
							{
								y[20]=0;
							}
						
						//alert(xmlDoc1.getElementsByTagName('networkcity')[0].firstChild.data);		
						y[21]=xmlDoc1.getElementsByTagName('networkcity')[0].firstChild.data;						
						return y;
			}
								
}
function GetDatafestival(KeyId,ActionId)
{
        var randomnumber=Math.floor(Math.random()*1001);
		var strPage1 = "XmlAjexSupport.aspx?Key=" + KeyId + "&ActionId="+ActionId+"&Random="+randomnumber;  
		var strXML1 = getXMLData(strPage1);	
		alert(strXML1);
		if (strXML1 == "")	
		 {		  
		  alert("The product/service selected by you is not deliverable/serviceable in the recipient's city selected by you.")		  
		 }	
		 else
		 {		 
						var xmlDoc1 = loadXMLstring(strXML1);								
						var y=new Array();	
						y[0]=xmlDoc1.getElementsByTagName('FirstName')[0].firstChild.data;								
						if((xmlDoc1.getElementsByTagName('MiddleName')[0].firstChild)!=null)
						{						
						y[1]=xmlDoc1.getElementsByTagName('MiddleName')[0].firstChild.data;								
						}
						else
						{
						y[1]='';
						}
						y[2]=xmlDoc1.getElementsByTagName('LastName')[0].firstChild.data;
						/*if((xmlDoc1.getElementsByTagName('DOB')[0])!=null)
						{						
						y[3]=xmlDoc1.getElementsByTagName('DOB')[0].firstChild.data;		
						}
						else
						{
						y[3]='';
						}				
						if((xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild)!=null)
						{						
						y[4]=xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild.data;				
						}
						else
						{
						y[4]='';
						}*/											
						y[5]=xmlDoc1.getElementsByTagName('Address')[0].firstChild.data;				
						y[6]=xmlDoc1.getElementsByTagName('State')[0].firstChild.data;				
						y[7]=xmlDoc1.getElementsByTagName('City')[0].firstChild.data;
						/*if((xmlDoc1.getElementsByTagName('Postcode')[0].firstChild)!=null)
						{						
						y[8]=xmlDoc1.getElementsByTagName('Postcode')[0].firstChild.data;				
						}
						else
						{
						y[8]='';
						}*/
						y[9]=xmlDoc1.getElementsByTagName('Country')[0].firstChild.data;
						y[10]=xmlDoc1.getElementsByTagName('PhoneNumber')[0].firstChild.data;				
						/*if((xmlDoc1.getElementsByTagName('AlternateContactNumber')[0].firstChild)!=null)
						{						
						y[11]=xmlDoc1.getElementsByTagName('AlternateContactNumber')[0].firstChild.data;				
						}
						else
						{
						y[11]='';
						}
						if((xmlDoc1.getElementsByTagName('ContactPersonName')[0].firstChild)!=null)
						{						
						y[12]=xmlDoc1.getElementsByTagName('ContactPersonName')[0].firstChild.data;				
						}
						else
						{
						y[12]='';
						}	
						if((xmlDoc1.getElementsByTagName('ContactPersonPhoneNo')[0].firstChild)!=null)
						{						
						y[13]=xmlDoc1.getElementsByTagName('ContactPersonPhoneNo')[0].firstChild.data;				
						}
						else
						{
						y[13]='';
						}
						if((xmlDoc1.getElementsByTagName('RelationShip')[0].firstChild)!=null)
						{						
						y[14]=xmlDoc1.getElementsByTagName('RelationShip')[0].firstChild.data;				
						}
						else
						{
						y[14]='';
						}
						if((xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild)!=null)
						{						
						y[15]=xmlDoc1.getElementsByTagName('BloodGroup')[0].firstChild.data;				
						}
						else
						{
						y[15]='--Select One--';
						}
						if((xmlDoc1.getElementsByTagName('PlaceOB')[0].firstChild)!=null)
						{						
						y[16]=xmlDoc1.getElementsByTagName('PlaceOB')[0].firstChild.data;				
						}
						else
						{
						y[16]='';
						}*/
						if((xmlDoc1.getElementsByTagName('Gender')[0].firstChild)!=null)
						{						
						y[17]=xmlDoc1.getElementsByTagName('Gender')[0].firstChild.data;
										
						}
						else
						{
						y[17]='--Select One--';
						}	
						if((xmlDoc1.getElementsByTagName('MaxOrderAmt')[0].firstChild)!=null)
						{						
						y[18]=xmlDoc1.getElementsByTagName('MaxOrderAmt')[0].firstChild.data;				
						}
						else
						{
						y[18]='';
						}
						// new area map code by rahul
						/*if(xmlDoc1.getElementsByTagName('Area')[0]!=null)
						{
							if((xmlDoc1.getElementsByTagName('Area')[0].firstChild)!=null)
							{						
							y[19]=xmlDoc1.getElementsByTagName('Area')[0].firstChild.data;				
							}
							else
							{
							y[19]='';
							}
						}
						else
							{
								y[19]='Other Area';
							}
						if(xmlDoc1.getElementsByTagName('BranchID')[0]!=null)
						{
						
							if((xmlDoc1.getElementsByTagName('BranchID')[0].firstChild)!=null)
							{						
							y[20]=xmlDoc1.getElementsByTagName('BranchID')[0].firstChild.data;				
							}
							else if((xmlDoc1.getElementsByTagName('BranchID')[0].firstChild)==0)
							{
							y[20]='';
							}
							else 
							{
							y[20]='';
							}
						}
						else
							{
								y[20]=0;
							}*/
					    if((xmlDoc1.getElementsByTagName('networkcity')[0].firstChild)!=null)
						{						
						y[21]=xmlDoc1.getElementsByTagName('networkcity')[0].firstChild.data;
										
						}
						else
						{
						y[17]='';
						}	
						return y;
			}
								
}

function GetPassPort(KeyId,ActionId)
{
var randomnumber=Math.floor(Math.random()*1001);
		var strPage1 = "XmlAjexSupport.aspx?Key=" + KeyId + "&ActionId="+ActionId+"&Random="+randomnumber;  
		var strXML1 = getXMLData(strPage1);	
		if (strXML1 == "")	
		 {
		  //alert(strXML1);
		  alert("The product/service selected by you is not deliverable/serviceable in the recipient's city selected by you.")		  
		 }	
		 else
		 {
		 //alert(strXML1);
						var xmlDoc1 = loadXMLstring(strXML1)		

						//var x = xmlDoc1.childNodes[0].childNodes;				
						var y=new Array();
						y[0]=xmlDoc1.getElementsByTagName('SCHPRICE')[0].firstChild.data;				
						y[1]=xmlDoc1.getElementsByTagName('CLIENTSCHPRICE')[0].firstChild.data;				
						y[2]=xmlDoc1.getElementsByTagName('SILVERSCHPRICE')[0].firstChild.data;	
						alert(y);
						return y;
			}
								
}

	function GetDataOnSelected1(objCmb,objCmbChild1,ActionId)
	{
		var abc = objCmb.options[objCmb.selectedIndex].value;
		var KeyId=abc.replace(/&/g,"*");
		var strPage1 = "XmlAjexSupport.aspx?Key=" + KeyId + "&ActionId="+ActionId  		
		var strXML1 = getXMLData(strPage1);
		
		if (strXML1 == "")	return;		
		var xmlDoc1 = loadXMLstring(strXML1)			
		//alert(strXML1);
		var xmlObj = xmlDoc1.documentElement;				
		var objCmbChild=document.getElementById(objCmbChild1);
		
		objCmbChild.options.length = 0;
		objCmbChild.options[objCmbChild.length] = new Option(' --Select One-- ', '');
		
		/*if (xmlObj.hasChildNodes())
			{
			var j=0;
			for(var i=0; i<=xmlObj.childNodes.length-1; i++)
			{			
					var mID = xmlObj.childNodes(i).childNodes(0).text;
					var vSubCatName = xmlObj.childNodes(i).childNodes(1).text;
					objCmbChild.options[j+1] = new Option(vSubCatName,mID);
					j++;			
			}			
		}
		*/
		
		/////
		//countryNode=xmlDoc1.documentElement;
		var stateNodes = xmlDoc1.getElementsByTagName('Location');
		//alert(stateNodes.length);
		var stateNodesId = xmlDoc1.getElementsByTagName('LocationId');
		var textValue; 
		var cityValue;
		//var optionItem;
		//stateList.options[0] = new Option('--Select One--', '');
		//Add new states list to the state combo box.
		for (var count = 0; count < stateNodes.length; count++)
		{
   			textValue = GetInnerText(stateNodes[count]);
   			cityValue = GetInnerText(stateNodesId[count]);
			optionItem = new Option( textValue, cityValue,  false, false);
			objCmbChild.options[objCmbChild.length] = optionItem;
		}	
		/////
}		
function loadXMLstring(strXML)
{	
	var xmlDoc = null;
	if ( document.implementation.createDocument)
	{
		var parser = new DOMParser();
        xmlDoc = parser.parseFromString(strXML, "text/xml");
	}	
	else
	{	
		try
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
			xmlDoc.async="false"			
			xmlDoc.loadXML(strXML);

		}
		catch(e)
		{
			alert("XML Document is not created Properly. Error: " + e)
		}
	}
	return xmlDoc	
}
//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXMLHTTP()
{
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			try
			{
				XmlHttp = new ActiveXObject("Msxml1.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;
			}
		}
	}
	//Creating object in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

/*------------------------------------------------------------------

 Send request to server and return response string.
 
------------------------------------------------------------------*/

var req;

function getXMLData1(url) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}



function getXMLData(strPage) 
{

	try
	{	
		 //firefox 
		if(window.XMLHttpRequest && !(window.ActiveXObject)) 
		//if (window.XMLHttpRequest)
		{
			var XmlHttp = new XMLHttpRequest()
			if (XmlHttp.overrideMimeType) 
			{
				XmlHttp.overrideMimeType('text/xml');
			}
//			alert(XmlHttp.onreadystatechange);
			XmlHttp.onreadystatechange = MozilaSupport(XmlHttp);
			
			
		} 
		
		//   IE
		else if (window.ActiveXObject)
		{
			try 
			{
				XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch(e) 
			{	
				try	{				
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{}
			}
		}
	
		
		//CreateXMLHTTP();
		
		XmlHttp.open("GET", strPage, false);
		XmlHttp.send(null);
		return XmlHttp.responseText;

	}
	catch(e)	
	{
		alert("XML Parser is not available on you machine. Please Install XMLParser");
		document.wirte("<a href='msxml.msi'>Click here to install MSXML Parser.</a>")
	}
	
}	
		
function MozilaSupport(XmlHttp)
{
//	alert(XmlHttp.readyState);
	if (XmlHttp.readyState == 4) 
	{
		if (XmlHttp.status == 200) 
		{
			var xmldoc = XmlHttp.responseXML;
			alert('a'+xmldoc);
		}
	}
}



document.write('><\/script>');









