// JavaScript Document

function custom_popup(filename,width,height) 
{
 var url = 'http://www.uscourtaudit.com/'+filename;
 var params = 'width='+width+', height='+height;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'PDF', params);
 if (window.focus) {newwin.focus()}
 return false;
}

function popup(filename) 
{
 var width  = 800;
 var height = 600;
 var params = 'width='+width+', height='+height;
 var url = filename;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=yes';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'PDF', params);
 if (window.focus) {newwin.focus()}
 return false;
}

function check_values() {
	var valid = '';
	
	var customer_name = document.getElementById("customer_name").value;
	var customer_email = document.getElementById("customer_email").value;
	var customer_phone = document.getElementById("customer_phone").value;
	var state = document.getElementById("state").value;
	var bar_num = document.getElementById("bar_num").value;
	if(trim(customer_name) == "" ||
		trim(customer_email) == "" ||
		trim(customer_phone) == "" ||
		trim(state) == "" ||
		trim(state) == "<state>" ||
		trim(bar_num) == "") {
			alert("Please complete all fields");
	} else {
		if(isEmail(customer_email)) {
			document.sampleRequest.submit();
		} else {
			alert("Email appears to be invalid. Please check.");
			document.getElementById("customer_email").focus();
			document.getElementById("customer_email").select();
		}
	}
}

function trim(a) {
	return a.replace(/^s*(S*(s+S+)*)s*$/, "$1");
}

function isEmail(a) {
   return (a.indexOf(".") > 0) && (a.indexOf("@") > 0);
}
