var AdSlider=Class.create(AC.Slider,{
	createMovieSizes:function(j){j.addClassName("adtrigger");
	var b=j.up("div").identify().replace(/ad-/,"");
	var a=document.createElement("div");
	if(this.movieSizeNav){
		var f=this.movieSizeNav.cloneNode(true);
		var h=f.select("a");
		h.each(function(l,k){
			l.href=l.href.replace(/.*#(.*)/,"#"+b+"-$1")
		}
		)
	}var g=a.cloneNode(true);
	g.id=b+"-large";
	g.className="size large";
	j.parentNode.appendChild(g);
	var c=a.cloneNode(true);
	c.className="movie";
	c.innerHTML+='<a class="movieLink" href="'+j.href.toString().replace("848x480","640x360")+'?width=640&amp;height=360"></a>';
	if(this.endState){
		c.appendChild(this.endState.cloneNode(true))
	}if(f){
		c.appendChild(f.cloneNode(true))
	}g.appendChild(c);
	var e=a.cloneNode(true);
	e.id=b+"-hd";
	e.className="size hd";
	j.parentNode.appendChild(e);
	var c=a.cloneNode(true);
	c.className="movie";
	c.innerHTML+='<a class="movieLink" href="'+j.href+'?width=848&amp;height=480"></a>';
	if(this.endState){
		c.appendChild(this.endState.cloneNode(true))
	}if(f){
		c.appendChild(f.cloneNode(true))
	}e.appendChild(c);var d=a.cloneNode(true);
	d.id=b+"-small";d.className="size small";
	j.parentNode.appendChild(d);
	var c=a.cloneNode(true);
	c.className="movie";
	c.innerHTML+='<a class="movieLink" href="'+j.href.toString().replace("848x480","320x180")+'?width=320&amp;height=180"></a>';
	if(this.endState){
		c.appendChild(this.endState.cloneNode(true))
	}if(f){
		c.appendChild(f.cloneNode(true))
	}d.appendChild(c);
	var i=a.cloneNode(true);
	i.id=b+"-medium";
	i.className="size medium";
	j.parentNode.appendChild(i);
	var c=a.cloneNode(true);
	c.className="movie";
	c.innerHTML+='<a class="movieLink" href="'+j.href.toString().replace("848x480","480x272")+'?width=480&amp;height=272"></a>';
	if(this.endState){
		c.appendChild(this.endState.cloneNode(true))
	}if(f){
		c.appendChild(f.cloneNode(true))
	}i.appendChild(c);
	j.href="#"+b+"-large"
},populate:function(a){
	this.endState=$$(".endState")[0];
	this.movieSizeNav=$$(".sizenav")[0];
	a.each(function(c){
		this.createMovieSizes(c);
		var b=new AC.SliderItem(c);
		this.items.push(b)
	}.bind(this));
	this.render(8)
},scrollToItem:function(a){
	var d=null;
	var c=this.itemsPerPage;
	for(var b=1;
	b<=this.totalPages+1;
	b++){
		var f=(b*this.itemsPerPage)-this.itemsPerPage;
		var e=f+c-1;
		if(b==this.currentPage&&a>=f&&a<=e){
			d=b
		}if(!d&&a>=f&&a<=e){d=b}}if(d!=this.currentPage){
			this.scrolltoPageNumber(d)
		}
	}
});
var AdSwap=Class.create({
	initialize:function(){
		this.wrapper=$("display").up();
		this.ads=$$("#ads-nojs div a");
		this.makeSlider(this.ads);
		this.swapView=new AC.ViewMaster.Viewer(null,"display","adtrigger",{
			animationDuration:0.4
		});
		this.swapView.setDelegate(this);
		if(document.location.hash){
			var c=document.location.hash.replace(/#/,"");
			var a=$(c);
			if(a){
				var b=this.swapView.addSection(a);
				this.swapView.show(b)
			}
		}if(!this.swapView.currentSection){
			var b=this.swapView.addSection($$("#ads-nojs div.size")[0]);
			this.swapView.show(b)
		}else{
			this.swapView.didAppendContent(this.swapView)
		}
	},makeSlider:function(b){
		this.slider=new AdSlider("slider",b);
		this.slider.setCarousel(false);
		this.slider.resetPages();
		if(document.location.hash){
			var c=document.location.hash.toString().replace(/.*#(.*)-.*/,"$1");
			var a=$$("#slider li:not(.cloned) a[href*=#"+c+"]")[0];if(a){
				this.slider.jumptoPageNumber(Math.floor(a.up().previousSiblings().length/this.slider.itemsPerPage))
			}
		}
	},willShow:function(b,c,a){
		this.currentId=a.id;var d=a.id.replace(/.*-/,"");b.options.shouldAnimateContentChange=!(this.currentSize==d);
		this.currentSize=d
	},didAppendContent:function(c){
		var b=c.currentSection;
		var a=c.view.view();
		if(b&&a){
			var d=b.content.getDimensions();
			var e=c.view.view().getDimensions();
			if(c.options.shouldAnimateContentChange){
				new Effect.Parallel([new Effect.Scale(a,((d.width/e.width)*100),{
					scaleY:false,scaleContent:false,sync:true
				}),new Effect.Scale(a,((d.height/e.height)*100),{
					scaleX:false,scaleContent:false,sync:true
				})],{
					duration:c.options.animationDuration
				})
				}else{
					a.style.width=d.width+"px";
					a.style.height=d.height+"px"
				}
			}
		},didShow:function(b,c,a){
			if(!this.currentId||!this.currentSize){
				this.currentId=a.id;
				this.currentSize=a.id.replace(/.*-/,"")
			}this.setSliderActive(a.id);
			b.options.shouldAnimateContentChange=false
		},setSliderActive:function(b){
			var b=this.currentId;
			var a=this.currentSize;
			this.slider.container.select("a."+this.swapView.triggerClassName).each(function(d){
				var c=d.href.replace(/.*#(.*)-.*/,"$1");
				d.href="#"+c+"-"+a;
				if(b.match(c)){d.addClassName("active")
			}else{
				d.removeClassName("active")
			}
		})
	}
});Event.observe(window,"load",function(){if(AC.Detector.isMobile()){
	var a=$("ads-nojs");
	a.addClassName("iphone");
	a.select("a").each(function(c){
		c.href=c.href.replace(c.href.substr(c.href.length-11,7),"r320-9cie")
		})
	}else{
		var b=new AC.ViewMaster.Tracker("click");new AdSwap()
	}
});