var map,localSearch,geocoder,infoWindow,centerIcon,searchCircle,ajaxXHR,ajaxWatchDogTimer,searcher={},searchcenter,result=[],response=[],initialposition,selected_country="",i,countries=[{code:"AU",name:"Australia",N:-9.2065,E:159.332,S:-43.9572,W:112.5},{code:"CA",name:"Canada",N:48.996667,E:-58.7,S:45,W:-139.9},{code:"IE",name:"Ireland",N:55.436211,E:-6.0025,S:51.424511,W:-10.65073},{code:"NZ",name:"New Zealand",N:-34.1436,E:-179.0112,S:-47.8427,W:165.6738},{code:"GB",name:"United Kingdom",N:60.8547,
E:1.769,S:49.8712,W:-8.1945},{code:"US",name:"United States",N:49.00139,E:-66.885075,S:25.837164,W:-124.482003}];
function ChangeCountry(a){var c;if($("#index_country_menu li:hidden").length>0&&typeof a!=="undefined")$("#index_country_menu li, .country_menu_text").show();else{for(i=0;i<countries.length;i+=1)if(a===countries[i].code){$("#index_country_menu li[code*="+a+"]").attr("selected",true);$("#index_country_menu li[code!="+a+"]").attr("selected",false);selected_country=a;if(!searchCircle){c=new google.maps.LatLngBounds(new google.maps.LatLng(countries[i].S,countries[i].W),new google.maps.LatLng(countries[i].N,
countries[i].E));map.setCenter(c.getCenter());map.fitBounds(c)}}$("#index_country_menu li[selected=false]").hide();$(".country_menu_text").fadeOut()}}
function BuildCountryMenu(a){if(a==="")a="GB";var c,f,g;c=document.createElement("div");$(c).attr("id","index_country_menu");f=document.createElement("ul");c.appendChild(f);for(i=0;i<countries.length;i+=1){g=document.createElement("li");$(g).html("<span class='country_menu_text'>"+countries[i].name+"</span><img src='images/flags/"+countries[i].code+".gif' alt='' width='25' />").attr("code",countries[i].code).attr("selected",a===countries[i].code);if(a===countries[i].code)$(g).attr("selected",true);
else{$(g).attr("selected",false);$(g).hide()}google.maps.event.addDomListener(g,"click",function(){ChangeCountry($(this).attr("code"))});f.appendChild(g)}map.controls[google.maps.ControlPosition.TOP_RIGHT].push(c);$("#index_country_menu li[selected*=false]").hide();$(".country_menu_text").fadeOut()}var numb="0123456789-",lwr="abcdefghijklmnopqrstuvwxyz ",upr="ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
function isValid(a,c){var f;if(a==="")return false;for(f=0;f<a.length;f+=1)if(c.indexOf(a.charAt(f),0)===-1)return false;return true}function isLower(a){return isValid(a,lwr+numb)}function isUpper(a){return isValid(a,upr+numb)}function toSimpleTitle(a){var c,f,g;a=a.split(/\s+/g);for(c=0;c<a.length;c+=1){f=a[c].substring(0,1).toUpperCase();g=a[c].substring(1,a[c].length).toLowerCase();a[c]=f+g}return a.join(" ")}function HaymaprToTitle(a){return isLower(a)||isUpper(a)?toSimpleTitle(a):a}
function NavigatorGeolcationCallback(a){a=a.coords||a.coordinate||a;initialposition=new google.maps.LatLng(a.latitude,a.longitude);searcher.initial_position_source="navigator.geolocation";searcher.initial_position=initialposition.y+","+initialposition.x;searcher["navigator.geolocation.accuracy"]=a.accuracy;for(i=0;i<countries.length;i+=1){a=new google.maps.LatLngBounds(new google.maps.LatLng(countries[i].S,countries[i].W),new google.maps.LatLng(countries[i].N,countries[i].E));if(a.contains(initialposition)){selected_country=
countries[i].code;ChangeCountry(countries[i].code)}}}
function displayTravelDistance(a){var c;c=searchcenter;a||(a=$("#distancetextbox").val());a=1609.344*a;if(typeof searchCircle=="undefined"){if(a!==0){c={center:c,clickable:false,fillColor:"#aaffaa",fillOpacity:0,map:map,radius:a,strokeColor:"#00ff00",strokeOpacity:0.85,strokeWeight:3};searchCircle=new google.maps.Circle(c);map.fitBounds(searchCircle.getBounds())}}else{searchCircle.setCenter(c);searchCircle.setRadius(a);map.fitBounds(searchCircle.getBounds())}}
function DrawCentrePoint(a){var c;a||(a=searchcenter);if(typeof centerIcon=="undefined"){c={draggable:true,icon:"images/icons/arrow.png",map:map,position:a,shadow:"images/icons/arrowshadow.png",title:"Searching around this location. ( Drag to change. )",visible:true};centerIcon=new google.maps.Marker(c);google.maps.event.addDomListener(centerIcon,"dragend",function(f){searchcenter=f.latLng;map.panTo(searchcenter);searchCircle&&displayTravelDistance()})}else{centerIcon.setPosition(a);searchCircle&&
displayTravelDistance()}map.panTo(a)}
function geocodeResult(a,c){var f;$("#geocoder-results").empty();$("#where").css("margin-top","125px");geocoder.firstItem||$("#Button2Next").attr("disabled","disabled");if(c===google.maps.GeocoderStatus.OK&&a[0]){geocoder.firstItem=a[0];if(a.length===1){geocoder.selectedItem=a[0];(f=a[0].geometry)&&f.viewport&&map.fitBounds(f.viewport);searchcenter=f.location;DrawCentrePoint(searchcenter);$("#Button2Next").attr("disabled",0)}else{geocoder.selectedItem=a[0];$("#where").css("margin-top","0px");$("#geocoder-results").css("margin-bottom",
"10px");$("#geocoder-results").append('<li id="geo_results_header" class="plain_list bold">Did you mean?</li>');for(c=0;c<a.length;c+=1){$("#geocoder-results").append('<li id="geo_results'+[c]+'" class="geo_results">'+a[c].formatted_address+"</li>");$("#geo_results"+[c]).data("geometry",a[c].geometry).data("formatted_address",a[c].formatted_address)}$(".geo_results").click(function(){geocoder.selectedItem.geometry=$(this).data("geometry");geocoder.selectedItem.formatted_address=$(this).data("formatted_address");
(f=$(this).data("geometry"))&&f.viewport&&map.fitBounds(f.viewport);searchcenter=f.location;DrawCentrePoint(searchcenter);$("#Button2Next").click();$("#geocoder-results").empty();$("#where").css("margin-top","125px")})}}else{c===google.maps.GeocoderStatus.ZERO_RESULTS?$("#geocoder-results").append('<li id="geo_results_header" class="plain_list bold">Sorry, \''+$("#addresstextbox").val()+"' not found.</li>"):$("#geolocate_results").html(c);geocoder.resultAddress="";geocoder.resultBounds=null}}
function sidebarclick(a){google.maps.event.trigger(result[a].marker,"click")}
function ListSearchResults(a){var c,f,g,d,e,b;clearTimeout(ajaxWatchDogTimer);response=a;result=a.sellers;window.console&&console.firebug&&console.dir(a);c=document.getElementById("localsearchresults");f=document.getElementById("distantsearchresults");g="";if(result.length<1){$("#progressbar").hide();$("#noresults").show()}else{for(b=0;b<=result.length-1;b+=1){result[b].point=new google.maps.LatLng(result[b].lat,result[b].lon);result[b].marker=new google.maps.Marker({map:map,position:result[b].point,
title:result[b].name,visible:true});result[b].marker.html="<strong>"+result[b].name+"</strong>\n<br/><small>"+result[b].results+" possible product(s)<br/><a class='iwlink' href=#"+result[b].s+" s='"+result[b].s+"' >View Products</a></small>";g="link"+b;d=document.createElement("div");$(d).html('<a class="sidebar-link" href=# onclick="sidebarclick('+b+');return false;">'+result[b].name+"</a> <small>("+result[b].distance.toFixed(1)+" miles)</small>").attr("id",g).attr("class","sidebar-element");result[b].type===
"local"?c.appendChild(d):f.appendChild(d);google.maps.event.addListener(result[b].marker,"click",function(){infoWindow.setContent(this.html);infoWindow.open(map,this);e=document.getElementById(g);e.focus()});$("#resultspanel").append("<div id=seller"+b+" class=seller><div id=seller"+b+"-details class=seller-details><div id=seller"+b+"-name class=seller-name><a name="+result[b].s+"></a>"+result[b].name+"</div><div id=seller"+b+"-contactdetails class=seller-contactdetails><small>(about "+result[b].distance.toFixed(1)+
" miles away)</small><p></div></div>");$("#seller"+b+"-contactdetails").append('<a class="emaillink" href="#" sr="'+a.sr+'" s="'+result[b].s+'" sellername="'+result[b].name+'"><b>Email This Seller</b></a><br/>');result[b].phone==="1"&&$("#seller"+b+"-contactdetails").append('<a class="phonelink" href="#" sr="'+a.sr+'" s="s'+result[b].s+'"><b>Display Phone Number</b></a><br/>');$("#seller"+b+"-contactdetails").append('<a href="#" onclick="sidebarclick('+b+');return false;">Show on Map</a><br/>');result[b].web!==
""&&$("#seller"+b+"-contactdetails").append('<a class="weblink" target="haymapr_window" href="'+result[b].web+'" sr="'+a.sr+'" urly="'+result[b].urly+'" >Website</a><br/>');$("#seller"+b).append("<div id=seller"+b+"-products class=seller-products></div>");for(d=0;d<result[b].products.length;d+=1){$("#seller"+b+"-products").append("<div id=seller"+b+"-product"+d+" class=seller-product><div id=seller"+b+"-product"+d+"-title class=seller-product-title>"+result[b].products[d].title+"</div><div id=seller"+
b+"-product"+d+"-description class=seller-product-description>"+result[b].products[d].description+"</div><div id='seller"+b+"-product"+d+"-attributes' class=seller-product-attributes></div></div>");$("#seller"+b+"-product"+d+"-attributes").append(result[b].products[d].baletype+" bales of "+result[b].products[d].type+". ");result[b].products[d].grasstype!==""&&$("#seller"+b+"-product"+d+"-attributes").append(result[b].products[d].grasstype+" grass.");$("#seller"+b+"-product"+d+"-attributes").append("<br/>");
result[b].products[d].price!==null&&$("#seller"+b+"-product"+d+"-attributes").append(result[b].products[d].symbol+result[b].products[d].price.toFixed(2)+" per "+result[b].products[d].priceunits+". ");result[b].products[d].quantity!==null&&$("#seller"+b+"-product"+d+"-attributes").append(result[b].products[d].quantity+" "+result[b].products[d].quantityunits+" available.");result[b].products[d].whenproduced!==""&&$("#seller"+b+"-product"+d+"-attributes").append(" Baled: "+result[b].products[d].whenproduced);
$("#seller"+b+"-product"+d+"-attributes").append("<br/>"+result[b].collection+" "+result[b].delivery);$("#seller"+b+"-products").append("<div class=clear></div>")}$("#resultspanel").append("</div></div>")}$("#form").hide();$("#results").show();$("#resultspanel").show()}$.cookie("first_search")||$.cookie("first_search","sr"+a.sr);searcher.first_search="sr"+a.sr;pageTracker._trackPageview("/eventlogger/SearchComplete");timeTracker._recordEndTime();timeTracker._track(pageTracker,"SearchTime","Search Complete");
$("a.iwlink").click(function(){var h=$(this).attr("s").val();$("#seller"+h).effect("highlight",{},3E3)});$("a.emaillink").click(function(){var h;if($("#email_s").val()!==$(this).attr("s")){$("#ui-dialog-title-email-dialog").html("Contact "+$(this).attr("sellername"));$("#ui-dialog-title-email-dialog-sent").html($(this).attr("sellername"));$("#email_s").val($(this).attr("s"));$("#email_sr").val($(this).attr("sr"));$("#email-dialog-message").val("Dear "+$(this).attr("sellername")+",\n");h=$.cookie("first_search")?
$.cookie("first_search"):haymapr_uid;$("#email_first_search").val("sr"+h)}searcher.name&&$("#email-dialog-name").val(searcher.name);searcher.email&&$("#email-dialog-email").val(searcher.email);searcher.telephone&&$("#email-dialog-telephone").val(searcher.telephone);searcher.location_email?$("#email-dialog-postcode").val(searcher.location_email):$("#email-dialog-postcode").val(searcher.location_search);searcher.delivery===1&&$("#email-dialog-delivery").attr("checked","checked");searcher.collection===
1&&$("#email-dialog-collection").attr("checked","checked");$("#email-dialog").dialog("open");searcher.name?$("#email-dialog-email").focus():$("#email-dialog-name").focus();return false});$("a.phonelink").click(function(){var h,k,j;h=$(this);if(searcher.name&&searcher.telephone){h.blur();h.html('<img border="0" height="12px" src="/images/ajax-circle.gif" alt="Content Loading" />');k=$.cookie("first_search")?$.cookie("first_search"):haymapr_uid;searcher.first_search=k;searcher.name=toSimpleTitle(searcher.name);
j={};j.searcher=searcher;j.type="phone";j.s=h.attr("s");j.source="search";j.sr=k;j=$.toJSON(j);$.ajax({type:"POST",url:"GetPhone",data:j,dataType:"json",success:function(l){h.replaceWith("<b>Phone: "+l.phone+"</b>");pageTracker._trackPageview("/eventlogger/phonenumber_requested");pageTracker._trackPageview("/eventlogger/contact_made")}})}else{searcher.name&&$("#phone-dialog-name").val(searcher.name);searcher.telephone&&$("#phone-dialog-telephone").val(searcher.telephone);$("#phone-dialog").dialog("open");
$("#phone-dialog").bind("dialogclose",function(){h.click()});searcher.name?$("#phone-dialog-telephone").focus():$("#phone-dialog-name").focus()}return false});$("a.weblink").mousedown(function(){var h=$(this).attr("urly");$(this).attr("href",h+"?source=search&sr="+a.sr+"&v="+searcher.first_search);$(this).mousedown(function(){});pageTracker._trackPageview("/eventlogger/website_clickthrough");pageTracker._trackPageview("/eventlogger/contact_made")})}
function ajaxSearchErrorHandler(a){$("#progressbar_content").html("<img src='/images/bluei.png' alt='!'><br />Just a second.<br />(This is taking longer than usual). <br /><div style=\"color:#888;font-size:80%\">"+a.status+": "+a.statusText+"</div>");searcher.search_retries>=1&&$("#progressbar_content").append('<br /><div style="color:#888;font-size:80%"><img border="0" height="10px" src="/images/ajax-circle.gif" alt="Retrying" /> Retries: <span id="number_of_retries">'+searcher.search_retries+"</span></div>");
pageTracker._trackPageview("/eventlogger/errors/SearchFailed/"+a.status+"_"+a.statusText+"_Try:"+searcher.search_retries);searcher.search_retries<3&&setTimeout(function(){searcher.search_retries+=1;$("#Button3Next").click()},searcher.search_retries*750+500);searcher.search_retries>=3&&$("#progressbar_content").html("<img src='/images/redcross.png' alt='X'><br />Sorry, something went wrong. <br /><a href= '/' class=\"resetall\">Start Again?</a><br />&nbsp;<br />");if(searcher.search_retries>=5){clearTimeout(ajaxWatchDogTimer);
ajaxXHR.abort()}}
$(function(){var a,c,f,g,d;localSearch=new GlocalSearch;geocoder=new google.maps.Geocoder;c=g="";navigator.geolocation&&navigator.geolocation.getCurrentPosition(NavigatorGeolcationCallback);if(google.loader&&google.loader.ClientLocation)for(i=0;i<countries.length;i+=1)if(google.loader.ClientLocation.address.country_code===countries[i].code){f=new google.maps.LatLngBounds(new google.maps.LatLng(countries[i].S,countries[i].W),new google.maps.LatLng(countries[i].N,countries[i].E));g=f.getCenter();d=
8;c=google.loader.ClientLocation.address.country_code}if(g===""){g=new google.maps.LatLng(0,0);d=2}a={backgroundColor:"b6b6b6",center:g,disableDefaultUI:true,disableDoubleClickZoom:true,draggable:false,keyboardShortcuts:false,mapTypeControl:false,mapTypeId:google.maps.MapTypeId.ROADMAP,navigationControl:false,navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL},scaleControl:false,scrollwheel:false,streetViewControl:false,zoom:d};map=new google.maps.Map(document.getElementById("index_map_canvas"),
a);f&&map.fitBounds(f);BuildCountryMenu(c);google.maps.event.addDomListener(map,"click",function(){ChangeCountry()});infoWindow=new google.maps.InfoWindow({content:"",disableAutoPan:false});infoWindow.close();$("#Button1Next").click(function(){a={disableDoubleClickZoom:false,draggable:true,keyboardShortcuts:true,navigationControl:true,scrollwheel:true};map.setOptions(a);ChangeCountry();$("#formproduct").hide();$("#formlocation").show();$("#addresstextbox").focus();pageTracker._trackPageview("/eventlogger/Page1Page2")});
$("#Button2Prev").click(function(){$("#formlocation").hide();$("#formproduct").show();pageTracker._trackPageview("/eventlogger/Page2Page1")});$("#Button2Next").click(function(){searchcenter=map.getCenter();$("#formlocation").hide();$("#formdistance").show();$("#addresstextbox").val(geocoder.selectedItem.formatted_address);displayTravelDistance();$("#distancetextbox").focus()});$("#Button3Prev").click(function(){$("#formdistance").hide();$("#formlocation").show();pageTracker._trackPageview("/eventlogger/Page3Page2")});
$("#Button3Next").click(function(){var e,b,h,k;$("#formdistance").hide();$("#formproduct").hide();$("#progressbar").show();centerIcon.setMap(null);pageTracker._trackPageview("/eventlogger/StartSearch");timeTracker._setHistogramBuckets([500,1E3,1500,2E3,2500,3E3,3500,4E3,4500,5E3,5500,6E3,6500,7E3,7500,8E3,8500,9E3,9500,1E4]);timeTracker._recordStartTime();e=$("input#addresstextbox").val();b=$("input[name='ProductType']:checked").val();h=$("input[name='Animal']:checked").val();k=$("input#distancetextbox").val();
searcher.first_search=$.cookie("first_search")?$.cookie("first_search"):"sr"+haymapr_uid;searcher.location_search=e;searcher.product=b;searcher.animal=h;searcher.delivery_distance=k;searcher.position={lat:searchcenter.lat(),lon:searchcenter.lng()};$.cookie("searcher",$.toJSON(searcher),{expires:7});if(!searcher.search_retries)searcher.search_retries=0;e=$.toJSON(searcher);ajaxXHR=$.ajax({type:"POST",url:"search",data:e,dataType:"json",success:ListSearchResults,timeout:1E4,error:ajaxSearchErrorHandler});
ajaxWatchDogTimer=setTimeout(function(){ajaxXHR.abort();$("#Button3Next").click()},12E3);pageTracker._trackEvent("UI","Search","Searching");return false});$("#addresstextbox").keyup(function(e){if((e.which&&e.which===13||e.keyCode&&e.keyCode===13)&&geocoder.firstItem){geocoder.firstItem.geometry&&geocoder.firstItem.geometry.viewport&&map.fitBounds(geocoder.firstItem.geometry.viewport);$("#addresstextbox").val(geocoder.firstItem.formatted_address);$("#geocoder-results").empty();$("#where").css("margin-top",
"125px");$("#Button2Next").click();return false}else{var b=this.value;if(b&&b.trim)b=b.trim();if(b!==geocoder.resultAddress&&b.length>1){clearTimeout(geocoder.waitingDelay);geocoder.waitingDelay=setTimeout(function(){geocoder.geocode({address:b,region:selected_country},geocodeResult)},600)}else{$("#geocoder-results").html("");geocoder.resultAddress="";geocoder.resultBounds=null}}});$("#distancetextbox").keyup(function(e){$(this).val($(this).val().replace(/[^0-9]/g,""));if(e.keyCode===13){clearTimeout($(this).waitingDelay);
$("#distancetextbox").change();$("#Button3Next").click()}clearTimeout($(this).waitingDelay);$(this).waitingDelay=setTimeout(function(){displayTravelDistance($(this).val())},600)});$("#Button2Next").attr("disabled","disabled");$("#Button1Next").attr("disabled",0).html("Next");$("#phone-dialog").dialog({bgiframe:true,autoOpen:false,height:400,width:450,modal:true,closeOnEscape:true,buttons:{Next:function(){searcher.name=$("#phone-dialog-name").val();searcher.telephone=$("#phone-dialog-telephone").val();
$("#phone-dialog-form").submit()},Cancel:function(){$("#phone-dialog").dialog("close")}},close:function(){$("#phone-dialog-validateTips").removeClass("ui-state-error").hide();$("#phone-dialog-button-send").html("Next").removeClass("ui-state-disabled").removeClass("ui-state-hover").removeAttr("disabled")}});$(".ui-dialog-buttonpane button:contains(Next)").attr("id","phone-dialog-button-send");$("#email-dialog").dialog({bgiframe:true,autoOpen:false,height:470,width:600,modal:true,closeOnEscape:true,
buttons:{Send:function(){searcher.name=$("#email-dialog-name").val();searcher.email=$("#email-dialog-email").val();searcher.telephone=$("#email-dialog-telephone").val();searcher.location_email=$("#email-dialog-postcode").val();searcher.delivery=$("#email-dialog-delivery:checked").val();if(searcher.delivery===undefined)searcher.delivery=0;searcher.collection=$("#email-dialog-collection:checked").val();if(searcher.collection===undefined)searcher.collection=0;var e=$.toJSON(searcher);$("#email-dialog-searcher").val(e);
$.cookie("searcher",e);$("#email-dialog-form").submit()},Cancel:function(){$("#email-dialog").dialog("close")}},close:function(){$("#email-dialog-validateTips").removeClass("ui-state-error").hide();$("#email-dialog-button-send").html("Send").removeClass("ui-state-disabled").removeClass("ui-state-hover").removeAttr("disabled")}});$(".ui-dialog-buttonpane button:contains(Send)").attr("id","email-dialog-button-send");$("#email-dialog-sent").dialog({bgiframe:true,autoOpen:false,modal:true,buttons:{Close:function(){$(this).dialog("close")}}});
$("#phone-dialog-name, #email-dialog-name").change(function(){var e=HaymaprToTitle($(this).val());$(this).val(e)});$("a.resetall").click(function(){var e,b;$("#noresults").hide();$("#progressbar").hide();$("#results").hide();$("#resultspanel").hide();$("#resultspanel").html("");$("#form").show();$("#formproduct").show();searchCircle.setMap(null);searchCircle=undefined;infoWindow.close();for(e=0;e<result.length;e+=1){result[e].marker.setMap(null);result[e]=undefined}e=document.getElementById("localsearchresults");
for(b=document.getElementById("distantsearchresults");e.firstChild;)e.removeChild(e.firstChild);for(;b.firstChild;)b.removeChild(b.firstChild);result=[];response=[];pageTracker._trackPageview("/eventlogger/NoResults-RetrySearch");return false});$(".content .left, .content input, .content textarea, .content select").focus(function(){$(this).parents(".row").addClass("over")}).blur(function(){$(this).parents(".row").removeClass("over")});$.validator.addMethod("phone",function(e){if(e===null||e==="")return true;
return/\d{8,}/i.test(e.replace(/[\s()+\-]|ext\.?/gi,""))},"Please enter a valid phone number");$("#email-dialog-form").validate({rules:{name:{required:true,minlength:4},email:{required:true,email:true},telephone:{required:false,phone:true},message:"required"},messages:{name:"Please enter your full name",email:"A valid email address is required.",telephone:"Your phone number doesn't look right. Don't forget the area code.",message:"Please write a message to the seller, explaining what you are looking for."},
submitHandler:function(e){var b;$(e).ajaxSubmit({beforeSubmit:function(){b=$("#email-dialog-button-send");b.text();b.blur();b.html('Sending &nbsp;<img border="0" height="12px" src="/images/ajax-circle.gif" alt="Sending..." />');b.addClass("ui-state-disabled");b.attr("disabled","disabled")},success:function(){$("#email-dialog-sent").dialog("open");$("#email-dialog").dialog("close");$("#email-dialog-message").val("");pageTracker._trackPageview("/eventlogger/email_sent");pageTracker._trackPageview("/eventlogger/contact_made")},
error:function(){b=$("#email-dialog-button-send");b.focus();b.html("Send");b.removeClass("ui-state-disabled");b.removeClass("ui-state-focus");b.attr("disabled",false);$("#email-dialog-validateTips").html("A network error occurred. Please try again.").addClass("ui-state-error").show()}})},invalidHandler:function(){$("#email-dialog-validateTips").addClass("ui-state-error").show()},errorLabelContainer:"#email-dialog-validateTips",wrapper:"li"});$("#phone-dialog-form").validate({rules:{name:{required:true,
minlength:4},telephone:{required:true,phone:true}},messages:{name:"Please enter your full name",telephone:"Please check your phone number."},submitHandler:function(){$("#phone-dialog").dialog("close")},invalidHandler:function(){$("#phone-dialog-validateTips").addClass("ui-state-error").show()},errorLabelContainer:"#phone-dialog-validateTips",wrapper:"li"})});var TimeTracker=function(a){this.bucket_=a?a.sort(this.sortNumber):TimeTracker.DEFAULT_BUCKET};
TimeTracker.DEFAULT_BUCKET=[100,500,1500,2500,5E3];TimeTracker.prototype._getTimeDiff=function(){return this.stopTime_-this.startTime_};TimeTracker.prototype.sortNumber=function(a,c){return a-c};TimeTracker.prototype._recordStartTime=function(a){this.startTime_=a!=undefined?a:(new Date).getTime()};TimeTracker.prototype._recordEndTime=function(a){this.stopTime_=a!=undefined?a:(new Date).getTime()};
TimeTracker.prototype._track=function(a,c,f){a=c!=undefined&&c.length!=0?a._createEventTracker(c):a._createEventTracker("TimeTracker");var g;for(c=0;c<this.bucket_.length;c++)if(this._getTimeDiff()<this.bucket_[c]){g=c==0?"0-"+this.bucket_[0]:this.bucket_[c-1]+"-"+(this.bucket_[c]-1);break}g||(g=this.bucket_[c-1]+"+");a._trackEvent(g,f,this._getTimeDiff())};TimeTracker.prototype._setHistogramBuckets=function(a){this.bucket_=a.sort(this.sortNumber)};

