$(document).ready(function() {

/**
 * rollovani produktu
 */
$(".product p.description").hover(function() {

					$(this).css('overflow', 'none');

					$(this).animate({
						height : '170px'
					},150);

				}, function() {

					$(this).animate({
						height : '42px'
					},150);

					$(this).css('height', '42px');
					$(this).css('overflow', 'none');
				});




	/*
	 * Placeholdery
	 */
	function placehol(el, placeholdtext) {

		$(el).val(placeholdtext);

		$(el).focusin(function() {
			if($(el).val() == placeholdtext)
				$(el).val('');
			/*$(el).animate({
			opacity : 0.8
			}, 'fast');*/
			//$(el).css('color', 'white');
		});

		$(el).focusout(function() {
			if($(el).val() == '') {
				$(el).val(placeholdtext);
				/*$(el).animate({
				opacity : 0.5
				}, 'fast');*/
				//$(el).css('color', 'silver');
			}
		});
	}

	var search = 'hledaný produkt, látka';

	placehol('#search', search);







	/**
	 * slider
	 */
	$("#slider").vSlider();
	$("#slider2").vSlider2();






	/*
	 * login
	 */
	$(".signin").click(function(e) {
		e.preventDefault();
		$("fieldset#signin_menu").slideToggle();

	});

	$("fieldset#signin_menu").mouseup(function() {
		return false
	});
	$(document).mouseup(function(e) {
		if($(e.target).parent("a.signin").length == 0) {

			$("fieldset#signin_menu").fadeOut();
		}
	});
	
	
	/*
	 * 4. produkt ve slideru
	 */
	$("a#kteryzobrazitcontrol").click(function(e) {
		e.preventDefault();
		$("div#kteryzobrazit").fadeIn();

	});

	$("div#kteryzobrazit").mouseup(function() {
		return false
	});
	$(document).mouseup(function(e) {
		if($(e.target).parent("a#kteryzobrazitcontrol").length == 0) {

			$("div#kteryzobrazit").fadeOut();
		}
	});
	
	
	
	
	
	/**
	 * menu hack
	 */
	function menuoverlay(el, pic){
		$(el).hover(function() {
			$("#menu-overlay").css("background", "url('"+pic+"')");
		}, function() {
			$("#menu-overlay").css("background", "none");
		});
	}
	
	menuoverlay(".first", "/imgs/menu/1.png");
	menuoverlay(".second", "/imgs/menu/2.png");
	menuoverlay(".third", "/imgs/menu/3.png");
	menuoverlay(".fourth", "/imgs/menu/4.png");
	menuoverlay(".fifth", "/imgs/menu/5.png");
	menuoverlay(".sixth", "/imgs/menu/6.png");
	
	
	$('.pointermouse').click(function(e) {
	  e.preventDefault();
	});
	
	
	
	
	
	
	
	
	
	
	/*
	 * nahodne zobrazovani referenci
	 */
  var ql = $("ul#refs li");
  ql.css("display", "block"); // Cancel CSS options
  ql.hide();
  ql.eq(Math.floor(Math.random() * ql.length)).show();
    
    
    
    /**
     * definice rozklikavani referenci pro fancybox
     */
    $(".various1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade'
	});
	
	
	
	
});







/*
 * JS menu hlavni
 */
sfHover = function() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("li");
	for(var i = 0; i < sfEls.length; i++) {
		sfEls[i].onmouseover = function() {
			this.className += " hover";
		}
		sfEls[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
if(window.attachEvent)
	window.attachEvent("onload", sfHover);

