/* Copyright: Copyright (c) 2008 http://ramui.com. All rights reserved.

This product is protected by copyright and distributed under licenses restricting copying, distribution. Permission is granted to the public to download and use this script provided that this Notice and any statement of authorship are reproduced in every page on all copies of the script. */

function validateForm(max){
	var errors='';
	var str=fw_trim(document.getElementById('fw_contact_name').value);
	if (str.length > 40){
		errors='Name must be within 40 characters.\n'; 
	}
	if (str.length <3){
		errors='Write your name.\n'; 
	}
	str=fw_trim(document.getElementById('fw_contact_message').value);
	if (str.length > max){
		errors+='Message length must be within '+max+'characters.\n'; 
	}
	if (str.length <10){
		errors+='Write some Message.\n'; 
	}
	/*
	str=fw_trim(document.getElementById('fw_contact_subject').value);
	if (str.length > 78){
	errors+='Subject length must be within 78 characters.\n'; }
	*/
	str=fw_trim(document.getElementById('fw_contact_from').value);
	if (!((str.indexOf(".") > 0) && (str.indexOf("@") > 0)&&(str.length < 100))){
		errors+='Enter correct email id\n'; 
	}
	/*
	var code = parseInt(document.getElementById('fw_contact_captcha').value);
	 if ((code < 1000) || (code > 9999) || isNaN(code)) {
	errors+='Enter correct varification code\n'; }
	*/
	if (errors){
		alert('The following error(s) occurred:\n'+errors);
		return false;
	}
	
	return true;
}

function fw_reset(){
	document.getElementById('fw_feedback').innerHTML="";
	document.getElementById('fw_contact_name').value="";
	document.getElementById('fw_contact_phone').value="";
	document.getElementById('fw_contact_from').value="";
	document.getElementById('fw_contact_message').value="";
}

function fw_mail(){
	document.getElementById('fw_feedback').innerHTML="";
	if(validateForm(3000)){
		var url = "/DHTMLPopupForm/SendContactUsForm.asp?sendmail=true";
		var params = "name=" + fw_total_encode(document.getElementById('fw_contact_name').value) + "&phone=" + fw_total_encode(document.getElementById('fw_contact_phone').value) + "&from=" +fw_total_encode(document.getElementById('fw_contact_from').value) +"&to=" +fw_total_encode(document.getElementById('fw_contact_to').value) +"&message=" +fw_total_encode(document.getElementById('fw_contact_message').value);
		//alert('<%=Request.Querystring("id")>');
		var fw_connection=fw_connect(url,params);
		fw_connection.onreadystatechange = function(){
			if(fw_connection.readyState == 4 && fw_connection.status == 200){
				fw_close();
				/*
				document.getElementById('fw_contact_name').disabled = true;
				document.getElementById('fw_contact_phone').disabled = true;
				document.getElementById('fw_contact_from').disabled = true;
				document.getElementById('fw_contact_message').disabled = true;
				document.getElementById('fw_button').disabled = true;
				document.getElementById('fw_feedback').innerHTML=fw_connection.responseText;
				*/
				//setTimeout("fw_close();",3000);
				//fw_image();
			}
			/*
			if(fw_connection.status == 200){
				fw_close();
			}
			*/
		}
	}
}

function fw_mouseMove(e){
	if(fw_cform!=null){e = e || window.event;
		fw_cform.style.left = fw_posX + e.clientX + "px";
		fw_cform.style.top  = fw_posY + e.clientY + "px";
		fw_deselect();
	}
}

function fw_start_draging(){
	fw_cform = document.getElementById('fw_dhtmlpopup');
	document.getElementById('fw_drag_header').style.cursor='move';
}

function fw_mouseUp(){
	if(parseInt(document.getElementById('fw_dhtmlpopup').style.left)<0){document.getElementById('fw_dhtmlpopup').style.left=0;}
	if(parseInt(document.getElementById('fw_dhtmlpopup').style.top)<0){document.getElementById('fw_dhtmlpopup').style.top=0;}
	document.getElementById('fw_drag_header').style.cursor='text';
	fw_cform = null;
}

