//Name: loginForm
//Called From: index.php, ourproperties.php, property_detail.php, access_error.php
function loginForm () {
	var strUsername = document.login.username.value;
	var strPassword = document.login.password.value;
	if (strUsername == "") {
		alert("A username must be provided.");
		document.login.username.focus();
		return false;
	}
	if (strPassword == "") {
		alert("A password must be provided.");
		document.login.password.focus();
		return false;
	}
	return true;
}

//Name: registrationForm
//Called From: registration_form.php
function registrationForm () {
	var strName = document.registration.name.value;
	var strCompany = document.registration.company.value;
	var strPhone = document.registration.phone.value;
	var strEmail = document.registration.email.value;
	var strUsername = document.registration.username.value;
	var strPassword = document.registration.password.value;
	
	if (strName == "") {
		alert("A name must be provided.");
		document.registration.name.focus();
		return false;
	}
	if (strCompany == "") {
		alert("A company name must be provided.");
		document.registration.company.focus();
		return false;
	}
	if (strPhone == "") {
		alert("A phone number must be provided.");
		document.registration.phone.focus();
		return false;
	}
	if (strEmail == "") {
		alert("An e-mail address must be provided.");
		document.registration.email.focus();
		return false;
	}
	if (strUsername == "") {
		alert("A username must be provided.");
		document.registration.username.focus();
		return false;
	} else if (strUsername.length < 6 || strUsername.length > 12){
		alert("The value of username must be between 6 and 12 characters.");
		document.registration.username.value = "";
		document.registration.username.focus();
		return false;
	}
	if (strPassword == "") {
		alert("A password must be provided.");
		document.registration.password.focus();
		return false;
	} else if (strPassword.length < 6 || strPassword.length > 12){
		alert("The value of password must be between 6 and 12 characters.");
		document.registration.password.value = "";
		document.registration.password.focus();
		return false;
	}
	
	if (!document.registration.privacy_policy.checked){
		alert("You must review and agree to our privacy policy to register");
		return false;
	}
	return true; 
	
}

//Name: deletePDF
//Called From: manage_pdfs.php
function deletePDF() {
	if (confirm("Are you sure you want to delete this property?")) {
		return true;
	}
	return false;
}

//Name: uploadPDF
//Called From: manage_pdfs.php
function uploadPDF() {
	var strFile = document.manage_pdfs.pdf.value;
	var strExt = strFile.substring(strFile.length - 3, strFile.length);
	
	if (strExt != 'pdf') {
		alert("The file you are attempting to upload is not a PDF.");
		return false;
	}
	return true;
}
//Name: viewLargeImg
//Called From: property_detail.php
function viewLargeImg(property){
	var doc = "large_image.php?property=" + property;
	var win = window.open(doc, "property_image", "width=700,height=530");
	return;
}