$(function(){
	var handler = null;
	var cacheImgs = new Array();
	var currentItem = null;
	var enabled = true;
	
	var hot = {
		slider: $("#hot-text-slider"),
		img: $("#hot-img"),
		title: $("#hot-title"),
		text: $("#hot-text"),
		imgLink: $("#hot-img-link"),
		link: $("#hot-link")
	}
	
	function switchInfo(data) {
		hot.slider.stop().css("top", "92px");
		hot.img[0].src = data.img;
		hot.title.removeClass("debates videos blogs custom-page").addClass(data.type);
		hot.link.text(data.title).attr("href", data.link);
		hot.text.html(data.text);
		hot.imgLink[0].href = data.link;

		
		window.clearTimeout(handler);
		handler = window.setTimeout(function(){
			hot.slider.stop().animate({
				top: 0
			}, 350, "linear", function(){
				hot.slider.css("top", 0);
			});
		}, 700);
	}

	var items = $("#hot-carousel").find("li");
	items.mouseenter(function(){
		if (enabled && this != currentItem) {
			var item = $(this);

			switchInfo({
				img: item.attr("big_image"),
				title: item.attr("title"),
				text: item.attr("fulltext"),
				type: item.attr("csstype"),
				link: item.attr("link_url")
			});
			currentItem = this;
		}
	}).click(function(){
		enabled = false;
	}).each(function(){
		if (this == items.eq(0)[0]) {
			currentItem = this;
		} else {
			var img = new Image();
			img.src = this.getAttribute("big_image");
			cacheImgs.push(img);		
		}
	});
});
