if(!srvrVar.qasProxy){throw"QAS service urls not generated."}var QAS_Variables={PROXY_PATH:srvrVar.qasProxy,ADD_PROXY_PATH:srvrVar.qasAddressProxy,TD_PROXY_PATH:srvrVar.qasTdProxy,QAS_LAYOUT:"CommonApp",PRE_ON_CLICK:null,POST_ON_CLICK:CommonApp_ShowAddress,BUTTON_ID:"",ADDRESS_FIELD_IDS:[["add1","add2","add3","city","county","state","zip","","","lat","lng"]],COUNTRY_FIELD_IDS:["country"],DATA_SETS:["USA","CAN"],ADD_DATA_SETS:["AFG","ALA","ALB","DZA","ASM","AND","AGO","AIA","ATA","ATG","ARG","ARM","ABW","AUS","AUT","AZE","BHS","BHR","BGD","BRB","BLR","BEL","BLZ","BEN","BMU","BTN","BOL","BIH","BWA","BVT","BRA","IOT","BRN","BGR","BFA","BDI","KHM","CMR","CPV","CYM","CAF","TCD","CHL","CHN","CXR","CCK","COL","COM","COD","COK","CRI","CIV","HRV","CUB","CYP","CZE","DNK","DJI","DMA","DOM","ECU","EGY","SLV","GNQ","ERI","EST","ETH","FLK","FRO","FJI","FIN","FRA","GUF","PYF","ATF","GAB","GMB","GEO","DEU","GHA","GIB","GRC","GRL","GRD","GLP","GUM","GTM","GGY","GIN","GNB","GUY","HTI","HMD","VAT","HND","HKG","HUN","ISL","IND","IDN","IRN","IRQ","IRL","IMN","ISR","ITA","JAM","JPN","JEY","JOR","KAZ","KEN","KIR","PRK","KOR","KWT","KGZ","LAO","LVA","LBN","LSO","LBR","LBY","LIE","LTU","LUX","MAC","MKD","MDG","MWI","MYS","MDV","MLI","MLT","MHL","MTQ","MRT","MUS","MYT","MEX","FSM","MDA","MCO","MOZ","MMR","NAM","NRU","NPL","NLD","ANT","NCL","NZL","NIC","NER","NGA","NIU","NFK","MNP","NOR","OMN","PAK","PLW","PSE","PAN","PNG","PRY","PER","PHL","PCN","POL","PRT","PRI","QAT","REU","ROU","RUS","RWA","SHN","KNA","LCA","SPM","VCT","WSM","SMR","STP","SAU","SEN","SRB","SYC","SLE","SGP","SVK","SVN","SLB","SOM","ZAF","SGS","ESP","LKA","SDN","SUR","SJM","SWZ","SWE","CHE","SYR","TWN","TJK","TZA","THA","TLS","TGO","TKL","TON","TTO","TUN","TUR","TKM","TCA","TUV","UGA","UKR","ARE","GBR","UMI","URY","UZB","VUT","VEN","VNM","VIB","VIR","WLF","ESH","YEM","ZMB","ZWE"],DEFAULT_DATA:"USA",COMMONAPP_ADDRESS_QUESTION_ID:"",COMMONAPP_QAS:"QAS",COUNTRY_MAP:[["US","USA"],["U.S.","USA"],["U.S.A.","USA"],["United States","USA"],["United States of America","USA"],["Canada","CAN"],["CA","CAN"],["China","CHN"],["Brazil","BRA"],["Hong Kong","HKG"],["India","IND"],["Indonesia","IDN"],["Italy","ITA"],["Japan","JPN"],["Korea","KOR"],["Mexico","MEX"]],PHONE_VALIDATE_COUNTRY:["AIA","ATG","BHS","BRB","BMU","CAN","CYM","DMA","DOM","GRD","JAM","MSR","KNA","LCA","TCA","TTA","USA","VCT","VGB","VIR"],LVR:7,EMAIL_FIELD_IDS:["email","billemail","altemail"],EMAIL_ERR_FIELD_IDS:["email_error","billemail_error","altemail_error"],PHONE_FIELD_IDS:["phone","billphone","altphone"],PHONE_ERR_FIELD_IDS:["phone_error","billphone_error","altphone_error"],DISPLAY_CUSTOM_EMAIL_ERR:true,DISPLAY_CUSTOM_PHONE_ERR:true,EMAIL_VAL_LEVEL:"2",EMAIL_PHONE_NUM_SUBMITS:2,ADDRESS_INTERACTION:true,EMAIL_PHONE_INTERACTION:true,EMAIL_PHONE_USEDIALOG:true,DISPLAY_ERRORS:true,TIMEOUT:5000,TIMEOUT_EMAILPHONE:5000,DISPLAY_LINES:6,previousBuildingNumberSearch:"",previousAptNumberSearch:"",blnResetPreviousBuildingNumber:false,blnResetPreviousAptNumber:false,};var QAS_PROMPTS={InteractionRequired:{header:"We think that your address may be incorrect or incomplete.",prompt:"Recommended address:",button:"Use Suggested Address"},PremisesPartial:{header:"We think your apartment/suite/unit is missing or wrong.",prompt:"Enter your apartment, suite or unit number below:",button:"Continue",showPicklist:"See all potential matches",invalidRange:"Apartment, suite, or unit number is not within valid range."},StreetPartial:{header:"Sorry, we do not recognize your house or building number.",prompt:"Confirm your House or Building number:",button:"Confirm number",showPicklist:"See all potential matches",invalidRange:"House or Building number not within valid range."},DPVPartial:{header:"Sorry, we do not recognize your house or building number.",prompt:"Confirm your House/Building number:",button:"Confirm number"},AptAppend:{header:"Sorry, we think your apartment/suite/unit may be missing.",prompt:"Confirm Apt/Ste:",button:"Continue",noApt:"I do not have an apt or suite"},Multiple:{header:"We have found more than one match for your address.",prompt:"Select one of the following potential matches:"},None:{header:"We were unable to verify your address."},RightSide:{prompt:"You entered an address that may be undeliverable:",edit:"Edit",button:"Use as entered",warning:""},ConfirmEmailPhone:{header:"<b>Sorry we could not confirm your e-mail address and phone number</b><br />To proceed, please confirm your e-mail address and phone number below.",headerPhone:"<b>Sorry we could not confirm your phone number</b><br />To proceed, please confirm your phone number below.",headerEmail:"<b>Sorry we could not confirm your e-mail address</b><br />To proceed, please confirm your e-mail address below.",promptEmail:"Confirm or edit your e-mail address",promptPhone:"Confirm or edit your phone number"},waitMessage:"Please wait, your details are being verified",title:"Verify your address details",emailphoneTitle:"Verify your contact details",noValueEntered:"No value entered."};var EMAIL_ERR_MESSAGES={"5":"Validation Timeout","10":"Syntax OK","20":"Syntax OK and domain valid according to the domain database","30":"Syntax OK and domain exists","40":"Syntax OK, domain exists, and domain can receive email","50":"Syntax OK, domain exists, and mailbox does not reject mail","100":"Email has a general syntax error","110":"Email has an invalid character","115":"Email domain syntax is invalid","120":"Email username syntax is invalid","125":"Username syntax is invalid for that domain","130":"Email is too long","135":"Incorrect parentheses, brackets, or quotes","140":"Email does not have a username","145":"Email does not have a domain","150":"Email does not have an @ sign","155":"Email has more than one @ sign","200":"Email has an invalid top-level-domain","205":"Email cannot have an IP address as domain","210":"Email address contains space or extra text","215":"Email has unquoted spaces","310":"Email domain is invalid","315":"Email domain IP address is not valid","325":"Email domain cannot receive email","400":"Email username is invalid or nonexistent","410":"Email mailbox is full","420":"Email is not accepted for this domain","500":"Email username is not permitted","505":"Emails domain is not permitted","510":"Email is suppressed and not permitted"};var PHONE_ERR_MESSAGES={"5":"Validation Timeout","10":"Successfully Parsed and Standardized, Area Code and Exchange Match","100":"Area code contains invalid exchange digits","110":"Invalid area code and exchange","120":"Phone number has too few digits","130":"Phone number has too many digits","133":"Phone exchange and number not allowed","134":"Phone number exchange not allowed","135":"Phone number not allowed","140":"Extension greater than 5 digits","150":"Toll free number was entered","160":"900 numbers was entered"};var QAS_TEMP_VARS={NUM_EMAIL_PHONE_SUBMITS:0,EMAIL_PHONE_POS:0};function Address(){var n=QAS_Variables.ADDRESS_FIELD_IDS;var d=QAS_Variables.COUNTRY_FIELD_IDS;if($("#"+d[0]+"_"+QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID).val()!="USA"){n=[["add1","add2","add3","city","state","zip"]]}var b=[];var s=[];var t=new Array(n.length);var r=[];var q=[];var g=[];var h=QAS_Variables.DATA_SETS;var a=QAS_Variables.ADD_DATA_SETS;var m,o,e;QAS_Variables.previousAptNumberSearch="";QAS_Variables.previousBuildingNumberSearch="";QAS_Variables.blnResetPreviousBuildingNumber=false;QAS_Variables.blnResetPreviousAptNumber=false;var k=function(){for(m=0;m<n.length;m++){var u=[];for(o=0;o<n[m].length;o++){if(n[m][o]==""){continue}var j=encodeURIComponent($("#"+n[m][o]+"_"+QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID).val());if(j===undefined){if(QAS_Variables.DISPLAY_ERRORS){alert("ID '"+n[m][o]+"' is undefined")}}else{j=j.replace(/^\s+|\s+$/g,"")}u.push(j)}var i=$("#"+d[m]+"_"+QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID).val();if((i==="")||(i===undefined)){i=QAS_Variables.DEFAULT_DATA}for(e=0;e<QAS_Variables.COUNTRY_MAP.length;e++){if(i.toLowerCase()===QAS_Variables.COUNTRY_MAP[e][0].toString().toLowerCase()){i=QAS_Variables.COUNTRY_MAP[e][1].toString()}}u.push(i);b.push(u)}};var l=function(){var i=true;var u=0;for(m=0;m<b.length;m++){t[m]=s.length;i=true;u=0;while(i&&(u<s.length)){if(b[m].toString().toLowerCase()===s[u].toString().toLowerCase()){i=false;t[m]=u}u++}if(i){s.push(b[m])}}};var f=function(u,v){var i=false;var w=0,x=0;while(w<u.length){if(u[w]!==""){i=true}if(u[w]===undefined){return false}w++}if(i){for(x=0;x<h.length;x++){if(v===h[x]){return true}}for(x=0;x<a.length;x++){if(v===a[x]){return true}}}return false};var c=function(){for(m=0;m<s.length;m++){q.push(s[m].pop());if(f(s[m],q[m])){r.push(s[m].join("|"))}else{r.push(false)}}};var p=function(){try{if(g[0][0]==""){if(g[0][1]!=""){g[0][0]=g[0][1];g[0][1]=""}else{if(g[0][2]!=""){g[0][0]=g[0][2];g[0][2]=""}}}}catch(i){}for(m=0;m<n.length;m++){if(g[t[m]]!==undefined){for(o=0;o<n[m].length;o++){if(n[m][o]==""){continue}$("#"+n[m][o]+"_"+QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID).val(decodeURIComponent(g[t[m]][o]))}}}};this.getSearchStrings=function(){return r};this.getSearchCountries=function(){return q};this.getOriginalAddresses=function(){return s};this.storeCleanedAddress=function(i){g.push(i)};this.returnCleanAddresses=function(){p()};k();l();c()}function Clean(w,d,b){var o=this;var l=b;var m=QAS_Variables.TIMEOUT;var r=false;var x=false;var q="";var n,j;var p=w;var h;var c=function(k){for(j=0;j<QAS_Variables.ADD_DATA_SETS.length;j++){if(k===QAS_Variables.ADD_DATA_SETS[j]){return QAS_Variables.ADD_PROXY_PATH}}return QAS_Variables.PROXY_PATH};var s=c(d);var y=function(k){switch(o.country){case"AUS":k=k.replace(/\d{4}$/,"");break;case"DEU":k=k.replace(/\d{5}-\d{5}$/,"");break;case"DNK":k=k.replace(/\s\d{4}\s/," ");break;case"FRA":k=k.replace(/\s\d{5}\s/," ");break;case"GBR":k=k.replace(/\w{1,2}\d{1,2}\w?\s\d\w{2}$/,"");break;case"LUX":k=k.replace(/\s\d{4}\s/,"");break;case"NLD":k=k.replace(/\s\d{4}\s\w{2}\s/," ");break;case"NZL":k=k.replace(/\d{4}$/,"");break;case"SGP":k=k.replace(/\d{6}$/,"");break;case"USA":k=k.replace(/-\d{4}$/,"");break}return k};var t=function(){o.result.push($(this).text())};var u=function(){var B=$(this).find("partialtext").text();var k=$(this).find("addresstext").text();var C=$(this).find("postcode").text();var A=decodeURIComponent($(this).find("moniker").text());var z=$(this).find("fulladdress").text();o.result.push({partialText:B,addressText:k,postCode:C,moniker:A,fulladdress:z})};var i=function(){var k;for(k=0;k<o.result.length;k++){if(o.result[k].fulladdress.toString().toLowerCase()==="false"){return o.result[k].partialText}}return null};var v=function(k){if(shd.comVar.inAjaxErrorRetryLoop){shd.comVar.inAjaxErrorRetryLoop=false;shd.comVar.qasConsecutiveAjaxRetries=0;shd.comVar.useAddressAsEntered=false;shd.comVar.switchToManualSave=false}o.verifylevel=$(k).find("verifylevel").text();o.dpv=$(k).find("dpvstatus").text();o.error=$(k).find("error").text();if(o.error!==""&&QAS_Variables.DISPLAY_ERRORS){l(k,o.error,"Error");return}if(r&&(o.verifylevel==="PremisesPartial")){r=false}else{if(x&&(o.verifylevel==="StreetPartial")){x=false}else{o.result=[];r=false;x=false;o.missingsubprem=false;if((o.verifylevel==="Verified")||(o.verifylevel==="VerifiedStreet")||(o.verifylevel==="VerifiedPlace")||(o.verifylevel==="InteractionRequired")){$(k).find("line").each(t);o.missingsubprem=$(k).find("missingsubprem").text()}else{o.fullMoniker=decodeURIComponent($(k).find("fullmoniker").text());$(k).find("picklistitem").each(u);if((o.verifylevel==="PremisesPartial")||(o.verifylevel==="StreetPartial")){q=i();if(q===null){o.verifylevel="Multiple"}}}}}$("#verifylevel_"+QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID).val(o.verifylevel);n()};var a=function(k){$.ajax({type:"POST",url:s,async:true,data:k,dataType:"xml",success:v,timeout:m,error:l})};var g=function(k,A){var z={action:"search",addlayout:QAS_Variables.QAS_LAYOUT,country:A,searchstring:k};a(z)};var e=function(z){var k={action:"GetFormattedAddress",addlayout:QAS_Variables.QAS_LAYOUT,moniker:z};a(k)};var f=function(B,k,A){var z={action:"search",addlayout:QAS_Variables.QAS_LAYOUT,moniker:B,searchstring:k,country:A};a(z)};this.result=[];this.fullPickListMoniker="";this.verifylevel="";this.dpv="";this.error="";this.missingsubprem=false;this.country=d;this.search=function(k){n=k;g(p,o.country)};this.searchPremisesPartial=function(A,B){n=B;r=true;var k=w.split("|");var z=k[0].split(",");if(QAS_Variables.blnResetPreviousAptNumber){if(z[2]!==undefined){z[2]=z[2].replace(QAS_Variables.previousAptNumberSearch,A)}else{if(z[1]!==undefined){z[1]=z[1].replace(QAS_Variables.previousAptNumberSearch,A)}}QAS_Variables.blnResetPreviousAptNumber=false}else{if(z[1]!==undefined){z[1]=z[1]+","+A}else{if(z[0]!==undefined){z[0]=z[0]+","+A}}}k[0]=z.join(",");k=k.join("|");w=k;QAS_Variables.previousAptNumberSearch=A;f(o.fullMoniker,w,d)};this.searchStreetPartial=function(A,B){n=B;x=true;var k=w.split("|");var z=k[0].split(",");if(QAS_Variables.blnResetPreviousBuildingNumber){if(z[0]!==undefined){z[0]=z[0].replace(QAS_Variables.previousBuildingNumberSearch,A)}QAS_Variables.blnResetPreviousAptNumber=false}else{z[0]=A+","+z[0]}k[0]=z.join(",");k=k.join("|");w=k;QAS_Variables.previousBuildingNumberSearch=A;f(o.fullMoniker,w,d)};this.searchDPVPartial=function(k,z){n=z;var A=o.result.join("|");A=encodeURIComponent(A.replace(/\|?\d+\w*\s/,"|"+k+" "));g(A,o.country)};this.formatAddress=function(z,k){n=k;e(z)};this.refineAddress=function(z,k){n=k;f(z,w,d)}}function Business(b,c,k,e){var j=this;var f=b;var g=c;var i=k;var h=e;i.push(g.country);var l="";var d=0;var a=function(n){var m="";m=g.result[n];if(m){var o=g.result.join("|");if(o.search(/\|?\d+\s*-\s*\d+/)!==-1){return true}else{return false}}else{return true}};this.noInteraction=function(){if((g.verifylevel==="Verified")||(j.verifylevel==="VerifiedStreet")||(j.verifylevel==="VerifiedPlace")||(g.verifylevel==="InteractionRequired")){f()}else{j.useOriginal()}};this.processResult=function(){d++;hideError();switch(g.verifylevel){case"Verified":case"VerifiedStreet":if(g.country==="USA"){if(c.dpv==="DPVNotConfirmed"){h.setDPVPartial(i,QAS_PROMPTS.DPVPartial,j.refineDPV,j.useOriginal);h.display()}else{if(c.dpv==="DPVConfirmedMissingSec"){h.setInterReq(g.result,i,QAS_PROMPTS.InteractionRequired,j.acceptInter,j.useOriginal);h.display()}else{f()}}}else{if(g.country==="CAN"){if(!a(QAS_Variables.LVR-1)){h.setAptAppend(i,QAS_PROMPTS.AptAppend,j.appendApt,f,j.useOriginal);h.display()}else{f()}}else{f()}}break;case"VerifiedPlace":case"InteractionRequired":if((g.country==="CAN")&&(!a(QAS_Variables.LVR-1))){h.setAptAppend(i,QAS_PROMPTS.AptAppend,j.appendApt,f,j.useOriginal);h.display()}else{if(d>1){f()}else{h.setInterReq(g.result,i,QAS_PROMPTS.InteractionRequired,j.acceptInter,j.useOriginal);h.display()}}break;case"PremisesPartial":h.setPartial(g.result,i,QAS_PROMPTS.PremisesPartial,j.refineApt,j.acceptMoniker,j.useOriginal);h.display();if(l==="PremisesPartial"){QAS_Variables.blnResetPreviousAptNumber=true;showError(QAS_PROMPTS.PremisesPartial.invalidRange)}l="PremisesPartial";break;case"StreetPartial":h.setPartial(g.result,i,QAS_PROMPTS.StreetPartial,j.refineBuild,j.acceptMoniker,j.useOriginal);h.display();if(l==="StreetPartial"){QAS_Variables.blnResetPreviousBuildingNumber=true;showError(QAS_PROMPTS.StreetPartial.invalidRange)}l="StreetPartial";break;case"Multiple":h.setMultiple(g.result,i,QAS_PROMPTS.Multiple,j.acceptMoniker,j.refineMult,j.useOriginal);h.display();break;case"None":h.setNone(i,QAS_PROMPTS.None,j.useOriginal);h.display();break}};this.acceptInter=function(){f()};this.acceptMoniker=function(m){g.formatAddress(m,f)};this.refineApt=function(){var m=$("#QAS_RefineText").val();g.searchPremisesPartial(m,j.processResult)};this.refineBuild=function(){var m=$("#QAS_RefineText").val();g.searchStreetPartial(m,j.processResult)};this.refineDPV=function(){var m=$("#QAS_RefineText").val();g.searchDPVPartial(m,j.processResult)};this.appendApt=function(){var o=$("#QAS_RefineText").val();var m=0;var n=false;while((!n)&&(m<g.result.length)){if(decodeURIComponent(g.result[m]).search(/^\d+\s/)!==-1){n=true;g.result[m]=o+"-"+g.result[m]}m++}f()};this.refineMult=function(m){g.refineAddress(m,j.processResult)};this.useOriginal=function(){i.pop();if(g.country=="USA"){i.splice(i.length-2,0,"","")}g.result=i;f()}}function Interface(d){var f=d;var j;var h;var g;var i="";var b=function(){var k;i="";for(k=0;k<j.length;k++){if(j[k].fulladdress.toString().toLowerCase()==="true"){i+="<tr><td NOWRAP><a href='#' class='QAS_StepIn' moniker='"+j[k].moniker+"'>"+decodeURIComponent(j[k].addressText)+"</a></td><td NOWRAP><a href='#' class='QAS_StepIn' moniker='"+j[k].moniker+"'>"+decodeURIComponent(j[k].postCode)+"</a></td></tr>"}else{i+="<tr><td NOWRAP>"+decodeURIComponent(j[k].addressText)+"</td><td NOWRAP>"+decodeURIComponent(j[k].postCode)+"</td></tr>"}}};var a=function(){var k;i="";for(k=0;k<j.length;k++){if(j[k].fulladdress.toString().toLowerCase()==="true"){i+="<tr><td NOWRAP><a href='#' class='QAS_StepIn' moniker='"+j[k].moniker+"'>"+decodeURIComponent(j[k].addressText)+"</a></td><td NOWRAP><a href='#' class='QAS_StepIn' moniker='"+j[k].moniker+"'>"+decodeURIComponent(j[k].postCode)+"</a></td></tr>"}else{i+="<tr><td NOWRAP><a href='#' class='QAS_Refine' moniker='"+j[k].moniker+"'>"+decodeURIComponent(j[k].addressText)+"</a></td><td NOWRAP><a href='#' class='QAS_Refine' moniker='"+j[k].moniker+"'>"+decodeURIComponent(j[k].postCode)+"</a></td></tr>"}}};var c=function(k){var m="";var l;for(l=0;l<h.length;l++){if(h[l]!==""){m+=controlsFunc.htmlEscape(decodeURIComponent(h[l]))+"<br />"}}$(".QAS_RightDetails").html("<div class='QAS_RightSidePromptText qasd-t'>"+QAS_PROMPTS.RightSide.prompt+"</div><div class='qasd-e'>"+m+"</div><a href='#' id='QAS_AcceptOriginal' class='qasd-l'>"+QAS_PROMPTS.RightSide.button+"</a><a href='#' id='QAS_Edit' class='qasd-l m-edit'>"+QAS_PROMPTS.RightSide.edit+"</a><div class='QAS_DeliverableWarning'></div>");$("#QAS_AcceptOriginal").click(function(n){shd.comVar.useAddressAsEntered=true;k();n.preventDefault()});$("#QAS_Edit").click(function(n){shd.comVar.editAddress=true;k();n.preventDefault()})};var e=function(){$("#QAS_Dialog").remove();$(document.body).append("<div id='QAS_Dialog' title='"+QAS_PROMPTS.title+"' class='modal' style='display:none;'>  <div class='qas-tb'>"+QAS_PROMPTS.title+"</div>  <div class='qas-wr'>  <div class='QAS_Header qas-h'></div>    <div class='qas-c h-clearfix'>      <div class='QAS_Prompt qasp h-clearfix'>        <div class='QAS_PromptText qasp-t'></div>        <div class='QAS_PromptData  qasp-d'></div>        <div class='QAS_Input qasp-i'></div>        <div class='QAS_Picklist qaspl'>          <div class='QAS_MultPick'></div>          <div class='QAS_ShowPick qaspl-s'></div>          <div class='QAS_Pick qaspl-p'></div>        </div>      </div>      <div class='QAS_RightDetails qasd'></div>    </div>  </div></div>");if($("#QAS_Wait").length===0){$(document.body).append("<div id='QAS_Wait' title = '"+QAS_PROMPTS.waitMessage+"' class='modal qas-w' style='display:none;'>Please wait<br/><small>Your details are being verified</small></div>")}$(".QAS_ShowPick, a.jqQSP").click(function(k){$(".QAS_Pick").slideToggle("slow");k.stopPropagation();k.preventDefault()});$(".QAS_Pick").hide()};this.waitOpen=function(){var k=$("#QAS_Wait");if(!k.isOverlay()){k.showOverlay({isChange:true,removeOnClose:true})}};this.waitClose=function(){$("#QAS_Wait").addClass("jqsoc")};this.display=function(){window.scroll(0,0);dialogOpen();hideError();$("#QAS_RefineBtn").blur();$(".QAS_Header").focus()};showError=function(l){var k=QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID+QAS_Variables.COMMONAPP_QAS;controlsFunc.showError(l,k)};hideError=function(){var k=QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID+QAS_Variables.COMMONAPP_QAS;controlsFunc.hideError(k)};this.setInterReq=function(l,p,o,k,q){h=p;g=o;var m="",n;c(q);for(n=0;n<QAS_Variables.DISPLAY_LINES;n++){m+=(l[n]==="")?"":decodeURIComponent(l[n])+"<br/>"}$(".QAS_Header").html(o.header);$(".QAS_PromptText").html(o.prompt);$(".QAS_PromptData").html(m);$(".QAS_Input").html("<input type='button' id='QAS_RefineBtn' value='"+o.button+"' class='primary_btn' />");$(".QAS_MultPick").html("");$(".QAS_ShowPick").html("");$(".QAS_Pick").html("");$(".QAS_MultPick").hide();$("#QAS_RefineBtn").click(function(){k()})};this.setPartial=function(p,n,l,q,m,o){j=p;h=n;g=l;var k=QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID+QAS_Variables.COMMONAPP_QAS;b();c(o);$(".QAS_Header").html(l.header);$(".QAS_PromptText").html(l.prompt);$(".QAS_PromptData").html("");$(".QAS_Input").html($.stringFormat(html.validationMessage,[k,""])+"<input type='text' id='QAS_RefineText' class='input' /><input type='button' id='QAS_RefineBtn' class='btnPrimary' value='"+l.button+"' />");$(".QAS_MultPick").html("");$(".QAS_ShowPick").html("<a class='jqQSP' href='#'>"+l.showPicklist+"</a>");$(".QAS_Pick").html("<table>"+i+"</table>");$(".QAS_MultPick").hide();$("#QAS_RefineBtn").click(function(){if($("#QAS_RefineText").val()===""){var s=$("div.QAS_PromptText").text();var r=QAS_PROMPTS.noValueEntered;if(s==QAS_PROMPTS.PremisesPartial.prompt){r="To continue, provide apartment, suite, or unit number."}else{if((s==QAS_PROMPTS.StreetPartial.prompt)){r="To continue, provide house or building number."}}showError(r)}else{q()}});$(".QAS_StepIn").click(function(r){var s=$(this).attr("moniker");m(s);r.preventDefault()})};this.setDPVPartial=function(m,l,o,n){h=m;g=l;var k=QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID+QAS_Variables.COMMONAPP_QAS;c(n);$(".QAS_Header").html(l.header);$(".QAS_PromptText").html(l.prompt);$(".QAS_PromptData").html("");$(".QAS_Input").html($.stringFormat(html.validationMessage,[k,""])+"<input type='text' id='QAS_RefineText' class='input' /><input type='button' id='QAS_RefineBtn' value='"+l.button+"' class='primary_btn' />");$(".QAS_MultPick").html("");$(".QAS_MultPick").hide();$("#QAS_RefineBtn").click(function(){if($("#QAS_RefineText").val()===""){showError(QAS_PROMPTS.noValueEntered)}else{o()}})};this.setAptAppend=function(n,l,p,m,o){h=n;g=l;var k=QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID+QAS_Variables.COMMONAPP_QAS;c(o);$(".QAS_Header").html(l.header);$(".QAS_PromptText").html(l.prompt);$(".QAS_PromptData").html("");$(".QAS_Input").html($.stringFormat(html.validationMessage,[k,""])+"<input type='text' id='QAS_RefineText' class='input' /><input type='button' id='QAS_RefineBtn' value='"+l.button+"' class='primary_btn' /><br /><input type='button' id='QAS_NoApt' value='"+l.noApt+"' class='primary_btn' />");$(".QAS_MultPick").html("");$(".QAS_MultPick").hide();$("#QAS_RefineBtn").click(function(){if($("#QAS_RefineText").val()===""){showError(QAS_PROMPTS.noValueEntered)}else{p()}});$("#QAS_NoApt").click(function(){m()})};this.setMultiple=function(o,m,l,k,p,n){j=o;h=m;g=l;a();c(n);$(".QAS_Header").html(l.header);$(".QAS_PromptText").html(l.prompt);$(".QAS_PromptData").html("");$(".QAS_Input").html("");$(".QAS_MultPick").html("<table>"+i+"</table>");$(".QAS_ShowPick").html("");$(".QAS_Pick").html("");$(".QAS_MultPick").show();$(".QAS_StepIn").click(function(q){var r=$(this).attr("moniker");k(r);q.preventDefault()});$(".QAS_Refine").click(function(){var q=$(this).attr("moniker");p(q)})};this.setNone=function(l,k,m){h=l;g=k;c(m);$(".QAS_Header").html(k.header);$(".QAS_Prompt").remove();$(".QAS_Input").remove();$(".QAS_MultPick").html("");$(".QAS_ShowPick").remove();$(".QAS_Pick").remove();$(".QAS_RightDetails").css("float","left");$(".QAS_MultPick").hide()};e()}function EmailPhoneInterface(a){var c;this.waitOpen=function(){var d=$("#QAS_Wait");if(!d.isOverlay()){d.showOverlay({isChange:true,removeOnClose:true})}};this.waitClose=function(){$("#QAS_Wait").addClass("jqsoc")};this.display=function(){window.scroll(0,0);dialogOpen();$("#QAS_RefineBtn").blur();$(".QAS_Header").focus()};this.displayResult=function(n,d){var g;var j=0;var h=$("#QAS_Dialog").children();var e=h.length;var f=0;var k=0;var o,p,i;var l=false;var m=false;c=n;for(i=0;i<e;i++){o=h[i];if($(o).attr("class")==="QAS_EmailPrompt"){f=i}else{if($(o).attr("class")==="QAS_PhonePrompt"){k=i}}}$(".QAS_Header").html("");$(".QAS_EmailPromptText").html("");$(".QAS_EmailErrText").html("");$(".QAS_EmailInput").html("");$(".QAS_EmailPromptData").html("");$(".QAS_PhonePromptText").html("");$(".QAS_PhoneErrText").html("");$(".QAS_PhoneInput").html("");$(".QAS_EmailSuggPrompt").html("");if(c.email!==undefined&&c.email!==null&&c.email.ok===false){l=true;$(".QAS_Header").html(QAS_PROMPTS.ConfirmEmailPhone.headerEmail);$(".QAS_EmailPromptText").html(QAS_PROMPTS.ConfirmEmailPhone.promptEmail);if(QAS_Variables.DISPLAY_CUSTOM_EMAIL_ERR===true){$(".QAS_EmailErrText").html(EMAIL_ERR_MESSAGES[c.email.status_code])}$(".QAS_EmailInput").html("<input type='text' id='QAS_EmailRefineText' value='"+c.email.address+"' />");if(c.email.corrections!==undefined&&c.email.corrections!==null&&c.email.corrections.length>0){$(".QAS_EmailSuggPrompt").html("Suggestions:");g="<table id='QAS_EmailSuggestions'><tbody>";for(i=0;i<c.email.corrections.length;i++){g+="<tr><td>"+c.email.corrections[i]+"</td></tr>"}g+="</tbody></table>";$(".QAS_EmailPromptData").html(g)}if(f>k){o=h[f];h[f]=h[k];h[k]=o}j++}if(c.phone!==undefined&&c.phone!==null&&c.phone.ok===false){m=true;$(".QAS_PhonePromptText").html(QAS_PROMPTS.ConfirmEmailPhone.promptPhone);if(QAS_Variables.DISPLAY_CUSTOM_PHONE_ERR===true){$(".QAS_PhoneErrText").html(PHONE_ERR_MESSAGES[n.phone.status_code])}$(".QAS_PhoneInput").html("<input type='text' id='QAS_PhoneRefineText' value='"+$("input#"+QAS_Variables.PHONE_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).val()+"' />");if(j===1){$(".QAS_Header").html(QAS_PROMPTS.ConfirmEmailPhone.header);$(".QAS_PhonePrompt").css("float","right")}else{$(".QAS_Header").html(QAS_PROMPTS.ConfirmEmailPhone.headerPhone);$(".QAS_PhonePrompt").css("float","left");if(f<k){o=h[f];h[f]=h[k];h[k]=o}}j++}$(h).remove();$("#QAS_Dialog").append($(h));if(l===true){$("tbody td").click(function(q){$("input#QAS_EmailRefineText").val($(this).text())})}if(j===1){dialogOpen();$(".QAS_EmailInput").focus()}else{dialogOpen()}if(j>0){$(".QAS_EmailPhoneContinue").html("<input type='button' id='QAS_TDContinue' value='Continue' />");$("#QAS_TDContinue").button();$("#QAS_TDContinue").click(function(){var q="action=validate";if(c.phone!==undefined&&c.phone!==null&&c.phone.ok===false){$("#"+QAS_Variables.PHONE_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).val($("#QAS_PhoneRefineText").val());q=q+"&phone="+$("#QAS_PhoneRefineText").val()}if(c.email!==undefined&&c.email!==null&&c.email.ok===false){$("#"+QAS_Variables.EMAIL_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).val($("#QAS_EmailRefineText").val());q=q+"&email="+$("#QAS_EmailRefineText").val();q=q+"&emaillev="+QAS_Variables.EMAIL_VAL_LEVEL}d(q)})}};var b=function(){$("#QAS_Dialog").remove();$(document.body).append("<div id='QAS_Dialog' title='"+QAS_PROMPTS.emailphoneTitle+"' style='display:none;'>  <div class='QAS_Header ui-state-highlight'></div>  <div class='QAS_EmailPrompt'>    <div class='QAS_EmailPromptText'></div>    <div class='QAS_EmailErrText'></div>    <div class='QAS_EmailInput'></div>    <div class='QAS_EmailSuggPrompt'></div>    <div class='QAS_EmailPromptData'></div>  </div>  <div class='QAS_PhonePrompt'>    <div class='QAS_PhonePromptText'></div>    <div class='QAS_PhoneErrText'></div>    <div class='QAS_PhoneInput'></div>  </div>  <div class='QAS_EmailPhoneContinue'></div></div>");if($("#QAS_Wait").length===0){$(document.body).append("<div id='QAS_Wait' title = '"+QAS_PROMPTS.waitMessage+"' class='modal qas-w' style='display:none;'>Please wait<br/><small>Your details are being verified</small></div>")}};b()}function EmailPhoneValidation(e,c,n){this.records=[];var r,k=e,j=c,l=n,i,m=false;var b=function(u,t,s){i.waitClose();shd.comVar.qasConsecutiveAjaxRetries++;shd.comVar.inAjaxErrorRetryLoop=true;if(shd.comVar.qasConsecutiveAjaxRetries<shd.consts.maxQasAjaxRetriesAllowed){QAS_Verify()}else{shd.comVar.inAjaxErrorRetryLoop=false;shd.comVar.qasConsecutiveAjaxRetries=0;shd.comVar.useAddressAsEntered=true;shd.comVar.switchToManualSave=true;if(k!==null&&k!==undefined){k()}}if(QAS_Variables.DISPLAY_ERRORS){}};var a=function(s){s()};var f=function(){$("select").css("visibility","");i.waitClose();if(l!==null&&l!==undefined){n(k,j)}else{if(k!==null&&k!==undefined){k()}if(j!==""){$("#"+j).attr("onclick","");$("#"+j).parent("form").attr("onsubmit","");$("#"+j).click()}}};var d=function(){var s;for(s=0;s<QAS_Variables.EMAIL_FIELD_IDS.length;s++){if($("input#"+QAS_Variables.EMAIL_FIELD_IDS[s]).val()!==""){m=true;break}}for(s=0;m===false&&s<QAS_Variables.PHONE_FIELD_IDS.length;s++){if($("input#"+QAS_Variables.PHONE_FIELD_IDS[s]).val()!==""){m=true;break}}};var o=function(){var u,s,t=false,v=false;if(QAS_TEMP_VARS.EMAIL_PHONE_POS>=QAS_Variables.EMAIL_FIELD_IDS.length&&QAS_TEMP_VARS.EMAIL_PHONE_POS>=QAS_Variables.PHONE_FIELD_IDS.length){return false}r="action=validate";r=r+"&emaillev="+QAS_Variables.EMAIL_VAL_LEVEL;u=encodeURIComponent($("input#"+QAS_Variables.EMAIL_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).val());if(u!==""){v=true;r=r+"&email="+u}if(QAS_Variables.PHONE_VALIDATE_COUNTRY[0]==="ALL"||QAS_Variables.COUNTRY_FIELD_IDS.length<QAS_TEMP_VARS.EMAIL_PHONE_POS){t=true}else{u=$("#"+QAS_Variables.COUNTRY_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).val();for(s=0;s<QAS_Variables.PHONE_VALIDATE_COUNTRY.length;s++){if(u===QAS_Variables.PHONE_VALIDATE_COUNTRY[s]){t=true;break}}}if(t===true){u=encodeURIComponent($("input#"+QAS_Variables.PHONE_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).val());if(u!==""){v=true;r=r+"&phone="+u}}return v};var q=function(s){if(QAS_TEMP_VARS.NUM_EMAIL_PHONE_SUBMITS<QAS_Variables.EMAIL_PHONE_NUM_SUBMITS||QAS_Variables.EMAIL_PHONE_NUM_SUBMITS===0){r=s;i.waitOpen();QAS_TEMP_VARS.NUM_EMAIL_PHONE_SUBMITS++;a(h)}else{QAS_TEMP_VARS.EMAIL_PHONE_POS++;p()}};var h=function(t){var s=false;i.waitClose();if(t!==undefined&&t!==null){if(t.d!==undefined&&t.d!==null){if(t.d.error!==undefined){s=true;if(QAS_Variables.DISPLAY_ERRORS){alert(t.d.error+"\n Error with AJAX call. Check to make sure the service is configured and running correctly.")}}if(t.d.additional_info!==null&&t.d.additional_info!==undefined){if(QAS_Variables.DISPLAY_ERRORS){alert(t.d.additional_info+"\n Error from ecommerce platform.")}}else{if(t.d.email!==undefined&&t.d.email!==null){if(t.d.email.ok===false){i.displayResult(t.d,q);i.display();s=true}}if(t.d.phone!==undefined&&t.d.phone!==null&&s===false){if(t.d.phone.ok===false){i.displayResult(t.d,q);i.display();s=true}}}}}if(s===false){QAS_TEMP_VARS.EMAIL_PHONE_POS++;p()}};var g=function(s){if(s!==null&&s.d!==null&&s!==undefined&&s.d!==undefined){if(s.d.email!==undefined&&s.d.email!==null&&s.d.email.ok===false){$("label#"+QAS_Variables.EMAIL_ERR_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).show();if(QAS_Variables.DISPLAY_CUSTOM_EMAIL_ERR===true){message=EMAIL_ERR_MESSAGES[s.d.email.status_code];if(message!==undefined&&message!==null){$("label#"+QAS_Variables.EMAIL_ERR_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).text(message)}}}if(s.d.phone!==undefined&&s.d.phone!==null&&s.d.phone.ok===false){$("label#"+QAS_Variables.PHONE_ERR_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).show();if(QAS_Variables.DISPLAY_CUSTOM_PHONE_ERR===true){message=PHONE_ERR_MESSAGES[s.d.phone.status_code];if(message!==undefined&&message!==null){$("label#"+QAS_Variables.PHONE_ERR_FIELD_IDS[QAS_TEMP_VARS.EMAIL_PHONE_POS]).text(message)}}}}QAS_TEMP_VARS.EMAIL_PHONE_POS++;p()};var p=function(){var s;QAS_TEMP_VARS.NUM_EMAIL_PHONE_SUBMITS=0;if(QAS_Variables.EMAIL_PHONE_USEDIALOG===true){s=h}else{s=g}if(o()===false){QAS_TEMP_VARS.EMAIL_PHONE_POS++;if(QAS_TEMP_VARS.EMAIL_PHONE_POS>=QAS_Variables.EMAIL_FIELD_IDS.length&&QAS_TEMP_VARS.EMAIL_PHONE_POS>=QAS_Variables.PHONE_FIELD_IDS.length){f();return}else{p()}}else{QAS_TEMP_VARS.NUM_EMAIL_PHONE_SUBMITS++;a(s)}};this.process=function(){if(m===false){f()}else{$("select").css("visibility","hidden");i.waitOpen();p()}};i=new EmailPhoneInterface(null);QAS_TEMP_VARS.NUM_EMAIL_PHONE_SUBMITS=0;QAS_TEMP_VARS.EMAIL_PHONE_POS=0;d()}function Main(d,b){var i=this;var h=d;var g=b;var a=new Address();var l=a.getSearchStrings();var e=a.getSearchCountries();var j=a.getOriginalAddresses();var f,c;var k=0;this.process=function(){$("select").css("visibility","hidden");f=new Interface(i.returnEarly);c=new Clean(l[k],e[k],i.ajaxError);if(l[k]){f.waitOpen();c.search(i.process2)}else{c.result=j[k];i.next()}};this.process2=function(){f.waitClose();var m=new Business(i.next,c,j[k],f);if(!QAS_Variables.ADDRESS_INTERACTION){m.noInteraction()}else{m.processResult()}};this.next=function(){if(c.result){var m=c.result.length;if(m<11){for(var n=m;n<11;n++){c.result.push("")}}}c.result.push(c.verifylevel);a.storeCleanedAddress(c.result);k++;if(k<l.length){i.process()}else{i.finish()}};this.finish=function(){$("select").css("visibility","");a.returnCleanAddresses();if(h!==null){h()}if(g!==""){$("#"+g).attr("onclick","");$("#"+g).parent("form").attr("onsubmit","");$("#"+g).click()}};this.returnEarly=function(){$("select").css("visibility","");a.returnCleanAddresses()};this.ajaxError=function(o,n,m){if(n==="timeout"){c.verifylevel="Timeout";n="Timeout";shd.comVar.qasConsecutiveAjaxRetries++;shd.comVar.inAjaxErrorRetryLoop=true;if(shd.comVar.qasConsecutiveAjaxRetries<shd.consts.maxQasAjaxRetriesAllowed){QAS_Verify()}else{shd.comVar.inAjaxErrorRetryLoop=false;shd.comVar.qasConsecutiveAjaxRetries=0;shd.comVar.useAddressAsEntered=true;shd.comVar.switchToManualSave=true;if(h!==null&&h!==undefined){h()}}}else{c.verifylevel="Error"}f.waitOpen();if(QAS_Variables.DISPLAY_ERRORS){}c.result=j[k];i.next()}}function CommonApp_ShowAddress(){if(shd.comVar.inAjaxErrorRetryLoop){$("#QAS_Wait").show();return}var b=QAS_Variables.COMMONAPP_ADDRESS_QUESTION_ID;addressFunc.displayAddressFields(b);var a=$("#QAS_Dialog"),e=addressFunc.validateAddressOverlay(b),d=false,c=false;if(a.isOverlay()){if(shd.comVar.switchToManualSave){c=true}else{if(shd.comVar.useAddressAsEntered){if(e){d=true}else{$("#lat_"+b+", #lng_"+b+", #county_"+b+", #verifylevel_"+b,$("#addressOverlay_"+b)).val("");c=true}}else{if(shd.comVar.editAddress){c=true}else{d=true}}}}else{if(shd.comVar.switchToManualSave){$("#QAS_Wait").hideOverlay(true)}else{$("#saveAddress_"+b).trigger("click");$("#QAS_Wait").hideOverlay()}return}if(d){$("#saveAddress_"+b).trigger("click")}a.hideOverlay(c)}function QAS_Verify(){var e=QAS_Variables.PRE_ON_CLICK;var d=QAS_Variables.POST_ON_CLICK;var a=QAS_Variables.BUTTON_ID;var b=null;var c=null;if(e===null){b=new Main(d,a);c=new EmailPhoneValidation(d,a,b.process);c.process()}else{if(e()){b=new Main(d,a);c=new EmailPhoneValidation(d,a,b.process);c.process()}}return false}function QAS_Verify_Address(){var d=QAS_Variables.PRE_ON_CLICK;var c=QAS_Variables.POST_ON_CLICK;var a=QAS_Variables.BUTTON_ID;var b=null;if(d===null){b=new Main(c,a);b.process()}else{if(d()){b=new Main(c,a);b.process()}}return false}function QAS_Verify_EmailPhone(){var d=QAS_Variables.PRE_ON_CLICK;var c=QAS_Variables.POST_ON_CLICK;var a=QAS_Variables.BUTTON_ID;var b=null;$(".error").hide();if(d===null){b=new EmailPhoneValidation(c,a);b.process()}else{if(d()){b=new EmailPhoneValidation(c,a);b.process()}}return false}function dialogOpen(){var a=$("#QAS_Dialog");if(!a.isOverlay()){a.showOverlay({isChange:true,removeOnClose:true})}}window.QAS_Verify=QAS_Verify;window.QAS_Verify_Address=QAS_Verify_Address;window.QAS_Verify_EmailPhone=QAS_Verify_EmailPhone;