if(!verani){var verani={}}verani.featuredListings={};verani.featuredListings.listingViews=[];verani.featuredListings.lastCount=0;verani.featuredListings.checkViewsIntervals=[];verani.featuredListings.checkViews=function(){if(verani.featuredListings.listingViews.length==verani.featuredListings.lastCount){globalInterface.recordListingViews(verani.featuredListings.listingViews,"Featured");verani.featuredListings.listingViews=[];for(var a in verani.featuredListings.checkViewsIntervals){clearInterval(verani.featuredListings.checkViewsIntervals[a])}}verani.featuredListings.lastCount=verani.featuredListings.listingViews.length};verani.FeaturedListingRotator=function(a){this.element=document.getElementById(a);this.container=null;this.currentIndex=0;this.listingElements=$(this.element).find("div.listings").children();this.thumbnailElements=$(this.element).find("div.thumbnails").children("img");this.perPage=3;this.initialize=function(){this.container=document.createElement("div");$(this.element).find("div.thumbnails").append(this.container);$(this.container).append(this.thumbnailElements);$(this.container).css("position","absolute");$(this.element).find("div.thumbnails").css("overflow","hidden");$(this.element).find("div.arrowLeft").click(function(){b.scrollTo(b.currentIndex-1,true);b.showListing(b.currentIndex)});$(this.element).find("div.arrowRight").click(function(){b.scrollTo(b.currentIndex+1,true);b.showListing(b.currentIndex)});this.showListing(0);this.scrollTo(0,false);var b=this;for(var c=0;c<this.thumbnailElements.length;c++){this.thumbnailElements[c]._thumbIndex=c;$(this.thumbnailElements[c]).click(function(){b.thumbnailClick(this)})}$(this.element).find("div.loading").hide()};this.thumbnailClick=function(b){this.showListing(b._thumbIndex);this.scrollTo(b._thumbIndex,true)};this.showListing=function(b){this.listingElements.hide();if(this.listingElements[b]){$(this.listingElements[b]).show();$(this.listingElements[b]).find("img.listingImage")[0].loadImage()}this.updateArrows()};this.updateArrows=function(){if(this.currentIndex==0){$(this.element).find("div.arrowLeft").hide()}else{$(this.element).find("div.arrowLeft").show()}if(this.currentIndex+1==this.thumbnailElements.length){$(this.element).find("div.arrowRight").hide()}else{$(this.element).find("div.arrowRight").show()}};this.scrollTo=function(h,b){if(this.thumbnailElements[h]){$(this.thumbnailElements).removeClass("selected");$(this.thumbnailElements[h]).addClass("selected");var j=0;var f=0;var g=true;var d=0;var k=0;var i=[];if(h<this.currentIndex){g=false}if(Math.abs(this.currentIndex-h)>2){d=this.thumbnailElements.length;if(this.currentIndex-h<0){g=false}else{g=true}}if(g){j=this.currentIndex-Math.floor(this.perPage/2);f=h+d+Math.floor(this.perPage/2)}else{j=h-Math.floor(this.perPage/2);f=this.currentIndex+d+Math.floor(this.perPage/2)}if(g){$(this.container).css("left",0)}else{$(this.container).css("left",-(this.thumbnailElements.fullWidth()*Math.abs(h-this.currentIndex-d)))}$(this.thumbnailElements).css("visibility","hidden");for(var c=j;c<=f;c++){virtualIndex=c;if(c<0){virtualIndex=this.thumbnailElements.length+c}if(c>=this.thumbnailElements.length){virtualIndex=c-this.thumbnailElements.length}var e=$(this.thumbnailElements[virtualIndex]);e.css("left",e.fullWidth()*k);e.css("visibility","visible");if(c>=h-Math.floor(this.perPage/2)&&c<=h+Math.floor(this.perPage/2)){verani.featuredListings.listingViews.push($(this.listingElements[virtualIndex]).find("span.mlsNumber").html());e[0].loadImage()}k++}verani.featuredListings.checkViewsIntervals.push(setInterval(verani.featuredListings.checkViews,500));$(this.container).width(k*this.thumbnailElements.fullWidth());if(b){if(g){$(this.container).animate({left:-(this.thumbnailElements.fullWidth()*Math.abs(h-this.currentIndex+d))})}else{$(this.container).animate({left:0})}}this.currentIndex=h}this.updateArrows()};this.initialize()};
