/* Function to open popup window */
function open_window(url,title,l, t, w, h) {
  var windowprops = "location=no,scrollbars=no,menubars=no,toolbars=no,resizable=no" +
  ",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;

  popup = window.open(url,title,windowprops);
}

function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}

function trim(str) { return str.replace(/^\s+|\s+$/g,""); }
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }	

function frmrequest()
{
	var Field= Array();
	var FieldName= Array();
	var msg="";
	var bval = true;
	
	Field[0] = document.frmEstimate.fName.value;
	Field[1] = document.frmEstimate.fEmail.value;
	Field[2] = document.frmEstimate.fPhone.value;

	Field[0] = Field[0].trim();
	Field[1] = Field[1].trim();
	Field[2] = Field[2].trim();

	FieldName[0] = "Your Name ";
	FieldName[1] = "Email ";
	FieldName[2] = "Phone ";

/*	alert('Name Field is: [' + Field[0] + ']');  */
	
	for(i=0; i<3; i++)
	{
		if(Field[i]=="" || Field[i]==null)
		{
			msg = msg + "Please Fill:"
			msg = msg + "\n" + ">> " + FieldName[i] + "Field";
			alert(msg);
			bval = false;
			break;
		}
	}
	
	if (bval) { bval=emailCheck(); }
/*	
	if (bval && document.frmCheck.txtcaptcha.value != document.frmCheck.captcha.value)
	 {
	 	alert("Invalid Captcha Number");
		return false;
	 }
*/
	return bval;
}

function emailCheck() 
{
	var emailPat=/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/
	var matchArray;	
	var emailStr1 =document.frmCheck.email.value;	
	
	matchArray = emailStr1.match(emailPat);
	if (matchArray == null) 
	{
		alert("Please Enter Valid Email Address"); 
		document.frmCheck.email.focus;
		return false;
	}	
	else 
	return true;
}