function fw_mouseDown(e){
	if(fw_cform!=null){
		if (!e){e = window.event;}
		fw_cform.style.zIndex = 100;
		fw_posX = parseInt(fw_cform.style.left)-e.clientX;
		fw_posY = parseInt(fw_cform.style.top)-e.clientY;
	}
}

function fw_DHTML_popup(){
	document.getElementById('fw_feedback').innerHTML=""; document.getElementById('fw_dhtmlpopup').style.display='block';scroll(0,0);
}

function fw_close(){
	document.getElementById('fw_dhtmlpopup').style.display='none';
}

function fw_deselect (){
	if(window.opera){
		document.getElementById('fw_deselectOpera').focus();return true;
	}

	if(document.selection){
		document.selection.empty();
	}
	else{
		if(window.getSelection){
			window.getSelection().removeAllRanges();
		}
	}
}

var fw_cform,fw_posX=0,fw_posY=0;
var fw_imageindex=0;
var fw_flag=true;
document.onmousedown = fw_mouseDown;
document.onmousemove = fw_mouseMove;
document.onmouseup = fw_mouseUp;

//document.write('<style type="text/css">\n<!--\n#fw_contact_holder{width:380px; padding: 10px 0px; background:#ffffff;}\n#fw_contact_holder p, #fw_contact_holder td{color:black; font-family:arial; font-size:12px;}\n#fw_contact_holder a{color:#226644; font-family:tahoma;}\n#fw_contact_holder a:hover{color:#6699aa;}\n.fw_text{height:17px; border:1px solid #aaaaaa; width:200px;}\n.fw_text:hover{background:#f0f0f0;}\n#fw_button{height:20px; border:1px solid gray; background:#dddddd; font-size:11px; font-family:tahoma;}\n#fw_button:hover{background:#f0f0f0;}\n-->\n</style>\n<div id="fw_dhtmlpopup" style="z-index:500; display:none; position:absolute; left:100px;top:0px; width:370px;">\n<input type="hidden" id="fw_deselectOpera" value="" />\n<table cellspacing="0" style="clear:both; border:1px solid; border-color:#999999 #999999 #dddddd #dddddd;"><tr>\n<td id="fw_drag_header" style="background:#004080; cursor:pointer; padding:0;" onmousedown="fw_start_draging()">\n<div style="float:left; clear:left; color:#ffffff;padding:2px 3px 2px 25px; background:url(\'webblog_files/icon.gif\') no-repeat; margin:0;line-height:100%;"><b>How can we be of service?:</b></div>\n<a href="javascript:fw_close();"><img style="float:right; border:none; margin:3px;" src="webblog_files/close.gif" /></a></td></tr>\n<tr><td style="padding:5px; background:#ffffff; color:black;">\n<div id="fw_contact_holder">\n<div style="clear:both;"><div style="clear:both; margin:10px 0;" id="fw_feedback"></div>\n<table cellspacing="4px" style="width:100%; padding:10px 0 10px 10px;">\n<tr><td><sup>*</sup>Your name:</td><td><input name="name" type="text" class="fw_text" id="fw_contact_name" /></td></tr>\n<tr><td><sup>*</sup>Your e-mail:</td><td><input name="from" type="text" id="fw_contact_from" class="fw_text" /></td></tr>\n<tr><td>Subject:</td><td><input name="subject" type="text" id="fw_contact_subject" class="fw_text" /></td></tr>\n<tr><td><sup>*</sup>Message:</td><td><textarea name="message" id="fw_contact_message" rows="1" cols="20" class="fw_text" style="height:150px;"></textarea></td></tr>\n<tr><td><sup>*</sup>Type <a href="javascript:fw_image()">verification image</a>:</td><td>\n<input id="fw_contact_captcha" name="captcha_code" type="text" class="fw_text" style="margin:0; padding:0; vertical-align:top; width:100px;" />\n<img id="fw_captcha_img" alt="verification image" style="border:none; padding:0 2px;height:16px;" /></td></tr></table>\n<p><input name="Submit" type="button" id="fw_button"  value="Send Message" onclick="fw_mail()" /></p>\n<p style="color:#c0c0c0; margin:10px 0 5px 0px; text-align:left;">___________________________<br />\n<span style="color:#004422; font-size:11px; margin-left:5px;"><sup>*</sup>Fields are mandatory</span></p>\n</div></div></td></tr></table></div>');

