

	getLatLon = function (postcode, outFunction)
	{

	}

	setMapImage = function (postcode)
	{
		if (postcode == "")
			return;

	   	geocoder2.href 			= "/latLon.php";
	    geocoder2.urlargument  	= "postcode="+postcode;
	    geocoder2.process 		= setMapImageComplete;
	    geocoder2.processIt();

	}

	setMapImageComplete = function ()
	{
		if (this.result == "")
			return;

		eval("postcodeResult = " + this.result + "");

		var lon = postcodeResult.lon;
		var lat = postcodeResult.lat;

		var imapS = "275x275";
		if (typeof GLOBALImapS != "undefined")
			imapS = GLOBALImapS;

		var tImageMap = document.getElementById('imageMap');
		tImageMap.src =  "http://maps.google.co.uk/staticmap?center=" + lat + "," + lon + "&zoom=13&size=" + imapS + "&markers=" + lat + "," + lon + ",redp&key=ABQIAAAApp8DlCR6-DkGTQZRmLqo0xSlfpaF0XPMjfqUXQ7UpmbSPrznqRS80riO7--Fvew888UXHexAD8CqWg";

	}

	// ****************************************************************************************************
	// JOURNEY STUFF
	setMapJourney = function (fromId, toId)
	{
		fromPostcode 	= document.getElementById(fromId).value;
		toPostcode 		= document.getElementById(toId).value;

	   	if (fromPostcode == "" || toPostcode == "")
			return;

	    geocoder2.href 			= "/latLon.php";

	    geocoder2.urlargument 	= "fromPostcode=" + fromPostcode + "&toPostcode=" + toPostcode;
	    geocoder2.process 		= setMapJourneyComplete;
	    geocoder2.processIt();

	}

	setMapJourneyComplete = function ()
	{
		eval("postcodeResult = " + this.result + "");

		var jorneyStr =  "http://maps.google.co.uk/staticmap?size=275x275&markers=" + postcodeResult.from.lat + "," + postcodeResult.from.lon +
			",redf|" + postcodeResult.to.lat + "," + postcodeResult.to.lon + ",bluet&key=ABQIAAAApp8DlCR6-DkGTQZRmLqo0xSlfpaF0XPMjfqUXQ7UpmbSPrznqRS80riO7--Fvew888UXHexAD8CqWg";

		var tImageMap 	= document.getElementById('imageMap');
		tImageMap.src 	= jorneyStr;
	}

	/**
	* createMarker
	*/
	createMarker = function (point, number, ptext)
	{
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(ptext);});
		return marker;
	}

	/**
	* setContactForm
	*/
	setContactForm = function (parkingspaceId)
	{

		cf = document.getElementById('contactForm');
		cd = document.getElementById('contentDetails');

	}

	/**
	* removeItem
	*/
	removeItem = function (id)
	{

		var fd = document.getElementById(id)
		if (fd != null)
		{
			var pn = fd.parentNode;
			pn.removeChild(fd);
		}
	}

	/**
	* setColours
	*/
	setColours = function (idArray)
	{
		for (i = 0; i < idArray.length; i ++)
		{
			bcSel[new String(idArray[i])] = 0;
			thisDom = document.getElementById(idArray[i]);
			if (thisDom != null)
			{
				thisDom.style.backgroundColor = '#efefef';
				thisDom.style.color = '#676767';
			}
		}
	}

	// adds to the total
	var acumTot = 0;
	addToTotal = function (amount)
	{
		acumTot = acumTot + amount;

		if (GLOBALNoTotal != true)
		{
			removeItem('bookingitemsTotal');

			// calc the total
			var totalStr 		= acumTot.toFixed(2);
			totalNewElement 	= document.createElement("div");
			totalNewElement.setAttribute("id", "bookingitemsTotal");
			totalNewElement.innerHTML 	= "<br />Total: &pound;" + totalStr + "<br />";

			itemE.appendChild(totalNewElement);
		}

	}

	removeFromTotal = function (amount)
	{
		acumTot = acumTot - amount;
		addToTotal(0);
	}

	/**
	* calculateBetterPrice
	* looks at what items we have in booking items...
	*/
	calculateBetterPrice = function ()
	{

		var bookedItems 	= new Array();
		var bookedWeekItems = new Array();

		var bi = document.getElementById("bookingitems");

		for (var i = 0; i < bi.childNodes.length - 1; i ++)
		{
			// check for a child node
			var bitem = bi.childNodes[i];
			var bname = bitem.getAttribute("name");

			if (bname != null)
			{
				var bid	  = bitem.getAttribute("id");
				if (bname.match(/daily/))
				{
					bidAr = bid.split('-');
					bidp  = bidAr[1]+'-'+bidAr[2]+'-'+bidAr[3];
					bookedItems.push(bidp);
				}
				else if (bname.match(/weekly/))
				{
					bidAr = bid.split('-');
					bidp  = bidAr[1]+'-'+bidAr[2]+'-'+bidAr[3];
					bookedWeekItems.push(bidp);
				}
			}
		}

		// check to see if greater than 4
		//if (bookedItems.length > 4 && (weeklyPrice > 0 || weeklyPriceWeekend > 0) && (GLOBALAvailable == "Weekdays" || GLOBALAvailable == "Anytime" || GLOBALAvailable == ""))
		if (((bookedItems.length > 4 && GLOBALAvailable == "Weekdays" && (weeklyPrice > 0 || weeklyPriceWeekend > 0)) || (bookedItems.length > 6 && (GLOBALAvailable == "" || GLOBALAvailable == "Any time")) && (weeklyPrice > 0 || weeklyPriceWeekend > 0)))
		{
			bookedItems.sort();
			bookedItems.reverse();

			var firstDate	= "";
			var lastDate	= "";
			var inRowCount 	= 0;
			var removeArray = new Array();
			for (var i = 0; i < bookedItems.length - 1; i ++)
			{
				var c1 = parseFloat(bookedItems[i].replace(/-/g, ""));
				var c2 = parseFloat(bookedItems[i+1].replace(/-/g, ""));

				if ((c1 - c2) == 1)
				{
					if (firstDate == "")
						firstDate = formatDateStr(c1);

					removeArray.push(bookedItems[i]);
					inRowCount ++;
					if (((inRowCount == 4 && GLOBALAvailable == "Weekdays") || (inRowCount == 6 && (GLOBALAvailable == "" || GLOBALAvailable == "Any time")) && weeklyPrice != ""))
					{
						lastDate = formatDateStr(c2);
						fret = confirm("The dates you have selected (" + lastDate + " to " + firstDate + ") could be booked as a week.\n\nWould you like to change this booking?");

						if (fret)
						{
							var bc  		= new basiccalendar();
							bc.type 		= "parkBooking";

							removeArray.push(bookedItems[i+1]);
							for (k = 0; k < removeArray.length; k ++)
							{
								bc.handler(document.getElementById(removeArray[k] + "-parkBooking"));
								bcSel[removeArray[k] + "-parkBooking"] = 0;
							}

							bc.weekBooking 	= true;
							bc.handler(document.getElementById(removeArray[removeArray.length-1] + "-parkBooking"));
						}
						else
						{
							firstDate 	= "";
							inRowCount 	= 0;
							var removeArray = new Array();
						}
					}
				}
				else
				{
					firstDate 	= "";
					inRowCount 	= 0;
					var removeArray = new Array();
				}

			}
		}

		// check for weekly items
		if (bookedWeekItems.length > 3 && monthlyPrice > 0)
		{
			bookedWeekItems.sort();
			bookedWeekItems.reverse();

			var firstDate	= "";
			var lastDate	= "";
			var inRowCount 	= 0;
			var removeArray = new Array();
			for (var i = 0; i < bookedWeekItems.length - 1; i ++)
			{

				var c1 = parseFloat(bookedWeekItems[i].replace(/-/g, ""));
				var c2 = parseFloat(bookedWeekItems[i+1].replace(/-/g, ""));

				if (firstDate == "")
					firstDate = formatDateStr(c1);

				if ((c1 - c2) == 7)
				{

					removeArray.push(bookedWeekItems[i]);
					inRowCount ++;

					if (inRowCount == 3)
					{
						lastDate = formatDateStr(c2 + 6);
						fret = confirm("The dates you have selected (" + lastDate + " to " + firstDate + ") could be booked as a month.\n\nWould you like to change this booking?");

						var bc  		= new basiccalendar();
						bc.type 		= "parkBooking";

						removeArray.push(bookedWeekItems[i+1]);
						for (k = 0; k < removeArray.length; k ++)
						{
							//removeItem("bitem-" + removeArray[k] + "-parkBooking");
							//removeFromTotal(weeklyPrice);

							var clearDom = document.getElementById("clear-" + removeArray[k] + "-parkBooking");
							var jsToRun  = clearDom.getAttribute("href");
							jsToRun 	 = jsToRun.replace("JAVASCRIPT:","");
							jsToRun 	 = jsToRun.replace("void(0);","");
							eval(jsToRun);

						}

						bc.monthBooking 	= true;
						bc.handler(document.getElementById(removeArray[removeArray.length-1] + "-parkBooking"));

					}
				}
				else
				{
					firstDate 	= "";
					inRowCount 	= 0;
					var removeArray = new Array();
				}

			}

		}

	}

	formatDateStr = function (dateStr)
	{
		dateStr 	= new String(dateStr);
		var output 	= dateStr[6] + dateStr[7] + "/" + dateStr[4] + dateStr[5] + "/" + dateStr[3] + dateStr[2] + dateStr[1] + dateStr[0];
		return output;
	}

	/**
	* sets a message to be set
	*/
	setMessageRead = function (messageId)
	{
		Ext.Ajax.request({
			url: 		"/action.php?action=setMessageRead&messageId=" + messageId
		});

		currentCount = parseInt(document.getElementById("accountMailboxCount").innerHTML);
		currentCount --;
		document.getElementById("accountMailboxCount").innerHTML = currentCount;
		document.getElementById("accountMailboxCount2").innerHTML = currentCount;
		document.getElementById("mcm-" + messageId).style.backgroundColor = "";

	}

	/**
	* sets the messages marked to be unread
	*/
	setMessageMarkedUnread = function ()
	{
		var getStr = "";
		var unreadAr = document.getElementsByName("selectedMessage");
		for (var x = 0; x < unreadAr.length; x++)
		{
			if (unreadAr[x].checked)
			{
				getStr += "&mid[]=" + unreadAr[x].value;
				document.getElementById("mcm-" + unreadAr[x].value).style.backgroundColor = "#F4E9E9";

				currentCount = parseInt(document.getElementById("accountMailboxCount").innerHTML);
				currentCount ++;
				document.getElementById("accountMailboxCount").innerHTML = currentCount;
				document.getElementById("accountMailboxCount2").innerHTML = currentCount;
			}
		}

		Ext.Ajax.request({
			url: 		"/action.php?action=setMessageUnRead" + getStr
		});

	}

	/**
	* deletes the message by sending a delete message to the server
	* and unsetting the mark up
	*/
	deleteMessage = function (messageId, messageTitle)
	{

		fret = confirm("Are you sure you would like to delete: " + messageTitle);
		if (fret)
		{
			document.getElementById("mc-" + messageId).style.opacity = "1";
			document.getElementById("mf-" + messageId).style.opacity = "1";

			$("#mf-" + messageId).animate({"opacity": 0}, 	"slow");
			$("#mc-" + messageId).animate({"opacity": 0}, 	"slow", function ()
			{

				document.getElementById("mc-" + messageId).style.display = "none";
				document.getElementById("mf-" + messageId).style.display = "none";

				if (document.getElementById("ms1-" + messageId))
					document.getElementById("ms1-" + messageId).style.display = "none";

				if (document.getElementById("ms2-" + messageId))
					document.getElementById("ms2-" + messageId).style.display = "none";
			});

			Ext.Ajax.request({
				url: 		"/action.php?action=setMessageDelete&mid=" + messageId
			});
		}

	}

	/**
	* checks the price, if any prices are set to 0 then ask
	*/
	checkParkingForm = function (e)
	{

		var d 	= parseInt(document.getElementById("dailyPrice").value);

		var w 	= parseInt(document.getElementById("monthlyPrice").value);

		var m 	= parseInt(document.getElementById("monthlyPrice").value);

		var y 	= parseInt(document.getElementById("yearlyPrice").value);


		if (d == 0 || w == 0 || m == 0 || y == 0)
		{
			fret = confirm("Some of your prices are set to zero. Are you sure you would like to continue?");

			if (!fret)
			{
				return false;
				//e.returnValue = false;
			}
		}

	}

	/**
	* toggles an element
	*/
	elTog = function (id)
	{

		if (document.getElementById(id).style.display == 'block' || document.getElementById(id).style.display == 'inline' || document.getElementById(id).style.display =='')
		{
			document.getElementById(id).style.opacity = "1";
			document.getElementById(id).style.filter  = "alpha(opacity=1)";
			$("#" + id).animate({"opacity": 0}, "fast", function(){document.getElementById(id).style.display = 'none';});

		}
		else
		{
			document.getElementById(id).style.opacity = 0;
			document.getElementById(id).style.display = 'block';
			$("#" + id).animate({"opacity": 1}, 	"slow");
		}
	}

	/**
	* elTogCollapse
	*/
	elTogCollapseArray = [];
	elTogCollapse = function (cId, linkId, saveSetting)
	{

		linkDom		= document.getElementById(linkId);
		cIdDom 		= document.getElementById(cId);
		var cIdH 	= $("#" + cId).height();

		// hide it if its displayed
		if (cIdDom.style.display != "none")
		{
			cIdDom.style.display = "block";
			cIdDom.style.float   = "none";
			cIdDom.style.opacity = "1";
			cIdDom.style.filter  = "alpha(opacity=1.0)";
			$("#" + cId).animate({"height": "0px","opacity": 0}, "slow",
			function ()
			{
				linkDom.innerHTML 		= "Expand";
				cIdDom.style.display 	= "none";
				elTogCollapseArray[cId] = {"htmlId": cId, "height": cIdH, "collapsed": 1};

				Ext.Ajax.request({
					params:		elTogCollapseArray[cId],
					url: 		"/action.php?action=saveSettings"
				});

			});
		}
		else
		{
			cIdDom.style.display = "block";
			cIdDom.style.opacity = 0;
			cIdDom.style.filter  = "alpha(opacity=0)";
			$("#" + cId).animate({"opacity": "1.0", "height": elTogCollapseArray[cId].height + ".px"}, "slow",
			function ()
			{
				linkDom.innerHTML 		= "Collapse";
				elTogCollapseArray[cId] = {"htmlId": cId, "height": cIdH, "collapsed": 0};

				Ext.Ajax.request({
					params:		elTogCollapseArray[cId],
					url: 		"/action.php?action=saveSettings"
				});

			});
		}
	}

	/**
	* elTogImage
	*/
	elTogImage = function (img1, img2)
	{

		imgdom1 = document.getElementById(img1);
		imgdom2 = document.getElementById(img2);

		$("#" + img1).animate({"opacity": 0}, "fast", function()
		{

			imgdom1.src = imgdom2.src;
			$("#" + img1).animate({"opacity": 1}, "fast");

		});

	}


	/**
	* deleteSpaceImage
	*/
	deleteSpaceImage = function (i)
	{

		document.getElementById("defaultImage" + i).src = "/images/uploadDefault.png";
		document.getElementById("userfile" + i).value	= "";

	}

	/**
	* toggles the class on the expand link and also toggles the expand div
	*/
	expandLink = function (expandLink, expandDiv)
	{
		elTog(expandDiv);

	}

	/**
	* addParkAlert
	*
	* looks at the missing parking space requested and adds an alert on action
	*/
	addParkAlert = function ()
	{

		var aEmail 		= document.getElementById("alertEmail");
		var aLocation 	= document.getElementById("alertLocation");

		Ext.Ajax.request({
			url: 		"/action.php",
			params:		{"action": "addSearchAlert", "email": aEmail.value, "location": aLocation.value},
			success:	function (r)
			{
				document.getElementById("searchAlertComplete").style.display 	= "inline";
				document.getElementById("searchInnerAlertForm").style.display 	= "none";
			}
		});

	}

	/**
	* actionSpace
	*/
	actionSpace = function (select, parkingspaceId)
	{

		// get the selected
		var selected = select[select.selectedIndex].value;

		fret = confirm("Are you sure you would like to " + selected + " this advert?");

		// check what they want to do
		if (fret)
		{

			// check what one we are dealing with
			switch(selected)
			{
				// publish
				case "publish":
					Ext.Ajax.request({
						url: 		"/action.php",
						params:
						{
							"action": 	"updateSpaceStatus",
							"or":		1,
							"parkingspaceId":parkingspaceId,
							"onsite":	"y"
						}
					});

					document.getElementById("spaceStatus_" + parkingspaceId).className = "liveAdvert";
					document.getElementById("spaceStatus_" + parkingspaceId).innerHTML = "Published advert";
					select.innerHTML = "<option value=\"\">Set status here</option><option value=\"unpublish\">Unpublish advert</option><option value=\"delete\">Delete advert</option>";

				break;

				// unpublish
				case "unpublish":
					Ext.Ajax.request({
						url: 		"/action.php",
						params:
						{
							"action": 	"updateSpaceStatus",
							"or":		1,
							"parkingspaceId":parkingspaceId,
							"onsite":	"n"
						}
					});

					document.getElementById("spaceStatus_" + parkingspaceId).className = "nonliveAdvert";
					document.getElementById("spaceStatus_" + parkingspaceId).innerHTML = "Unpublished advert";
					select.innerHTML = "<option value=\"\">Set status here</option><option value=\"publish\">Publish advert</option><option value=\"delete\">Delete advert</option>";

				break;

				// delete
				case "delete":
					Ext.Ajax.request({
						url: 		"/action.php",
						params:
						{
							"action": 	"updateSpaceStatus",
							"or":		1,
							"parkingspaceId":parkingspaceId,
							"onsite":	"d"
						}
					});

					var cn = document.getElementById("spaceAdvert_" + parkingspaceId);
					var pn = cn.parentNode;
					pn.removeChild(cn);

					if (pn.getElementsByTagName("div").length == 0)
					{


						//vh  = "<div style=\"height: 160px;\" id=\"yourSpacesSub\" class=\"greyContent\">";
						vh  = "<div style=\"float: left; display: inline; width: 350px;\">";
						vh += "<span style=\"font-size: 1.1em;\"><strong>You currently have no advertised spaces</strong><br /><br />Click the Advertise space button to advertise your space. </span></span><br/><br/>";
						vh += "<br/><a href=\"/account/add-space/\" alt=\"Advertise space\" title=\"Advertise space\"><img border=\"0\" src=\"/images/buttonAdvertiseSpaceLarge.png\"/></a>	";
						vh += "</div><div style=\"float: right; margin-top: -40px; margin-right: 60px;\"><img src=\"/images/splashEarnMoneyFromSpace.png\"/></div>";
						pn.innerHTML = vh;
						pn.style.height = "160px";
					}

				break;
			}

		}

	}


	/**
	* actionJourney
	*/
	actionJourney = function (select, journeyshareId)
	{

		// get the selected
		var selected = select[select.selectedIndex].value;

		fret = confirm("Are you sure you would like to " + selected + " this advert?");

		// check what they want to do
		if (fret)
		{

			// check what one we are dealing with
			switch(selected)
			{
				// publish
				case "publish":
					Ext.Ajax.request({
						url: 		"/action.php",
						params:
						{
							"action": 	"updateJourneyStatus",
							"or":		1,
							"journeyshareId":journeyshareId,
							"onsite":	"y"
						}
					});

					document.getElementById("journeyStatus_" + journeyshareId).className = "liveAdvert";
					document.getElementById("journeyStatus_" + journeyshareId).innerHTML = "Published advert";
					select.innerHTML = "<option value=\"\">Set status here</option><option value=\"unpublish\">Unpublish advert</option><option value=\"delete\">Delete advert</option>";

				break;

				// unpublish
				case "unpublish":
					Ext.Ajax.request({
						url: 		"/action.php",
						params:
						{
							"action": 	"updateJourneyStatus",
							"or":		1,
							"journeyshareId":journeyshareId,
							"onsite":	"n"
						}
					});

					document.getElementById("journeyStatus_" + journeyshareId).className = "nonliveAdvert";
					document.getElementById("journeyStatus_" + journeyshareId).innerHTML = "Unpublished advert";
					select.innerHTML = "<option value=\"\">Set status here</option><option value=\"publish\">Publish advert</option><option value=\"delete\">Delete advert</option>";

				break;

				// delete
				case "delete":
					Ext.Ajax.request({
						url: 		"/action.php",
						params:
						{
							"action": 	"updateJourneyStatus",
							"or":		1,
							"journeyshareId":journeyshareId,
							"onsite":	"d"
						}
					});

					var cn = document.getElementById("journeyAdvert_" + journeyshareId);
					var pn = cn.parentNode;
					pn.removeChild(cn);

					if (pn.getElementsByTagName("div").length == 0)
					{
						vh  = "<div style=\"float: left; display: inline; width: 300px;\">";
						vh += "<p><span style=\"font-size: 1.1em;\"><strong>You currently have no journeys</strong><br /><br />Click the Advertise journey button to advertise a journey.</span></span><br/><br/>";
						vh += "</p>";
						vh += "<br/>";
						vh += "<a href=\"/account/add-journey/\" alt=\"Advertise journey\" title=\"Advertise journey\"><img border=\"0\" src=\"/images/buttonAdvertiseJourneyLarge.png\"/></a>";
						vh += "</div><div style=\"float: right; margin-top: -37px; margin-right: 20px;\">";
						vh += "<img src=\"/images/splashRoad.png\"/></div>";

						pn.innerHTML = vh;
						pn.style.height = "164px";
					}

				break;
			}

		}

	}

