function validEmail(email) {
			var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			return re.test(email); 
		}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function isFilled(elm) {
	//alert(elm.type);
	//Last Updated by Sol - 6/14/07
	switch(elm.type){
	case "text":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "password":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "textarea":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "select-one":
		var myindex=elm.selectedIndex;
		if (myindex==0){
		return false;}
		else {return true;}
		break;
	}
}

function arethesame(condition1,condition2){
	if (condition1 == condition2) {
			return true;
			} else {
			return false;
			}
}

function validateform(formname){
	//last updated on 6/14/07
	//index of is mo betta
	var x = document.forms[formname];
	var allgood = true;
	for (var i=0;i<x.length;i++){
		if (x.elements[i].className.indexOf('required')>-1) {
		 	var thisformname = x.elements[i].name;
			var thisformid = x.elements[i].id;
			if (!isFilled(x.elements[i])) {
				document.getElementById(thisformid).style.background = "#A7C2EB";
				allgood = false;
				} else {
				  document.getElementById(thisformid).style.background = "#284877"; 
				}
			}
		}
		if (allgood) {
			return true;
			} else {
			return false;
			}
}

function submitcontact(formname,validateid){
	if (validateform(formname)){
		if (validEmail(document.getElementById('email').value)){
			
			//AJAX POST
			new Ajax.Request('/ajax/contact.asp', {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
				document.getElementById(validateid).innerHTML = transport.responseText;
				Effect.Shake(validateid);
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
		} else {
			
			document.getElementById(validateid).innerHTML = 'Invalid Email'
			//Effect.Appear(validateid);
		}
		
		
	}
}
	

//ROLLOVER
function setupRollover(thisImage) {
	var a = thisImage.src.split("/");
	var a_length = a.length-1;
	aa = a[a_length];
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	thisImage.overImage = new Image();
	thisImage.overImage.src = "/images/nav/on/" + aa ;
	thisImage.onmouseover = rollOver;	
}

//ROLLOVER
function rolloverInit(){
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].getAttribute('name') == "rollover") {			
			setupRollover(document.images[i]);
		}
	}
}

//ROLLOVER
function rollOver() {
	this.src = this.overImage.src;
}

//ROLLOVER
function rollOut() {
	this.src = this.outImage.src;
}

window.onload = masterloader;

function masterloader(){
	rolloverInit();
}

