var InstallationUrl = '/newsletter/'; var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no) var bustcacheparameter=""; function createRequestObject(){ try { xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert('Sorry, but your browser doesn\'t support XMLHttpRequest.'); }; return xmlhttp; }; var http = createRequestObject(); function ajaxpage(url, containerid){ var page_request = createRequestObject(); if (bustcachevar) bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) { document.getElementById(containerid).innerHTML=page_request.responseText; }; } function SubmitNewsletterForm2(poststr, vcode) { var flagCaptcha = false; if(http.readyState == 4) { var showcheck = http.responseText; if(showcheck == '1') { flagCaptcha = true; } else { flagCaptcha = false; }; if (flagCaptcha == false) { alert('Incorrect verification code'); } else { poststr += '&captcha=' + vcode.value; ajaxpage('/newsletter/frontend/form.php?do=save&group=2'+poststr,'divNewsletter2'); } } }; function refreshImg2(){ var url = InstallationUrl + 'frontend/captcha-refresh.php?grid=2'; doRefresh2(url, displayImg2); }; function doRefresh2(url, callback) { http.open('POST', url, true); http.onreadystatechange = displayImg2; http.send(null); }; function displayImg2() { if(http.readyState == 4) { var showimage = http.responseText; document.getElementById('captchaImage').innerHTML = showimage; }; }; function CheckNewsletterForm2() { //var submission = document.NewsletterForm2.vercode.value; //var url = InstallationUrl + 'frontend/captcha-process.php?captcha=' + submission; var flagFields = true; var re = /([0-9a-zA-Z\.\-\_]+)@([0-9a-zA-Z\.\-\_]+)/; var message = 'Please fill in all fields ! \n'; var poststr = "&email=" + encodeURIComponent( document.NewsletterForm2.email.value ); if (document.NewsletterForm2.name.value=='') { message += 'Name \n'; flagFields = false; } else { poststr += "&name="+ encodeURIComponent( document.NewsletterForm2.name.value ); } if (document.NewsletterForm2.email.value=='') { message += 'Email \n'; flagFields = false; } if (document.NewsletterForm2.email.value.length!=0 && document.NewsletterForm2.email.value.match(re)==null){ message += 'Email \n'; flagFields = false; } if (document.NewsletterForm2.address.value=='') { message += 'Address \n'; flagFields = false; } else { poststr += "&address="+ encodeURIComponent( document.NewsletterForm2.address.value ); } if (document.NewsletterForm2.phone.value=='') { message += 'Phone \n'; flagFields = false; } else { poststr += "&phone="+ encodeURIComponent( document.NewsletterForm2.phone.value ); } if (document.NewsletterForm2.website.value=='') { message += 'Website \n'; flagFields = false; } else { poststr += "&website="+ encodeURIComponent( document.NewsletterForm2.website.value ); } if (flagFields) { if (document.NewsletterForm2.vercode) { http.open('POST', InstallationUrl + 'frontend/captcha-process.php?captcha=' + document.NewsletterForm2.vercode.value, true); http.onreadystatechange = function () { SubmitNewsletterForm2(poststr, document.NewsletterForm2.vercode); }; http.send(null); } else { ajaxpage('/newsletter/frontend/form.php?do=save&group=2'+poststr,'divNewsletter2'); } } else { alert(message); } }; loadNewsletter = '
'; document.writeln(loadNewsletter);