var base_url=window.location.hostname;var host_name=parseBaseUrl();function parseBaseUrl(){var a=base_url;var b=new Array();b=a.match(/www\./i);if(b!=null&&b.length==1){a=base_url.substring(base_url.indexOf(".")+1)}return a}var images=new Array();images.aload=new Image();images.aload.src="http://static2."+host_name+"/index/images_loader.gif";function AjaxLoader(){this.html='<div id="ajax-loader"><img class="ajax-img" src="'+images.aload.src+'" width="42" height="42" /></div>'}AjaxLoader.prototype.run=function(){$(this.html).appendTo("body")};AjaxLoader.prototype.end=function(){$("#ajax-loader").fadeTo(500,0,function(){$(this).remove()})};function Comment(a,d,c,b){this.commentBody=a;this.commentLength=d;this.minLength=c;this.maxLength=b;this.postLocation=new String();this.refResource=new String()}Comment.prototype.checkLength=function(){if(this.commentLength<this.minLength){return 1}else{if(this.commentLenth>this.maxLength){return 2}else{return 3}}};Comment.prototype.post=function(){ajaxLoad.run();$.ajax({type:"post",url:this.postLocation,data:"comment="+this.commentBody+"&ref="+this.refResource,dataType:"html",error:function(){ajaxLoad.end();var a=new InfoBox(1,"Oops! Post Error");a.addMsg("I don't think that was suppose to happen.<br /><br />It is probably best if you try again.");a.display()},success:function(a){ajaxLoad.end();$(a).prependTo(".all-comments");$("#comment-text").val("")}})};function InfoBox(a,b){this.type=a;this.header=b;this.content=new String();this.runTimer=false;this.timerTime=0;this.html='<div id="ajax-loader"><div id="info-box"><div id="info-head"><span id="info-header">'+this.header+'</span><span id="info-close-x">x</span></div><div id="info-content" class="[:type:]">[:content:]</div></div></div>'}InfoBox.prototype.addMsg=function(a){this.content=a;this.html=this.html.replace("[:content:]",this.content)};InfoBox.prototype.addTimer=function(a){this.runTimer=true;this.timerTime=a};InfoBox.prototype.display=function(){if(this.type==1){this.html=this.html.replace("[:type:]","info-error")}else{if(this.type==2){this.html=this.html.replace("[:type:]","info")}else{if(this.type==3){this.html=this.html.replace("[:type:]","info-emailer")}}}if($("#info-box").length>0){$("#info-box").remove()}$(this.html).prependTo("body");$("#info-close-x").click(function(a){$("#ajax-loader").remove();a.preventDefault()});if(this.runTimer){setTimeout(function(){$("#ajax-loader").fadeTo(3000,0,function(){$(this).remove()})},this.timerTime)}};function Emailer(a){this.location="http://"+base_url+a;this.linkLocation=window.location.toString();this.form='<form method="post" action="http://'+base_url+this.location+'" id="form-emailer"><textarea id="emailer-text" cols="0" rows="0">Separate each email address by a space.</textarea><div id="emailer-view-box"><input type="submit" id="email-submit" value="Send Email" /></div></form>'}Emailer.prototype.addFocusClear=function(){$("#emailer-text").focus(function(){if(jQuery.trim($(this).val())=="Separate each email address by a space."){$(this).val("")}})};Emailer.prototype.addEmptyString=function(a){$("#emailer-text").blur(function(){if(jQuery.trim($(this).val()).length==0){$(this).val(a)}})};Emailer.prototype.addErrorBox=function(a,b){if($("#emailer-error").length==0){$(a).parent().parent().css({height:"180px"});$("#emailer-view-box").prepend('<p id="emailer-error"></p>')}$("#emailer-error").html(b.toString())};Emailer.prototype.addSubmitListener=function(){var a=this;$("#form-emailer").submit(function(b){var c=$("#emailer-text").val().split(" ");var d=new Array();d[0]="Oops! Invalid address(es):<br />";if(c.length>50){d[d.length]="You have added too many addresses.<br />Maximum is 50."}else{jQuery.each(c,function(){if(!RegexTester.testEmail(this)){d[d.length]=this}})}if(d.length==1){$.ajax({type:"post",url:a.location,data:"addresses="+c+"&link="+a.linkLocation,dataType:"text",error:function(){var e=new InfoBox(1,"Oops! Post Error");e.addMsg("I don't think that was suppose to happen.<br /><br />It is probably best if you try again.");e.display()},success:function(e){console.log(e);var f=new InfoBox(2,"Email Sent");f.addMsg("Friend(s) have been emailed.<br /><br />Thanks for recommending this article.");f.addTimer(5000);f.display()}})}else{d=d.join(" ");a.addErrorBox($(this),d)}b.preventDefault()})};Emailer.prototype.getForm=function(){return this.form};Emailer.prototype.sendEmail=function(){$.ajax({type:"post",url:this.postLocation,data:"comment="+this.commentBody+"&ref="+this.refResource,dataType:"html",error:function(){var a=new InfoBox(1,"Oops! Post Error");a.addMsg("I don't think that was suppose to happen.<br /><br />It is probably best if you try again.");a.display()},success:function(a){$(a).prependTo(".all-comments");$("#comment-text").val("")}})};Emailer.prototype.init=function(a){this.addFocusClear();this.addEmptyString(a);this.addSubmitListener()};function RegexTester(){}RegexTester.testEmail=function(a){var b=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/i;return b.test(a)};RegexTester.testUserName=function(a){var b=/^[a-z]((\d*)|([a-z]*)|(_))*$/i;return b.test(a)};RegexTester.testPhoneNumber=function(a){var b=/^[1-9]{1}[0-9]{2}(-|\s)?[0-9]{4}$/;return b.test(a)};RegexTester.testPassword=function(b){var a=/^([A-Z-a-z-0-9])*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])([A-Z-a-z-0-9])*$/;return a.test(b)};RegexTester.testNumeric=function(a){var b=/^\d+$/;return b.test(a)};function TimeRemain(a,c,b){this.startTime=c;this.nowTime=0;this.location=a;this.daysRemain=0;this.hoursRemain=0;this.minutesRemain=0;this.secondsRemain=0;this.uid=b}TimeRemain.prototype.updateNow=function(){this.nowTime=Math.round(new Date().getTime()/1000)};TimeRemain.prototype.updateTimes=function(){var b=this.startTime-this.nowTime;if(b<0){window.location=window.location.toString()}var d=60*60*24;var c=60*60;var a=60;this.daysRemain=Math.floor(b/d);b=b%d;this.hoursRemain=Math.floor(b/c);b=b%c;this.minutesRemain=Math.floor(b/a);this.secondsRemain=b%a};TimeRemain.prototype.updateDisplay=function(){var c="#"+this.uid;if($(c).length==0){var f='<div id="'+this.uid+'" class="timer"><div class="timer-bg"></div><span class="timer-days">'+TimeRemain.padNumber(this.daysRemain)+'</span><span> Days </span><span class="timer-hours">'+TimeRemain.padNumber(this.hoursRemain)+'</span><span>:</span><span class="timer-minutes">'+TimeRemain.padNumber(this.minutesRemain)+'</span><span>:</span><span class="timer-seconds">'+TimeRemain.padNumber(this.secondsRemain)+"</span></div>";$(this.location).append(f)}else{var a=$(c).children(".timer-seconds");var e=$(c).children(".timer-minutes");var g=$(c).children(".timer-hours");var d=$(c).children(".timer-days");var j=a.html();if(j!=this.secondsRemain){a.html(TimeRemain.padNumber(this.secondsRemain))}var h=e.html();if(h!=this.minutesRemain){e.html(TimeRemain.padNumber(this.minutesRemain))}var b=g.html();if(b!=this.hoursRemain){g.html(TimeRemain.padNumber(this.hoursRemain))}var i=d.html();if(i!=this.daysRemain){d.html(TimeRemain.padNumber(this.daysRemain))}}};TimeRemain.prototype.run=function(a){setInterval(function(){a.updateNow()},1000);setInterval(function(){a.updateTimes()},1000);setInterval(function(){a.updateDisplay()},1000)};TimeRemain.padNumber=function(a){return(a<10?"0":"")+a};var ajaxLoad=new AjaxLoader();