
String.prototype.addCommas=function(){var temp=this+'';var x=temp.split('.');var x1=x[0];var x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
return x1+x2;};var AjaxIndicator=$('busy');Ajax.Responders.register({onCreate:function(){if(Ajax.activeRequestCount>1){AjaxIndicator.show();}},onComplete:function(){if(Ajax.activeRequestCount<2){AjaxIndicator.hide();}}});Windows.overlayShowEffectOptions=null;Windows.overlayHideEffectOptions=null;Window.keepMultiModalWindow=true;WindowCloseKey.init();var PageController=Class.create({initialize:function(){this.modalId=0;this.mWin=null;this.imgModal=null;this.Wizard=null;this.Wizards={};},ajaxForm:function(FORM,CALLBACK,NODEID){var form=$(FORM);var node=$(NODEID);var action=form.readAttribute('action');var ajaxOptions=Object.extend((typeof CALLBACK=='function')?{onComplete:CALLBACK}:{},{evalScripts:true});if(node){new Ajax.Updater(node,[action,'?',form.serialize()].join(""),ajaxOptions);}
else{form.request(ajaxOptions);}
return false;},getModalId:function(){this.modalId++;return'modal'+this.modalId;},getModalWindow:function(width,height,title){var mWindow=new Window(this.getModalId(),{className:"cambria",width:width,height:height,resizable:true,minimizable:false,maximizable:true,draggable:false,destroyOnClose:true,showEffect:Element.show,hideEffect:Element.hide});if(!!title){mWindow.setTitle(['<small>',title,'</small>'].join(""));}
return mWindow;},showPageModal:function(mwin){mwin.showCenter(true,45);return mwin;},getURLModal:function(width,height,url,title){var mWindow=this.getModalWindow(width,height,title);mWindow.setURL(url);return this.showPageModal(mWindow);},getAjaxModal:function(width,height,url,options,title){var mWindow=this.getModalWindow(width,height,title);mWindow.setAjaxContent(url,(options||{}),false,false);return this.showPageModal(mWindow);},getContentModal:function(width,height,content,title){var mWindow=this.getModalWindow(width,height,title);mWindow.setContent(content,false,true);return this.showPageModal(mWindow);},getHTMLModal:function(width,height,html,title){var mWindow=this.getModalWindow(width,height,title);mWindow.setHTMLContent(html,false,true);return this.showPageModal(mWindow);},getHelp:function(url){this.getURLModal(600,400,url,'Help');},itemZoom:function(id){this.getContentModal(648,432,['ZoomImage',id].join(""));},itemPDF:function(id){this.getURLModal(713,454,['getPDFPreview.ajax?',id].toString());},cartItemPDF:function(oiid){this.getURLModal(713,454,['getPDF.ajax?',oiid].toString());},supportModal:function(path){this.getURLModal(500,120,path,'Support');},dialogOptions:function(){return{buttonClass:"dialogButton",width:300,height:100,showEffect:Element.show,hideEffect:Element.hide,className:"cambria",showProgress:true};},dialogInfoToAlert:function(cssClass,buttonClass,callBackString,message){var alert=["<div class=\"",cssClass,"_buttons\"><input type=\"button\" value=\"Close\" onclick=\"Dialog.okCallback(),",callBackString,"\" class=\"",buttonClass,"\" /></div>"].join("");Dialog.setInfoMessage(message);$("modal_dialog_message").up("div").insert(alert,{position:"bottom"});$("modal_dialog_progress").remove();},alert:function(message,options){return Dialog.alert(message,Object.extend(this.dialogOptions(),options));},confirm:function(message,options){return Dialog.confirm(message,Object.extend(this.dialogOptions(),options));},info:function(message,options){return Dialog.info(message,Object.extend(this.dialogOptions(),options));}});var hiliter=Class.create({initialize:function(areaNode){this.imprint=$(areaNode);this.mapNode=$(areaNode.parentNode);this.container=this.mapNode.previous('div');this.name=this.imprint.getAttribute("name");this.title=this.imprint.getAttribute("title");this.asCM=String(this.imprint.coords).split(',');this.hiNode=Element.extend(Builder.node('div',{className:'hiliter',id:'hiliter_'+this.name},this.title));var padding=3;var height=(parseInt(this.asCM[3]-1)-parseInt(this.asCM[1]))-padding*2;var width=(parseInt(this.asCM[2]-1)-parseInt(this.asCM[0]))-padding*2;var top=parseInt(this.asCM[1]-1);var left=parseInt(this.asCM[0]-1);var fontsize=height/4;var lineheight=fontsize*1.2;this.hiNode.setStyle({top:top+'px',width:width+'px',height:height+'px',left:left+'px','font-size':fontsize+'px','font-family':'serif','line-height':lineheight+'px','text-align':'center',padding:padding+'px',overflow:'hidden'});this.imprint.onmouseover=null;this.hiNode.observe('mouseover',this.hilite.bindAsEventListener(this),true);this.imprint.observe('mouseover',this.hilite.bindAsEventListener(this),true);this.imprint.onmouseout=null;this.hiNode.observe('mouseout',this.lolite.bindAsEventListener(this),true);this.imprint.observe('mouseout',this.lolite.bindAsEventListener(this),true);if(this.imprint.onclick){this.hiNode.observe('click',this.imprint.onclick.bind(this),true);}
this.container.appendChild(this.hiNode);},lolite:function(evt){Event.stop(evt);Element.removeClassName(this.hiNode,'hiliteOn');Element.addClassName(this.hiNode,'hiliteOff');},hilite:function(evt){Event.stop(evt);Element.removeClassName(this.hiNode,'hiliteOff');Element.addClassName(this.hiNode,'hiliteOn');}});var LeadGenerator;var LeadsController=Class.create({initialize:function(seeds,minimumLeads,previousState,previousCount){this.SeedCount=seeds;this.MinimumCount=minimumLeads;this.DB=$('DB');this.HMV=$('HOME_MARKET_VALUE');this.LOR=$('LENGTH_RESIDENCE');this.EINR=$('EST_INCOME_NARROW_RANGE');this.ZIP=$('ZIP5');this.RADIUS=$('RADIUS');this.COUNTS=$('COUNTS');this.ACXIOMQUERY=$('ACXIOMQUERY');this.GETCOUNTS=$('btnSubmit');this.RESULTS=$('Results');this.FORM=this.GETCOUNTS.up("form");this.FORM.action='getGrandTotals.ajax';this.GETCOUNTS.observe('click',this.doAccuDataQuery.bindAsEventListener(this));this.RADIUS.observe('blur',function(){if(this.RADIUS.value>50){alert('The maximum radius is 50 miles.');this.RADIUS.value=50;}}.bind(this),false);if(previousState){var count=previousCount?previousCount:-1;this.COUNTS.value=count;previousState=previousState.replace(/^&|&$/gi,'');$A(previousState.split('&')).each(function(kvp){var pair=kvp.split('=');var k=pair[0],v=(pair.length>1)?decodeURIComponent(pair[1]):'';var INPUT=$(k);switch(INPUT.tagName){case'INPUT':switch(INPUT.type){case'text':case'hidden':INPUT.value=v;break;default:break;}
break;case'SELECT':var option=$A(INPUT.options).detect(function(option){return(option.value==v);});if(option){option.selected=true;}
break;default:break;}});this.initializeForm(count);}else{this.RESULTS.update('Enter criteria and click the <strong>Get Counts</strong> button.');this.status=false;this.setCurrentResults();}},doAccuDataQuery:function(evt){evt.stop();var validZip=/^\d{5}(?:-?\d{4})?$/;if(!validZip.test($F(this.ZIP))){alert('Please enter a valid zip-code.');return false;}
this.FORM.fire('hold');this.GETCOUNTS.disable();this.RESULTS.update('<span id="Wait"><img src="images/ajax-loader.gif" alt="Busy" title="Querying" border="0" />&nbsp;Executing query. Average processing time: 30 seconds.</span>');if($F(this.RADIUS)=='0'){this.RADIUS.value='';}
this.FORM.request({onSuccess:this.doAccuDataQueryCallBack.bind(this),onComplete:function(){this.GETCOUNTS.enable();}.bind(this),onFailure:function(){this.status=false;this.RESULTS.update('<img src="images/database_error.png" alt="Error" title="Error" border="0" />&nbsp;There has been an <strong class="totalS">Error</strong> with your request.');}.bind(this)});return false;},doAccuDataQueryCallBack:function(resp,json){var count=new Number(json.count);this.initializeForm(count);},initializeForm:function(countValue){this.status=(countValue!=-1);if(this.status){this.RESULTS.update('<img src="images/email-contact-purple.gif" alt="Results" title="Results" border="0" />&nbsp;Your criteria would yield <strong class="totalS">'+(countValue+this.SeedCount).toString().addCommas()+'</strong> households.');var hash,qs=new Array();[this.HMV,this.LOR,this.ZIP,this.RADIUS,this.DB,this.EINR].each(function(inp){hash=inp.serialize();if(hash!=''){qs.push(hash);}});var formVars=qs.join('&').replace(/&{2}/gi,'&');this.ACXIOMQUERY.value=formVars;this.FORM.fire('release');}else{this.RESULTS.update('<img src="images/database_error.png" alt="Error" title="Error" border="0" />&nbsp;There has been an <strong class="totalS">Error</strong> with your request.');}
this.COUNTS.value=countValue;this.setCurrentResults();},formatHMVRanges:function(){var ranges=new Array();var marketRanges=new Array();var i,vals,r1,r2,end,optLen=this.HMV.length;if(!this.HMV[0].selected){for(i=1;i<optLen;i++){if(this.HMV[i].selected){vals=this.HMV[i].text.match(/^\$([\d,]*?)\W*?\$?([\d,]*?)$/i);end=ranges.length-1;r1=parseInt(vals[1].replace(/,/ig,''));r2=parseInt(vals[2].replace(/,/ig,''));if(vals[2]===''){r2=Infinity;}
if(end<0){ranges.push(r1);ranges.push(r2);}else{if(ranges[end]==(r1-1)){ranges[end]=r2;}else{ranges.push(r1);ranges.push(r2);}}}}
ranges.inGroupsOf(2).each(function(range){var start='$'+(range[0].toLocaleString());var end=isFinite(range[1])?' - $'+range[1].toLocaleString():' - $1,000,000 +';marketRanges.push(start+end);}.bind(this));return marketRanges.join('; ');}else{return this.HMV[0].text;}},formatLORRanges:function(){var ranges=new Array();var lorRanges=new Array();var i,val,r1,r2,end,optLen=this.LOR.length;for(i=0;i<optLen;i++){if(this.LOR[i].selected){r1=parseInt(this.LOR[i].value);end=ranges.length-1;if(end<0){ranges.push(r1);ranges.push(r1);}else{if(ranges[end]==(r1-1)){ranges[end]=r1;}else{ranges.push(r1);ranges.push(r1);}}}}
if((ranges.length%2)==1){ranges.push(0);}
ranges.inGroupsOf(2).each(function(range){var start=range[0];var end=((range[1]>range[0])?(' - '+ranges[1]):'')+' years';lorRanges.push(start+end);}.bind(this));return lorRanges.join('; ');},setCurrentResults:function(){var MIOption=$A(this.EINR.options).detect(function(opt){return opt.selected;});this.currentResults=this.status?{ZipCode:$F(this.ZIP),Radius:$F(this.RADIUS),MinimumIncome:(MIOption?MIOption.text:'$0'),MarketValues:this.formatHMVRanges(),LengthOfResidence:this.formatLORRanges(),Query:$F(this.ACXIOMQUERY),Available:$F(this.COUNTS)}:{};}});var CardType={MasterCard:0x01,VISA:0x02,Amex:0x04,DinersClub:0x08,enRoute:0x10,Discover:0x20,JCB:0x40,Unknown:0x80,All:(this.Amex|this.DinersClub|this.Discover|this.enRoute|this.JCB|this.MasterCard|this.VISA)};var CCValidator=Class.create({initialize:function(ccNum,ccType,ccMonth,ccYear){this._validateCardType=true;this._creditCardTextBox=$(ccNum);this._creditCardTypeSelect=$(ccType);this._creditCardExpMonth=$(ccMonth);this._creditCardExpYear=$(ccYear);this.acceptTypes=CardType.All|CardType.Unknown;},IsValidCardType:function(cardNumber){var cardLength=cardNumber.length;if((/^(?:34|37)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.Amex)!==0)){return(15==cardLength);}
else if((/^(?:51|52|53|54|55)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.MasterCard)!==0)){return(16==cardLength);}
else if((/^(?:4)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.VISA)!==0)){return(13==cardLength||16==cardLength);}
else if((/^(?:300|301|302|303|304|305|36|38)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.DinersClub)!==0)){return(14==cardLength);}
else if((/^(?:2014|2149)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.DinersClub)!==0)){return(15==cardLength);}
else if((/^(?:6011)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.Discover)!==0)){return(16==cardLength);}
else if((/^(?:3)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.JCB)!==0)){return(16==cardLength);}
else if((/^(?:2131|1800)\d+$/.test(cardNumber))&&((this.acceptTypes&CardType.JCB)!==0)){return(15==cardLength);}else{return((this.acceptTypes&CardType.Unknown)!==0);}},ValidateFutureDate:function(){try{var exp=new Date(parseInt($F(this._creditCardExpYear),10),parseInt($F(this._creditCardExpMonth),10));var now=new Date();return(exp>now);}catch(e){return false;}},EvaluateIsValid:function(){if(this.ValidateFutureDate()){var cardNumber=$F(this._creditCardTextBox);if(this._validateCardType){if(this.IsValidCardType(cardNumber)){var vn=CCValidator.ValidateCardNumber(cardNumber);return vn;}else{return false;}}else{return CCValidator.ValidateCardNumber(cardNumber);}}else{return false;}}});CCValidator.ValidateCardNumber=function(cardNumber){try{var CheckNumbers=new Array();var CardLength=cardNumber.length;var digitValue;for(var i=CardLength-2;i>=0;i-=2){digitValue=parseInt(cardNumber.substring(i,i+1),10);CheckNumbers.push(digitValue*2);}
var CheckSum=0;for(var iCount=0;iCount<=CheckNumbers.length-1;iCount++){var _count=0;if(parseInt(CheckNumbers[iCount],10)>9){var _numLength=CheckNumbers[iCount].toString().length;for(var x=0;x<_numLength;x++){_count+=parseInt(CheckNumbers[iCount].toString().substring(x,x+1),10);}}else{_count=CheckNumbers[iCount];}
CheckSum+=_count;}
var OriginalSum=0;for(var y=CardLength-1;y>=0;y=y-2){var digit=cardNumber.substring(y,y+1);OriginalSum+=parseInt(digit,10);}
return(((OriginalSum+CheckSum)%10)===0);}
catch(e){alert(e.message);return false;}};Validation.addAllThese([['validate-pwd','Passwords must be between 6 and 13 characters and cannot be \'password\'.',{minLength:6,maxLength:13,notOneOf:['password','PASSWORD']}],['validate-equal-pwd','Passwords do not match.',{equalToField:'password'}],['validate-stateddl','Please select a State or Province.',{isNot:'-1'}],['validate-usphone','Please enter a valid US phone number such as: 2345678901, (223) 456-7890 or 223-456-7890.',function(v){var isTollFree=true,isN11=true,is555=true,is555Station=true,isReserved=false;var NPA,NXX,Station;var matched=v.match(/^1?-?(?:\(([2-9]\d{2})\)\ ?|([2-9]\d{2})(?:\-?|\ ?))([2-9]\d{2})[- ]?(\d{4})$/);var isValid=(matched!==null);if(isValid){NPA=(matched[1]||matched[2]);NXX=matched[3];Station=matched[4];isTollFree=(/^8(?:00|11|22|33|44|55|66|77|88|99)$/.test(NPA));isN11=(/^\d11$/.test(NXX));is555=(NXX=='555');is555Station=(/^01\d{2}$/.test(Station));isReserved=(is555&&is555Station);}
return Validation.get('IsEmpty').test(v)||(isValid&&(!isTollFree&&!isN11&&!isReserved));}],['validate-uszipcode','Please enter a valid US zip code number such as: 57388 or 57388-1234.',function(v){return Validation.get('IsEmpty').test(v)||(/^\d{5}\D*?\d{4}$/.test(v));}],['validate-ccnumber','Please enter a valid credit card number.',function(v){return Validation.get('IsEmpty').test(v)||CCValidator.ValidateCardNumber(v);}],['validate-secnumber','Please enter a valid credit card security number.',function(v){return Validation.get('IsEmpty').test(v)||(/^\d{3}$/.test(v));}]]);var Wizard=Class.create({initialize:function(options){this.step=-1;this.modalComplete=false;this.title=options.title||'Wizard';this.modalId=this.getModalId();this.steps=options.steps;this.width=options.width;this.height=options.height;this.maximizable=options.maximizable;this.modalAdjustY=Prototype.Browser.IE?18:2;this.onSetState=this.setState.bindAsEventListener(this);this.modal=this.drawWizardModal();this.totalSteps=this.steps.length;this.finishEvent=(options.finishEvent)?function(){options.finishEvent();Windows.close(this.modalId);}.bind(this):function(){Windows.close(this.modalId);}.bind(this);this.cancelEvent=(options.cancelEvent)?function(){options.cancelEvent();return true;}.bind(this):function(){return true;};this.OrderItemID=options.orderitemid;this.ItemID=options.itemid;this.controls={};this.modal.showCenter(true,30);this.modalStep(1);},setState:function(evt){alert(evt);},defaultOptions:function(){return{useAjax:false,useBack:false,useFinish:false,cancelText:'Cancel',backText:'Back',nextText:'Next',finishText:'Finish',autoTitle:true};},getModalId:function(){var d=new Date();return('modal'+d.getUTCHours()+d.getUTCMilliseconds());},getModalInnerDocument:function(){return this.getWindowContext(this.modal.getContent()).document;},getWindowContext:function(frameObj){frameObj=$(frameObj);return(frameObj.contentWindow)?frameObj.contentWindow:frameObj.contentDocument.defaultView;},modalStep:function(amount){var nextStep=(this.step+amount),title='',stepURL,stepOptions;if((nextStep<0)||(nextStep>this.totalSteps-1)){this.modalComplete=true;this.finishEvent();}else{this.step=nextStep;stepUrl=this.steps[this.step][0];stepOptions=Object.extend(this.defaultOptions(),this.steps[this.step][1]);if(stepOptions.helpText){title=['<a class="modalHelpLink" href="javascript:void(',stepOptions.helpEvent,')">',stepOptions.helpText,'</a>'].join("");}
title+=['<small>',(stepOptions.wizardCaption||'&nbsp;'),(stepOptions.autoTitle?([' (Step ',(nextStep+1),' of ',this.totalSteps,')'].join("")):''),'</small>'].join("");this.modal.setTitle(title);if(stepOptions.useAjax){this.modal.setAjaxContent(stepUrl,{evalScripts:true,onComplete:function(stepOptions){var modalContainer,modalDiv,modalDimensions;try{modalContainer=$(this.modal.getContent());modalDiv=(modalContainer.down('.modalContent')||modalContainer);if(stepOptions.headlineHTML){modalDiv.insert({top:stepOptions.headlineHTML});}
this.drawWizardControls(stepOptions,'bottom',modalDiv);modalDimensions=Element.getDimensions(modalDiv);this.modal.setSize(modalDimensions.width,(modalDimensions.height+this.modalAdjustY));this.modal.updateHeight();}catch(e){alert(['AJAX: ',e.message].join(""));}}.bind(this,stepOptions),onException:function(req,exc){alert(['Error: ',exc.message,'\n\n',req.toString()].join(""));}});}else{try{var idoc,body,sh,eh,newHeight,modalContainer,modalDiv,modalDimensions;this.modal.setURL(stepUrl);this.drawWizardControls(stepOptions,"after");idoc=this.getModalInnerDocument();body=$(idoc.body);sh=body.scrollHeight;eh=body.getHeight();newHeight=(sh>ef?sh:eh);if(stepOptions.headlineHTML){body.insert({top:stepOptions.headlineHTML});}
this.modal.setSize(this.width,newHeight,true);modalContainer=$(this.modal.getContent());modalDiv=(modalContainer.down('.modalContent')||modalContainer);var match=stepURL.match(/\.\w{3,4}#(.+?)$/i);if(match!=-1&&match.length==2){idoc.getElementById(match[1]).scrollIntoView(true);}}catch(e){this.modal.setSize(this.width,this.height,true);}}}},refreshStep:function(){this.modalStep(0);},drawWizardModal:function(){var mw=new Window(this.modalId,{className:"cambria",width:this.width,resizable:true,draggable:false,minimizable:false,maximizable:this.maximizable,showEffect:Element.show,hideEffect:Element.hide,recenterAuto:false,onClose:function(){if(!this.modalComplete){this.cancelEvent();}}.bind(this)});mw.setDestroyOnClose();var mc=mw.getContent();mc.observe('hold',this.onSetState);mc.observe('release',this.onSetState);return mw;},drawWizardControls:function(options,ins,node){var controlContainer;this.controls={};this.controls.html=new Template(['<p class="buttons wizard">',(options.useBack)?'<a class="back" href="#">#{backText}</a>':'<a class="cancel" href="#">#{cancelText}</a>',(options.useFinish)?'<a class="finish" href="#">#{finishText}</a>':'<a class="next" href="#">#{nextText}</a>','</p>'].join("")).evaluate(options);controlContainer=(node||this.modal.getContent());switch(ins){case'top':controlContainer.insert({top:this.controls.html});break;case'bottom':controlContainer.insert({bottom:this.controls.html});break;default:controlContainer.insert(this.controls.html);break;}
if(options.loadEvent&&typeof(options.loadEvent=='function')){options.loadEvent();}
if(options.useBack){(this.controls.back=$$('p.buttons.wizard a.back')[0]).observe('click',this.modalStep.bind(this,-1),false);if(options.backEvent){this.controls.back.observe('click',options.backEvent,false);}}else{(this.controls.cancel=$$('p.buttons.wizard a.cancel')[0]).observe('click',function(){Windows.close(this.modalId);}.bind(this),false);if(options.cancelEvent){this.controls.cancel.observe('click',options.cancelEvent,false);}}
if(options.useFinish){this.controls.finish=$$('p.buttons.wizard a.finish')[0];if(options.nextEvent){this.controls.finish.observe('click',function(){if(options.nextEvent()){this.modalComplete=true;this.finishEvent();}}.bind(this),false);}else{this.controls.finish.observe('click',function(){this.modalComplete=true;this.finishEvent();}.bind(this),false);}}else{this.controls.next=$$('p.buttons.wizard a.next')[0];if(options.nextEvent){this.controls.next.observe('click',function(){if(options.nextEvent()){this.modalStep(1);}}.bind(this),false);}else{this.controls.next.observe('click',this.modalStep.bind(this,1),false);}}}});