// JavaScript Document
var xmlHttp;
var origHTML="";
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
  	{
  		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
  	}
	catch (e)
  	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function stateChangedRegion() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		if (xmlHttp.status==200)
		{
			origHTML = xmlHttp.responseText+"";
			ddls = origHTML.split("<mytag/>");
			document.getElementById('div_regiune_list').innerHTML = origHTML;
			
		}
		else
		{
			alert("Problem retrieving XML data");
		}
	}
}

function stateChangedRegion_admin() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		if (xmlHttp.status==200)
		{
			origHTML = xmlHttp.responseText+"";
			ddls = origHTML.split("<mytag/>");
			document.getElementById('put_country').innerHTML = origHTML;
			
		}
		else
		{
			alert("Problem retrieving XML data");
		}
	}
}

function stateChangedLocation() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		if (xmlHttp.status==200)
		{
			origHTML = xmlHttp.responseText+"";
			ddls = origHTML.split("<mytag/>");
			document.getElementById('div_statiune_list').innerHTML = origHTML;
			
		}
		else
		{
			alert("Problem retrieving XML data");
		}
	}
}


function getRegionFront(country)
{
	document.getElementById('div_regiune_first_text').innerHTML='Alege';
	document.getElementById('div_statiune_first_text').innerHTML='Alege';
	xmlHttp=GetXmlHttpObject(); 
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	xmlHttp.onreadystatechange=stateChangedRegion;
	xmlHttp.open("GET","getRegions.php?country="+country,true);
	xmlHttp.send(null);
}

function getLocationFront(region)
{
	document.getElementById('div_statiune_first_text').innerHTML='Alege';
	
	xmlHttp=GetXmlHttpObject(); 
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	xmlHttp.onreadystatechange=stateChangedLocation;
	xmlHttp.open("GET","getLocations.php?region="+region,true);
	xmlHttp.send(null);
}

function getRegion(country)
{
	xmlHttp=GetXmlHttpObject(); 
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	xmlHttp.onreadystatechange=stateChangedRegion_admin;
	xmlHttp.open("GET","getRegions_admin.php?country="+country,true);
	xmlHttp.send(null);
}

