<!--
// 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;

} // EO function getHTTPObject()



// Two objects are created for displaying state and city drop downs because one is overwriting another..



//################ Builds the options for City drop down..###################

//Instantiate an object to call method..
var http = new getHTTPObject();

var check_selected_country;
var check_city_obj;


function display_dropdown(selected_country,city_obj)
{
	//alert('333');
	//alert(escape(selected_country))
	////if(flag==1)
	//{
	var myurl = "ajax-Load.php?cmbsize=" + escape(selected_country);
	//alert(myurl);
	//}
	/*if(flag==2)
	{
	var myurl = "ajax-edit-city.asp?state=" + escape(selected_country) + "&city=" + escape(selected_city);
	}*/
  //alert(selected_country);
//	alert(selected_city);
	//alert(city_obj);
//	alert(img_url,flag);
	
	check_city_obj = city_obj;

	if(selected_country == "")
	{
		city_obj.options.length = 0;
		city_obj[0] = new Option("All dynamic loads", "");
		//return false;
	}
	else
	{
	//	document.getElementById("loading_city").innerHTML = "<img src=\"http://jigar/build4islam/include/loading.gif\" hspace=\"16\" align=\"absmiddle\">";
	}

	//alert(selected_country);
	check_selected_country = selected_country;
	http.open("GET", myurl, true);
	http.onreadystatechange = useHttpResponse;
	http.send(null);
}

/// For  NEW DROP DOWN

var http_size= new getHTTPObject();

var check_selected_country;
var check_size_obj;

function display_dropdown1(selected_country,city_obj)
{
	//alert('333');
	//alert("-->"+escape(selected_country));
	//alert("-->>"+escape(city_obj));
	////if(flag==1)
	//{
	var myurl = "ajax-size.php?cmbload=" + escape(selected_country);
	//alert(myurl);
	//}
	/*if(flag==2)
	{
	var myurl = "ajax-edit-city.asp?state=" + escape(selected_country) + "&city=" + escape(selected_city);
	}*/
  //alert(selected_country);
//	alert(selected_city);
	//alert(city_obj);
//	alert(img_url,flag);
	
	check_size_obj = city_obj;

	if(selected_country == "")
	{
		city_obj.options.length = 0;
		city_obj[0] = new Option("All dynamic Size", "");
		//return false;
	}
	else
	{
	//	document.getElementById("loading_city").innerHTML = "<img src=\"http://jigar/build4islam/include/loading.gif\" hspace=\"16\" align=\"absmiddle\">";
	}

	//alert(selected_country);
	check_selected_country = selected_country;
	http_size.open("GET", myurl, true);
	http_size.onreadystatechange = useHttpResponse_size;
	http_size.send(null);
}

function useHttpResponse_size()
{
	// readyState = 0 being unintialised, 1 being loading, 2 being loaded, 3 being interactive and 4 being finished
	//alert('pppppppp');
	////alert(http.status);	
	//alert(http.readyState);	
	if (http_size.readyState != 4)
	{
	var t=setTimeout("useHttpResponse_size()",2000);
	}
	
	if (http_size.readyState == 4)
	{
		var textout = http_size.responseText;
		//alert(textout);
		//alert('priti');
		myString    = new String(textout);
		splitString = myString.split("|");
		//alert("Lnegth=="+splitString.length);
		check_size_obj.options.length = 0;
		check_size_obj[0] = new Option("All Dimensions", "-1");
		//alert("Lnegth==>>>>>>>>>>>>"+splitString.length);

		for(var i=0; i<splitString.length-1; i++)
		{
			//alert(splitString[i].trim());
			var curr_city = splitString[i].trim();
			var curr_city_val;

			//when getting 'Other' value then internally in database passing it as '-'..
			if(curr_city == "Not Found")
			{
				curr_city_val = "Not Found";
			}
			else
			{
				curr_city_val = curr_city;
			}

			//Creating new options of city ..
			if(curr_city == check_selected_country)
			{
				//alert('223')
				check_size_obj[i+1] = new Option(curr_city, curr_city_val, false, true);
			}
			else
			{
				//alert('111')
				check_size_obj[i+1] = new Option(curr_city, curr_city_val);
			}
		}

	//	document.getElementById("loading_city").innerHTML = "";
	}
}
// FOR NEW DROPDOWN
 // EO function display_dropdown()

