// JavaScript Document
var myImgWindow = null;
function imgpop (myImg, myWidth, myHeight) {
	if (myImg != null && myImg != ''){
		if (myImgWindow){
			if (!myImgWindow.closed && !macie_sniff())
				myImgWindow.close();
		}
		//var myWidth = 640;
		//var myHeight = 610;
		myImgWindow = window.open('', "hpsre_pop", "width="+myWidth+",height="+myHeight+",directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes");
		myImgWindow.focus();
		
		var winContent = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Haves, Pine &amp; Seligman, Commercial Real Estate Financing, Real Estate Brokers</title><link href="css/hps-styles1.css" rel="stylesheet" type="text/css" /></head><body><table border="0" cellspacing="0" cellpadding="0" align="center"><tr><td align="center"><div id="imgdisplay"><img src="'+myImg+'" /></div></td></tr><tr><td><div id="imgaddress"><h1>Haves, Pine &amp; Seligman</h1><h2>Commercial Real Estate Financing, Real Estate Brokers</h2><p>708 Third Avenue, 14th Floor<br />New York, NY 10017<br />(212) 953-2400</p></div></td></tr><tr><td><div id="closewindow"><p><a href="#" onclick="javascript: window.close()">close</a></p></div></td></tr></table></body></html>';
	myImgWindow.document.write(winContent);
    myImgWindow.document.close();
	}
}

function validateform (myform) {
	if (myform.employee_name.value == 0) {
		alert ('Please select an Employee.');
		myform.employee_name.focus();
		return false;
	}
	if (myform.user_name.value == ''){
		alert ('Please provide your Name.');
		myform.user_name.focus();
		return false;
	}
	if (myform.phone_number.value == ''){
		alert ('Please provide your Phone Number.');
		myform.phone_number.focus();
		return false;
	}
	if (myform.email.value == '' || !email_validate(myform.email.value)){
		alert ('Please provide a valid E-mail Address.');
		myform.email.focus();
		return false;
	}	
	if (myform.message.value == ''){
		alert ('Please include a message.');
		myform.message.focus();
		return false;
	}
	myform.submit();
}

function email_validate(myEmail){
	//mac ie does not seem to like regular expressions
	if (macie_sniff())
		return true;
	//it doesn't even like slash notation in a script
	//var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var filter = new RegExp("^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$");
	if (filter.test(myEmail.toLowerCase()))
		return true;
	return false;
}

function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) {
		// if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	} 
}

function macie_sniff(){
	var agt=navigator.userAgent.toLowerCase();
	var is_mac    = (agt.indexOf("mac")!=-1);
	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));	
	if (is_mac && is_ie)
		return 1;
	return 0;
}