/*
JS Loaded: 
0.mlib+tour+js+layouts+default.js
*/



 // Including ./mlib/tour/js/layouts/default.js 


$(document).ready(function(){

	$("ul.models_list li").click(function(){
		window.location = $(this).find("a.link_watch_her_videos").attr("href");
	});

	$("ul.models_list li").hover(function(){
		$("ul.models_list li.active").removeClass("active");
		$(this).addClass("active");
	}, function(){	});

});




function generateHeader(bannerId, headObj)
{
	if (!headObj || !headObj.headers) return false;

	this.header = $(bannerId);
	var dis = this;
	var header = this.header;
	this.active = -1;

	this.basepath = headObj.basepath;
	this.images = headObj.headers || headObj.headers;

	this.playbtn = this.header.find(".play_trailer");

	//Randomize the header
	this.images.sort(function() {return 0.5 - Math.random()});
	// Keep only 4 header
	this.images = this.images.slice(0,4);



	//Show first header
	this.header.find(".header_left").attr("id", 0);
	this.header.find(".header_left").css("background-image", "url("+this.basepath +  this.images[0].id+")");

	this.imgLoader = $(document.createElement('img'));

	this.showplaybtn = function(){
		setTimeout(function() {
			dis.playbtn.animate({width: '144px'}, 250);
		}, 500);
	};
	this.showplaybtn();

	this.hideplaybtn = function(){
		this.playbtn.animate({width: '0px'}, 100);
	};
	this.init = function(){

		this.header.find(".header_left").click(function(){
			var id = $(this).attr("id");
			window.location = dis.images[id].url;
		});

		// Top Gradient hover the first element
		this.header.find(".top_gradient").hover(function(){
			header.find("ul.header_img_sets li:eq(0)  .info").addClass("hover");
		}, function(){
			header.find("ul.header_img_sets li:eq(0) .info").removeClass("hover");
		});

		// Bottom Gradient hover the fourth element
		this.header.find(".bottom_gradient").hover(function(){
			header.find("ul.header_img_sets li:eq(3)  .info").addClass("hover");
		}, function(){
			header.find("ul.header_img_sets li:eq(3) .info").removeClass("hover");
		});

		// Thumb hover effect
		this.header.find("ul.header_img_sets li").hover(function(){
			$(this).find(".info").addClass("hover");
		},
		function(){
			$(this).find(".info").removeClass("hover");
		});

		// Thumb click
		this.header.find("ul.header_img_sets li").click(function(){
			dis.hideplaybtn();
			var id = $(this).attr("id");
			//Show first header

			dis.header.find(".header_left").attr("id", id);
			dis.header.find(".header_left").css("background-image", "url("+dis.basepath +  dis.images[id].id+")");

			dis.showplaybtn();
		});

		this.playbtn.click(function(){
			dis.header.find(".header_left").click();
		});

		// Bottom Gradient click the fourth element
		this.header.find(".bottom_gradient").click(function(){
			dis.header.find("ul.header_img_sets li:eq(3)").click();
		});

		// Top Gradient click the fourth element
		this.header.find(".top_gradient").click(function(){
			dis.header.find("ul.header_img_sets li:eq(0)").click();
		});
	};

	this.listWrapper = this.header.find(".header_img_sets");

	//Generate thumbnail
	$.each(this.images, function(i, image){
					islast = ((i == 0) ? 'lastone' : '');
			dis.listWrapper.prepend('<li id="' + i + '"><div class="info '+ islast  + '"><strong>'+ image.shortTitle +'</strong></div><div class="img" style="background:transparent url( ' + dis.basepath +  image.thumb + ') left top no-repeat;"></div></li>');
	});

	//Install hover effect
	this.init();

	return this;
}




function gotojoin()
{
   window.location = "http://" + SITE_DOMAIN + "/" + AREA + "/join/";
}
