//=======================================================================
//Created by Michael Alperovich
//Opens a new window -- a pop up (Params: url, height, width)
  function openWd(url, h, w){
    var mywin = "";
    var param = "width=" + w + ",height=" + h + ",status=no,menubar=no,location=no,toolbar=no,scrollbars=yes,resizable=no,directories=no";
    myWin = window.open(url, "newWd", param);
  }

//=======================================================================
//Created by Michael Alperovich
//Opens a new window -- a pop up (Params: url, height, width)
  function openModalDialog(url, h, w){
    var mywin = "";
    var param = 'dialogHeight:' + h + 'px;dialogWidth:' + w + 'px';

    myWin = window.showModalDialog(url,'',param);
  }

//=======================================================================
  function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}


//=======================================================================
//Validate Email
//Parameters: field name, text message
function validate_email(field,alerttxt){
//	alert("Testing email value --> " + field.name);
	with (field){
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2){
			alert(alerttxt);
			value="";
			return false;
		}
		else {
			return true;
		}
	}
}
//=======================================================================


function validate_required(field,alerttxt){
	with (field){
//		alert("Testing for value --> " + field.name);
		if (value==null||value==""){
			alert(alerttxt);
			return false;
		}
		else{
			return true;
		}
	}
}

//=======================================================================
function validate_form(thisform){
	with (thisform){
		if (validate_required(comments,"Answers must be filled out!")==false){
			comments.focus();
			return false;
		}
		
		if (validate_required(firstname,"First Name must be filled out!")==false){
			firstname.focus();
			return false;
		}
		
		if (validate_required(lastname,"Last Name must be filled out!")==false){
			lastname.focus();
			return false;
		}
		
		if (validate_required(Branch,"Branch/Firm must be filled out!")==false){
			Branch.focus();
			return false;
		}
		
		if (validate_required(email,"E-mail must be filled out!")==false){
			email.focus();
			return false;
		}
		
		if (validate_email(email, "Not a valid E-mail address!")==false){
			email.focus();
			return false;
		}
	}
	alert("Thank you for participating.");
	parent.close();
	
}












var validated = "";

function checkForm(theForm) {
	var why = "";
	why += isEmpty(theForm.comments.value);
	why += isEmpty(theForm.firstname.value);
	why += isEmpty(theForm.lastname.value);
	why += isEmpty(theForm.Branch.value);
	why += isEmpty(theForm.email.value);
	why += validate_email(email, "Not a valid e-mail address!");

	alert (why);
	
	if (why != "") {
	       alert("Please fill in all of the required fields.");
	       validated = false;
	       return false;
    	}
	validated = true;
	return false;
}



