
	GLOBALSearchType = "space";

	// ****************************************************************************************************
	searchForm = function ()
	{		
		
		this.postURL 		= "/locationSearch.php";
		this.postWantedURL 	= "/wantedSearch.php";
		this.postJourneyURL	= "/journeySearch.php";
		this.notb 			= false;
		this.usepc			= "";
		this.changeLocation = false;
		
		/**
		* removes contents of search box 
		*/
		this.clearSearchBox = function (id)
		{
			var textBox = document.getElementById(id);
			if (textBox.value == "location/postcode" || textBox.value == "search text")
			{
				textBox.value 	= "";
				//textBox.style.backgroundImage	= "";
				//textBox.style.backgroundColor 	= "#FFFFFF";
			}
		}
		
		/**
		* resets to the default value
		*/
		this.unclearSearchBox = function (id)
		{
			var textBox = document.getElementById(id);
			if (textBox.value == "" || textBox.value == "search text")
			{
				if (id == "searchLocationWant")
						textBox.value 	= "search text";
				else	textBox.value 	= "location/postcode";
				//textBox.style.backgroundImage	= "/images/greyslicesmall.jpg";
				//textBox.style.backgroundColor 	= "#676767";
			}
		}
	
		/**
		* changes the container color depending on where you have clicked
		*/
		this.setMapContainerColour = function (id)
		{	
			
			// sets the map colours
			var mc = document.getElementById('mainMapContainer');		
			switch (id)
			{
				case "searchLocationPark":
					mc.style.background 	 = 'url("/images/redslice.jpg") repeat-x';
					mc.style.backgroundColor = "#FBC6D8";
				break;
				
				case "searchLocationWant":
					mc.style.background  	 = 'url("/images/greenslicebig.jpg") repeat-x';
					mc.style.backgroundColor = "#D9EAD8";										
				break;
				
				default:
					if (id == "searchLocationLiftFrom" || id == "searchLocationLiftTo")
					{	
						mc.style.background  	 = 'url("/images/orangeslicebig.jpg") repeat-x';
						mc.style.backgroundColor = "#FFE7CF";
					}	
				break;
				
			}	
			
		}
		

		// ****************************************************************************************************
		function callAjaxLatLon ()
		{
			this.urlargument 	= "";
			this.href 			= "";
			 
	 		// process result
			this.processIt = function ()
			{
				// create the pukAJAX class and run
				var amaj 			= new pukAJAX;
				amaj.href 			= this.href;
				amaj.urlargument 	= this.urlargument;
				amaj.process 		= this.process;
				amaj.get();
	
			}
		}

		/**
		* run the map moving! 
		*/	
		this.runMapMove = function (lat, lon, z)
		{	
			if (GLOBALSearchType == "space")
			{

				//getStr += "&st=" + document.getElementById("spaceType").value;		
				var spaceTypeAr = document.getElementsByName("spaceType");
				for (var x = 0; x < spaceTypeAr.length; x++)
				{	
					if (spaceTypeAr[x].checked)
						getStr += "&st[]=" + spaceTypeAr[x].value;
				}	

				var carTypeAr = document.getElementsByName("carType");
				for (var x = 0; x < carTypeAr.length; x++)
				{	
					if (carTypeAr[x].checked)
						getStr += "&ct[]=" + carTypeAr[x].value;
				}	

				var spaceAvailAr = document.getElementsByName("spaceAvailable");
				for (var x = 0; x < spaceAvailAr.length; x++)
				{	
					if (spaceAvailAr[x].checked)
						getStr += "&a[]=" + spaceAvailAr[x].value;
				}							
				//getStr += "&sf=" + document.getElementById("sizeRestriction").value;
				//getStr += "&a=" + document.getElementById("spaceAvailable").value;
				
				getStr = "";
				getStr += "&fKR=" + document.getElementById("featureKeyRequired").checked;
				getStr += "&fCCTV=" + document.getElementById("featureCCTV").checked;
				getStr += "&fG=" + document.getElementById("featureGated").checked;
				getStr += "&fU=" + document.getElementById("featureUnderground").checked;
				getStr += "&fL=" + document.getElementById("featureLighted").checked;
				getStr += "&fS=" + document.getElementById("featureSheltered").checked;
				getStr += "&fSG=" + document.getElementById("featureSecurityGuards").checked;

				var s 	= document.createElement('script');
				s.src 	= this.postURL + "?lls=1&lat=" + lat + "&lon=" + lon + "&mz=" + z + getStr;
				s.type 	= 'text/javascript';
				document.getElementsByTagName('head')[0].appendChild(s);	
			}
		}
		
		/** 
		* performs the search, returns js to update the 
		*/
		this.runSearch = function (runCurrent)
		{	
			var searchType_journey 		= document.getElementById("searchType_journey");
			var searchType_space 		= document.getElementById("searchType_space");
			var searchType_sellspace 	= document.getElementById("searchType_sellspace");	

			
			if (typeof this.idf != "undefined")
					var pc = document.getElementById(this.idf);	
			else	var pc = document.getElementById("spostcode");	
			
			if (runCurrent == false)
			{
				var type = "space";
				if (searchType_space.checked)
					type = "space";
				else if (searchType_sellspace.checked)
					type = "sellspace";
				else if (searchType_journey.checked)
					type = "journey";

				if (typeof this.type != 'undefined')
					type = this.type;
				
				var urlType = "";
				if (type == 'space')
						urlType = "parking"
				else	urlType = type;
				
				window.location = "/search/" + urlType + "/" + pc.value + "/";// + "&run=1";
				
			}else{

				var getStr = "";				
				if (searchType_space.checked || this.type == "space")
				{	

					if (runCurrent)
					{

						var alertLocation			= document.getElementById("alertLocation");						
						var postcodeLocation 		= document.getElementById("postcode").value;

						document.getElementById("searchAlertForm").style.display = "none";
						document.getElementById("searchAlertComplete").style.display 	= "none";
						document.getElementById("searchInnerAlertForm").style.display 	= "inline";
						
						alertLocation.value			= postcodeLocation;

						//getStr += "&st=" + document.getElementById("spaceType").value;		
						var spaceTypeAr = document.getElementsByName("spaceType");
						for (var x = 0; x < spaceTypeAr.length; x++)
						{	
							if (spaceTypeAr[x].checked)
								getStr += "&st[]=" + spaceTypeAr[x].value;
						}	

						var carTypeAr = document.getElementsByName("carType");
						for (var x = 0; x < carTypeAr.length; x++)
						{	
							if (carTypeAr[x].checked)
								getStr += "&ct[]=" + carTypeAr[x].value;
						}	

						var spaceAvailAr = document.getElementsByName("spaceAvailable");
						for (var x = 0; x < spaceAvailAr.length; x++)
						{	
							if (spaceAvailAr[x].checked)
								getStr += "&a[]=" + spaceAvailAr[x].value;
						}							
						//getStr += "&sf=" + document.getElementById("sizeRestriction").value;
						//getStr += "&a=" + document.getElementById("spaceAvailable").value;
						
						getStr += "&fKR=" + document.getElementById("featureKeyRequired").checked;
						getStr += "&fCCTV=" + document.getElementById("featureCCTV").checked;
						getStr += "&fG=" + document.getElementById("featureGated").checked;
						getStr += "&fU=" + document.getElementById("featureUnderground").checked;
						getStr += "&fL=" + document.getElementById("featureLighted").checked;
						getStr += "&fS=" + document.getElementById("featureSheltered").checked;
						getStr += "&fSG=" + document.getElementById("featureSecurityGuards").checked;
					}	
					else	var postcodeLocation = document.getElementById("spostcode").value;

					if (this.usepc != "")
						postcodeLocation = this.usepc;
					
					if (postcodeLocation == "Location / Postcode")
						postcodeLocation = "";
										
					if (this.notb)
						getStr = getStr + "&notb=1";
					
					if (this.changeLocation == false)
					{
						var s 	= document.createElement('script');
						s.src 	= this.postURL + "?l=" + postcodeLocation + getStr;
						s.type 	= 'text/javascript';
						document.getElementsByTagName('head')[0].appendChild(s);	
					}
					else
					{		
						window.location = "/search/parking/" + postcodeLocation + "/" + getStr;
					}
					
				}
				else if (searchType_sellspace.checked)
				{
					var stext = document.getElementById(id).value;
					var s 	= document.createElement('script');
					s.src 	= this.postWantedURL + "?t=" + stext;
					s.type 	= 'text/javascript';
					document.getElementsByTagName('head')[0].appendChild(s);					
				}
				else if (searchType_journey.checked || this.type == "journey")
				{	
					var stextfr = document.getElementById("toPostcode").value;
					var stextto = document.getElementById("fromPostcode").value;
					
					//getStr += "&ct=" + document.getElementById("carType").checked;
					//getStr += "&a=" + document.getElementById("journeyAvailable").checked;
					var carTypeAr = document.getElementsByName("carType");
					for (var x = 0; x < carTypeAr.length; x++)
					{	
						if (carTypeAr[x].checked)
							getStr += "&ct[]=" + carTypeAr[x].value;
					}	

					var journeyAvailAr = document.getElementsByName("journeyAvailable");
					for (var x = 0; x < journeyAvailAr.length; x++)
					{	
						if (journeyAvailAr[x].checked)
							getStr += "&a[]=" + journeyAvailAr[x].value;
					}	
					
					if (stextfr == "From: Location / Postcode")
						stextfr = "";						

					if (stextto == "To: Location / Postcode")
						stextto = "";

					if (this.changeLocation == false)
					{						
						var s 	= document.createElement('script');
						s.src 	= this.postJourneyURL + "?t=" + stextto + "&f=" + stextfr + getStr;
						s.type 	= 'text/javascript';
						document.getElementsByTagName('head')[0].appendChild(s);	
					}else{
						window.location = "/search/journey/from_" + stextfr + "/to_" + stextto + "/" + getStr;
					}
				}
				else if (this.type == "viewParking")
				{
					var s 	= document.createElement('script');
					s.src 	= this.postURL + "?nb=1&vp=1&l=" + this.postcode;
					
					s.type 	= 'text/javascript';
					document.getElementsByTagName('head')[0].appendChild(s);						
				}	

			}
			
		}
	}
	

