/*
 * script.js - scripty pro amaxim
 * Autor: Radek Liska, radarfox at seznam.cz 
 */

// Expandujici boxy

var zindex = 1000;

function smallBox(id) {
	$(id + " .more a").click(function() {
		$(id).css('z-index',zindex++);
		$(id + " .bg").animate({width: "482px"}, {queue:false, duration:1200}).animate({height: "407px"}, 1200);
		$(id + " .full").fadeIn(1200);
		$(id + " .more").fadeOut(400);
		$(id + " .less").animate({opacity: 1.0}, 800).fadeIn(400);
	});
	$(id + " .less a").click(function() {
		$(id + " .bg").animate({width: "238px"}, {queue:false, duration:1200}).animate({height: "201px"}, 1200);
		$(id + " .full").fadeOut(1200);
		$(id + " .more").animate({opacity: 1.0}, 800).fadeIn(400);
		$(id + " .less").fadeOut(400);
	});
}

function mediumBox(id) {
	$(id + " .more a").click(function() {
		$(id).css('z-index',zindex++);
		$(id + " .bg").animate({width: "726px"}, {queue:false, duration:1200}).animate({height: "407px"}, 1200);
		$(id + " .full").fadeIn(1200);
		$(id + " .more").fadeOut(400);
		$(id + " .less").animate({opacity: 1.0}, 800).fadeIn(400);
	});
	$(id + " .less a").click(function() {
		$(id + " .bg").animate({width: "482px"}, {queue:false, duration:1200}).animate({height: "201px"}, 1200);
		$(id + " .full").fadeOut(1200);
		$(id + " .more").animate({opacity: 1.0}, 800).fadeIn(400);
		$(id + " .less").fadeOut(400);
	});
}

function largeBox(id) {
	$(id + " .more a").click(function() {
		$(id).css('z-index',zindex++);
		$(id + " .bg").animate({width: "482px"}, {queue:false, duration:1200}).animate({height: "819px"}, 1200);
		$(id + " .full").fadeIn(1200);
		$(id + " .more").fadeOut(400);
		$(id + " .less").animate({opacity: 1.0}, 800).fadeIn(400);
	});
	$(id + " .less a").click(function() {
		$(id + " .bg").animate({width: "482px"}, {queue:false, duration:1200}).animate({height: "407px"}, 1200);
		$(id + " .full").fadeOut(1200);
		$(id + " .more").animate({opacity: 1.0}, 800).fadeIn(400);
		$(id + " .less").fadeOut(400);
	});
}

function tallBox(id) {
	$(id + " .more a").click(function() {
		$(id).css('z-index',zindex++);
		$(id + " .bg").animate({width: "238px"}, {queue:false, duration:1200}).animate({height: "819px"}, 1200);
		$(id + " .full").fadeIn(1200);
		$(id + " .more").fadeOut(400);
		$(id + " .less").animate({opacity: 1.0}, 800).fadeIn(400);
	});
	$(id + " .less a").click(function() {
		$(id + " .bg").animate({width: "238px"}, {queue:false, duration:1200}).animate({height: "407px"}, 1200);
		$(id + " .full").fadeOut(1200);
		$(id + " .more").animate({opacity: 1.0}, 800).fadeIn(400);
		$(id + " .less").fadeOut(400);
	});
}

// Document ready

