﻿var currentTime,mainSlideShow,socialSlideShow;$(document).ready(function(){$.ajaxSetup({cache:false});$.getJSON("/Home/CurrentTime",function(a){currentTime=Date.parseExact(a,"dd-MM-yyyy h:mm:ss tt")});mainSlideShow=new Slideshow(0,312,"#slideshow_wrapper ul",8,4,10);socialSlideShow=new Slideshow(1,152,"#social_slideshow_wrapper ul",4,3,6);setInterval("UpdateTime()",1e3)});function UpdateTime(){if(currentTime!=null){currentTime.add(1).seconds();$("span.calendar-time span").text(currentTime.toString("h:mm:ss tt"))}}function Slideshow(b,f,c,a,e,d){this.direction=b;this.count=$(c).find("li").length;this.width=f;this.target=c;this.index=b==0?this.count-1:0;this.initialInterbal=a;this.minInterval=e;this.maxInterval=d;$(this.target).css("left",-1*this.width*this.index+"px");$(this.target).css("width",this.width*this.count+"px");this.SetTimer(a)}Slideshow.prototype.SetTimer=function(b){var d=this;function c(){d.HandleTimer()}if(b!=null)setTimeout(c,b*1e3);else{var a=Math.floor(Math.random()*this.maxInterval);while(a<this.minInterval)a=Math.floor(Math.random()*this.maxInterval);setTimeout(c,a*1e3)}};Slideshow.prototype.HandleTimer=function(){if(this.direction==0)if(this.index+1<this.count)this.index++;else{this.index--;this.direction=1}else if(this.index-1>=0)this.index--;else{this.index++;this.direction=0}$(this.target).animate({left:-1*this.width*this.index},500,"swing");$(this.target).parent().css("background-image","none");this.SetTimer()}
