var notInitialized=0;var setUp=1;var requestSent=2;var requestInProcess=3;var requestComplete=4;var xmlHttp;var tmpNewSubReq;function NewSubscriptionRequest(Q,R,X,M,E,A,G,O,L,U,K,W,C,z,T,V,D,B,P,H,F,I,N,S,J){this.txtEmailAddress=E;this.txtPostalCode=A;this.ddlCountryList=G;this.chkNewsflash=O;this.chkInformer=L;this.btnSubmit=U;this.lblEmalAddressStatus=K;this.lblPostalCodeStatus=W;this.lblNewsflashMessage=C;this.divSignUpPanel=z;this.divConfirmationPanel=T;this.divAlmostDonePanel=V;this.divLoadingPanel=D;this.spnEmailAddress=B;this.hrfEmailCorrectionLink=P;this.spnEmailDomainUrl=H;this.spnStraightToInbox=F;this.trackingAlmostDone=S;this.trackingThankYou=J;this.trackingCallback=I;this.tzLocale=Q;this.urlPrefix=R;this.signUpSource=X;this.signUpCode=M;this.Adid=N;this.newsflashCheckedDefault=true;this.informerCheckedDefault=true;this.showFormAfterComplete=false;this.customConfirmationPanel=null;this.init()}NewSubscriptionRequest.prototype.init=function(){var b=this;b.btnSubmit.onclick=function(f){goodPostalCode=validPostalCode(b.txtPostalCode.value,b.ddlCountryList.value,b.lblPostalCodeStatus,b.lblNewsflashMessage);goodEmailAddress=validEmailAddress(b.txtEmailAddress.value,b.lblEmalAddressStatus);var e=b.newsflashCheckedDefault;var a=b.informerCheckedDefault;if(b.chkNewsflash){e=b.chkNewsflash.checked}if(b.chkInformer){a=b.chkInformer.checked}if(goodPostalCode&&goodEmailAddress){if(b.txtPostalCode.value=="postcode"||b.txtPostalCode.value=="Postleitzahl"||b.txtPostalCode.value=="Code postal"||b.txtPostalCode.value=="ZIP code"){b.txtPostalCode.value=""}tmpNewSubReq=b;processSubscriptionRequest()}}};NewSubscriptionRequest.prototype.setCustomConfirmationPanel=function(c){var d=this;d.customConfirmationPanel=c};function GetXmlHttpObject(){xmlHttp=null;try{xmlHttp=new XMLHttpRequest()}catch(b){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}}return xmlHttp}function processSubscriptionRequest(){xmlHttp=GetXmlHttpObject();if(xmlHttp==null){alert("Your browser does not support AJAX!");return}var b=(tmpNewSubReq.urlPrefix==""?"":"/"+tmpNewSubReq.urlPrefix)+"/NewSubscriptionRequestHandler.ashx";b=b+"?emailAddress="+urlEncode(tmpNewSubReq.txtEmailAddress.value);b=b+"&postalCode="+urlEncode(tmpNewSubReq.txtPostalCode.value);b=b+"&countryCode="+tmpNewSubReq.ddlCountryList.value;b=b+"&signUpSource="+urlEncode(tmpNewSubReq.signUpSource);b=b+"&signUpCode="+urlEncode(tmpNewSubReq.signUpCode);b=b+"&campaignID="+tmpNewSubReq.Adid;b=b+"&newsflash="+tmpNewSubReq.chkNewsflash.checked;b=b+"&informer="+tmpNewSubReq.chkInformer.checked;b=b+"&tzLocale="+tmpNewSubReq.tzLocale;b=b+"&urlPrefix="+tmpNewSubReq.urlPrefix;b=b+"&sid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",b,true);xmlHttp.send(null)}function stateChanged(){if(xmlHttp.readyState==requestSent){fadeOut(tmpNewSubReq.divSignUpPanel.id,1);tmpNewSubReq.txtEmailAddress.disabled=true;tmpNewSubReq.txtPostalCode.disabled=true;tmpNewSubReq.btnSubmit.disabled=true;tmpNewSubReq.ddlCountryList.disabled=true}if(xmlHttp.readyState==requestInProcess){fadeIn(tmpNewSubReq.divLoadingPanel.id,2000)}if(xmlHttp.readyState==requestComplete){var k;var h;var i;var j;var l;var g;setTimeout("fadeOut('"+tmpNewSubReq.divLoadingPanel.id+"', 0)",1000);if(tmpNewSubReq.showFormAfterComplete){setTimeout("fadeIn('"+tmpNewSubReq.divSignUpPanel.id+"', 0)",1000)}h=xmlHttp.responseText.split("|");k=h[0];if(h.length>1){i=h[1];j=h[2];l=h[3];g=h[4]}if(tmpNewSubReq.customConfirmationPanel){setTimeout("fadeIn('"+tmpNewSubReq.customConfirmationPanel.id+"', 0)",1000)}else{if(isNumeric(k)){if(typeof ovrlyadurl!="undefined"){location.href=ovrlyadurl+"?conf=1&cm=signedup&source="+tmpNewSubReq.signUpSource}setTimeout("fadeIn('"+tmpNewSubReq.divConfirmationPanel.id+"', 0)",1000);if(g&&tmpNewSubReq.trackingThankYou){tmpNewSubReq.trackingThankYou.style.display="";tmpNewSubReq.trackingThankYou.innerHTML=""+g+""}}else{if(k=="currentmember"){window.top.location="http://"+tmpNewSubReq.urlPrefix+"top20.travelzoo.com/Confirm.aspx?currentmember"}else{tmpNewSubReq.spnEmailAddress.innerHTML=tmpNewSubReq.txtEmailAddress.value;tmpNewSubReq.hrfEmailCorrectionLink.href="http://"+tmpNewSubReq.urlPrefix+"top20.travelzoo.com/SignUp.aspx?uid="+k+"&se=1";if(i&&j&&tmpNewSubReq.spnStraightToInbox&&tmpNewSubReq.spnEmailDomainUrl){tmpNewSubReq.spnStraightToInbox.style.display="";tmpNewSubReq.spnEmailDomainUrl.innerHTML='<a href="'+j+'" target="_blank">'+i+"</a>"}if(l&&tmpNewSubReq.trackingAlmostDone){tmpNewSubReq.trackingAlmostDone.style.display="";tmpNewSubReq.trackingAlmostDone.innerHTML=""+l+""}setTimeout("fadeIn('"+tmpNewSubReq.divAlmostDonePanel.id+"', 0)",1000)}}}if(typeof tmpNewSubReq.trackingCallback=="function"){tmpNewSubReq.trackingCallback()}}}function urlEncode(m){var h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";var n="0123456789ABCDEF";var i="";for(var k=0;k<m.length;k++){var j=m.charAt(k);if(j==" "){i+="+"}else{if(h.indexOf(j)!=-1){i+=j}else{var l=j.charCodeAt(0);if(l>255){i+="+"}else{i+="%";i+=n.charAt((l>>4)&15);i+=n.charAt(l&15)}}}}return i};