$(document).ready(function(){

	// SIPKY

	var speed = 200;

	// MENU 01
	var menu01x01 = $("#menu01x01").width() / 2 + 0 * 5 - 10;
	var menu01x02 = $("#menu01x01").width() + $("#menu01x02").width() / 2 + 1 * 5 - 10;
	var menu01x03 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() / 2 + 2 * 5 - 10;
	var menu01x04 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() + $("#menu01x04").width() / 2 + 3 * 5 - 10;
	var menu01x05 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() + $("#menu01x04").width() + $("#menu01x05").width() / 2 + 4 * 5 - 10;
	var menu01x06 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() + $("#menu01x04").width() + $("#menu01x05").width() + $("#menu01x06").width() / 2 + 5 * 5 - 10;
	var menu01x07 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() + $("#menu01x04").width() + $("#menu01x05").width() + $("#menu01x06").width() + $("#menu01x07").width() / 2 + 6 * 5 - 10;
	var menu01x08 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() + $("#menu01x04").width() + $("#menu01x05").width() + $("#menu01x06").width() + $("#menu01x07").width() + $("#menu01x08").width() / 2 + 7 * 5 - 10;
	var menu01x09 = $("#menu01x01").width() + $("#menu01x02").width() + $("#menu01x03").width() + $("#menu01x04").width() + $("#menu01x05").width() + $("#menu01x06").width() + $("#menu01x07").width() + $("#menu01x08").width() + $("#menu01x09").width() / 2 + 7 * 5 - 10;
	$("#menu01x01").hover(function(){$("#sipka01").animate({left: menu01x01}, speed);});
	$("#menu01x02").hover(function(){$("#sipka01").animate({left: menu01x02}, speed);});
	$("#menu01x03").hover(function(){$("#sipka01").animate({left: menu01x03}, speed);});
	$("#menu01x04").hover(function(){$("#sipka01").animate({left: menu01x04}, speed);});
	$("#menu01x05").hover(function(){$("#sipka01").animate({left: menu01x05}, speed);});
	$("#menu01x06").hover(function(){$("#sipka01").animate({left: menu01x06}, speed);});
	$("#menu01x07").hover(function(){$("#sipka01").animate({left: menu01x07}, speed);});
	$("#menu01x08").hover(function(){$("#sipka01").animate({left: menu01x08}, speed);});
	$("#menu01x09").hover(function(){$("#sipka01").animate({left: menu01x09}, speed);});	
	$("#menu01").hover(function(){},function(){$("#sipka01").animate({left: 0}, speed);});

	// MENU 02
	var menu02x01 = $("#menu02x01").width() / 2 + 0 * 5 - 10;
	var menu02x02 = $("#menu02x01").width() + $("#menu02x02").width() / 2 + 1 * 5 - 10;
	$("#menu02x01").hover(function(){$("#sipka02").animate({left: menu02x01}, speed);});
	$("#menu02x02").hover(function(){$("#sipka02").animate({left: menu02x02}, speed);});
	$("#menu02").hover(function(){},function(){$("#sipka02").animate({left: 0}, speed);});

	// ZALOZKY
	$("#menu02x01").addClass('active');
	$("#menu02x01").click(function(){
		$("#menu02x01").addClass('active');
		$("#menu02x02").removeClass('active');
		$("#slides").animate({left: 0}, "slow");
	});
	$("#menu02x02").click(function(){
		$("#menu02x02").addClass('active');
		$("#menu02x01").removeClass('active');
		$("#slides").animate({left: -728}, "slow");
	});

	// MENU 03
	var menu03x01 = $("#menu03x01").width() / 2 + 0 * 4 - 4;
	var menu03x02 = $("#menu03x01").width() + $("#menu03x02").width() / 2 + 1 * 4 - 4;
	var menu03x03 = $("#menu03x01").width() + $("#menu03x02").width() + $("#menu03x03").width() / 2 + 2 * 4 - 4;
	var menu03x04 = $("#menu03x01").width() + $("#menu03x02").width() + $("#menu03x03").width() + $("#menu03x04").width() / 2 + 3 * 4 - 4;
	var menu03xactive;
	if ($("#menu03x01").hasClass('active')) {
		menu03xactive = menu03x01;
	}
	else if ($("#menu03x02").hasClass('active')) {
		menu03xactive = menu03x02;
	}
	else if ($("#menu03x03").hasClass('active')) {
		menu03xactive = menu03x03;
	}
	else if ($("#menu03x04").hasClass('active')) {
		menu03xactive = menu03x04;
	}
	$("#sipka03").animate({left: menu03xactive}, speed);
	$("#menu03x01").hover(function(){$("#sipka03").animate({left: menu03x01}, speed);});
	$("#menu03x02").hover(function(){$("#sipka03").animate({left: menu03x02}, speed);});
	$("#menu03x03").hover(function(){$("#sipka03").animate({left: menu03x03}, speed);});
	$("#menu03x04").hover(function(){$("#sipka03").animate({left: menu03x04}, speed);});
	$("#menu03").hover(function(){},function(){$("#sipka03").animate({left: menu03xactive}, speed);});

	// BOXY

	// SMALLBOX
	smallBox('#smallbox01');
	smallBox('#smallbox02');
	smallBox('#smallbox03');
	smallBox('#smallbox04');
	smallBox('#smallbox05');
	smallBox('#smallbox06');
	smallBox('#smallbox07');
	smallBox('#smallbox08');
	smallBox('#smallbox09');	
	smallBox('#smallbox10');
	smallBox('#smallbox11');
	smallBox('#smallbox12');
	smallBox('#smallbox13');
	smallBox('#smallbox14');
	smallBox('#smallbox15');

	// MEDIUMBOX
	mediumBox('#mediumbox01');
	mediumBox('#mediumbox02');
	mediumBox('#mediumbox03');
	mediumBox('#mediumbox04');

	// LARGEBOX
	largeBox('#largebox01');
	largeBox('#largebox02');

	// TALLBOX
	tallBox('#tallbox01');
	tallBox('#tallbox02');

});
