function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}


// The below code checks if the users have filled the form
function validate_form()
{
   var valid;
   valid=true;

    if ( document.form1.name.value == "" ||
	     document.form1.address.value == "" ||
		 document.form1.zip.value == "" ||
		 document.form1.lastname.value == "" ||
		 document.form1.homenumber.value == "" )
    {
		valid=false;
        alert ( "Please fill out all the required fields" );
        

    }

    if ( document.form1.email.value != document.form1.emailconfirm.value )
    {
        alert ( "Your email did not match your confirm email." );
        valid=false;
	
    }
	
	    if (is_nan(document.form1.zip.value) == true)
    {
        alert ( "You must use real numbers in your post code.." );
        valid=false;

    }
	
	if(document.form1.terms.checked){
	    alert ( "You must agree to our terms and conditions to contine.");
	    valid=false;

	}

    return valid;
}



function leaveHome(){
	if(document.form1.home.checked){
		document.form1.notes.value = "leave if nobody is home";
	} else {
		document.form1.notes.value = "";
	}
}



function disableSubmit( ){

	document.form1.Submit.disabled=true;

}


function termsTicked(){
//if(document.form1.Submit.disabled==false) {
		if(document.form1.terms.checked) {
				document.form1.Submit.disabled=false;
			} else {
				document.form1.Submit.disabled=true;
		}
	
	}


function showhide(divid){
		thediv = document.getElementById(divid);
			if(thediv.style.display== 'none' ){
					thediv.style.display='block'
				}else{
					thediv.style.display='none'
		}
	}






function checkLength(form){
    if (form1.zip.value.length > 20){
        alert("Australian post codes are 4 intergers long, please check your zip code.");
        return false;
    }
    return true;
}


function checkNum(){
	if (isNaN(document.form1.zip.value)){
				alert("Hey! That post code is not a real number!");
					valid = false;
					return false;
			}
	}
