/* Sliding windows */
var currentItem = null;
var undoTimerHodler = false;
$(document).ready(function() {
	// Init Animations
	$('#slider div.block .bg').css({opacity: "1", filter: "alpha(opacity=100)"});
	$('#slider div.block .text-bg').css({opacity: "0"});
	$('#slider div.block .text').css({opacity: "0"});
	// Set Events
	$('#slider div.block').bind('click', doItem);
	$('#slider div.block').hover(hoverItem, unhoverItem);
	// Init Vars
	currentItem = null;
});
function hoverItem() {
	$(this).children(".bg").animate({opacity: 1}, 200,'linear');
}
function unhoverItem() {
	if (currentItem != this) {
		$(this).children(".bg").animate({opacity: 1}, 200,'linear');
	}
}
function doItem() {				
	if (currentItem == this) {
		$(this).children(".bg").animate({opacity: 1}, 200,'linear');
		$('#slider div.block').animate({width: 180}, 200,'linear');
		$(this).children(".bg").children(".text-bg").animate({opacity: 0}, 200,'linear');
		$(this).children(".bg").children(".text").animate({opacity: 0}, 200,'linear');
		currentItem = null;
	} else {
		$(this).children(".bg").animate({opacity: 1}, 200,'linear');
		$(this).animate({width: 280}, 200,'linear');
		$(this).children(".bg").children(".text-bg").animate({opacity: 1}, 200,'linear');
		$(this).children(".bg").children(".text").animate({opacity: 1}, 200,'linear');
		$('#slider div.block').not(this).animate({width: 150}, 200,'linear');
		$('#slider div.block').not(this).children(".bg").animate({opacity: 1}, 200,'linear');
		$('#slider div.block').not(this).children(".bg").children(".text-bg").animate({opacity: 0}, 200,'linear');
		$('#slider div.block').not(this).children(".bg").children(".text").animate({opacity: 0}, 200,'linear');
		currentItem = this;
	}
}