/*
function selectVideo(elem){
	elem.style.background = "#BBB url(images/bg_promobox_on.jpg) top repeat-x;";
}
function deselectVideo(elem){
	elem.style.background = "#CCC url(images/bg_promobox_off.jpg) top repeat-x;"
}
*/
function popUpMovie(url){
	var win = window.open(url,"movieWindow","location=0,status=0,toolbar=0,scrollbars=0,menubar=0,resizable=0,width=600,height=550");
}

function validateReportsForm(){
	if(document.reports.name.value <= 0){
		document.reports.name.select();
		AlertError('Full name');
		return false;
	}

	if(ValidatePhone(document.reports.phone.value) == false){
		document.reports.phone.select();
		AlertError('Phone number');
		return false;
	}

	if(ValidateEmail(document.reports.email.value) == false){
		document.reports.email.select();
		AlertError('Email');
		return false;
	}
	
	if(document.reports.available.selectedIndex <= 0){
		AlertError('Availability');
		return false;
	}
	
	if(document.reports.planning_to.selectedIndex <= 0){
		AlertError('Planning to...');
		return false;
	}
	// Otherwise valid form input
	return true;	
}
function validateLeadsForm(){
	if(document.leads.name.value <= 0){
		document.leads.name.select();
		AlertError('Full name');
		return false;
	}

	if(ValidatePhone(document.leads.phone.value) == false){
		document.leads.phone.select();
		AlertError('Phone number');
		return false;
	}

	if(ValidateEmail(document.leads.email.value) == false){
		document.leads.email.select();
		AlertError('Email');
		return false;
	}

	if(document.leads.state.selectedIndex <= 0){
		AlertError('State');
		return false;
	}
	
	if(ValidateDollarAmount(document.leads.loan_amount.value) == false){
		AlertError('Loan amount');
		return false;
	}
	
	if(ValidateDollarAmount(document.leads.property_value.value) == false){
		AlertError('Property value');
		return false;
	}
	
	if(document.leads.credit.selectedIndex <= 0){
		AlertError('Credit score');
		return false;
	}
	// Otherwise valid form input
	return true;	
}
function ValidateEmail(str)
{
	//This is insufficient, fix later
	if(str.search('@')==-1) {
		return false;
	} else {
		return true;
	}
}

function ValidatePhone(strPhone){
	var stripped = strPhone.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))){
	   return false;
	}
	//then check for exactly 10 digits
	if (!(stripped.length == 10)) {
		return false;
	}
	return true;
}
function ValidateDollarAmount(strAmount){
	//Strip all commas
	var stripped = strAmount.replace(/[,]/g,'');
	if(stripped.match(/^\$?\d+\.?\d*$/))
		return true;
	else
		return false;
}

function AlertError(fieldName){
	//document.getElementById('formerror').style.backgroundColor='#ff9999';
	alert("Invalid input to the following field: "+fieldName);
	return true;
}