﻿function intro()
{
	var intro_timer = setTimeout('location.replace("uvod")', 4500);
}

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","auto");
		});
	}
})(jQuery);

function uvod()
{
	var timer2 = setTimeout("$('#uvod-sub-navigation li.menu-nabidka').equalHeights()", 800);
	var timer = setTimeout("$('div#container.fade-start').fadeIn(2000)", 500);
	var el = $('#uvod-sub-navigation li:has(> ul)');
	$('#uvod-sub-navigation li:has(> ul)').hover(function()
	{
		el.not(this).stop(false, true).animate({'opacity': '0.5', 'margin-top': '0'}, 'fast');
		$(this).stop(false, true).animate({'min-height': '346px', 'margin-top': '-15px', 'padding-top': '15px', 'margin-bottom': '0px'}, 'fast');
	}, function()
	{
		el.not(this).stop(false, true).animate({'opacity': '1', 'margin-top': '0'}, 'slow');
		$(this).stop(false, true).animate({'min-height': '333px', 'margin-top': '0', 'padding-top': '0', 'margin-bottom': '25px'}, 'fast');
	});
}

function nabidka()
{
	$('#menu-switcher').hover(function()
	{
		$('#menu-switcher li').stop(false, true).fadeIn('fast');
	}, function()
	{
		$('#menu-switcher li.menu-nabidka').stop(false, true).fadeOut('slow');
		var timer1 = setTimeout("$('#menu-switcher li.current-menu-ancestor').css('display', 'block')", 850);
	});
	$('ul.sub-menu li:not(.current-menu-ancestor, .current-menu-item) a').hover(function()
	{
		$(this).stop().animate({'color': '#CFEE01'}, 'fast');
	}, function()
	{
		$(this).stop().animate({'color': '#fff'}, 'slow');
	})
}

function gallery()
{
	$("a.gallery-link:has(img)").fancybox(
	{
	'centerOnScroll': true,
	'scrolling'	: 'no',
	'autoDimensions'	: true,
	'titleShow'	: true,
	'height'	:	'auto',
	'width'		: 'auto',
	onComplete	: function()
	{
		;
	}
	});
	$(".pick-nabidka ul a").fancybox({
		'titleShow'	: false,
		'centerOnScroll': true,
		'scrolling'	: 'auto',
		ajax : {
			type	: "POST"
		}
	});
}

function loader()
{
	pic1 = new Image();
	pic2 = new Image();
	pic3 = new Image();
	pic1.src="/wp/wp-content/themes/simplez/img/bila-pronajem.png";
	pic2.src="/wp/wp-content/themes/simplez/img/bila-prodej.png";
	pic3.src="/wp/wp-content/themes/simplez/img/bila-produkce.png";
}

function wrapper()
{
	$(".produkt .right img").each(function() {
	$(this).wrap('<div class="corner f-right img-div" />');
	var imgSrc = $(this).attr("src");
	var imgHeight = $(this).height();
	var imgWidth = $(this).width();
	$(this).parent()
	.css("background-image", "url(" + imgSrc + ")")
	.css("background-repeat","no-repeat")
	.css("height", imgHeight + "px")
	.css("width", imgWidth + "px");
	$(this).remove();
	});
}

function stranka()
{
	$('.stranka .nav-nabidka li.menu-nabidka a').hover(function()
	{
		$(this).stop().animate({'opacity': '1'}, 'fast');
	}, function()
	{
		$(this).stop().animate({'opacity': '0.6'}, 'fast');
	});
}

function kontakt()
{
	var timer3;
	$('a.mapa-link').fancybox({
		'titleShow'	: false,
		'centerOnScroll': true,
		'scrolling'	: 'auto',
		ajax : {
			type	: "POST"
		}
	});
	$('body:not(.ie8, .ie7) #mapa').hover(function()
	{
		clearTimeout(timer3);
		$(this).stop(false, true).animate({'opacity': '1'}, 'fast');
	}, function()
	{
		timer3 = setTimeout("$('#mapa').stop(false, true).animate({'opacity': '0.55'}, 'slow')", 1000);
	})
}

function galerie()
{
	$('.jcarousel-skin-tango').jcarousel(
	{
		scroll: 1
	});
	$('a.gallery-link').fancybox({
		'titleShow'	: false,
		'centerOnScroll': true
	});
}