//document.write('<style type="text/css">\n<!--\n#fw_contact_holder{width:300px; padding: 10px 0px; background:#ffffff;}\n#fw_contact_holder p, #fw_contact_holder td{color:black; font-family:arial; font-size:12px;}\n#fw_contact_holder a{color:#226644; font-family:tahoma;}\n#fw_contact_holder a:hover{color:#6699aa;}\n.fw_text{height:17px; border:1px solid #aaaaaa; width:200px;}\n.fw_text:hover{background:#f0f0f0;}\n#fw_button{height:20px; border:1px solid gray; background:#dddddd; font-size:11px; font-family:tahoma;}\n#fw_button:hover{background:#f0f0f0;}\n-->\n</style>\n<div id="fw_dhtmlpopup" style="z-index:99999; display:none; position:absolute; left:350px;top:250px; width:370px;">\n<input type="hidden" id="fw_deselectOpera" value="" />\n<table cellspacing="0" style="clear:both; border:1px solid; border-color:#999999 #999999 #dddddd #dddddd;"><tr>\n<td id="fw_drag_header" style="background:#ce1127; cursor:pointer; padding:0;" onmousedown="fw_start_draging()">\n<div style="float:left; clear:left; color:#ffffff;padding:2px 3px 2px 3px; margin:0;line-height:100%;"><font style="face:Arial;size:12px;color:#ffffff;"><b>How can we be of service?</b></font></div>\n<a href="javascript:fw_close();"><img style="float:right; border:none; margin:3px;" src="/DHTMLPopupForm/close.gif" /></a></td></tr>\n<tr><td style="padding:5px; background:#ffffff; color:black;">\n<div id="fw_contact_holder">\n<div style="clear:both;"><div style="clear:both; margin:10px 0;" id="fw_feedback"></div>\n<table cellspacing="4px" style="width:100%; padding:10px 0 10px 10px;">\n<tr><td><sup>*</sup>NAME:</td><td><input name="name" type="text" class="fw_text" id="fw_contact_name" /></td></tr>\n<tr><td><sup>*</sup>EMAIL:</td><td><input name="from" type="text" id="fw_contact_from" class="fw_text" /></td></tr>\n<tr><td valign="top"><sup>*</sup>MESSAGE:</td><td><textarea name="message" id="fw_contact_message" rows="1" cols="20" class="fw_text" style="height:99px;"></textarea></td></tr>\n<tr><td></td><td><input type="hidden" name="myid" value="<%=myid %>"><input name="Submit" type="button" id="fw_button"  value="SEND MESSAGE" onclick="fw_mail()" /></td></tr></table>\n</div></div></td></tr></table></div>');

