// JavaScript Document xMousePos = 0; // Horizontal position of the mouse on the screen yMousePos = 0; // Vertical position of the mouse on the screen if (document.layers) { // Netscape document.captureEvents(Event.MOUSEMOVE); document.onmousemove = captureMousePosition; } else if (document.all) { // Internet Explorer document.onmousemove = captureMousePosition; } else if (document.getElementById) { // Netcsape 6 document.onmousemove = captureMousePosition; } // set the searchform url for ajax data var ajax_url_bro_popup = '/apps/inc/javascripts/ajax_brochure_popup.php'; function AjaxObject101() { this.createRequestObject = function() { try { var ro = new XMLHttpRequest(); } catch (e) { var ro = new ActiveXObject("Microsoft.XMLHTTP"); } return ro; } this.sndReq = function(action, url, data) { if (action.toUpperCase() == "POST") { this.http.open(action,url,true); this.http.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); this.http.onreadystatechange = this.handleResponse; this.http.send(data); } else { this.http.open(action,url + '?' + data,true); this.http.onreadystatechange = this.handleResponse; this.http.send(null); } } this.handleResponse = function() { if ( me.http.readyState == 4) { if (typeof me.funcDone == 'function') { me.funcDone();} var rawdata = me.http.responseText.split("^"); for ( var i = 0; i < rawdata.length; i++ ) { var item = (rawdata[i]).split("=>"); if (item[0] != "") { if (item[1].substr(0,3) == "%V%" ) { document.getElementById(item[0]).value = item[1].substring(3); } else { document.getElementById(item[0]).innerHTML = item[1]; } } } } if ((me.http.readyState == 1) && (typeof me.funcWait == 'function')) { me.funcWait(); } } var me = this; this.http = this.createRequestObject(); var funcWait = null; var funcDone = null; } // try to self fire so we dont need the tags on the html page var ao = new AjaxObject101(); ao.sndReq('get', ajax_url_bro_popup,'do=intialize'); function sendLead(obj) { if (CheckPopupFormValues(obj) == true) { setThankYouVisible(obj); var lead_data = 'do=submit_lead&f_name='+encodeURIComponent(document.getElementById('popup_f_name').value)+'&l_name='+encodeURIComponent(document.getElementById('popup_l_name').value)+'&email='+encodeURIComponent(document.getElementById('popup_email').value)+'&zip_code='+encodeURIComponent(document.getElementById('popup_zip').value)+'&popup_checkbox='+encodeURIComponent(document.getElementById('popup_checkbox').value)+'&phone='+encodeURIComponent(document.getElementById('popup_phone').value); var ao = new AjaxObject101(); var ajax_url_bro_popup = '/apps/inc/javascripts/ajax_brochure_popup.php'; ao.sndReq('POST', ajax_url_bro_popup, lead_data); } } function setVisible(obj, id, popuptype) { puDiv = document.getElementById(obj); if (id == '0') { puDiv.style.visibility = 'hidden'; puDiv.style.left = -1000 + 'px'; puDiv.style.top = -1000 + 'px'; } else { puDiv.style.visibility = 'visible'; puDiv.style.left = (xMousePos - 150)+ 'px'; puDiv.style.top = (yMousePos - 250) + 'px'; document.getElementById('request_info_thankyou_popup').style.visibility = 'hidden'; // append a tracking image to the document var e=document.createElement("img"); e.src="http://view.atdmt.com/jaction/bvkahg_GetaFreeBrochureButton_1"; e.alt="BKV"; document.getElementsByTagName("body")[0].appendChild(e); createCookie('pos_x', xMousePos + 'px', 1); createCookie('pos_y', (yMousePos - 150) + 'px', 1); createCookie('popListingID', id, 1); createCookie('popuptype', popuptype, 1); } } function setThankYouVisible(obj) { puDiv = document.getElementById(obj); puDiv.style.visibility = 'visible'; puDiv.style.left = (xMousePos - 415) + 'px'; puDiv.style.top = (yMousePos - 145) + 'px'; //puDiv.style.width = 350 + "px"; document.getElementById('request_info_popup').style.visibility = 'hidden'; // append a tracking image to the document var e=document.createElement("img"); e.src="http://view.atdmt.com/jaction/bvkahg_FreeBrochureThankYou_3"; e.alt="BKV"; document.getElementsByTagName("body")[0].appendChild(e); } function closeThankYou(obj) { puDiv = document.getElementById(obj); puDiv.style.visibility = 'hidden'; puDiv.style.left = -1000 + 'px'; puDiv.style.top = -1000 + 'px'; } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; } function captureMousePosition(e) { if (document.layers) { xMousePos = e.pageX; yMousePos = e.pageY; } else if (document.all) { xMousePos = window.event.clientX + getViewportScrollX(); yMousePos = window.event.clientY + getViewportScrollY(); } else if (document.getElementById) { xMousePos = e.pageX; yMousePos = e.pageY; } } function getViewportScrollX() { var scrollX = 0; if (document.documentElement && document.documentElement.scrollLeft) { //IE standards compliant and W3C scrollX = document.documentElement.scrollLeft; } else if (document.body && document.body.scrollLeft) { // IE 6 not standards compliant scrollX = document.body.scrollLeft; } else if (window.pageXOffset) { // older browsers scrollX = window.pageXOffset; } else if (window.scrollX) { // Gecko and KHTML/Webkit browsers I think... scrollX = window.scrollX; } return scrollX; } function getViewportScrollY() { var scrollY = 0; if (document.documentElement && document.documentElement.scrollTop) { scrollY = document.documentElement.scrollTop; } else if (document.body && document.body.scrollTop) { scrollY = document.body.scrollTop; } else if (window.pageYOffset) { scrollY = window.pageYOffset; } else if (window.scrollY) { scrollY = window.scrollY; } return scrollY; } // JavaScript Document function CheckPopupFormValues (frmObj){ var iValidationCounter = 0; var alertMsg = "The following fields are required:\n"; if (document.getElementById('popup_f_name').value.length == 0) { alertMsg += " * Your First Name.\n"; iValidationCounter = iValidationCounter + 1; } if (document.getElementById('popup_l_name').value.length == 0) { alertMsg += " * Your Last Name.\n"; iValidationCounter = iValidationCounter + 1; } if (document.getElementById('popup_email').value.length == 0) { alertMsg += " * Your E-mail Address\n"; iValidationCounter = iValidationCounter + 1; } else { validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i; strEmail = document.getElementById('popup_email').value; if (strEmail.search(validRegExp) == -1) { alertMsg += " * Invalid E-mail Address: must be formated like john@doe.com\n"; iValidationCounter = iValidationCounter + 1; } } if (document.getElementById('popup_zip').value == "") { alertMsg += " * Your Zip Code\n"; iValidationCounter = iValidationCounter + 1; } else { validRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/; strZip = document.getElementById('popup_zip').value; if (strZip.search(validRegExp) == -1) { alertMsg += " * Invalid Zip Code: must be formated like 12345 or 12345-6789\n"; iValidationCounter = iValidationCounter + 1; } } if (iValidationCounter == 0){ return true; } else { alert(alertMsg); return false; } }