var xmlHttp;
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 getModels(cid)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	}
  	document.getElementById("load_img1").style.display="block";
  	var url="profiledata.php"; 
  	url=url+"?cid="+cid+"&action=getmodels&pseudoParam="+new Date().getTime();
  	
  	xmlHttp.onreadystatechange=companyStateChanged;
  	xmlHttp.open("GET",url,true);
  	xmlHttp.send(null);
}

function companyStateChanged()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("load_img1").style.display="none";
		document.getElementById("model_div").innerHTML=xmlHttp.responseText;
		
	}
}

function getOperators(coid)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	}
	document.getElementById("load_img2").style.display="block";
  	var url="profiledata.php"; 
  	url=url+"?coid="+coid+"&action=getoperators&pseudoParam="+new Date().getTime();
  	
  	xmlHttp.onreadystatechange=operatorStateChanged;
  	xmlHttp.open("GET",url,true);
  	xmlHttp.send(null);
}

function operatorStateChanged()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("load_img2").style.display="none";
		document.getElementById("operator_div").innerHTML=xmlHttp.responseText;
	}
}

function trim(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function validate()
{
	var validated=true;
	if(document.getElementById("company").selectedIndex==0)
	{
		document.getElementById("company_req").style.display="block";
		validated=false;
	}
	else
	{
		document.getElementById("company_req").style.display="none";
	}
	
	if(document.getElementById("model").selectedIndex==0)
	{
		document.getElementById("model_req").style.display="block";
		validated=false;
	}
	else
	{
		document.getElementById("model_req").style.display="none";
	}
	
	if(document.getElementById("country").selectedIndex==0)
	{
		document.getElementById("country_req").style.display="block";
		validated=false;
	}
	else
	{
		document.getElementById("country_req").style.display="none";
	}
	
	if(document.getElementById("operator").selectedIndex==0)
	{
		document.getElementById("operator_req").style.display="block";
		validated=false;
	}
	else
	{
		document.getElementById("operator_req").style.display="none";
	}
	
	return validated;
}