// JavaScript Document
  function submitMiniSearch() {
    document.miniSearch.submit()
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500');");
}

function popUpMap(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=1000,height=600');");
}

function RemoveContent(d) {
document.getElementById(d).style.display = "none";
}
function InsertContent(d) {
document.getElementById(d).style.display = "";
}

function Validate() {
    var failed = false;
    var message = "You must enter the following before the form can be processed \n\n";
    if (document.forum.name.value == "") {
        if (!failed){ firstfocus = document.forum.name;}
        failed = true;
        message += "Name \n";
    }
    if (document.forum.address.value == "") {
        if (!failed){ firstfocus = document.forum.address;}
        failed = true;
        message += "Address \n";
    }
	if (document.forum.email.value == "") {
        if (!failed){ firstfocus = document.forum.email;}
        failed = true;
        message += "Email \n";
    }
	if (echeck(document.forum.email.value)==false){
		document.forum.email.value =""
		document.forum.email.focus()
		return false
	}
    if (document.forum.postCopy.value == "") {
        if (!failed){ firstfocus = document.forum.postCopy;}
        failed = true;
        message += "Comments \n";
    }
   // stick some form field validation in here
    if (failed){
        alert(message);
        firstfocus.focus();
        return false;
    }    
    return true;
} 


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){
		   alert("Please enter valid email")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter valid email")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Please enter valid email")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Please enter valid email")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Please enter valid email")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Please enter valid email")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Please enter valid email")
		    return false
		 }

 		 return true					
	}


function valEmail() {
	if (document.advSearch.eUpdate.checked == true){
    var failed = false;
    var message = "You must enter the following before the form can be processed \n\n";
    if (document.advSearch.uFname.value == "") {
        if (!failed){ firstfocus = document.advSearch.uFname;}
        failed = true;
        message += "Firstname\n";
    }
    if (document.advSearch.uSname.value == "") {
        if (!failed){ firstfocus = document.advSearch.uSname;}
        failed = true;
        message += "Surname \n";
    }
	if (document.advSearch.uEmail.value == "") {
        if (!failed){ firstfocus = document.advSearch.uEmail;}
        failed = true;
        message += "Valid Email Address \n";
    }
	if (echeck(document.forum.uEmail.value)==false){
		document.forum.uEmail.value =""
		document.forum.uEmail.focus()
		return false
	}
	if (document.advSearch.ppolicy.checked == false){
		if (!falied){ firstfocus = document.advSearch.ppolicy;}
		failed = true;
		message += "You must agree with the privacy policy \n";
	}
   // stick some form field validation in here
    if (failed){
        alert(message);
        firstfocus.focus();
        return false;
    } return true;
}
    } 
	
function ValSubscribe() {
    var failed = false;
    var message = "You must enter the following before the form can be processed \n\n";
    if (document.subscribe.uFname.value == "") {
        if (!failed){ firstfocus = document.subscribe.uFname;}
        failed = true;
        message += "Name \n";
    }
    if (document.subscribe.uSname.value == "") {
        if (!failed){ firstfocus = document.subscribe.uSname;}
        failed = true;
        message += "Address \n";
    }
	if (document.subscribe.email.value == "") {
        if (!failed){ firstfocus = document.subscribe.email;}
        failed = true;
        message += "Email \n";
    }
	if (echeck(document.subscribe.email.value)==false){
		document.subscribe.email.value =""
		document.subscribe.email.focus()
		return false
	}
    if (document.subscribe.uAddress.value == "") {
        if (!failed){ firstfocus = document.subscribe.uAddress;}
        failed = true;
        message += "Postal Address \n";
    }
   // stick some form field validation in here
    if (failed){
        alert(message);
        firstfocus.focus();
        return false;
    }    
    return true;
} 
