function brakeFrame(){
    if(top.location != self.location){
        top.location.href = document.location.href;
    }
}

function auToCom(){
	var urlStr1 = window.location;
	var urlStr2 = urlStr1.toString();
	if(urlStr2.substring(0) == "http://www.petermount.au.com/"){
	window.location="http://www.petermount.com/";
	}
	if(urlStr2.substring(0) == "http://www.petermount.au.com/onoffer/"){
	window.location="http://www.petermount.com/onoffer/";
	}
	if(urlStr2.substring(0) == "http://www.petermount.au.com/folio/"){
	window.location="http://www.petermount.com/folio/";
	}
	if(urlStr2.substring(0) == "http://www.petermount.au.com/contact/"){
	window.location="http://www.petermount.com/contact/";
	}
}

function goBack(){
	window.history.back();
}

function contactValidate(){
    	//flag for error message
    	var flagError = 0;

    	//for error message
    	var errorText = "ERROR\nPlease enter\n";

	//for blank enquiryComment
	var flagEnquiryCommentBlankError = 0;

	//flag for blank form
	var flagBlankFormError = 0;

	//flag for arrayAddress
	var addressCount = 0;

	//flag for arrayPhoneEmail
	var phoneEmailCount = 0;

	//**********Testing for blanks in Name block************
	if (window.document.getElementById("contactForm").name.value == ""){ 
		errorText += "Name\n";
		flagError++;
		}
	
	//**********Array for testing for entries in Address Block*************
	var arrayAddress = new Array(2);
	arrayAddress[0] = window.document.getElementById("contactForm").address.value;
	arrayAddress[1] = window.document.getElementById("contactForm").country.value;

	for (var count = 0; count < arrayAddress.length; count++)
	{
		if (arrayAddress[count] != "")
		{
			addressCount++;
		}
	}

	//**********Array for testing for entries in Phone/Email Block************
	var arrayPhoneEmail = new Array(2);
	arrayPhoneEmail[0] = window.document.getElementById("contactForm").phone.value;
	arrayPhoneEmail[1] = window.document.getElementById("contactForm").email.value;

	for (var count = 0; count < arrayPhoneEmail.length; count++)
	{
		if (arrayPhoneEmail[count] != "")
		{
			phoneEmailCount++;
		}
	}

	//**********To see if anything has been entered on the form****************
	if((window.document.getElementById("contactForm").name.value == "") &&
	(window.document.getElementById("contactForm").businessName.value == "") &&
	(addressCount < 1) &&
	(phoneEmailCount < 1) &&
	(window.document.getElementById("contactForm").enquiryComment.value == ""))
	{
		flagBlankFormError++;
		flagError++;
	}

	//************To see if address or country or phone or email is on the form**************
	if((flagBlankFormError < 1) &&
	(addressCount < 1) &&	
	(phoneEmailCount < 1))
	{
		flagError++;
		errorText += "Address (with Country) OR Phone OR Email\n";
	}	 

	//To see if Address block filled in completely
	if((addressCount > 0) && (addressCount < 2))
	{
		flagError++;
		errorText += "Address with Country\n";
	}

	//************Email Block************
	//To validate for valid email address
	var x=window.document.getElementById("contactForm") ;
	var Temp=x.email.value ;
	var EmailOk  = true ;
	var AtSym    = Temp.indexOf('@') ;
	var Period   = Temp.lastIndexOf('.');
	var Space    = Temp.indexOf(' ') ;
	var Length   = Temp.length - 1;
	if (((AtSym < 1) ||                // '@' cannot be in first position
		(Period <= AtSym+1) ||         // Must be atleast one valid char btwn '@' and '.'
		(Period == Length ) ||         // Must be atleast one valid char after '.'
		(Space  != -1)) &&             // No empty spaces permitted
		!(window.document.getElementById("contactForm").email.value == ""))
		{
		flagError++;
		errorText += "Valid Email Address\n";
		}

	//***********To see if textarea has text in it***************
	if(
	(window.document.getElementById("contactForm").enquiryComment.value == ""))
	{
		flagError++;
		errorText += "Enquiry/Comment\n";
	}

	//**********Output block****************
	if(flagBlankFormError > 0){
		errorText = "ERROR\nNothing entered on form";
	}

   	//Test to see if error message is shown
   	if(flagError > 0){
        	window.alert(errorText);
   	}

    	//Return statements
   	if(flagError < 1)
         	return true;
    	return false;
}