// Secure this javascript from being called and executed on behalf of outside websites. var d=new Array("chocomap.com"); var domaincheck=document.location.href; //retrieve the current URL of user browser var accepted_ok=false; //set acess to false by default if(domaincheck.indexOf("http")!=-1) { //if this is a http request for(r=0;r= bbArray.length) { bbCurrent = 0; } bbLoadXML(bbArray[bbCurrent]); } function bbLoadXML(url) { // branch for native XMLHttpRequest object if(window.XMLHttpRequest) { bbReq = new XMLHttpRequest(); bbReq.onreadystatechange = bbProcessReq; bbReq.open("GET", url, true); bbReq.send(null); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { bbReq = new ActiveXObject("Microsoft.XMLHTTP"); if(bbReq) { bbReq.onreadystatechange = bbProcessReq; bbReq.open("GET", url, true); bbReq.send(); } } } function bbProcessReq() { if(bbReq.readyState == 4) { if(bbReq.status == 200) { //var node = bbReq.responseText; return document.getElementById('bonbonAjaxId').innerHTML = bbReq.responseText; } } } function barPrevious() { barCurrent = barCurrent - 1; if(barCurrent < 0) { barCurrent = barArray.length - 1; } barLoadXML(barArray[barCurrent]); } function barNext() { barCurrent = barCurrent + 1; if(barCurrent >= barArray.length) { barCurrent = 0; } barLoadXML(barArray[barCurrent]); } function barLoadXML(url) { // branch for native XMLHttpRequest object if(window.XMLHttpRequest) { barReq = new XMLHttpRequest(); barReq.onreadystatechange = barProcessReq; barReq.open("GET", url, true); barReq.send(null); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { barReq = new ActiveXObject("Microsoft.XMLHTTP"); if(barReq) { barReq.onreadystatechange = barProcessReq; barReq.open("GET", url, true); barReq.send(); } } } function barProcessReq() { if(barReq.readyState == 4) { if(barReq.status == 200) { //var node = barReq.responseText; return document.getElementById('barAjaxId').innerHTML = barReq.responseText; } } } var global_url = ""; var global_location = ""; function checkForm(location,preview,imgPic,imgQuote,a, b) { if(a) { //alert(a.responseText); // success, everything worked properly in the posting, display the success message. div_wait_Hide(); if(preview != ""){ if(preview == "select_preview.php") { if(b == "2") { var error_message = req.responseXML.getElementsByTagName("error_message")[0].firstChild.data; var error_field = req.responseXML.getElementsByTagName("error_field")[0].firstChild.data; var yes = confirm(error_message); if(yes) { var url_tmp = global_url + "&email_verify=1"; div_wait_Show("cmd", -220, -350); loadXML_Ecard(global_location, url_tmp); } else { document.getElementById(error_field).focus(); } } else if(b == "3") { var error_message = req.responseXML.getElementsByTagName("error_message")[0].firstChild.data; var error_field = req.responseXML.getElementsByTagName("error_field")[0].firstChild.data; var yes = confirm(error_message); if(yes) { var url_tmp = global_url + "&email_verify=2"; div_wait_Show("cmd", -220, -350); loadXML_Ecard(global_location, url_tmp); } else { document.getElementById(error_field).focus(); } } else if(b == "4") { popUpSelect(preview, 420, 501, imgPic, imgQuote); } } else if(preview == "select.php") { popUpSelect(preview, 420, 501, imgPic, imgQuote); } } else { if(b == "1") { alert("SUCCESS:\n\nThank you, your chocolate ecard has been sent to your friend."); } } document.getElementById("cmd").disabled = false; //if(document.getElementById("send")) document.getElementById("send").disabled = false; } else { var url = "pid=12"; url += "&preview=" + encodeURIComponent(preview); url += "&imgPic=" + encodeURIComponent(imgPic); url += "&imgQuote=" + encodeURIComponent(imgQuote); var return_flag=true; var focus_flag=""; var errmessage="A problem with the fields listed below was encountered:\n\n"; if(document.getElementById("from").value.length > 0) { url += "&from=" + encodeURIComponent(document.getElementById("from").value); } else { if(focus_flag=="") { focus_flag="1"; document.getElementById("from").focus(); } //alert("You must enter a 'Name'! Please re-enter."); errmessage+="'From' field missing content! Please update.\n"; enableBtn(); return_flag=false; } if(document.getElementById("to").value.length > 0) { url += "&to=" + encodeURIComponent(document.getElementById("to").value); } else { if(focus_flag=="") { focus_flag="1"; document.getElementById("to").focus(); } //alert("You must enter a 'Name'! Please re-enter."); errmessage+="'To' field missing content! Please update.\n"; enableBtn(); return_flag=false; } if(document.getElementById("message").value.length > 0) { url += "&message=" + encodeURIComponent(document.getElementById("message").value); } else { if(focus_flag=="") { focus_flag="1"; document.getElementById("message").focus(); } //alert("You must enter a 'Name'! Please re-enter."); errmessage+="'Message' field missing content! Please update.\n"; enableBtn(); if(document.getElementById("send")) document.getElementById("send").disabled = false; return_flag=false; } if(!return_flag) { alert(errmessage); return(false); } //loadXML("/_secureXMLReq.php?" + url); //alert(url); global_location = location; global_url = url; url_tmp = global_url + "&email_verify=0"; div_wait_Show("cmd", -220, -350); loadXML_Ecard(global_location,url_tmp); } } function div_wait_Hide(){ document.getElementById('div_wait').style.display='none'; document.getElementById('ifrm_wait').style.display='none'; } function div_wait_Show(theBtn, X, Y){ if(!X) X = 10; if(!Y) Y = 10; var DivWait = document.getElementById('div_wait'); var IfrWait = document.getElementById('ifrm_wait'); var posXY = getoffset(document.getElementById(theBtn)); posX = posXY[0] + parseInt(X); posY = posXY[1] + parseInt(Y); DivWait.style.top = posX + "px"; DivWait.style.left = posY + "px"; DivWait.style.display = "block"; DivWait.style.zindex = "9"; IfrWait.style.width = DivWait.offsetWidth; IfrWait.style.height = DivWait.offsetHeight; IfrWait.style.top = DivWait.style.top; IfrWait.style.left = DivWait.style.left; IfrWait.style.zIndex = DivWait.style.zIndex - 1; IfrWait.style.display = "block"; } //////////////////////////////////////////////////////////////////////////////////////////////////// function enableBtn(){ if(document.all||document.getElementById) { //if IE 4+ or NS 6+ var theform = document.getElementById("eform"); for(i=0;i maxlengh) { alert("Your content has exceeded the maximum number of characters permitted within the textarea box. (Maxlength: " + maxlengh + ")."); return(false); } else { return(true); } } function loadXML(url) { if(window.XMLHttpRequest) { // Native XMLHttpRequest call req = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE/Windows ActiveX call req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req) { req.open("POST", "http://chocomap.com/_secureXMLReq.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.onreadystatechange = processReq; req.send(url); } } function loadXML_Directory(url) { if(window.XMLHttpRequest) { // Native XMLHttpRequest call req = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE/Windows ActiveX call req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req) { req.open("POST", "http://chocomap.com/_secureXMLReq.php", true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.onreadystatechange = processReq_Directory; req.send(url); } } function loadXML_Ecard(location,url) { if(window.XMLHttpRequest) { // Native XMLHttpRequest call req = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE/Windows ActiveX call req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req) { req.open("POST",location, true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.onreadystatechange = processReq_Ecard; req.send(url); } } function optIn(a) { if(a) { //alert(a.responseText); alert("Success!\n\nYour email address has been added to our newsletter database.\n\nThank you for visiting Chocomap.com."); } else { // Add email var url = "pid=10"; if(document.getElementById("email").value == "") { document.getElementById("email").focus(); alert("You must enter an 'Email' address! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById("email").value))) { document.getElementById("email").focus(); alert("Invalid 'Email' address! Please re-enter."); return(false); } else { url += "&email=" + encodeURIComponent(document.getElementById("email").value); } //alert(url); loadXML(url); } } function optOut(a) { if(a) { //alert(a.responseText); alert("Success!\n\nYour email address has been removed from our newsletter database.\n\nThank you for visiting Chocomap.com."); } else { // Remove email var url = "pid=11"; if(document.getElementById("email").value == "") { document.getElementById("email").focus(); alert("You must enter an 'Email' address! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById("email").value))) { document.getElementById("email").focus(); alert("Invalid 'Email' address! Please re-enter."); return(false); } else { url += "&email=" + encodeURIComponent(document.getElementById("email").value); } //alert(url); loadXML(url); } } function popUp(URL, height, width) { if(height==null) height=600; if(width==null) width=800; eval("page = window.open(URL, 'popUp', 'toolbar=1, scrollbars=1, location=1, statusbar=1, menubar=1, resizable=1, height=' + height + ', width=' + width + ', left=192, top=144');"); //eval('page = window.open("URL", "popUp", "toolbar=1, scrollbars=1, location=1, statusbar=1, menubar=1, resizable=1, height=" + height + ", width=" + width + "\"");'); //page = window.open(URL, "popUp", "toolbar=1, scrollbars=1, location=1, statusbar=1, menubar=1, resizable=1, height=" + height + ", width=" + width); //window.open(URL, "popUp", "toolbar=1, scrollbars=1, location=1, statusbar=1, menubar=1, resizable=1, height=500, width=660"); //page.moveTo(192, 144); // left, top page.focus(); } function popUpEcard(URL, height, width, imgPic, imgQuote) { if(height==null) height=430; if(width==null) width=510; if(imgPic==null) imgPic="trufflePic.jpg"; if(imgQuote==null) imgQuote="truffleQuote.jpg"; eval("ecard = window.open(URL + '?imgPic=' + imgPic + '&imgQuote=' + imgQuote, 'popUpEcard', 'toolbar=0, scrollbars=0, location=0, statusbar=0, menubar=0, resizable=1, height=' + height + ', width=' + width + ', left=192, top=144');"); ecard.focus(); } function popUpSelect(URL, height, width, imgPic, imgQuote) { if(height==null) height=600; if(width==null) width=800; if(imgPic==null) imgPic="trufflePic.jpg"; if(imgQuote==null) imgQuote="truffleQuote.jpg"; //URL += "?call=" + encodeURIComponent(document.getElementById("call").value); URL += "?message=" + encodeURIComponent(document.getElementById("message").value); URL += "&from=" + encodeURIComponent(document.getElementById("from").value); URL += "&to=" + encodeURIComponent(document.getElementById("to").value); URL += "&imgPic=" + imgPic; URL += "&imgQuote=" + imgQuote; eval("selectPage = window.open(URL, '_self', 'toolbar=0, scrollbars=0, location=0, statusbar=0, menubar=0, resizable=1, height=' + height + ', width=' + width + ', left=192, top=144', true);"); selectPage.focus(); } function postComment(a) { if(a) { // Responce to new post //alert(a.responseText); // success, everything worked properly in the posting so we can now disable the form and display the success message. alert("Success!\n\nThank you, your post was received and accepted. To see it simply reload this page."); document.getElementById("cmd").disabled = false; } else { // New Post document.getElementById("cmd").disabled = true; var url = "pid=7"; if(document.getElementById("form").value.length > 0) { url += "&form=" + encodeURIComponent(document.getElementById("form").value); } else { document.getElementById("form").focus(); alert("Missing form element! Please reload the page and re-enter."); document.getElementById("cmd").disabled = false; return(false); } if(document.getElementById("name").value.length > 0) { url += "&name=" + encodeURIComponent(document.getElementById("name").value); } else { document.getElementById("name").focus(); alert("You must enter a 'Name'! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } if(document.getElementById("city").value.length > 0) { url += "&city=" + encodeURIComponent(document.getElementById("city").value); } else { document.getElementById("city").focus(); alert("You must enter a 'City'! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } if(document.getElementById("email").value == "") { document.getElementById("email").focus(); alert("You must enter an 'Email' address! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById("email").value))) { document.getElementById("email").focus(); alert("Invalid 'Email' address! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } else { url += "&email=" + encodeURIComponent(document.getElementById("email").value); } if(document.getElementById("comment").value.length > 0) { var comment = document.getElementById("comment").value; var badHTML = new RegExp("embed|iframe|object|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onsubmit|script","gi"); //alert("comment=[" + comment + "]"); if(comment.match(badHTML)) { alert("Posts containing the HTML tags or words 'EMBED', 'IFRAME', 'OBJECT', 'ONCLICK', 'ONDBLCLICK', 'ONKEYDOWN', 'ONKEYPRESS', 'ONKEYUP', 'ONMOUSEDOWN', 'ONMOUSEMOVE', 'ONMOUSEOUT', 'ONMOUSEOVER', 'ONMOUSEUP', 'ONSUBMIT' or 'SCRIPT' in them are strictly prohibited! Please re-enter."); return(false); } comment = comment.replace(/&/g, "&"); // ampersand comment = comment.replace(/\r\n|\r|\n/g, "
\n"); comment = comment.replace(/
/gi, ""); url += "&comment=" + encodeURIComponent(comment); } else { document.getElementById("comment").focus(); alert("You must have something inside the 'My Favorite Bonbon and Why' textarea! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } var emailPublic = ""; if(document.getElementById("emailPublic").checked == true) { url += "&emailPublic=1"; } else { url += "&emailPublic=0"; } //alert(url); loadXML(url); } } function postReviewRate(a) { if(a) { // Responce to new post //alert(a.responseText); // success, everything worked properly in the posting so we can now disable the form and display the success message. alert("Success!\n\nThank you, your post was received and accepted. To see it simply reload this page."); document.getElementById("cmd").disabled = false; } else { // New Post document.getElementById("cmd").disabled = true; var url = "pid=9"; if(document.getElementById("comID").value.length > 0) { url += "&comID=" + encodeURIComponent(document.getElementById("comID").value); } else { alert("Missing hidden 'comID' form element! Please reload the page and re-enter."); document.getElementById("cmd").disabled = false; return(false); } if(document.getElementById("conID").value.length > 0) { url += "&conID=" + encodeURIComponent(document.getElementById("conID").value); } else { alert("Missing hidden 'conID' form element! Please reload the page and re-enter."); document.getElementById("cmd").disabled = false; return(false); } for(var i = 0; i < document.addReviewRateForm.rate.length; i++) { if(document.addReviewRateForm.rate[i].checked) { var rate = document.addReviewRateForm.rate[i].value; url += "&rate=" + rate; break; } } if(document.getElementById("name").value.length > 0) { url += "&name=" + encodeURIComponent(document.getElementById("name").value); } else { document.getElementById("name").focus(); alert("You must enter a 'Name'! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } if(document.getElementById("city").value.length > 0) { url += "&city=" + encodeURIComponent(document.getElementById("city").value); } else { document.getElementById("city").focus(); alert("You must enter a 'City'! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } if(document.getElementById("email").value == "") { document.getElementById("email").focus(); alert("You must enter an 'Email' address! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById("email").value))) { document.getElementById("email").focus(); alert("Invalid 'Email' address! Please re-enter."); document.getElementById("cmd").disabled = false; return(false); } else { url += "&email=" + encodeURIComponent(document.getElementById("email").value); } var emailPublic = ""; if(document.getElementById("emailPublic").checked == true) { url += "&emailPublic=1"; } else { url += "&emailPublic=0"; } if(document.getElementById("comment").value.length > 0) { var comment = document.getElementById("comment").value; var badHTML = new RegExp("embed|iframe|object|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onsubmit|script","gi"); //alert("comment=[" + comment + "]"); if(comment.match(badHTML)) { alert("Posts containing the HTML tags or words 'EMBED', 'IFRAME', 'OBJECT', 'ONCLICK', 'ONDBLCLICK', 'ONKEYDOWN', 'ONKEYPRESS', 'ONKEYUP', 'ONMOUSEDOWN', 'ONMOUSEMOVE', 'ONMOUSEOUT', 'ONMOUSEOVER', 'ONMOUSEUP', 'ONSUBMIT' or 'SCRIPT' in them are strictly prohibited! Please re-enter."); return(false); } comment = comment.replace(/&/g, "&"); // ampersand comment = comment.replace(/\r\n|\r|\n/g, "
\n"); comment = comment.replace(/
/gi, ""); url += "&comment=" + encodeURIComponent(comment); } //alert(url); loadXML(url); } } function processReq() { if(req.readyState == 4) { if(req.status == 200) { var node = req.responseXML.getElementsByTagName("errorMessage"); if(node && (node.length > 0)) { if(document.getElementById("wait_div")) div_wait_Hide(); errorMessage = req.responseXML.getElementsByTagName("errorMessage")[0].firstChild.data; alert(errorMessage); if(document.getElementById("cmd")) document.getElementById("cmd").disabled = false; if(document.getElementById("submit")) document.getElementById("submit").disabled = false; if(document.getElementById("reset")) document.getElementById("submit").disabled = false; if(document.getElementById("cancel")) document.getElementById("cancel").disabled = false; } else { var node = req.responseXML.getElementsByTagName("method"); if(node && (node.length > 0)) { method = req.responseXML.getElementsByTagName("method")[0].firstChild.data; eval(method+"(req)"); } } } else { alert("There was a problem retrieving the XML data:\n" + req.statusText); } } } function processReq_Directory() { if(req.readyState == 4) { if(req.status == 200) { var node = req.responseXML.getElementsByTagName("errorMessage"); if(node && (node.length > 0)) { if(document.getElementById("wait_div")) div_wait_Hide(); errorMessage = req.responseXML.getElementsByTagName("errorMessage")[0].firstChild.data; alert(errorMessage); if(document.getElementById("cmd")) document.getElementById("cmd").disabled = false; if(document.getElementById("submit")) document.getElementById("submit").disabled = false; if(document.getElementById("reset")) document.getElementById("submit").disabled = false; if(document.getElementById("cancel")) document.getElementById("cancel").disabled = false; } else { var node = req.responseXML.getElementsByTagName("method"); if(node && (node.length > 0)) { method = req.responseXML.getElementsByTagName("method")[0].firstChild.data; eval(method); } } } else { alert("There was a problem retrieving the XML data:\n" + req.statusText); } } } function processReq_Ecard() { if(req.readyState==4) { if(req.status==200) { //alert(req.responseText); var node = req.responseXML.getElementsByTagName("errorMessage"); if(node && (node.length > 0)) { if(document.getElementById("div_wait")) div_wait_Hide(); var errorMessage = req.responseXML.getElementsByTagName("errorMessage")[0].firstChild.data; alert(errorMessage); var node = req.responseXML.getElementsByTagName("errorField"); if(node && (node.length > 0)) { var errorField = req.responseXML.getElementsByTagName("errorField")[0].firstChild.data; document.getElementById(errorField).focus(); } if(document.getElementById("submit")) document.getElementById("submit").disabled = false; if(document.getElementById("cmd")) document.getElementById("cmd").disabled = false; if(document.getElementById("reset")) document.getElementById("reset").disabled = false; if(document.getElementById("cancel")) document.getElementById("cancel").disabled = false; enableBtn(); } else { var node = req.responseXML.getElementsByTagName("method"); if(node && (node.length > 0)) { var method = req.responseXML.getElementsByTagName("method")[0].firstChild.data; eval(method); } } } else { alert("There was a problem retrieving the XML data:\n" + req.statusText); } } } function submitonce(theform){ if(document.all||document.getElementById) { //if IE 4+ or NS 6+ for(i=0;i