// JavaScript Document

function getCat(country){
	var xmlhttp;
	if (country=="*"){ 
		//alert(country);
		//return;
		theUrl = 'catlist3.php';
	}else{
		theUrl = "getCatList.php?q="+country;
	}
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
//					document.getElementById("cat").disabled=false;
//					document.getElementById("cat").innerHTML= "<div id='catDiv'>" + xmlhttp.responseText + "</div>";
			document.getElementById("catDiv").innerHTML= "<select name='category' id='cat'>" + xmlhttp.responseText + "</select>";
			document.getElementById("headerCatDiv").innerHTML= "<select size='6' name='category' id='headerCat' style='width:210px'>" + xmlhttp.responseText + "</select>";
			
			//alert(document.getElementById("headerCatDiv").innerHTML);
			
			//document.getElementById("headerCat").innerHTML=xmlhttp.responseText;
			document.getElementById("headerCat").disabled=false;
		}
	}
	xmlhttp.open("GET",theUrl,true);
	xmlhttp.send();
}
function getIslands(){
	//alert("testing on load");
	var xmlhttp2;
	theUrl2 = "getIslandList.php";
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2=new XMLHttpRequest();
		//alert("1");
	}else{// code for IE6, IE5
		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
		//alert("2");
	}
	xmlhttp2.onreadystatechange=function(){
		if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
			//alert(xmlhttp.responseText);
//					document.getElementById("islandsDiv").innerHTML=xmlhttp2.responseText;
			document.getElementById("islandsDiv").innerHTML="<select name='country' id='islands' onchange='getCat(form.country.options[form.country.selectedIndex].value)'>"+xmlhttp2.responseText+"</select>";
//					document.getElementById("headerIslands").innerHTML=xmlhttp2.responseText;
			document.getElementById("headerIslandDiv").innerHTML="<select size='6' name='country' id='headerIslands' style='width:210px' onchange='getCat(form.country.options[form.country.selectedIndex].value)'>"+xmlhttp2.responseText+"</select>";
			document.getElementById("cat").disabled=true;
			document.getElementById("headerCat").disabled=true;

		}
	}
	xmlhttp2.open("GET",theUrl2,true);
	xmlhttp2.send();
}

