		var path = "http://www.findagaragesale.co.nz/wp-content/themes/theme767/";
		//var path = "http://localhost/findagaragesale/wp-content/themes/theme767/";
	
		function checkData()
		{
			var message = "";		
			//var e = document.getElementById("regionid_post");
			//var region = e.options[e.selectedIndex].value;
			//alert(document.getElementById("regionid_post").options[document.getElementById("regionid_post").selectedIndex].value);
			//alert(document.getElementById("regionid_post").value);

			if(document.getElementById("name").value == "")
				message += "\n- enter your first name.";
					
			if(document.getElementById("street").value == "" || document.getElementById("suburb").value == "" || document.getElementById("city").value == "")
				message += "\n- specify the location of the garage sale.";
			
			if(document.getElementById("regionid_post").value == "-1")
				message += "\n- select your region.";
				
			if(document.getElementById("email").value == "")
				message += "\n- enter a valid email address.";

			if(document.getElementById("date").value == "")
				message += "\n- specify the date and time of the garage sale.";
				
			if(!document.form1.confirm.checked)
				message += "\n\nPlease confirm you have read the Terms and Conditions.";
			
			if(message != "")
			{
				alert("Errors were found in your regsitration:\n"+message);
				return false;
			}
			else
				return true;
		}
	  
	    	function OpenMap()
		{
	  		var address = document.getElementById('street').value+', '+document.getElementById('suburb').value+', '+document.getElementById('city').value;
	  		
	  		if(address != "" && document.getElementById("regionid_post").value != "-1")
	  		{
	  			var win = window.open(path+"map.php?address="+address, "map", "width=520,height=420,resizable=no,scrollbars=no");
	  			win.focus();
	  			return false;
	  		}
	  		else
	  		{
	  			alert("Please check your address and region have been defined correctly.");
	  		}
		}

	    	function mapLookUp(address)
		{
	  		//alert("Hello");
	  		var win = window.open(path+"map.php?address="+address, "map", "width=520,height=420,resizable=no,scrollbars=no");
	  		win.focus();
	  		return false;
		}

	    	function smsPopup(id)
		{
	  		var win = window.open(path+"sms.php?id="+id, "SMS", "width=520,height=80,resizable=no,scrollbars=no,toolbar=no");
	  		win.focus();
	  		return false;
		}
		
		function gender(gen)
		{		
	  		var win = window.location=path+"process.php?mode=gender&gen="+gen;
	  		return false;
		}

		function addInput()
		{	
			var e = document.getElementById("more");
			var cnt = e.options[e.selectedIndex].text;

			for (var i = 1; i <= cnt; i++)
			{
				var x = document.getElementById("inputs");
				x.innerHTML += "Additional image: <input type=\"file\" name=\"imageUpload[]\" /><br>";
				
				var chg = document.getElementById("charge").value * 1;
				chg = chg + 0.5;
				document.getElementById("charge").value = chg;
				//sub_total.innerHTML = "Sub total: $ " + CurrencyFormatted(chg);
			}

			document.getElementById('more').style.visibility = "hidden";
			document.getElementById('add').style.visibility = "hidden";		
		}

		function getQuerystring(key, default_)
		{
			if (default_==null) default_=""; 
			key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
			var qs = regex.exec(window.location.href);
			if(qs == null)
				return default_;
			else
				return qs[1];
		}
		
	    	function updateListing(id)
		{
	  		var win = window.open(path+"update.php?id="+id, "Update", "width=750,height=320,resizable=no,scrollbars=no,toolbar=no");
	  		win.focus();
	  		return false;
		}
		
	    	function payment(id)
		{
	  		//alert('Hello '+id);
	  		window.location = path+"payment.php?id="+id;
	  		return false;
		}
		
		function checkEmail()
		{
			var email = document.getElementById('newsletter').value;
			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!filter.test(email))
			{
				alert('Please provide a valid email address');
				email.focus;
				return false;
			}
		}				