document.write('<style type="text/css">\n<!--\n#fw_contact_holder{width:250px; padding: 10px 0px; background:#ffffff;}\n#fw_contact_holder p, #fw_contact_holder td{color:black; font-family:arial; font-size:12px;}\n#fw_contact_holder a{color:#226644; font-family:tahoma;}\n#fw_contact_holder a:hover{color:#6699aa;}\n.fw_text{height:17px; border:1px solid #aaaaaa; width:200px;}\n.fw_text:hover{background:#f0f0f0;}\n#fw_button{height:20px; border:1px solid gray; background:#dddddd; font-size:11px; font-family:tahoma;}\n#fw_button:hover{background:#f0f0f0;}\n-->\n</style>\n<div id="fw_dhtmlpopup" style="z-index:99999; display:none; position:absolute; left:350px;top:250px; width:370px;">\n<input type="hidden" id="fw_deselectOpera" value="" />\n<table cellspacing="0" style="clear:both; border:1px solid; border-color:#999999 #999999 #dddddd #dddddd;"><tr>\n<td id="fw_drag_header" style="background:#ffffff; cursor:pointer; padding:0;" onmousedown="fw_start_draging()">\n<div style="float:left; clear:left; color:#ffffff;padding:2px 3px 2px 3px; margin:0;line-height:100%;"><font style="face:Arial;size:12px;color:#ce1127;"><b>How can we be of service?</b></font></div>\n<a href="javascript:fw_close();"><img style="float:right; border:none; margin:3px;" src="/DHTMLPopupForm/close.gif" /></a></td></tr>\n<tr><td style="padding:5px; background:#ffffff; color:black;">\n<div id="fw_contact_holder">\n<div style="clear:both;"><div style="clear:both; margin:0;" id="fw_feedback" style="display:none;"></div>\n<table cellspacing="4px" style="width:100%; padding:0;">\n<tr><td><font color="#ce1127">Thank you for your interest in PBK. Please complete the information below and one of our teammates will be in touch with you shortly.<br /><br /></font></td></tr>\n<tr><td><font color="#7b7b7b">NAME:</font><br /><input name="name" type="text" class="fw_text" id="fw_contact_name" /></td></tr>\n<tr><td><font color="#7b7b7b">PHONE:</font><br /><input name="phone" type="text" class="fw_text" id="fw_contact_phone" /></td></tr>\n<tr><td><font color="#7b7b7b">EMAIL:</font><br /><input name="from" type="text" id="fw_contact_from" class="fw_text" /><input name="to" type="hidden" id="fw_contact_to" value="mark.madorsky@pbk.com" /></td></tr>\n<tr><td valign="top"><font color="#7b7b7b">MESSAGE:</font><br /><textarea name="message" id="fw_contact_message" rows="1" cols="20" class="fw_text" style="height:99px;"></textarea></td></tr>\n<tr><td><input name="Submit" type="button" id="fw_button"  value=" SUBMIT " onclick="fw_mail()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="Reset" type="button" id="fw_button"  value=" RESET " onclick="fw_reset()" /></td></tr><tr><td><br/><p style="color:gray; font: 80% Arial,Helvetica,sans-serif;">NOTICE: All inquiries and applications regarding employment with PBK should be directed to the firm’s listings on <a style=" font: 110% Arial,Helvetica,sans-serif;" href="http://www.careerbuilder.com/Jobseeker/Jobs/JobResults.aspx?SB%3Asbkw=PBK+Architects&SB%3As_freeloc=&SB%3Asbfr=30&sbsbmt=Find+Jobs+%C2%BB&cid=US&excrit=QID%3DA6658245157695%3Bst%3Da%3Buse%3DALL%3BrawWords%3DPBK%3BCID%3DUS%3BSID%3D%3F%3BTID%3D0%3BENR%3DNO%3BDTP%3DDRNS%3BYDI%3DYES%3BIND%3DALL%3BPDQ%3DAll%3BPDQ%3DAll%3BPAYL%3D0%3BPAYH%3Dgt120%3BPOY%3DNO%3BETD%3DALL%3BRE%3DALL%3BMGT%3DDC%3BSUP%3DDC%3BFRE%3D30%3BQS%3Dsid_unknown%3BSS%3DNO%3BTITL%3D0%3BJQT%3DRAD%3BJDV%3DFalse%3BExpHigh%3Dgt50%3BExpLow%3D0%3BMaxLowExp%3D-1&IPath=QHKCV" target="_blank"> CareerBuilder.com</a></p></td></tr></table>\n</div></div></td></tr></table></div>');

//fw_image();
