// JavaScript Document

// JavaScript Document
var req;

function loadXMLDocCountryLocation(url)
{
		
	document.getElementById("displayLocationPick").style.display = "none";
	document.getElementById("displayLocationDrop").style.display = "none";
	document.getElementById('ImageDis').style.display = '';	
	if (window.XMLHttpRequest) 
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChangeCountryLocation;
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
	} 
	else if (window.ActiveXObject) 
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) 
		{
			req.onreadystatechange = processReqChangeCountryLocation;
			req.open("GET", url, true);
			req.send();
		}
	}
}



function processReqChangeCountryLocation()
{
	// only if req shows "complete"
	if (req.readyState == 4) 
	{
		// only if "OK"
		if (req.status == 200) 
		{
			
			// ...processing statements go here...
			response = req.responseXML.documentElement;
			TotalArt = response.getElementsByTagName('TotalLocation')[0].firstChild.data;
			
			if ( TotalArt > 0 )
			{
				result_id = Array();
				result_name = Array();
				removeAllOptions(document.ProductForm.CmbLocationPick);
				removeAllOptions(document.ProductForm.CmbLocationDrop);	
				for ( i = 0 ; i < TotalArt ; i++ )
				{
					result_name[i] = response.getElementsByTagName('location')[i].firstChild.data ;
					result_id[i] = response.getElementsByTagName('location_id')[i].firstChild.data ;
					addOption(document.ProductForm.CmbLocationPick,result_name[i],result_id[i])
					addOption(document.ProductForm.CmbLocationDrop,result_name[i],result_id[i])
				}	
			}
			else
			{
				removeAllOptions(document.ProductForm.CmbLocationPick);
				removeAllOptions(document.ProductForm.CmbLocationDrop);
				addOption(document.ProductForm.CmbLocationPick,"No Location Found","0");
				addOption(document.ProductForm.CmbLocationDrop,"No Location Found","0");
			}
			setTimeout("document.getElementById('ImageDis').style.display = 'none'", '500');
	 		setTimeout("document.getElementById('displayLocationPick').style.display = ''", '500');
			setTimeout("document.getElementById('displayLocationDrop').style.display = ''", '500');
		} 
		else 
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}


function GetCountryLocation(input)
{
	url = SiteRootPath + "get_location_country.php?param=" + input;
	
	loadXMLDocCountryLocation(url);
}



