function linktoid(theid){
	window.location.href = document.getElementById(theid).href
}

//VALIDATION
function validEmail(email) {
			var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			return re.test(email); 
		}
		
//VALIDATION
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
		
//VALIDATION
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
		
//VALIDATION
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function isFilled(elm) {
	//alert(elm.type);
	//Last Updated by Sol - 6/5/07
	switch(elm.type){
	case "text":
		if (elm.value == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "password":
		if (elm.value == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "textarea":
		if (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 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 = "#f0e998";
				allgood = false;
				} else {
				  document.getElementById(thisformid).style.background = "#f0e998"; 
				}
			}
		}
		if (allgood) {
			return true;
			} else {
			return false;
			}
	}

function spiderform(formname,validateid,successid,indicatorid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname,'#f0e998','#f0e998')){	
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//alert('got here')
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
			document.getElementById(successid).innerHTML = transport.responseText;
			document.getElementById(indicatorid).style.display = "none";
				//alert(transport.responseText);			
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}

//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 = "/gl_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 rolloverInit1(){
		if (getElementById["submit"].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 = rolloverInit;
