<!--
// To get the HTTP object to call a method..
function getHTTPObject()
{
	var xmlhttp;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){
			try{
				xmlhttp = new XMLHttpRequest();
			}
			catch (e){
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
}

//Instantiate an object to call method..
var http = new getHTTPObject();
var check_selected_country;
var check_city_obj;

function display_dropdownState(selected_country,city_obj){
	var myurl = "Ajax_ShippingMethodState.asp?CountryFor=" + escape(selected_country);
	check_city_obj = city_obj;
	check_selected_country = selected_country;
	http.open("GET", myurl, true);
	http.onreadystatechange = useHttpResponseState;
	http.send(null);	
}
// To populate the drop down with city values..
function useHttpResponseState(){
	if (http.readyState == 4){
		var textout = http.responseText;
		myString = new String(textout);
		if(myString!=""){
			check_city_obj.disabled = false;
			splitString = myString.split("|");
			check_city_obj.options.length = 0;
			check_city_obj[0] = new Option("Select State", "0");
			for(var i=0; i<splitString.length; i++){
				var curr_city = splitString[i].trim();
				var curr_city_val;
				curr_city_valarray = curr_city.split("#");
				//when getting 'Other' value then internally in database passing it as '-'..
				if(curr_city == "Other"){
					curr_city_val = "";
				}
				else{
					curr_city_val = curr_city_valarray[0];
				}
				//Creating new options of city ..
				if(curr_city == check_selected_country){
					check_city_obj[i+1] = new Option(curr_city_valarray[1], curr_city_val, false, true);
				}
				else{
					if (curr_city_val!= "" )
					check_city_obj[i+1] = new Option(curr_city_valarray[1], curr_city_val);
				}
			}
		}
		else{
			check_city_obj.options.length = 0;
			//check_city_obj[0] = Option("", "");
			check_city_obj.disabled = true;
		}
	}
}

//################################ END ####################################

function display_SetdropdownState(selected_country,city_obj,Selected_State){
	var myurl = "Ajax_ShippingMethodState.asp?CountryFor=" + escape(selected_country);
	check_city_obj = city_obj;
	check_selected_country = selected_country;
	check_selected_State = Selected_State;
	http.open("GET", myurl, true);
	http.onreadystatechange = useHttpResponseStateSelected;
	http.send(null);	
}

function useHttpResponseStateSelected(){
	if (http.readyState == 4){
		var textout = http.responseText;
		myString = new String(textout);
		if(myString!=""){
			check_city_obj.disabled = false;
			splitString = myString.split("|");
			check_city_obj.options.length = 0;
			check_city_obj[0] = new Option("Select State", "0");
			for(var i=0; i<splitString.length; i++){
				var curr_city = splitString[i].trim();
				var curr_city_val;
				curr_city_valarray = curr_city.split("#");
				//when getting 'Other' value then internally in database passing it as '-'..
				if(curr_city == "Other"){
					curr_city_val = "";
				}
				else{
					curr_city_val = curr_city_valarray[0];
				}
				//Creating new options of city ..
				//alert(check_selected_State);
				if (curr_city.indexOf(check_selected_State) != -1){
					check_city_obj[i+1] = new Option(curr_city_valarray[1], curr_city_val, false, true);
				}
				else{
					if (curr_city_val!= "" )
					check_city_obj[i+1] = new Option(curr_city_valarray[1], curr_city_val);
				}
			}
		}
		else{
			check_city_obj.disabled = true;
		}
	}
}

// To trim the string in JS..
// create the prototype on the String object
String.prototype.trim = function()
{
	// skip leading and trailing whitespace
	// and return everything in between
	var x=this;
	x=x.replace(/^\s*(.*)/, "$1");
	x=x.replace(/(.*?)\s*$/, "$1");
	return x;
}

//-->
