// JavaScript Document
function validate_qsif_form(theForm)
{
  if (theForm.p.value=="") {
    alert('Please enter the OfferNow ID of the property to locate.');
	theForm.p.focus();
	return false;
  }
  return true;
}

function validate_qsaf_form(theForm)
{
  if (theForm.suburb.value=="") {
    alert('Please enter the suburb to search.');
	theForm.suburb.focus();
	return false;
  }
  return true;
}

function validate_agentsignupForm(theForm)
{
  if (formPosted)
    return false;
  if (theForm.agency.value=="") {
    alert('Please enter the agency name.');
	theForm.agency.focus();
	return false;
  }
  if (theForm.street.value=="") {
    alert('Please enter the agency street address.');
	theForm.street.focus();
	return false;
  }
  if (theForm.suburb.value=="") {
    alert('Please enter the suburb the agency is located in.');
	theForm.suburb.focus();
	return false;
  }
  if (theForm.phone.value=="") {
    alert('Please enter the main phone number of the agency.');
	theForm.phone.focus();
	return false;
  }
  if (!theForm.licence[0].checked && !theForm.licence[1].checked) {
    alert('Please select the licence type you are subscribing under.');
	return false;
  }
  if (theForm.licenceNo.value=="") {
    alert('Please enter the licence number.');
	theForm.licenceNo.focus();
	return false;
  }
  if (theForm.contact.value=="") {
    alert('Please enter the name of the authorised contact.');
	theForm.contact.focus();
	return false;
  }
  if (theForm.aphone.value=="") {
    alert('Please enter the phone number of the authorised contact.');
	theForm.aphone.focus();
	return false;
  }
  if (theForm.aemail.value=="" || !validateEmailv2(theForm.aemail.value)) {
    alert("Please enter a valid email address for the authorised contact.");
	theForm.aemail.focus();
	return false;
  }

  if (theForm.spfirstname.value=="") {
    alert("Please enter the firstname of the initial administrator");
    theForm.spfirstname.focus();
    return false;
  }
  if (theForm.spsurname.value=="") {
    alert("Please enter the surname of the initial administrator");
    theForm.spsurname.focus();
    return false;
  }
  if (theForm.spmobile.value=="") {
    alert("Please enter the mobile of the initial administrator");
    theForm.spmobile.focus();
    return false;
  }
  if (theForm.email.value=="" || !validateEmailv2(theForm.email.value)) {
    alert("Please enter a valid email address for the logon email account.");
    theForm.email.focus();
    return false;
  }
  if (theForm.password.value=="" || theForm.password.value.length < 6 || theForm.password.value.length > 16) {
    alert('Please enter a password between 6 and 16 characters long.');
    theForm.password.focus();
    return false;
  }
  if (theForm.password.value != theForm.cpassword.value) {
    alert('Your password and confirmed password do not match.  Please type your password in to both the \'Password\' and \'Confirm\' fields to avoid any typos.');
    theForm.cpassword.focus();
    return false;
  }

/*  if (!theForm.v && theForm.logo.value=="") {
    alert('Please nominate a logo to upload for your branding on the offer forms/emails.');
	theForm.logo.focus();
	return false;
  }
*/  
  if (!validateEmailv2(theForm.oemail.value)) {
    alert("Please enter a valid email address for the 'Offer From Email' account.");
	theForm.oemail.focus();
	return false;
  }

  if (!theForm.v && theForm.code.value=="") {
    alert('Please enter the security code as shown');
	theForm.code.focus();
	return false;
  }

  formPosted=true;
  return true;
}

function validate_sellersignupForm(theForm)
{
  if (formPosted)
    return false;
  if (theForm.spfirstname.value=="") {
    alert("Please enter your firstname");
    theForm.spfirstname.focus();
    return false;
  }
  if (theForm.spsurname.value=="") {
    alert("Please enter your surname");
    theForm.spsurname.focus();
    return false;
  }
  if (theForm.street.value=="") {
    alert('Please enter your street address.');
    theForm.street.focus();
    return false;
  }
  if (theForm.suburb.value=="") {
    alert('Please enter your suburb.');
    theForm.suburb.focus();
    return false;
  }
  if (theForm.phone.value=="") {
    alert('Please enter your contact number.');
    theForm.phone.focus();
    return false;
  }

  if (theForm.spmobile.value=="") {
    alert("Please enter the contact number to display on offer forms");
    theForm.spmobile.focus();
    return false;
  }
  if (theForm.email.value=="" || !validateEmailv2(theForm.email.value)) {
    alert("Please enter a valid email address for the logon email account (offers will go here).");
    theForm.email.focus();
    return false;
  }
  if (theForm.password.value=="" || theForm.password.value.length < 6 || theForm.password.value.length > 16) {
    alert('Please enter a password between 6 and 16 characters long.');
    theForm.password.focus();
    return false;
  }
  if (theForm.password.value != theForm.cpassword.value) {
    alert('Your password and confirmed password do not match.  Please type your password in to both the \'Password\' and \'Confirm\' fields to avoid any typos.');
    theForm.cpassword.focus();
    return false;
  }

  if (!theForm.v && theForm.code.value=="") {
    alert('Please enter the security code as shown');
    theForm.code.focus();
    return false;
  }

  formPosted=true;
  return true;
  
}

function demoGallery(idx)
{
  window.open('demo_gallery.php'+(idx ? '?index='+idx : ''),'','width=990,height=650,left=0,top=0,scrollbars=1');
}

