﻿$(document).ready(function(){var request_params="tt="+tourtype_id;if(honeymoon)request_params+="&hm=1";$("#firstpagetour").firstpagetour("firstpagetour.aspx",{nextBtn:".next",prevBtn:".prev",auto:10000,request_params:request_params});});(function($){$.fn.firstpagetour=function(url,options){var defaults={nextBtn:null,prevBtn:null,auto:null,request_params:null};var options=$.extend(defaults,options);var url=url;return this.each(function(){var div=$(this);var ul=$("ul",div);var li=$("li",ul);var h=li.outerHeight();var w=li.outerWidth();var nm=Math.floor(Math.random()*20);var timer=null;div.css("width",li.length*w);if(options.nextBtn)$(options.nextBtn).click(next);if(options.prevBtn)$(options.prevBtn).click(prev);if(options.auto){startTimer();div.mouseenter(stopTimer);div.mouseleave(startTimer);}
return this;function startTimer(){timer=setInterval(next,options.auto);}
function stopTimer(){if(timer)clearInterval(timer);}
function next(){stopTimer();startTimer();nm++;$.get(getHref(),function(data){showNextTour(data);})}
function prev(){stopTimer();startTimer();nm--;$.get(getHref(),function(data){showPevTour(data);})}
function getHref(){var tmp=url+"?nm="+nm;if(options.request_params)tmp+="&"+options.request_params;return tmp;}
function showNextTour(data){ul.css("width",5000+"px");var oldLi=$("li",ul)
var shift=oldLi.length*w;ul.append(data);ul.animate({left:-shift},1500,removeOldLi);function removeOldLi(){var cnt=oldLi.length*w;oldLi.remove();ul.css("left","0px");ul.css("width",cnt+"px");};}
function showPevTour(data){ul.css("width",5000+"px");var oldLi=$("li",ul)
var shift=oldLi.length*w;ul.prepend(data);ul.css("left",-shift);ul.animate({left:0},1500,removeOldLi);function removeOldLi(){var cnt=oldLi.length*w;oldLi.remove();ul.css("left","0px");ul.css("width",cnt+"px");};}});};})(jQuery);