
function validate_form(){
	if (document.frmsubmit.selectedid1.value == null || document.frmsubmit.selectedid1.value ==""){
		alert("Maaf, Anda belum pilih hp pertama");
		return false;
	}
	if (document.frmsubmit.selectedid2.value == null || document.frmsubmit.selectedid2.value ==""){
		alert("Maaf, Anda belum pilih hp kedua");
		return false;
	}

	return true;
}
function fillselected(selid, selcode,fnum)
{
	if(fnum ==1){
		document.frmsubmit.selectedcode1.value= selcode;
		document.frmsubmit.selectedid1.value= selid;
	}
	else if(fnum ==2){
		document.frmsubmit.selectedcode2.value= selcode;
		document.frmsubmit.selectedid2.value= selid;
	}
}
function showhp1(brandcode, skey, fnum)
{
	var xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Your browser does not support AJAX!");return;
	}
  	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==1){
			document.getElementById("fresult1").innerHTML="<div class=\"loading\">Loading...</div>";
		}
		if (xmlhttp.readyState==4)
		{
			document.getElementById("fresult1").innerHTML=xmlhttp.responseText;
		}
	}
	
	var url="/js/filterhp.php";
	url=url+"?brandcode="+brandcode;
	url=url+"&sword="+skey;
	url=url+"&target="+fnum;
	xmlhttp.open("GET",url,true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(null);
}
function showhp2(brandcode, skey, fnum)
{	
	var xmlhttp = GetXmlHttpObject();
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==1){
			document.getElementById("fresult2").innerHTML="<div class=\"loading\">Loading...</div>";
		}
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("fresult2").innerHTML=xmlhttp.responseText;
		}
	}

	var url="/js/filterhp.php";
	url=url+"?brandcode="+brandcode;
	url=url+"&sword="+skey;
	url=url+"&target="+fnum;
	xmlhttp.open("GET",url,true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(null);
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}	
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
