// JavaScript Document
formchangedstatus = false;


function ShowOurTerms()
{
	window.open("ourterms.htm",'','toolbar=no,status=no,scrollbars=yes');
}

function in_array(needle,haystack)
{
	for(i=0;i<haystack.length;i++) if(haystack[i]==needle) return true;
	return false;
}




function submitpropertydetails()
{
	var form = document.propertydetailsform;
	var price2 = form.price.value;
	if(form.price.value=="") 
		alert("Please enter a property price.");
	else if(!isNumber(price2)) 
		alert("Please only use numbers here! No commas, symbols or decimal points please.");
	else if(form.description.value=="") 
		alert("Please enter a short description of your site in the field provided.");
	else 
		form.submit();
}
function submitpropertylocation()
{
	var form = document.propertylocationform;
	if(form.town.value=="") 
		alert("Please enter the postal town of your property.");
	else if(form.postcode.value=="") 
		alert("Please enter the property postcode.");
	else 
		form.submit();
}

function submitpropertyimages()
{
	document.propertyimagesform.submit();
}

function deletesiteimage2(number,property)
{
	var answer = confirm("Are you sure you want to delete this image?")
	if(answer) document.location='../lib/deletepropertyimages.php?propid='+property+'&picid='+number;
}
function deletesiteimage3(number,property)
{
	var answer = confirm("Are you sure you want to delete this image?")
	if(answer) document.location='../lib/deletepropertyimage.php?propid='+property+'&picid='+number;
}


function submit_to_us(propid)
{
	var answer = confirm("The information you have entered will now be processed and listed on our top ranked Google pages.\n\nCheck List:\n\n   1. Entered as much detail as possible.\n   2. Entered accurate location details including position on the map.\n   3. Added all your property pictures.\n\nIf you are completely happy with the information you have entered, click 'OK' to proceed.\n\nIf you would like to review your details, please click 'Cancel'.");
	if(answer) document.location='../lib/submitdetailstous.php?propid='+propid;
}

function isPic(file)
{
	return ((file).substring(file.length-3) == "gif"||(file).substring(file.length-3) == "GIF"||(file).substring(file.length-3) == "jpg"||(file).substring(file.length-3) == "JPG")
}

function formchanged()
{
	formchangedstatus = true;	
}



function submitsiteform()
{
	var form = document.register_form;
	var nametaken = false;
	for(i=20;i<form.elements.length;i++) if(form.username.value==form.elements[i].value) nametaken = true;
	if(form.username.value=='') alert("You must enter a username!");
	else if(nametaken) alert("Sorry but the username you have specified has already been taken. Please choose another.");
	else if(form.pass1.value==''||form.pass2.value=='') alert("You must enter a password in both fields!");
	else if(form.pass1.value!=form.pass2.value) alert("Your passwords must match!");
	else if(form.firstname.value=='') alert("Please enter partner's first name.");
	else if(form.lastname.value=='') alert("Please enter partner's last name.");
	else if(form.siteemail.value==''||!goodEmail(form.siteemail.value)) alert("You must enter a valid email address!");
	else if(!form.agreetoterms.checked) alert("You must agree to the terms of this service in order to proceed!");
	else form.submit();
}
function validate_required(field,alerttxt){
	with (field){
		if (value==null||value==""){
			alert(alerttxt);return false;
		}else {
			return true
		}
	}
}
function validate_form(thisform){
	with (thisform){
		if(validate_required(firstname,"First Name must be filled out!")==false){
			firstname.focus();return false;
		}else if(validate_required(lastname,"Last Name must be filled out!")==false){
			lastname.focus();return false;
		}else if((validate_required(email,"You must enter a valid email address!")==false)||!goodEmail(email)){
			email.focus();return false;
		}else if(!goodEmail(email)){
			email.focus();return false;
		}
	}
}


function isNumber(value,allowfloat)
{
	if (allowfloat) value = value.replace('.','');
	value = replaceIt(value," ","");
	value = replaceIt(value,"0","");
	value = replaceIt(value,".","");
	return (parseInt(value)==value);
}

function replaceIt(sString, sReplaceThis, sWithThis) { 
if (sReplaceThis != "" && sReplaceThis != sWithThis) { 
var counter = 0; 
var start = 0; 
var before = ""; 
var after = ""; 
while (counter<sString.length) { 
start = sString.indexOf(sReplaceThis, counter); 
if (start == -1) { 
break; 
} else { 
before = sString.substr(0, start); 
after = sString.substr(start + sReplaceThis.length, sString.length); 
sString = before + sWithThis + after; 
counter = before.length + sWithThis.length; 
} 
} 
} 
return sString; 
} 

function goodEmail(value)
{
	 var at = (value.indexOf('@')!=-1);
	 var dot = (value.indexOf('.')!=-1);
	 return (at&&dot);
}
function define(obj)
{
	window.open('../../propertyE/lib/tooltip.php?title=' + obj,'', 'width=200,height=255,scrollbars=no,status=no,left=300,top=250,menubar=no,toolbar=no,screenX=300,screenY=250');
}
function showmap(code)
{
	window.open('/bookingE/lib/showmap.php?code=' + code,'', 'width=620,height=560,scrollbars=no,status=no,resizable=no,left=300,top=250,menubar=no,toolbar=no,screenX=300,screenY=250');
}
function showmap2(code)
{
	window.open('/bookingE/lib/showmap2.php?code=' + code,'', 'width=620,height=560,scrollbars=no,status=no,resizable=no,left=300,top=250,menubar=no,toolbar=no,screenX=300,screenY=250');
}
function href(action)
{
	document.location='control.php?action=' + action;
}

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
