// Opening a popup window
function openWin1(strHtml) {
	window.open(strHtml,"newWin","resize=yes,scrollbars=yes,width=550,height=600,toolbar=no");
}

function openWinDemo(strHtml, x, y) {
	window.open(strHtml,"newWin","resize=yes,scrollbars=yes,width="+x+",height="+y+",toolbar=no,location=no,menubar=no");
    //window.open(strHtml,"newWin","width="+x+",height="+y);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

// Mandatory field check for popup windows
function checkForm(objForm)
{
	// Check First Name
	if (isFormValid(objForm.first_name, "label_first_name") == false) {
		return false;
	}
	
	// Check Last Name
	if (isFormValid(objForm.last_name, "label_last_name") == false) {
		return false;
	}
	
	// Check Company
	if (isFormValid(objForm.company, "label_company") == false) {
		return false;
	}

	// Check E-Mail
	if (isFormValid(objForm.email, "label_email") == false) {
		return false;
	}
	if (isEmailValid(objForm.email, "label_email") == false) {
		return false;
	}

	// Check Phone
	if (isFormValid(objForm.phone, "label_phone") == false) {
		return false;
	}
}

function isFormValid(objField, strLabel)
{
	if ((objField.value == null) || (objField.value.length ==0)) {
		alert("Please enter " + document.getElementById(strLabel).innerHTML +".");
 		objField.focus();
		return false;
	}
	return true;
}

function isEmailValid(objField, strLabel)
{
	var strEmail = objField.value;
	// The line below is not working for email addresses such as "s.mochida@lattice3d.com".
    /*
       if ((strEmail.indexOf(".") > 1) && (strEmail.indexOf("@") > 0)) {
		return true;
	}*/
    // New line from http://javascript.internet.com/forms/email-validation---basic.html  1/4/08
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail)){
        return (true)
    }
	
	alert(document.getElementById(strLabel).innerHTML + " is invalid.");
	objField.focus();
	return false;
}
