function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}



function validate_contactform()
{
    valid = true;
	var errors = "";

    if ( document.contact.name.value == "" )
    {errors += " Name\n";
        valid = false;
    }	
	if ( document.contact.phone.value.length < 11 || document.contact.phone.value.search(/^([0-9\s]+)$/) )
    {errors += " Phone\n";
        valid = false;
    }
	if ( document.contact.email.value == "" || echeck(document.contact.email.value)==false )
    {errors += " Email\n";
        valid = false;
    }	
	
	if ( document.contact.address.value == "" )
    { errors += " Address\n";
        valid = false;
    }
	
	if ( document.contact.postcode.value == "" )
    {errors += " Postcode\n";
        valid = false;
    }

	
	if ( valid == false )
    {
        alert("     Missing Data\n\nPlease fill in the following required fields:\n===============================\n"+errors+"===============================\n\n Thanks.");
    }

    return valid;

}


function validate_miniform()
{
    valid = true;
	var errors = "";

    if ( document.miniform.name.value == "" )
    {errors += " Name\n";
        valid = false;
    }	
	if ( document.miniform.phone.value.length < 11 || document.miniform.phone.value.search(/^([0-9\s]+)$/) )
    {errors += " Phone\n";
        valid = false;
    }
	if ( document.miniform.email.value == "" || echeck(document.miniform.email.value)==false )
    {errors += " Email\n";
        valid = false;
    }	
	
	if ( document.miniform.address.value == "" )
    { errors += " Address\n";
        valid = false;
    }
	
	if ( document.miniform.postcode.value == "" )
    {errors += " Postcode\n";
        valid = false;
    }


	
	if ( valid == false )
    {
        alert("     Missing Data\n\nPlease fill in the following required fields:\n===============================\n"+errors+"===============================\n\n Thanks.");
    }

    return valid;

}
