if(!Ecap){Fool.onLoad(function(){$$("div.ecap").each(function(A){new Ecap(A)})})}var Ecap=function(D){var A=$(D),B;A.addClassName("watched");this.container=A;this.title=A.down("h4");this.fields=A.down("span.ecapFields");this.input=B=A.down("input.ecapInput");this.inputs=A.select("input");this.button=A.down("input.ecapButton");this.shield=new Fx.Shield(this.container,{wait:false,duration:150});var C=this.controller.bindAsEventListener(this);["click","keydown"].each(function(E){A.observe(E,C)});["focus","blur"].each(function(E){B.observe(E,C)})};Ecap.prototype={enable:function(){this.input.disabled=this.button.disabled=false},disable:function(){this.input.disabled=this.button.disabled=true},submit:function(){var A={};this.inputs.each(function(B){A[B.name]=$F(B)});new Ajax.Request("/Common/Controls/Landing/EmailCaptureHandler.ashx",{parameters:A,onCreate:this.onCreate.bind(this),onComplete:this.onComplete.bind(this)})},throttle:{delta:1000,last:0,timeout:null},controller:function(B){if(this.throttle.timeout!=null){return }var C=B.target,A="Enter Email Address";switch(B.type){case"click":case"keydown":if(C.hasClassName("ecapButton")||(C.hasClassName("ecapInput")&&B.keyCode==13)){this.throttle.last=new Date().getTime();this.submit();B.stop()}break;case"focus":this.input.addClassName("ecapInputFocus");if($F(this.input)==A){this.input.value=""}break;case"blur":this.input.removeClassName("ecapInputFocus");if($F(this.input)==""){this.input.value=A}break;default:break}},onCreate:function(A){this.disable();this.shield.start(0,0.6);this.container.addClassName("ecapLoading")},onComplete:function(B){var A=new Date().getTime()-this.throttle.last;if(this.throttle.delta>A){this.throttle.timeout=this.onComplete.bind(this).delay((this.throttle.delta-A)/1000,B);return }if(this.throttle.timeout!=null){clearTimeout(this.throttle.timeout);this.throttle.timeout=null}this.enable();this.shield.start(0.6,0);this.container.removeClassName("ecapLoading");this[(B.responseJSON.statusCode==200)?"onSuccess":"onFailure"](B.responseJSON)},onSuccess:function(B){this.title.update(B.message);this.container.removeClassName("ecapError").addClassName("ecapSuccess");this.fields.remove();if($("bottomFeeder")&&Fool.BottomFeeder){setTimeout(function(){Fool.BottomFeeder.close("sbt")},5000)}var A=new Image();A.src=B.vsTrackUrl},onFailure:function(A){this.title.update(A.message);this.container.addClassName("ecapError")}};