// To populate the drop down with city values..

function useHttpResponse()
{
	// readyState = 0 being unintialised, 1 being loading, 2 being loaded, 3 being interactive and 4 being finished
	//alert('pppppppp');
	//alert(http.status);	
	//alert(http.readyState);	
	if (http.readyState != 4)
	{
	var t=setTimeout("useHttpResponse()",2000);
	}
	
	if (http.readyState == 4)
	{
		var textout = http.responseText;
		//alert(textout);
		myString    = new String(textout);
		splitString = myString.split("|");

		check_city_obj.options.length = 0;
		check_city_obj[0] = new Option("All dynamic loads", "-1");

		for(var i=0; i<splitString.length-1; i++)
		{
			var curr_city = splitString[i].trim();
			var curr_city_val;

			//when getting 'Other' value then internally in database passing it as '-'..
			if(curr_city == "Not Found")
			{
				curr_city_val = "Not Found";
			}
			else
			{
				curr_city_val = curr_city;
			}

			//Creating new options of city ..
			if(curr_city == check_selected_country)
			{
				check_city_obj[i+1] = new Option(curr_city, curr_city_val, false, true);
			}
			else
			{
				check_city_obj[i+1] = new Option(curr_city, curr_city_val);
			}
		}

	//	document.getElementById("loading_city").innerHTML = "";
	}
}

//################################ END ####################################


//################ Builds the options for State drop down..###################

//Instatiate another object to call method..
var http_state = new getHTTPObject();

var check_selected_country;
var check_state_obj;


function display_state_dropdown(selected_country, selected_country, selected_city, img_url)
{
	var myurl = "ajax-state.asp?country=" + escape(selected_country) + "&state=" + escape(selected_country) + "&city=" + escape(selected_city);

	check_state_obj = document.registration2.stateofresidence;

	if(selected_country == "")
	{
		check_state_obj.options.length = 0;
		check_state_obj[0] = new Option("Select a state", "");
		return false;
	}

	document.getElementById("loading_state").innerHTML = "<img src=\"http://jigar/build4islam/include/loading.gif\" hspace=\"16\" align=\"absmiddle\">";

	if(selected_country == "-")
	{
		check_selected_country = "Other";
	}
	else
	{
		check_selected_country = selected_country;
	}

	http_state.open("GET", myurl, true);
	http_state.onreadystatechange = useHttpResponse_state;
	http_state.send(null);

} // EO function display_state_dropdown()


// To populate the drop down with city values..
function useHttpResponse_state()
{
	if (http_state.readyState == 4 && http_state.status == 200)
	{
		var textout = http_state.responseText;

		myString    = new String(textout);
		splitString = myString.split("|");

		check_state_obj.options.length = 0;
		check_state_obj[0] = new Option("Select a state", "");

		for(var i=0; i<splitString.length; i++)
		{
			curr_state = new String(splitString[i].trim());
			//alert(curr_state);
			var curr_state_txt;
			var curr_state_val;

			//when getting 'Other' value then internally in database passing it as '-'..
			/*if(curr_state == "Other")
			{
				curr_state_val = "Other";
			}
			else
			{
				curr_state_val = curr_state;
			}*/
			strsp=curr_state.split("~");
			
			curr_state_txt=strsp[0].trim();
			curr_state_val=strsp[1].trim();
			//alert(curr_state_txt+"="+curr_state_val);

			//Creating new options of state ..
			if(curr_state_val == check_selected_country)
			{
				check_state_obj[i+1] = new Option(curr_state_txt, curr_state_val, false, true);
			}
			else
			{
				check_state_obj[i+1] = new Option(curr_state_txt, curr_state_val);
			}
		}

		document.getElementById("loading_state").innerHTML = "";
	}
}

//################################ END ####################################


// 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;
}

//-->
