<!--
// =============================================================
// copyright 2004 Alpine-Property.com - all rights reserved
// =============================================================

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) xx.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=(arguments ? arguments : MM_preloadImages.arguments);
    for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// return y position, minus
function getLayerX($objname) {
	$x = event.clientX;
	//$objW = MM_findObj($objname).width;
	//$x = document.body.clientWidth - $objW - 10;
	return $x;
}

// return y position, minus
function getLayerY($objname) {
	//$y = event.clientY;
	$objH = MM_findObj($objname).height;
	$y = (event.clientY - $objH);
	return $y;
}

// ===================================================================================================

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

// checks if date passed is in valid dd/mm/yyyy format

function isValidDate (myDate,sep) {
    if (myDate.length == 10) {
        if (myDate.substring(2,3) == sep && myDate.substring(5,6) == sep) {
            var date  = myDate.substring(0,2);
            var month = myDate.substring(3,5);
            var year  = myDate.substring(6,10);
            var test = new Date(year,month-1,date);
            if ( year == y2k(test.getYear() ) && ( month-1 == test.getMonth() ) && ( date == test.getDate() ) ) {
                return true;
            }
            else {
                //alert('valid format but invalid date');
                return false;
            }
        }
        else {
            // alert('invalid separators');
            return false;
        }
    }
    else {
        // alert('invalid length');
        return false;
    }
}

// ================================================================================================================
// resist right click script is now stored separately in norc.js
// ================================================================================================================

//checks if field is empty
function isEmpty( str ){
    strRE = new RegExp( );
    strRE.compile( '^[\s ]*$', 'gi' );
    return strRE.test( str.value );
}

//checks if email is valid
function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
}

