function validateContact(){	
	var emailV = 1;
	if(document.contact.name.value==""){
		
		alert("Please enter the name");return false;
	}
	else if(document.contact.email.value=="") 
	 {
		 alert("Please enter the email");return false;
	 }

	
	email = document.contact.email.value;
	if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        emailV = 0;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        emailV = 0;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        emailV = 0;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		emailV = 0;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
		emailV = 0;
    }
    
    if(emailV == 0){
		alert("Please enter a valid email address");
		return false;
	}
	
	else if(document.contact.message.value==""){
		 alert("Please enter the message");
		return false;
	}
		else if(document.contact.security.value==""){
		 alert("Please enter the security code");
		return false;
	}
	
}

function validateNewsletter(){
	var emailV = 1;
	if(document.newsletter_form.name.value==""){
		alert("Please enter the name");return false;
	}
	else if(document.newsletter_form.email.value=="" )
	{
		 alert("Please enter the email");return false;
	}
	email = document.newsletter_form.email.value;
	 if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        emailV = 0;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        emailV = 0;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        emailV = 0;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
		emailV = 0;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
		emailV = 0;
    }
    
    if(emailV == 0){
		alert("Please enter a valid email address");
		return false;
	}
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

function openimage(image, w, h){

	window.open(image, "newWind", "menubar=0,status=0,resizable=1, width="+w+", height="+h);
}

function validateLogin(){
	if(document.login.username.value=="" || document.login.pass.value=="" ){
		alert("Please fill in the required fields");
		return false;
	}
}
