function munu(id) {
	if(document.getElementById(id).src == "/gl_images/nav/off/click.gif"){
		document.getElementById(id).src = "/gl_images/nav/on/click.gif";
	} else {
		document.getElementById(id).src = "/gl_images/nav/off/click.gif";
	}
}


function menu(id){
    if (document.getElementById(id).style.display == "none"){
        document.getElementById('click').src = "/gl_images/nav/on/click.gif";
    }else{
		document.getElementById('click').src = "/gl_images/nav/off/click.gif";        
    }    
}

//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+$/,"");
}

//VALIDATION
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;
	}
}

//VALIDATION
function validateform(formname,color1,color2){
	//last updated on 9/27/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 = color1;
				allgood = false;
				} else {
				  document.getElementById(thisformid).style.background = color2; 
				}
			}
		}
		if (allgood) {
			return true;
			} else {
			return false;
			}
	}

function arethesame(condition1,condition2){
	if (condition1 == condition2) {
			return true;
			} else {
			return false;
			}
}

function logina(formname,validateid,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){
		//AJAX POST
		new Ajax.Request('/ajax/login.asp', {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onSuccess: function(transport,formname) { 	
			//LOG IN EXISTS?
			if (transport.responseText=='true'){
				//document.forms.formname.submit();
				document.getElementById(validateid).innerHTML = '';
				document.location.reload()
			} else {
				document.getElementById(validateid).innerHTML = 'Invalid Log In';
				if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
				} else {
					Effect.Shake(validateid);
					}
				}
			}//-onSuccess
			}//-request arguments
			);// new ajax request		
	} else {
			//FILL IN THE REQUIRED FIELDS
			if (document.getElementById(validateid).style.display == "none"){
				document.getElementById(validateid).innerHTML = 'Please fill in required fields';
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
	}
}



function logoff(){
		//AJAX POST
		new Ajax.Request('/ajax/logoff.asp', {
		method: "get",
		onSuccess: function(transport,formname) { 	
				document.location.reload()
			}
			//-onSuccess
			}//-request arguments
			);// new ajax request		
}

function switchpageimage(divid,assetid){
	new Ajax.Request('/ajax/pageimage.asp?id='+ assetid, {
	method: "get",
	onSuccess: function(transport) {
		document.getElementById(divid).innerHTML = transport.responseText;	
		}//-onSuccess
		}//-request arguments
		);// new ajax request	

}


function signup(formname,validateid,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){
		//AJAX POST
		new Ajax.Request('/ajax/signup.asp', {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onSuccess: function(transport,formname) { 	
			document.getElementById(validateid).innerHTML = transport.responseText;
			
			if (transport.responseText=='Thank you.'){
				Effect.toggle('moo_wrapper','appear',{ delay: 2.5 });
				menu('moo_wrapper');
			}
			
			}//-onSuccess
			}//-request arguments
			);// new ajax request		
	} else {
			//FILL IN THE REQUIRED FIELDS
			if (document.getElementById(validateid).style.display == "none"){
				document.getElementById(validateid).innerHTML = 'Please fill in required fields';
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
	}
}
