function LoadModel()
	{	
		
		var theSel;
		var url;
		theSel = document.getElementById("watchManfacturer");
		str = theSel.options[theSel.selectedIndex].value;
		url="Manage Watches/loadmodel.php";
		removeOldValuesOfModel();
		xmlHttp=GetXmlHttpObjectOnLoad()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		//var url="ajaxResult.php"
		url=url+"?id="+str
		
		url=url+"&sid="+Math.random()		
		xmlHttp.onreadystatechange=stateChangedOfLoad
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
	}
	/*
	function stateChangedOfLoad()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			var arrResult = new Array();
			var arrcon = new Array(); 
			ajaxResult = xmlHttp.responseText;
			if(ajaxResult != "")
			{
				//insertValuesOfModel("Please select", 0);
				arrResult = ajaxResult.split("\r\n");
				var i = 0;				
				while(i < arrResult.length)
				{					
					if(arrResult[i] != "")
					{
						arrcon = arrResult[i].split("|||");
						insertValuesOfModel(arrcon[1], arrcon[0]);
					}
						
					i++;
				}
				//insertValuesOfModel("Please select", 0);
			}		
		}		
	}*/
	function stateChangedOfLoad()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			var arrResult = new Array();
			var arrcon = new Array(); 
			ajaxResult = xmlHttp.responseText;
			if(ajaxResult != "")
			{
				//insertValuesOfModel("Please select", 0);
				arrResult = ajaxResult.split("\r\n");
				var i = 0;	
				var length = arrResult.length;
				while(length > 0)
				{					
					if(arrResult[length-1] != "")
					{
						arrcon = arrResult[length-1].split("|||");
						insertValuesOfModel(arrcon[1], arrcon[0]);
					}
						
					length--;
				}
				//insertValuesOfModel("Please select", 0);
			}		
		}		
	}
	function GetXmlHttpObjectOnLoad()
	{
		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 removeOldValuesOfModel()
	{
		var theSel;		
		theSel = document.getElementById("watchModel");
		for(i=theSel.length-1; i>=0; i--)
	    {      	
        	theSel.options[i] = null;
      	}
    }
    
	var ios = 0;
	var aos = 0;
	function insertValuesOfModel(newText, newValue)
	{		
		var theSel;
		theSel = document.getElementById("watchModel");
	  	if (theSel.length == 0) 
	  	{
		    var newOpt1 = new Option(newText, newValue);
		    theSel.options[0] = newOpt1;
		    theSel.selectedIndex = 0;
	  	} 
	  	else if (theSel.selectedIndex != -1) 
	  	{
		    var selText = new Array();
		    var selValues = new Array();
		    var selIsSel = new Array();
		    var newCount = -1;
		    var newSelected = -1;
		    var i;
		    for(i=0; i<theSel.length; i++)
		    {
		      newCount++;
		      if (newCount == theSel.selectedIndex) 
		      {
		        selText[newCount] = newText;
		        selValues[newCount] = newValue;
		        selIsSel[newCount] = false;
		        newCount++;
		        newSelected = newCount;
		      }
		      selText[newCount] = theSel.options[i].text;
		      selValues[newCount] = theSel.options[i].value;
		      selIsSel[newCount] = theSel.options[i].selected;
		    }
		    for(i=0; i<=newCount; i++)
		    {
		      var newOpt = new Option(selText[i], selValues[i]);
		      theSel.options[i] = newOpt;
		      theSel.options[i].className = "combobox-list";
		      theSel.options[i].selected = selIsSel[i];
		    }
	  	}
	}
	
	function advanceSearchvalidation()
	{
		if(document.advancesearchform.searchPostcode.value != "" || document.advancesearchform.searchDist.value != "-1")
		{		
			if(document.advancesearchform.searchDist.value == "-1")
			{
				alert("Please select distance.");
				document.advancesearchform.searchDist.focus();
				return false;
			}
			if(document.advancesearchform.searchPostcode.value == "")
			{
				alert("Please enter postcode.");
				document.advancesearchform.searchPostcode.focus();
				return false;
			}
		}
		return true;
	}
