(function($){$.fn.PriceView=function(date,options){var $this=this,$terms=eval($("#ctl00_cp1_hfSearch").val()),$proxy=Enlighten.Jasons.Site.Services.Search,$months=[],$opts=$.extend({},$.fn.PriceView.defaults,options);this.date=new Date;var showLoading=function(){$("#loading-icon").show();$("#loading-icon").height(parseFloat($(".SearchPriceDays").height())-35)},hideLoading=function(){$("#loading-icon").hide()},Next=function(){$this.date.setDate($this.date.getDate()+7);var d=$this.date.getFullYear()+"/"+(parseFloat($this.date.getMonth())+1)+"/"+$this.date.getDate();setDate(d);showLoading();$proxy.SearchByPrice($terms,d,function(result){$this.find(".price-scroll").append(result);if($this.find(".price-week:first").length>0){var _s=$this.find(".price-week:first").offset().left,_e=$this.find(".price-week:last").offset().left;$this.animate({scrollLeft:_e-_s},1500,function(){$this.find(".price-week:first").remove();$this.scrollLeft(0);CheckButtons();hideLoading()})}})},Back=function(){$this.date.setDate($this.date.getDate()-7);var d=$this.date.getFullYear()+"/"+(parseFloat($this.date.getMonth())+1)+"/"+$this.date.getDate();setDate(d);showLoading();$proxy.SearchByPrice($terms,d,function(result){$this.find(".price-scroll").prepend(result);if($this.find(".price-week:first").length>0){var _s=$this.find(".price-week:last").offset().left,_e=$this.find(".price-week:first").offset().left;$this.scrollLeft(_s-_e);$this.animate({scrollLeft:0},1500,function(){$this.find(".price-week:last").remove();CheckButtons();hideLoading()})}})},Change=function(date){var d;if(date.indexOf("/")!=-1)d=date.split("/")[2]+"/"+date.split("/")[1]+"/"+date.split("/")[0];else d=date.split(" ")[2]+"/"+$months[date.split(" ")[1]]+"/"+date.split(" ")[0];var old=new Date($this.date);setDate(d);showLoading();if($this.date<old)$proxy.SearchByPrice($terms,d,function(result){$this.find(".price-scroll").prepend(result);if($this.find(".price-week:first").length>0){var _s=$this.find(".price-week:last").offset().left,_e=$this.find(".price-week:first").offset().left;$this.scrollLeft(_s-_e);$this.animate({scrollLeft:0},1500,function(){$this.find(".price-week:last").remove();CheckButtons();hideLoading()})}});else $proxy.SearchByPrice($terms,d,function(result){$this.find(".price-scroll").append(result);if($this.find(".price-week:last").length>0){var _s=$this.find(".price-week:first").offset().left,_e=$this.find(".price-week:last").offset().left;$this.animate({scrollLeft:_e-_s},1500,function(){$this.find(".price-week:first").remove();$this.scrollLeft(0);CheckButtons();hideLoading()})}})},CheckButtons=function(){if($this.date<=new Date){$($opts.back).css({visibility:"hidden"});$($opts.back).attr("disabled","disabled")}else{$("#ctl00_cp1_btnBack").css({visibility:"visible"});$($opts.back).removeAttr("disabled")}},setDate=function(d){try{$this.date.setYear(d.split("/")[0]);$this.date.setMonth(parseFloat(d.split("/")[1])-1);$this.date.setDate(d.split("/")[2]);if($this.date<new Date)$this.date=new Date}catch(e){console.log(e)}};this.render=function(){setDate(date);CheckButtons();$months.January=1;$months.February=2;$months.March=3;$months.April=4;$months.May=5;$months.June=6;$months.July=7;$months.August=8;$months.September=9;$months.October=10;$months.November=11;$months.December=12;for(var i in $terms){$terms[i].FeatureExpiry="";$terms[i].StartDate=""}$($opts.forward).click(function(e){e.preventDefault();Next();return false});$($opts.back).click(function(e){e.preventDefault();Back();return false});return $this};return this.render()};$.fn.PriceView.defaults={back:"",forward:"",date:"",prices:""}})(jQuery);$(document).ready(function(){var $deal=$(".image .hot-deal").qtip({show:"mouseover",hide:{fixed:true},position:{corner:{target:"bottomLeft",tooltip:"topLeft"},adjust:{x:25}},style:{background:"#fff",border:{width:1,radius:3,color:"#ff0000"},tip:{corner:"topLeft",background:"#fff"},width:400},api:{beforeShow:function(){$me=this;var html="<div class='hot-deal-container'><div class='hot-deal-text-container'>"+$me.elements.target.attr("data-hot-deal")+"<br /><a href='"+$me.elements.target.attr("data-hot-deal-url")+"'>more >></a></div></div>";$me.updateContent(html)}}});if(document.cookie.length>0&&$(".order-by-tool-tip").length&&document.cookie.indexOf("TimesSeenToolTip=3")<0){var seen0=document.cookie.indexOf("TimesSeenToolTip")<0,seen1=document.cookie.indexOf("TimesSeenToolTip=1")>=0,seen2=document.cookie.indexOf("TimesSeenToolTip=2")>=0;if(seen0||seen1||seen2){$(".order-by-tool-tip").css("display","block");if(seen0)document.cookie="TimesSeenToolTip=1";else if(seen1)document.cookie="TimesSeenToolTip=2";else if(seen2)document.cookie="TimesSeenToolTip=3";setTimeout(function(){$(".order-by-tool-tip").fadeOut("slow")},2e4);$(".order-by-tool-tip").effect("bounce",{times:5,distance:20},500)}}})
