// site features

window.name = "corbeauwebsite";

function validateRequest(the_form) {
	var result = true;

	if (Trim(the_form.Email.value) == '') {
		the_form.Email.focus();			
		alert("Please enter an email address.");	
		result = false;
	} 
	else if ( ! isValidEmail(Trim(the_form.Email.value)) ) {
		the_form.Email.focus();			
		alert("Please enter an email address in the format a@b.c");	
		result = false;
	} 
	else if (Trim(the_form.EmailConfirm.value) == '') {
		the_form.EmailConfirm.focus();			
		alert("Please confirm your email address by typing it again in the Confirm Email field.");	
		result = false;
	}
	else if (Trim(the_form.Email.value) != Trim(the_form.EmailConfirm.value)) {
		the_form.Email.focus();			
		alert("The two email addresses you entered are not the same. Please enter your correct email address in both fields.");	
		result = false;
	}
	
	return(result);
}

function isValidEmail(str) { 
	at_sign = str.indexOf("@");
	//guarantee the prefix part is at least one char
	if (at_sign > 0) {
		after_at_sign = str.substring(at_sign + 1);
//alert("after_at_sign-" + after_at_sign + "-");
		//guarantee the domain part is at least one char
		dot = after_at_sign.indexOf(".");
		if (dot > 0) {
			after_dot = after_at_sign.substring(dot + 1);
//alert("after_dot-" + after_dot + "-");
			return (after_dot.length > 0); 
		} else return (false);
	} else return (false);
} 

function infoPopup(link) {
	var windowW=580;
	var windowH=450;
		
	s = "width="+windowW+",height="+windowH+",scrollbars=yes,resizable=yes";
	mywin = window.open(link ,'info', s);	
	if (mywin != null) mywin.focus();
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End function


function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";

	if(v_length < 0){
		return"";
	}

	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}

		iTemp = iTemp-1;

	} //End While

	return strTemp;

} //End function

function LTrim(VALUE){

	var w_space = String.fromCharCode(32);

	if(v_length < 1){
		return"";
	}

	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}

		iTemp = iTemp + 1;
	} //End While

	return strTemp;

} //End function


function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");

	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 

	return("");

} //End function


