/*
*	Javascript Functions
*		-Aug 31, 2006	Charles - Created
*		-Oct 05, 2006	Charles	- Added Trimmer
*/


function ValidateSignupForm(frm){
		
		frm.email.value     = trimString(frm.email.value);
		frm.username.value  = trimString(frm.username.value);
		frm.password1.value = trimString(frm.password1.value);
		frm.password2.value = trimString(frm.password2.value);
		
		var $errs = '';
		
		if ( ! frm.email.value.match((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/) ) ) 
			$errs += "--> E-mail Address\n";
			
		if ( ! frm.username.value.match(/^[a-z0-9\.\-\_]{5,30}$/i) ) 
			$errs += "--> Username must be between 5 and 30 chars (a-z 0-9 . - _) no spaces\n";
			
		if ( ! frm.password1.value.match(/^.{5,30}$/i) ) 
			$errs += "--> Password must be between 5 and 30 chars\n";
			
		if ( frm.password1.value != frm.password2.value ) 
			$errs += "--> Passwords do not match\n";
			
		if ( frm.chkTerms.checked != 1 ) 
			$errs += "--> Please agree to our terms\n";
		
		if($errs == ''){
			//frm.submit();
			return true;
		}
		else{
			alert("Please enter or correct the following:\n" + $errs);
			return false;
		}
}



function trimString(str) {
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


function clock(elmID){
	elm = document.getElementById(elmID);
	elm.innerHTML -= 1; 
	if  (elm.innerHTML == 0) {
		window.clearInterval(intval);
		document.forms.frm.submit();
	}
}
