jQuery(document).ready(function(){

	jQuery(".box img").animate({opacity: 0.5}, 1);

        /* ovladani chovani boxiku na titulce */
	var temp_obj;
	jQuery(".box a").mouseenter(function(){
		jQuery(this).parent().children("img").animate({opacity: 1}, 400);
		var temp_color = jQuery(this).parent().parent().css("background-color");
		var temp_height = jQuery(this).children("span").height();
		temp_obj = jQuery("<span id='span_overlay'></span>").animate({opacity: 0.5}, 0).css({height: temp_height + "px", width: "207px", background: temp_color, zIndex: "4", padding: "5px", left: "0", bottom: "0"});
		jQuery(this).append(temp_obj);
	}).mouseleave(function(){
		jQuery(".box img").animate({opacity: 0.5}, 150);
		temp_obj.fadeOut(150, function(){jQuery(this).remove();});
	});
	
	/* darecek pro kktz IE6 */
	jQuery(".box img").mouseenter(function(){
		jQuery(this).parent().mouseenter();
	});

        /* animace - postranni menu */
        jQuery(".widget_pages li:not(.current_page_item) a").mouseenter(function(){
            jQuery(this).animate({paddingLeft: "+=12px"}, 100).css({background: "url(/wp-content/themes/hanhart/img/menu-items.gif) no-repeat -1020px 50%"});
        }).mouseleave(function(){
            jQuery(this).animate({paddingLeft: "-=12px"}, 100);
            if(!jQuery(this).parent().hasClass("current_page_item")){
                jQuery(this).css({background: "none"});
            }
        });
		
		/* animace - postranni menu - vyjizdeni podslozek */
		jQuery("#column li:not(.current_page_item) ul").hide()

		category = '';
		categories = '';

		jQuery("#column ul li:not(.current_page_item)").filter(function(){
			return jQuery(this).children("ul").length > 0
		}).mouseenter(function(){
			category = jQuery(this);
			categories = category.children("ul:first");
			categories.slideDown("slow");
		});
		jQuery("#column").mouseleave(function(){
			jQuery("#column ul li:not(.current_page_item) ul").slideUp("slow");
		});
		
        /* formular napiste nam */
        jQuery("#contact_us_inner").hide();
        var visible_form = false;
        jQuery("#contact_us h3 a").click(function(e){
            e.preventDefault();
            visible_form ? jQuery("#contact_us_inner").slideUp(350) : jQuery("#contact_us_inner").fadeIn(350);
            visible_form = !visible_form;
            return false;
        });
		
		
		var my_wp_lang = '';
		var heading = '';
		var slogan = '';
		/* zjisteni jazyka na prezentaci */
		if((document.location.href).indexOf('/de/') != -1){
			my_wp_lang = 'de';
		}
		if ((document.location.href).indexOf('/en/') != -1){
			my_wp_lang = 'en';
		}
		switch(my_wp_lang){
			case "de":
				heading = "Frage zum Artikel";
				jQuery("#slogan").addClass(my_wp_lang);
				break;
			case "en":
				heading = "Question related to article";
				jQuery("#slogan").addClass(my_wp_lang);
				break;
			default:
				heading = "Dotaz k článku";
				break;
		}
        
		heading += " \"" + jQuery("h1").text() + "\"";
		jQuery("input[name=your-subject]").val(heading);//.attr("readonly", "readonly");
		if(slogan != ''){
			jQuery("#slogan").text(slogan).addClass(my_wp_lang);
		}
		
        jQuery("#contact_us input:submit").addClass("btn_submit");
		
		/* pruhovani tabulek */
		jQuery(".tabulka tr:odd, .tabulka-2 tr:odd").addClass("odd");
		
		/* nacteni google mapy */
		options = 
		{ markers: [{ latitude: 49.2528,
						  longitude: 17.2110,
						  html: "<strong>HANHART Morkovice, s.r.o.</strong><br /><address>Nádražní 453<br />Morkovice – Sližany, 768 33</address><p>GPS: 49°15′10.217″N, 17°12′39.466″E</p>",
						  popup: true
						  }
						/*  html: "_latlng" },
						{ address: "Tettnang, Germany",
						  html: "The place I live" },
						{ address: "Langenargen, Germany",
						  html: "_address" }*/],
			  address: "Morkovice, Czech republic",
			  zoom: 12 
		};
		
		jQuery("#map").gMap(options);
		
		/* uprava inline vlastnosti */
		jQuery("*[vAlign=top]").css({verticalAlign: "top"});
		
		/* zarovnani single obrazku z galerie */
		jQuery("a[rel*=singlepic]").css({float: "right", margin: "0 0 10px 15px"});
		
		
		/* EN + DE fast_nav */
		if(my_wp_lang == 'de' || my_wp_lang == 'en'){
			src_item_id = 0;
			my_wp_lang == 'de' ? src_item_id = 363 : src_item_id = 271
			
			if(src_item_id == 0) { return false; }
			
			var source = jQuery("#column li.page-item-" + src_item_id).children("ul").clone().removeAttr("style");
			var placeholder = jQuery("<div id='flexipages-2'></div>");
			placeholder.append(source);

			jQuery("#column .ngg_images").after(placeholder);
		}
});