//checks content is only letters
function isLetters( str ) {
	var myregexp = new RegExp("[^a-zA-Z]");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks content is only uppercase letters
function isUppercaseLetters( str ) {
	var myregexp = new RegExp("[^A-Z]");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks content is only uppercase letters or spaces
function isUppercaseLettersOrSpaces( str ) {
	var myregexp = new RegExp("[^A-Z] ");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks content is only numbers and lowercase letters
function isNumbersAndLowercaseLetters( str ) {
	var myregexp = new RegExp("[^a-z0-9]");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks content is only numbers and letters
function isNumbersAndLetters( str ) {
	var myregexp = new RegExp("[^a-zA-Z0-9]");
	if (str.match(myregexp)) {
		return true;
	}
	return false;
}

//checks content is only numbers
function isPhoneNumber( str ) {
	if (str.match(/[^0-9+() ]/)) {
		return true;
	}
	return false;
}

//checks content is only numbers
function isNumbers( str ) {
	if (str.match(/[^0-9]/)) {
		return true;
	}
	return false;
}

//checks if box is ticked
function notChecked( box ){
    if( box.checked ){
        return false;
    }
    else{
        return true;
    }
}

function checkMultiEmailPicker( form ){
    if( isEmpty( form.pp_id ) ){
        alert('You need to choose a property...' );
        return false;
    }
    return true;
}

function checkForgetPropertyHistory( form ){
    if( isEmpty( form.pp_id ) ){
        alert('You need to choose a property...' );
        return false;
    }
    return true;
}

function checkForgetProspectHistory( form ){
    if( isEmpty( form.p_id ) ){
        alert('You need to choose a prospect...' );
        return false;
    }
    return true;
}

function checkProspectEdit( form ){
    if( isEmpty( form.pros_email ) ){
        alert('Please enter an email address (field blank)' );
        return false;
    }
    if( notValidEmail( form.pros_email ) ){
        alert('Please enter a VALID email address' );
        return false;
    }
    if( isEmpty( form.pros_name ) ){
        alert('Please enter the first name.' );
        return false;
    }
    if( isEmpty( form.pros_surname ) ){
        alert('(Please enter the surname.' );
        return false;
    }
//    if (isValidDate( form.pros_expires.value,'/')) {
//    }
//    else {
//        alert('\'expires\' date should be a valid date, numbers and slashes as dd/mm/yyyy.' );
//        form.pros_expires.focus();
//        return false;
//    }
    return true;
}

function checkProspect( form , userlang){

	if (userlang == "fr") {
		var errormessage_pros_email1 = "Sorry, but you need to tell us your email address so we can keep you informed.";
		var errormessage_pros_email2 = "Sorry, but you need to give us a valid email address so we can keep you informed.";
		var errormessage_pros_name = "Sorry, but you need to give us your first name.";
		var errormessage_pros_surname = "Sorry, but you need to give us your surname.";
		var errormessage_pros_min = "Sorry, but you need to tell us your minimum budget.";
		var errormessage_pros_max = "Sorry, but you need to tell us your maximum budget.";
		var errormessage_pros_minmax = "Sorry, but your minimum budget cannot be greater than or equal to your maximum.";
		var errormessage_pros_loc = "Sorry, but you need to tell us at least one location that interests you.";
		var errormessage_pros_type = "Sorry, but you need to tell us at least one type of property you are looking for.";
	} else {
		var errormessage_pros_email1 = "Sorry, but you need to tell us your email address so we can keep you informed.";
		var errormessage_pros_email2 = "Sorry, but you need to give us a valid email address so we can keep you informed.";
		var errormessage_pros_name = "Sorry, but you need to give us your first name.";
		var errormessage_pros_surname = "Sorry, but you need to give us your surname.";
		var errormessage_pros_min = "Sorry, but you need to tell us your minimum budget.";
		var errormessage_pros_max = "Sorry, but you need to tell us your maximum budget.";
		var errormessage_pros_minmax = "Sorry, but your minimum budget cannot be greater than or equal to your maximum.";
		var errormessage_pros_loc = "Sorry, but you need to tell us at least one location that interests you.";
		var errormessage_pros_type = "Sorry, but you need to tell us at least one type of property you are looking for.";
	}

    if (form.pros_email) {
    	if( isEmpty( form.pros_email ) ){
    	    alert(errormessage_pros_email1);
    	    return false;
    	}
    	if( notValidEmail( form.pros_email ) ){
    	    alert(errormessage_pros_email2);
    	    return false;
    	}
    }
    if( isEmpty( form.pros_name ) ) {  alert(errormessage_pros_name);return false;}
    if( isEmpty( form.pros_surname ) ){alert(errormessage_pros_surname);return false;}
    if( isEmpty( form.pros_min ) ){ alert(errormessage_pros_min);return false;}
    if( isEmpty( form.pros_max ) ){alert(errormessage_pros_max);return false;}
    if ( (form.pros_max.value - form.pros_min.value) < 0 ) {alert(errormessage_pros_minmax);return false;}

    // loc_refs contains reference for fields pros_loc_X where at least one must be checked
    var loc_checked = false;
    // retrieve values, split them an check each one
    var loc_refs_str = MM_findObj("loc_refs").value;
    // split them
    var loc_refs = loc_refs_str.split(",");
    // check each one
    for (i=0; i<(loc_refs.length);i++) {
		if( MM_findObj("pros_loc_"+loc_refs[i]).checked ){
			var loc_checked = true;
		}
    }
    if (loc_checked){}
    else {alert(errormessage_pros_loc);return false;}

    if ( (notChecked(form.pros_type1)) && (notChecked(form.pros_type2)) && (notChecked(form.pros_type3)) && (notChecked(form.pros_type4)) && (notChecked(form.pros_type5)) ){
        alert(errormessage_pros_type);return false;
    }
    return true;
}

function checkRegiInfo( form ){
    if( isEmpty( form.regi_name ) ){
        alert('area name cannot be blank.' );
        return false;
    }
    return true;
}

function checkPropInfo( form ){
    if( isEmpty( form.prop_name ) ){
        alert('please specify the name of the property.' );
        form.prop_name.focus();
        return false;
    }
    if( isEmpty( form.prop_agent ) ){
        alert('please specify the agent for this property.' );
        form.prop_agent.focus();
        return false;
    }
    if( isEmpty( form.prop_price ) ){
        alert('price cannot be blank.' );
        form.prop_price.focus();
        return false;
    }
    if( isNumbers( form.prop_price.value ) ){
        alert('price must be a number.' );
        form.prop_price.focus();
        return false;
    }
    if( isEmpty( form.prop_type ) ){
        alert('type cannot be blank.' );
        form.prop_type.focus();
        return false;
    }
    if( isEmpty( form.prop_floorarea ) ){
        alert('floor area cannot be blank (set to zero if not known)' );
        form.prop_floorarea.focus();
        return false;
    }
    if( isNumbers( form.prop_floorarea.value ) ){
        alert('floor area must be a number.' );
        return false;
    }
    if( isEmpty( form.prop_landarea ) ){
        alert('land area cannot be blank (set to zero if not known)' );
        return false;
    }
    if( isNumbers( form.prop_landarea.value ) ){
        alert('land area must be a number.' );
        form.prop_landarea.focus();
        return false;
    }
    if( isEmpty( form.prop_nearestskiing ) ){
        alert('nearest skiing cannot be blank (set to zero if not known)' );
        return false;
    }
    if( isNumbers( form.prop_nearestskiing.value ) ){
        alert('nearest skiing must be a number.' );
        form.prop_nearestskiing.focus();
        return false;
    }
    if( isEmpty( form.prop_nearestshops ) ){
        alert('nearest shops cannot be blank (set to zero if not known)' );
        form.prop_nearestshops.focus();
        return false;
    }
    if( isNumbers( form.prop_nearestshops.value ) ){
        alert('nearest shops must be a number.' );
        form.prop_nearestshops.focus();
        return false;
    }
    if( isEmpty( form.prop_taxes ) ){
        alert('taxes cannot be blank (set to zero if not known)' );
        form.prop_taxes.focus();
        return false;
    }
    if( isNumbers( form.prop_taxes.value ) ){
        alert('taxes must be a number' );
        form.prop_taxes.focus();
        return false;
    }
    if( isEmpty( form.prop_brief_en ) ){
        alert('english brief cannot be blank' );
        form.prop_brief_en.focus();
        return false;
    }
    return true;
}

function submitEventId( form ){
    if( isEmpty( form.event_id ) ){
        alert('please choose an event..' );
        return false;
    }
    return true;
}

function submitNewEvent( form ){
	if( form.event_time.value == '00:00' ) {
		alert('Please enter the time of the event as hh:mm' );
		form.event_time.focus();
		return false;
	}
	if( form.event_vendor.value == 0 ) {
		if( form.event_prospect.value == 0 ) {
			if( form.event_property_1.value == 0 ) {
				if( form.event_agent_assigned.value == 0 ) {
					alert('please select at least one (assigned agent, vendor, prospect or property).' );
					return false;
				}
			}
		}
	}
	if( form.event_method.value == 0 ) {
		alert('please select the method' );
		form.event_method.focus();
		return false;
	}
	if( form.event_subject.value == 0 ) {
		alert('please select the subject' );
		form.event_subject.focus();
		return false;
	}
	return true;
}

function submitVendorId( form ){
    if( isEmpty( form.vendor_id ) ){
        alert('please choose a vendor..' );
        return false;
    }
    return true;
}

function submitNewVendor( form ){
	// if not empty and vendor_email is valid
	if( isEmpty( form.vendor_email ) ){}
	else {
		if( notValidEmail( form.vendor_email ) ){
			alert('please enter a valid email address..' );
			form.vendor_email.focus();
			return false;
		}
	}

	if( isEmpty( form.vendor_name ) ){
		alert('Please enter the first name.' );
		form.vendor_name.focus();
		return false;
	}

	if( isEmpty( form.vendor_surname ) ){
		alert('Please enter the surname.' );
		form.vendor_surname.focus();
		return false;
	}

	if( isEmpty( form.vendor_full_name ) ){
		alert('Please enter the full_name.' );
		form.vendor_full_name.focus();
		return false;
	}

	var phonemsg = '\nfor example:\n +33 (0)1 23456789 for a French number\n +44 (0)123 456789 for a UK number\n\n..allowed characters are : +0123456789() and spaces\n\nnote: if you do not have any phone numbers for this entry\nyou can enter ten zeros 0000000000 in the home number field.\nThe field will then appear highlighted in red to remind you to update it later';

	// one of these 3 must be completed
	if( form.vendor_hometel.value.length < 10 ){
		if( form.vendor_worktel.value.length < 10 ){
			if( form.vendor_mobtel.value.length < 10 ){
				alert('Please enter at least one phone number' + phonemsg );
				form.vendor_hometel.focus();
				return false;
			}
			else {
			    if( isPhoneNumber( form.vendor_mobtel.value ) ){
				alert('Please enter the mobile number' + phonemsg );
				form.vendor_mobtel.focus();
				return false;
			    }
			}
		}
		else {
		    if( isPhoneNumber( form.vendor_worktel.value ) ){
			alert('Please enter the work number' + phonemsg );
			form.vendor_worktel.focus();
			return false;
		    }
		}
	}
	else {
	    if( isPhoneNumber( form.vendor_hometel.value ) ){
		alert('Please enter the home number' + phonemsg );
		form.vendor_hometel.focus();
		return false;
	    }
	}

	// vendor_lang length = 2
	if( isEmpty( form.vendor_lang ) ){
		alert('Please enter the principal language spoken' );
		form.vendor_lang.focus();
		return false;
	}

	// vendor_address1 length > 0
	if( isEmpty( form.vendor_address1 ) ){
		alert('Please complete the first line of the address (at least the first two lines must be completed).' );
		form.vendor_address1.focus();
		return false;
	}

	if( isEmpty( form.vendor_address2 ) ){
		alert('Please complete the second line of the address (at least the first two lines must be completed).' );
		form.vendor_address2.focus();
		return false;
	}

	// vendor_postcode length > 0
	if( isEmpty( form.vendor_postcode ) ){
		alert('Please enter the postcode.' );
		form.vendor_postcode.focus();
		return false;
	}

	// vendor_country length = 2
	if( isEmpty( form.vendor_country ) ){
		alert('Please select the country of residence.' );
		form.vendor_country.focus();
		return false;
	}
	return true;
}

function submitBuyerId( form ){
    if( isEmpty( form.buyer_id ) ){
        alert('please choose a buyer..' );
        return false;
    }
    return true;
}

function submitNewBuyer( form ){
	// if not empty and buyer_email is valid
	if( isEmpty( form.buyer_email ) ){}
	else {
		if( notValidEmail( form.buyer_email ) ){
			alert('Please enter a valid email address..' );
			form.buyer_email.focus();
			return false;
		}
	}

	if( isEmpty( form.buyer_name ) ){
		alert('Please enter the first name.' );
		form.buyer_name.focus();
		return false;
	}

	if( isEmpty( form.buyer_surname ) ){
		alert('Please enter the surname.' );
		form.buyer_surname.focus();
		return false;
	}

	if( isEmpty( form.buyer_full_name ) ){
		alert('Please enter the full_name.' );
		form.buyer_full_name.focus();
		return false;
	}

	var phonemsg = '\nfor example:\n +33 (0)1 23456789 for a French number\n +44 (0)123 456789 for a UK number\n\n..allowed characters are : +0123456789() and spaces\n\nnote: if you do not have any phone numbers for this entry\nyou can enter ten zeros 0000000000 in the home number field.\nThe field will then appear highlighted in red to remind you to update it later';

	// one of these 3 must be completed
	if( form.buyer_hometel.value.length < 10 ){
		if( form.buyer_worktel.value.length < 10 ){
			if( form.buyer_mobtel.value.length < 10 ){
				alert('Please enter at least one phone number' + phonemsg );
				form.buyer_hometel.focus();
				return false;
			}
			else {
			    if( isPhoneNumber( form.buyer_mobtel.value ) ){
				alert('Please enter the mobile number' + phonemsg );
				form.buyer_mobtel.focus();
				return false;
			    }
			}
		}
		else {
		    if( isPhoneNumber( form.buyer_worktel.value ) ){
			alert('Please enter the work number' + phonemsg );
			form.buyer_worktel.focus();
			return false;
		    }
		}
	}
	else {
	    if( isPhoneNumber( form.buyer_hometel.value ) ){
		alert('Please enter the home number' + phonemsg );
		form.buyer_hometel.focus();
		return false;
	    }
	}

	// buyer_lang length = 2
	if( isEmpty( form.buyer_lang ) ){
		alert('Please enter the principal language spoken.' );
		form.buyer_lang.focus();
		return false;
	}

	// buyer_address1 length > 0
	if( isEmpty( form.buyer_address1 ) ){
		alert('Please complete the first line of the address (at least the first two lines must be completed).' );
		form.buyer_address1.focus();
		return false;
	}

	if( isEmpty( form.buyer_address2 ) ){
		alert('Please complete the second line of the address (at least the first two lines must be completed).' );
		form.buyer_address2.focus();
		return false;
	}

	// buyer_postcode length > 0
	if( isEmpty( form.buyer_postcode ) ){
		alert('Please enter the postcode.' );
		form.buyer_postcode.focus();
		return false;
	}

	// buyer_country length = 2
	if( isEmpty( form.buyer_country ) ){
		alert('Please select the country of residence.' );
		form.buyer_country.focus();
		return false;
	}
	return true;
}


function submitMandateId( form ){
    if( (form.mandate_id.value == 0) ){
        alert('please choose a mandate..' );
        return false;
    }
    if( isEmpty( form.mandate_id ) ){
        alert('please choose a mandate..' );
        return false;
    }
    return true;
}

function submitNewMandate( form ) {
	if( form.mandate_id.value == 0 ) {
		alert('Please enter the mandate number as it appears on the top right of the hardcopy.');
		form.mandate_id.focus();
		return false;
	}
	if( form.mandate_agent.value == 0 ) {
		alert('Please specify the agent (creator)' );
		form.mandate_agent.focus();
		return false;
	}
	if( (form.mandate_type.value == 0) ){
		alert('Please select the mandate type.' );
		form.mandate_type.focus();
		return false;
	}
	if( (form.mandate_type.value == 1) ){
		if( (form.mandate_vendor_1.value == 0) ){
			alert('Please indicate the vendor.' );
			form.mandate_vendor_1.focus();
			return false;
		}
		if (form.mandate_vendor_2.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_2.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_2.focus();return false;}
		}
		if (form.mandate_vendor_2.value == 0) {
			if (form.mandate_vendor_3.value > 0  ||  form.mandate_vendor_4.value > 0  ||  form.mandate_vendor_5.value > 0  ) {
				alert('You cannot select the next vendor when the previous is blank...' );
				form.mandate_vendor_2.focus();return false;
			}
		}
		if (form.mandate_vendor_3.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_3.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_3.focus();return false;}
			if (form.mandate_vendor_2.value === form.mandate_vendor_3.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_3.focus();return false;}
		}
		if (form.mandate_vendor_3.value == 0) {
			if (form.mandate_vendor_4.value > 0  ||  form.mandate_vendor_5.value > 0  ) {
				alert('You cannot select the next vendor when the previous is blank...' );
				form.mandate_vendor_3.focus();return false;
			}
		}
		if (form.mandate_vendor_4.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_4.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_4.focus();return false;}
			if (form.mandate_vendor_2.value === form.mandate_vendor_4.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_4.focus();return false;}
			if (form.mandate_vendor_3.value === form.mandate_vendor_4.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_4.focus();return false;}
		}
		if (form.mandate_vendor_4.value == 0) {
			if (form.mandate_vendor_5.value > 0) {
				alert('You cannot select the next vendor when the previous is blank...' );
				form.mandate_vendor_4.focus();
				return false;
			}
		}
		if (form.mandate_vendor_5.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
			if (form.mandate_vendor_2.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
			if (form.mandate_vendor_3.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
			if (form.mandate_vendor_4.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
		}
	}
	if( (form.mandate_type.value == 2) ){
		if( (form.mandate_vendor_1.value == 0) ){
			alert('Please indicate the vendor, (buyer is optional).' );
			form.mandate_vendor_1.focus();
			return false;
		}
		if (form.mandate_vendor_2.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_2.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_2.focus();return false;}
		}
		if (form.mandate_vendor_2.value == 0) {
			if (form.mandate_vendor_3.value > 0  ||  form.mandate_vendor_4.value > 0  ||  form.mandate_vendor_5.value > 0  ) {
				alert('You cannot select the next vendor when the previous is blank...' );
				form.mandate_vendor_2.focus();return false;
			}
		}
		if (form.mandate_vendor_3.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_3.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_3.focus();return false;}
			if (form.mandate_vendor_2.value === form.mandate_vendor_3.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_3.focus();return false;}
		}
		if (form.mandate_vendor_3.value == 0) {
			if (form.mandate_vendor_4.value > 0  ||  form.mandate_vendor_5.value > 0  ) {
				alert('You cannot select the next vendor when the previous is blank...' );
				form.mandate_vendor_3.focus();return false;
			}
		}
		if (form.mandate_vendor_4.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_4.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_4.focus();return false;}
			if (form.mandate_vendor_2.value === form.mandate_vendor_4.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_4.focus();return false;}
			if (form.mandate_vendor_3.value === form.mandate_vendor_4.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_4.focus();return false;}
		}
		if (form.mandate_vendor_4.value == 0) {
			if (form.mandate_vendor_5.value > 0) {
				alert('You cannot select the next vendor when the previous is blank...' );
				form.mandate_vendor_4.focus();
				return false;
			}
		}
		if (form.mandate_vendor_5.value > 0) {
			if (form.mandate_vendor_1.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
			if (form.mandate_vendor_2.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
			if (form.mandate_vendor_3.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
			if (form.mandate_vendor_4.value === form.mandate_vendor_5.value) {alert('Sorry, you cannot enter the same vendor twice...' );form.mandate_vendor_5.focus();return false;}
		}

		if (form.mandate_buyer_1.value > 0) {
			if (form.mandate_buyer_2.value > 0) {
				if (form.mandate_buyer_1.value === form.mandate_buyer_2.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_2.focus();return false;}
			}
			if (form.mandate_buyer_2.value == 0) {
				if (form.mandate_buyer_3.value > 0  ||  form.mandate_buyer_4.value > 0  ||  form.mandate_buyer_5.value > 0  ) {
					alert('You cannot select the next buyer when the previous is blank...' );
					form.mandate_buyer_2.focus();return false;
				}
			}
			if (form.mandate_buyer_3.value > 0) {
				if (form.mandate_buyer_1.value === form.mandate_buyer_3.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_3.focus();return false;}
				if (form.mandate_buyer_2.value === form.mandate_buyer_3.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_3.focus();return false;}
			}
			if (form.mandate_buyer_3.value == 0) {
				if (form.mandate_buyer_4.value > 0  ||  form.mandate_buyer_5.value > 0  ) {
					alert('You cannot select the next buyer when the previous is blank...' );
					form.mandate_buyer_2.focus();return false;
				}
			}
			if (form.mandate_buyer_4.value > 0) {
				if (form.mandate_buyer_1.value === form.mandate_buyer_4.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_4.focus();return false;}
				if (form.mandate_buyer_2.value === form.mandate_buyer_4.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_4.focus();return false;}
				if (form.mandate_buyer_3.value === form.mandate_buyer_4.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_4.focus();return false;}
			}
			if (form.mandate_buyer_4.value == 0) {
				if (form.mandate_buyer_5.value > 0) {
					alert('You cannot select the next buyer when the previous is blank...' );
					form.mandate_buyer_4.focus();return false;
				}
			}
			if (form.mandate_buyer_5.value > 0) {
				if (form.mandate_buyer_1.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
				if (form.mandate_buyer_2.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
				if (form.mandate_buyer_3.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
				if (form.mandate_buyer_4.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
			}
		}
	}
	if( (form.mandate_type.value == 3) ){
		if( (form.mandate_buyer_1.value == 0) ){
			alert('Please indicate the buyer.' );
			form.mandate_buyer_1.focus();
			return false;
		}
		if (form.mandate_buyer_2.value > 0) {
			if (form.mandate_buyer_1.value === form.mandate_buyer_2.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_2.focus();return false;}
		}
		if (form.mandate_buyer_2.value == 0) {
			if (form.mandate_buyer_3.value > 0  ||  form.mandate_buyer_4.value > 0  ||  form.mandate_buyer_5.value > 0  ) {
				alert('You cannot select the next buyer when the previous is blank...' );
				form.mandate_buyer_2.focus();return false;
			}
		}
		if (form.mandate_buyer_3.value > 0) {
			if (form.mandate_buyer_1.value === form.mandate_buyer_3.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_3.focus();return false;}
			if (form.mandate_buyer_2.value === form.mandate_buyer_3.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_3.focus();return false;}
		}
		if (form.mandate_buyer_3.value == 0) {
			if (form.mandate_buyer_4.value > 0  ||  form.mandate_buyer_5.value > 0  ) {
				alert('You cannot select the next buyer when the previous is blank...' );
				form.mandate_buyer_3.focus();return false;
			}
		}
		if (form.mandate_buyer_4.value > 0) {
			if (form.mandate_buyer_1.value === form.mandate_buyer_4.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_4.focus();return false;}
			if (form.mandate_buyer_2.value === form.mandate_buyer_4.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_4.focus();return false;}
			if (form.mandate_buyer_3.value === form.mandate_buyer_4.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_4.focus();return false;}
		}
		if (form.mandate_buyer_4.value == 0) {
			if (form.mandate_buyer_5.value > 0) {
				alert('You cannot select the next buyer when the previous is blank...' );
				form.mandate_buyer_4.focus();
				return false;
			}
		}
		if (form.mandate_buyer_5.value > 0) {
			if (form.mandate_buyer_1.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
			if (form.mandate_buyer_2.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
			if (form.mandate_buyer_3.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
			if (form.mandate_buyer_4.value === form.mandate_buyer_5.value) {alert('Sorry, you cannot enter the same buyer twice...' );form.mandate_buyer_5.focus();return false;}
		}

	}
	if( isEmpty( form.mandate_title ) ){
		alert('Please enter the title.' );
		form.mandate_title.focus();
		return false;
	}

	if( isEmpty( form.mandate_price ) && notChecked(form.mandate_price_grille) ){
		alert('Please EITHER enter the price (no spaces or decimals) \nOR leave it as 0 and tick the checkbox for `Prix selon grille`.\n\n(error - no price or checkbox)' );
		form.mandate_price.focus();
		return false;
	}
	else {
		if( notChecked(form.mandate_price_grille) ){
			if( (form.mandate_price.value == 0) ){
				alert('Please EITHER enter the price (no spaces or decimals) \nOR leave it as 0 and tick the checkbox for `Prix selon grille` (not both).\n\n(error - no checkbox and no price (price is 0)' );
				form.mandate_price.focus();
				return false;
			}
			if( isNumbers( form.mandate_price.value ) ){
				alert('Please EITHER enter the price (no spaces or decimals) \nOR leave it as 0 and tick the checkbox for `Prix selon grille` (not both).\n\n(error - no checkbox, but price is not just numbers)' );
				form.mandate_price.focus();
				return false;
			}
		}
		else {
			if( (form.mandate_price.value != 0 ) ){
				alert('Please EITHER enter the price (no spaces or decimals) \nOR leave it as 0 and tick the checkbox for `Prix selon grille` (not both).\n\n(error - checkbox, but price is not 0)' );
				form.mandate_price.focus();
				return false;
			}
		}
	}

	if( (form.mandate_commission_rate.value == 0) ){
		if( (form.mandate_commission_fixed.value == 0) ){
			alert('Please enter the commission (EITHER percentage OR fixed, not both)' );
			form.mandate_commission_rate.focus();
			return false;
		}
	}

	if( (form.mandate_commission_rate.value > 0) ){
		if( (form.mandate_commission_fixed.value > 0) ){
			alert('Please enter the commission (EITHER percentage OR fixed, not both)' );
			form.mandate_commission_rate.focus();
			return false;
		}
	}

	if( (form.mandate_p1_months.value == 0) ){
		alert('Please indicate the number of months for period A.' );
		form.mandate_p1_months.focus();
		return false;
	}

	if( isEmpty( form.mandate_place_signed ) ){
		alert('Please enter the place of signature.' );
		form.mandate_place_signed.focus();
		return false;
	}
	else if (form.mandate_place_signed.length == 0) {
		alert('Please enter the place of signature.' );
		form.mandate_place_signed.focus();
		return false;
	}
	else {
		return true;
	}

}

function submitProsId( form ){
    if( isEmpty( form.pros_id ) ){
        alert('please choose a prospect..' );
        return false;
    }
    return true;
}

function submitPropId( form ){
    if( isEmpty( form.prop_id ) ){
        alert('please choose a property..' );
        return false;
    }
    return true;
}

function checkClientLogIn( form, msg1, msg2, msg3 ){
    if( isEmpty( form.pros_em ) ){
        alert(msg1);
        form.pros_em.focus();
        return false;
    }
    if( notValidEmail( form.pros_em ) ){
        alert(msg1);
        form.pros_em.focus();
        return false;
    }
    if( isEmpty( form.pros_pw ) ){
        alert(msg2);
        form.pros_pw.focus();
        return false;
    }
    if ( form.captcha_input != null) {
    	if( isEmpty( form.captcha_input ) ){
        	alert(msg3);
        	form.captcha_input.focus();
        	return false;
        }
    }
    return true;
}

function checkLogIn( form ){
    if( isEmpty( form.user_em ) ){
        alert('please enter your email address..' );
        form.user_em.focus();
        return false;
    }
    if( notValidEmail( form.user_em ) ){
        alert('please enter your email address..' );
        form.user_em.focus();
        return false;
    }
    if( isEmpty( form.key ) ){
        alert('please enter your password..' );
        form.key.focus();
        return false;
    }
    return true;
}

//check file is selected
//check filename
function checkUploadJPG( form ){
    if( isEmpty( form.userfile ) ){
    	if (form.filename1.value == form.filename2.value){
    		alert( 'please browse to the file to upload (' + form.filename1.value + ')');
    	}
        else {
        	alert( 'please browse to the file to upload (' + form.filename1.value + ' or ' + form.filename2.value + ')');
        }
        form.userfile.focus();
        return false;
    }
    if (form.filename1.value == form.filename2.value){
	    var str = form.userfile.value;
		var pos = str.lastIndexOf(form.filename1.value);
		if (pos == -1) {
			alert( 'the filename must be ' + form.filename1.value);
			return false;
		}
    }
    if (form.filename1.value != form.filename2.value){
	    var str = form.userfile.value;
		var pos = str.lastIndexOf(form.filename1.value);
		var pos2 = str.lastIndexOf(form.filename2.value);
		if ((pos == -1) && (pos2 == -1)) {
			alert( 'the filename must be ' + form.filename1.value + ' or ' + form.filename2.value);
			return false;
		}
    }
    return true;
}

function checkProspectSendMany( form ){
    if( isEmpty( form.mail_message ) ){
        alert('message cannot be blank.' );
        return false;
    }
    if( isEmpty( form.mail_subject ) ){
        alert('subject cannot be blank.' );
        return false;
    }
    return true;
}

// TODO find way to validate all fields are not empty

function checkProspectSendOne( form ){
	if( notValidEmail( form.mail_to ) ){
		alert('\'To\' value is not a valid email address..' );
		form.mail_cc.focus();
		return false;
	}
    if( isEmpty( form.mail_message ) ){
        alert('message cannot be blank.' );
        return false;
    }
    if( isEmpty( form.mail_subject ) ){
        alert('subject cannot be blank.' );
        return false;
    }
    return true;
}

function checkUpdateMeta( form ){
    if( isEmpty( form.meta_t) ){
        alert('meta title cannot be blank.' );
        return false;
    }
    if( isEmpty( form.meta_d ) ){
        alert('meta description cannot be blank.' );
        return false;
    }
    if( isEmpty( form.meta_k ) ){
        alert('meta keywords cannot be blank.' );
        return false;
    }
    return true;
}

function checkUpdateLanguage( form ){
    if( isEmpty( form.tran_id ) ){
        alert('id cannot be blank.' );
        return false;
    }
    if( isEmpty( form.tran_en ) ){
        alert('english translation cannot be blank.' );
        return false;
    }
    if( isEmpty( form.tran_fr ) ){
        alert('french translation cannot be blank.' );
        return false;
    }
//    if( isEmpty( form.tran_ne ) ){
//        alert('nederlands translation cannot be blank.' );
//        return false;
//    }
    return true;
}

function checkSendMessageEN( form ){
    if( notValidEmail( form.sender ) ){
        alert('Please enter your email address, so we can reply to you.' );
        form.sender.focus();
        return false;
    }
    if( isEmpty( form.message ) ){
    	alert('Please enter your message.');
        form.message.focus();
        return false;
    }
    return true;
}

function checkSendMessageFR( form ){
    if( notValidEmail( form.sender ) ){
        alert('(fr)Please enter your email address, so we can reply to you.' );
        form.sender.focus();
        return false;
    }
    if( isEmpty( form.message ) ){
    	alert('(fr)Please enter your message.');
        form.message.focus();
        return false;
    }
    return true;
}

function checkDeleteGlossary( form ){
    if( isEmpty( form.glossary_id ) ){
        alert('please choose an entry to delete.' );
        return false;
    }
    return true;
}

function checkDeleteToDo( form ){
    if( isEmpty( form.todo_id ) ){
        alert('please choose an action to delete.' );
        return false;
    }
    return true;
}

function checkDeleteFAQ( form ){
    if( isEmpty( form.faq_id ) ){
        alert('please choose an entry to delete.' );
        return false;
    }
    return true;
}

function checkAddGlossary( form ){
    if( isEmpty( form.glossary_ref ) ){
        alert('new entry cannot be blank.' );
        return false;
    }
    return true;
}

function checkAddToDo( form ){
    if( isEmpty( form.todo_description ) ){
        alert('new description cannot be blank.' );
        return false;
    }
    if( isEmpty( form.todo_user ) ){
        alert('please choose a name' );
        return false;
    }
    return true;
}

function checkAddFAQ( form ){
    if( isEmpty( form.faq_q_en ) ){
        alert('please enter a new english question.' );
        return false;
    }
    return true;
}

function checkUpdateGlossary( form ){
    if( isEmpty( form.todo_description ) ){
        alert('new description cannot be blank.' );
        return false;
    }
    return true;
}

function checkUpdateToDo( form ){
    if( isEmpty( form.todo_user ) ){
        alert('you need to choose a person cannot be blank.' );
        return false;
    }
    if( isEmpty( form.glossary_en ) ){
        alert('english explanation cannot be blank - please enter (en) if you don\'t have one yet.' );
        return false;
    }
    return true;
}

function checkUpdateFAQ( form ){
    if( isEmpty( form.faq_id ) ){
        alert('entry cannot be blank.' );
        return false;
    }
    if( isEmpty( form.faq_q_en ) ){
        alert('english question cannot be blank - please enter (en) if you don\'t have one yet.' );
        return false;
    }
    if( isEmpty( form.faq_a_en ) ){
        alert('english answer cannot be blank - please enter (en) if you don\'t have one yet.' );
        return false;
    }
    if( isEmpty( form.faq_q_fr ) ){
        alert('french question cannot be blank - please enter (fr) if you don\'t have one yet.' );
        return false;
    }
    if( isEmpty( form.faq_a_fr ) ){
        alert('french answer cannot be blank - please enter (fr) if you don\'t have one yet.' );
        return false;
    }
    return true;
}

function checkAddProp( form ){
    if( isEmpty( form.prop_ref ) ){
        alert('reference cannot be blank.' );
        return false;
    }
    if( isNumbersAndLowercaseLetters( form.prop_ref.value ) ){
        alert('reference must be composed of numbers 0-9 and/or lowercase letters a-z' );
        return false;
    }
    if ((form.prop_ref.value.length < 3) || (form.prop_ref.value.length > 20)){
        alert('reference length must be between 3 and 20 characters long' );
        return false;
    }
    if( (form.prop_mandate.value == 0) ){
    	alert('Please select the mandate.' );
	form.prop_mandate.focus();
	return false;
    }
    return true;
}

// TABLE 1A

// USER INPUTS
// cc1_purchaseprice_lessthan5
// cc1_loan_lessthan5
// CALCULATIONS
// cc1_calc_feesduty4purchase_lessthan5
// cc1_calc_feesduty4loan_lessthan5
// cc1_calc_feesduty_lessthan5
// cc1_calc_feesdutypercentage_lessthan5
// HIDDEN
// cc1_droitsdenregistrement_lessthan5
// cc1_honorairesfixed
// cc1_tva
// cc1_fraisfixe

function calculate_ap_cc_1_lessthan5(form) {
	var calc_errors = 0;
	if (document.ap_cc_1.cc1_purchaseprice_lessthan5.value === 0) {alert('purchase price?');return false;calc_errors++;}
	//if (document.ap_cc_1.cc1_loan_lessthan5.value === 0) {alert('loan?');return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_1.cc1_purchaseprice_lessthan5.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	//if (!parseFloat(document.ap_cc_1.cc1_loan_lessthan5.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (calc_errors == 0) {
		// (a) Honoraires de Notaire - variables
			//	Math.round(429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825)
//			alert('honoraires de notaire (variable) : ' + Math.round(429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825));
		// (b) TVA
			//	Math.Round(429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value));
//			//alert('tva : ' + Math.Round(429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)));
		// (c) Honoraires de Notaire - fixed
			// honoraires_fixed = parseFloat(document.ap_cc_1.cc1_honorairesfixed.value);
//			alert('honoraires de notaire (fixed) : ' + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value));
		// (d) Droits d'enregistrement
			// (document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value);
//			alert('droits d\'enregistrement : ' + Math.round(document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value));
		// (e) Fees and taxes paid to the Notaire on the purchase
				document.ap_cc_1.cc1_calc_feesduty4purchase_lessthan5.value = Math.round(429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value);
		// (f) Taxe
			// Math.round(document.ap_cc_1.cc1_loan_lessthan5.value * 0.00615)
//				alert('taxe : ' + Math.round(document.ap_cc_1.cc1_loan_lessthan5.value * 0.00615));
		// (g) Notaire
			// Math.round(337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769 ) * 0.0055)
//				alert('notaire : ' + Math.round(337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) );
		// (h) TVA
			// ( taxe + notaire )*0,196
			// Math.round(((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value))
//				alert('tva : ' + Math.round(((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) );
		// (i) Frais fixe
				// parseFloat(document.ap_cc_1.cc1_fraisfixe.value)
		// (j) Fees and taxes paid to the Notaire for the loan
				if (parseFloat(document.ap_cc_1.cc1_loan_lessthan5.value) > 0) {document.ap_cc_1.cc1_calc_feesduty4loan_lessthan5.value = Math.round((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + (((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value));}
				else {document.ap_cc_1.cc1_calc_feesduty4loan_lessthan5.value = 0;}

		// (k) Total Frais
			// j + e
				if (parseFloat(document.ap_cc_1.cc1_loan_lessthan5.value) > 0) {document.ap_cc_1.cc1_calc_feesduty_lessthan5.value = Math.round( ((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + (((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) + (429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value) );}
				else {document.ap_cc_1.cc1_calc_feesduty_lessthan5.value = Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value));}

		// (l) % of price
			// k / purchase_price
				if (parseFloat(document.ap_cc_1.cc1_loan_lessthan5.value) > 0) {document.ap_cc_1.cc1_calc_feesdutypercentage_lessthan5.value = Math.round((((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + (((337 + (document.ap_cc_1.cc1_loan_lessthan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) + (429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value)) / parseFloat(document.ap_cc_1.cc1_purchaseprice_lessthan5.value) * 100);}
				else {document.ap_cc_1.cc1_calc_feesdutypercentage_lessthan5.value = Math.round(((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_lessthan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_lessthan5.value * document.ap_cc_1.cc1_droitsdenregistrement_lessthan5.value)) / parseFloat(document.ap_cc_1.cc1_purchaseprice_lessthan5.value) * 100);}
	}
    	return null;
}

// TABLE 1B

// USER INPUTS
// cc1_purchaseprice_morethan5
// cc1_loan_morethan5
// CALCULATIONS
// cc1_calc_feesduty4purchase_morethan5
// cc1_calc_feesduty4loan_morethan5
// cc1_calc_feesduty_morethan5
// cc1_calc_feesdutypercentage_morethan5
// HIDDEN
// cc1_droitsdenregistrement_morethan5
// cc1_honorairesfixed
// cc1_tva

function calculate_ap_cc_1_morethan5(form) {
	var calc_errors = 0;
	if (document.ap_cc_1.cc1_purchaseprice_morethan5.value === 0) {alert('purchase price?');return false;calc_errors++;}
	//if (document.ap_cc_1.cc1_loan_morethan5.value === 0) {alert('loan?');return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_1.cc1_purchaseprice_morethan5.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	//if (!parseFloat(document.ap_cc_1.cc1_loan_morethan5.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (calc_errors == 0) {
		// (a) Honoraires de Notaire - variables
			//	Math.round(429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825)
//			alert('honoraires de notaire (variable) : ' + Math.round(429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825));
		// (b) TVA
			//	Math.Round(429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value));
//			//alert('tva : ' + Math.Round(429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)));
		// (c) Honoraires de Notaire - fixed
			// honoraires_fixed = parseFloat(document.ap_cc_1.cc1_honorairesfixed.value);
//			alert('honoraires de notaire (fixed) : ' + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value));
		// (d) Droits d'enregistrement
			// (document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value);
//			alert('droits d\'enregistrement : ' + Math.round(document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value));
		// (e) Fees and taxes paid to the Notaire on the purchase
				document.ap_cc_1.cc1_calc_feesduty4purchase_morethan5.value = Math.round(429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value);
		// (f) Taxe
			// Math.round(document.ap_cc_1.cc1_loan_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value)
//				alert('taxe : ' + Math.round(document.ap_cc_1.cc1_loan_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value));
		// (g) Notaire
			// Math.round(337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769 ) * 0.0055)
//				alert('notaire : ' + Math.round(337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) );
		// (h) TVA
			// ( taxe + notaire )*0,196
			// Math.round(((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value))
//				alert('tva : ' + Math.round(((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) );
		// (i) Frais fixe
				// parseFloat(document.ap_cc_1.cc1_fraisfixe.value)
		// (j) Fees and taxes paid to the Notaire for the loan
				if (parseFloat(document.ap_cc_1.cc1_loan_morethan5.value) > 0) {document.ap_cc_1.cc1_calc_feesduty4loan_morethan5.value = Math.round((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + (((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value));}
				else {document.ap_cc_1.cc1_calc_feesduty4loan_morethan5.value = 0;}

		// (k) Total Frais
			// j + e
				if (parseFloat(document.ap_cc_1.cc1_loan_morethan5.value) > 0) {document.ap_cc_1.cc1_calc_feesduty_morethan5.value = Math.round( ((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + (((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) + (429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value) );}
				else {document.ap_cc_1.cc1_calc_feesduty_morethan5.value = Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value));}

		// (l) % of price
			// k / purchase_price
				if (parseFloat(document.ap_cc_1.cc1_loan_morethan5.value) > 0) {document.ap_cc_1.cc1_calc_feesdutypercentage_morethan5.value = Math.round((((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + (((337 + (document.ap_cc_1.cc1_loan_morethan5.value - 16769) * 0.0055) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_fraisfixe.value)) + (429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value)) / parseFloat(document.ap_cc_1.cc1_purchaseprice_morethan5.value) * 100);}
				else {document.ap_cc_1.cc1_calc_feesdutypercentage_morethan5.value = Math.round(((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) + Math.round((429 + (document.ap_cc_1.cc1_purchaseprice_morethan5.value - 16769) * 0.00825) * parseFloat(document.ap_cc_1.cc1_tva.value)) + parseFloat(document.ap_cc_1.cc1_honorairesfixed.value) + Math.round(document.ap_cc_1.cc1_purchaseprice_morethan5.value * document.ap_cc_1.cc1_droitsdenregistrement_morethan5.value)) / parseFloat(document.ap_cc_1.cc1_purchaseprice_morethan5.value) * 100);}
	}
	return null;
}
// =============================================================
// TABLE 2
// USER INPUTS
//cc2_loan
//cc2_period
//cc2_interest
// CALCULATIONS
//cc2_calc_monthlyrepayment
//cc2_calc_totalinterest

function calculate_ap_cc_2(form) {
	var calc_errors = 0;
	var TxPer = 0;
	var NbEch = 0;
	var MEch = 0;
	var Loan = 0;
	var Period = 0;
	var Interest = 0;
	if (document.ap_cc_2.cc2_loan.value === 0) {alert('loan?');return false;calc_errors++;}
	if (document.ap_cc_2.cc2_period.value === 0) {alert('period?');return false;calc_errors++;}
	if (document.ap_cc_2.cc2_interest.value === 0) {alert('interest rate?');return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_2.cc2_loan.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_2.cc2_period.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_2.cc2_interest.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (calc_errors == 0) {
		Loan = document.ap_cc_2.cc2_loan.value;
		Period = document.ap_cc_2.cc2_period.value;
		Interest = document.ap_cc_2.cc2_interest.value / 100;
		//	(a)TxPer
			TxPer = Interest / 12;
//			alert('monthly interest : ' + TxPer);
		//	(b)NbEch
			NbEch = Period * 12;
//			alert('no of monthly payments : ' + NbEch);
		//	(c)Monthly repayments
			MEch = Math.round( Loan * TxPer * Math.pow((1 + TxPer), NbEch) / ( Math.pow(( 1 + TxPer), NbEch) - 1 ) );
//			alert('monthly payments : ' + MEch);
			document.ap_cc_2.cc2_calc_monthlyrepayment.value = MEch;
		//	(d)Total Interest paid	291755
			document.ap_cc_2.cc2_calc_totalinterest.value = Math.round((MEch * NbEch) - Loan);
	}
	return null;
}

// =============================================================
// TABLE 3
// USER INPUTS
//	document.ap_cc_3.cc3_saleprice.value;
//	document.ap_cc_3.cc3_sellingexpenses.value;
//	document.ap_cc_3.cc3_completeyears.value;
//	document.ap_cc_3.cc3_purchaseprice.value;
// CALCULATIONS
// document.ap_cc_3.cc3_calc_netsaleprice.value;
// document.ap_cc_3.cc3_calc_purchaseexpenses.value;
// document.ap_cc_3.cc3_calc_renovationcosts.value;
// document.ap_cc_3.cc3_calc_grosspurchaseprice.value;
// document.ap_cc_3.cc3_calc_grosscapitalgain.value;
// document.ap_cc_3.cc3_calc_reduction.value;
// document.ap_cc_3.cc3_calc_netcapitalgain.value;
// document.ap_cc_3.cc3_calc_netcapitalgaintaxtopay.value;
// HIDDEN
// document.ap_cc_3.cc3_purchaseexpenses.value;
// document.ap_cc_3.cc3_renovationcosts.value;
// document.ap_cc_3.cc3_capitalgainstaxrate.value;


function calculate_ap_cc_3(form) {

	var calc_errors = 0;
	if (document.ap_cc_3.cc3_saleprice.value === 0) {alert('sale price?');return false;calc_errors++;}
	//if (document.ap_cc_3.cc3_sellingexpenses.value === 0) {alert('selling expenses?');return false;calc_errors++;}
	if (document.ap_cc_3.cc3_completeyears.value === 0) {alert('period from purchase to sale? (years)');return false;calc_errors++;}
	if (document.ap_cc_3.cc3_purchaseprice.value === 0) {alert('purchase price ? (years)');return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_3.cc3_saleprice.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	//if (!parseFloat(document.ap_cc_3.cc3_sellingexpenses.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_3.cc3_completeyears.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (!parseFloat(document.ap_cc_3.cc3_purchaseprice.value)) {alert("Please enter numeric values.");return false;calc_errors++;}
	if (calc_errors == 0) {
		document.ap_cc_3.cc3_calc_netsaleprice.value = document.ap_cc_3.cc3_saleprice.value - document.ap_cc_3.cc3_sellingexpenses.value;
		document.ap_cc_3.cc3_calc_purchaseexpenses.value = (document.ap_cc_3.cc3_purchaseprice.value * parseFloat(document.ap_cc_3.cc3_purchaseexpenses.value));
		document.ap_cc_3.cc3_calc_renovationcosts.value = (document.ap_cc_3.cc3_purchaseprice.value * document.ap_cc_3.cc3_renovationcosts.value);

		document.ap_cc_3.cc3_calc_grosspurchaseprice.value = parseFloat(document.ap_cc_3.cc3_purchaseprice.value) + parseFloat(document.ap_cc_3.cc3_calc_purchaseexpenses.value) + parseFloat(document.ap_cc_3.cc3_calc_renovationcosts.value);
		document.ap_cc_3.cc3_calc_grosscapitalgain.value =  parseFloat(document.ap_cc_3.cc3_calc_netsaleprice.value) - parseFloat(document.ap_cc_3.cc3_calc_grosspurchaseprice.value);
		if (parseFloat(document.ap_cc_3.cc3_completeyears.value) > 5) {
			if (parseFloat(document.ap_cc_3.cc3_completeyears.value) < 15) {
				// take off 10% for each year over 5
				//document.ap_cc_3.cc3_calc_reduction.value = (parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) * 0.1);
				//alert(document.ap_cc_3.cc3_completeyears.value + ' years, so ' + (parseFloat(document.ap_cc_3.cc3_completeyears.value)-5) + '0% reduction in capital gains');
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 6) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.1) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 7) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.2) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 8) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.3) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 9) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.4) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 10) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.5) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 11) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.6) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 12) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.7) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 13) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.8) - 1000;}
				if (parseFloat(document.ap_cc_3.cc3_completeyears.value) == 14) {document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - (document.ap_cc_3.cc3_calc_grosscapitalgain.value * 0.9) - 1000;}
				document.ap_cc_3.cc3_calc_netcapitalgaintaxtopay.value = (document.ap_cc_3.cc3_calc_netcapitalgain.value * document.ap_cc_3.cc3_capitalgainstaxrate.value);
			}
			else {
				// more than or equal to 15 years, so no capital gains
				//document.ap_cc_3.cc3_calc_reduction.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value);
				//alert('more than 15 years, so no Capital Gains');
				document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - 1000;
				document.ap_cc_3.cc3_calc_netcapitalgaintaxtopay.value = 0;
			}
		}
		else {
			//document.ap_cc_3.cc3_calc_reduction.value = 0;
			// less or equal to 5 years, so no reduction in Capital Gains
			//alert('less or equal to 5 years, so no reduction in Capital Gains');
			document.ap_cc_3.cc3_calc_netcapitalgain.value = parseFloat(document.ap_cc_3.cc3_calc_grosscapitalgain.value) - 1000;
			document.ap_cc_3.cc3_calc_netcapitalgaintaxtopay.value = (document.ap_cc_3.cc3_calc_netcapitalgain.value * 0.26);
		}
	}
	return null;
}

//    EXAMPLES:
//    if ((form.ref1.value.length < 6) || (form.ref1.value.length > 6)){
//        alert('(error 1.1)\n\nSorry, but the first field should contain 6 numbers (the date you booked your holiday, YYYYMMDD).\nPlease try again.' );
//        return false;
//    }
//    if( isNumbers( form.ref1.value ) ){
//		alert('(error 1.2)\n\nSorry, but the first field should contain 6 numbers (the date you booked your holiday, YYYYMMDD).\nPlease try again.' );
//        return false;
//    }
//    if( isEmpty( form.ref2 ) ){
//        alert('(error 2.1)\n\nSorry, but the second field should contain one letter (the first letter of your surname)..\nPlease try again.' );
//        return false;
//    }
//    if( isLetters( form.ref2.value ) ){
//		alert('(error 2.3)\n\nSorry, but the second field should contain one letter (the first letter of your surname)..\nPlease try again.' );
//        return false;
//    }

function submitConvertProspect2Buyer( form ){
	// if not empty and buyer_email is valid
	if( isEmpty( form.buyer_email ) ){}
	else {
		if( notValidEmail( form.buyer_email ) ){
			alert('Please enter a valid email address..' );
			form.buyer_email.focus();
			return false;
		}
	}

	if( isEmpty( form.buyer_name ) ){
		alert('Please enter the first name.' );
		form.buyer_name.focus();
		return false;
	}

	if( isEmpty( form.buyer_surname ) ){
		alert('Please enter the surname.' );
		form.buyer_surname.focus();
		return false;
	}

	if( isEmpty( form.buyer_full_name ) ){
		alert('Please enter the full_name.' );
		form.buyer_full_name.focus();
		return false;
	}

	var phonemsg = '\nfor example:\n +33 (0)1 23456789 for a French number\n +44 (0)123 456789 for a UK number\n\n..allowed characters are : +0123456789() and spaces\n\nnote: if you do not have any phone numbers for this entry\nyou can enter ten zeros 0000000000 in the home number field.\nThe field will then appear highlighted in red to remind you to update it later';

	// one of these 3 must be completed
	if( form.buyer_hometel.value.length < 10 ){
		if( form.buyer_worktel.value.length < 10 ){
			if( form.buyer_mobtel.value.length < 10 ){
				alert('Please enter at least one phone number' + phonemsg );
				form.buyer_hometel.focus();
				return false;
			}
			else {
			    if( isPhoneNumber( form.buyer_mobtel.value ) ){
				alert('Please enter the mobile number' + phonemsg );
				form.buyer_mobtel.focus();
				return false;
			    }
			}
		}
		else {
		    if( isPhoneNumber( form.buyer_worktel.value ) ){
			alert('Please enter the work number' + phonemsg );
			form.buyer_worktel.focus();
			return false;
		    }
		}
	}
	else {
	    if( isPhoneNumber( form.buyer_hometel.value ) ){
		alert('Please enter the home number' + phonemsg );
		form.buyer_hometel.focus();
		return false;
	    }
	}

	// buyer_lang length = 2
	if( isEmpty( form.buyer_lang ) ){
		alert('Please enter the principal language spoken.' );
		form.buyer_lang.focus();
		return false;
	}

	// buyer_address1 length > 0
	if( isEmpty( form.buyer_address1 ) ){
		alert('Please complete the first line of the address (at least the first two lines must be completed).' );
		form.buyer_address1.focus();
		return false;
	}

	if( isEmpty( form.buyer_address2 ) ){
		alert('Please complete the second line of the address (at least the first two lines must be completed).' );
		form.buyer_address2.focus();
		return false;
	}

	// buyer_postcode length > 0
	if( isEmpty( form.buyer_postcode ) ){
		alert('Please enter the postcode.' );
		form.buyer_postcode.focus();
		return false;
	}

	// buyer_country length = 2
	if( isEmpty( form.buyer_country ) ){
		alert('Please select the country of residence.' );
		form.buyer_country.focus();
		return false;
	}
	return true;
}

//-->