// JavaScript Document
/*
var timeout = 0;
var timeoutSubChild = 0;
var $menu_el = null;
var $child_menu_el = null;

$(document).ready(function(){
	$(".childMenuItem").hover(
		function () {
			clearTimeout(timeout);
			timeout = 0;
			
			$child_menu_el = $(this).children('ul').css({"display":"block"}); 
		},
		function () {
			if (timeout == 0) {
				timeout = setTimeout(function () {
					$menu_el.css({"display":"none"}); 
				},1000);
			}
			
			$(".childMenuLevel3").hide();
			$(this).children('ul').css({"display":"none"}); 
			$child_menu_el = null;
		}
	);
	$(".childMenuLevel3").mouseout(function(){
		$(this).css({"display":"none"})
	});
	$(".childMenuLevel3").mouseover(function(){
		$(this).css({"display":"block"});
	});
});

function showChildMenu(id) {
	if ($menu_el != null) {
		$menu_el.hide();
	}
	clearTimeout(timeout);
	timeout = 0;
	$menu_el = null;
	$menu_el = $("#"+id).css({"display":"block"}); 
}

function hideChildMenu(id) {
	if (timeout == 0) {
		timeout = setTimeout(function () {
			$("#"+id).css({"display":"none"}); 
		},1000);
	}
}
*/

$(function () {
	var timeout = null;
	
	$(".menuItemContent").hover(
		function() {
			clearTimeout(timeout);
			if($(this).has("ul")) {
				if ($(".childMenuBlock").is(":visible")) {
					$(".childMenuBlock").hide();
				}
				$(this).children("ul")
					   .show()
					   .find("li")
					   .hover(
						   function (e) {
						   		if($(this).has("ul")) {
						   			$(this).children("ul").show();
						   		}
						   },
						   function (e) {
						   		if($(this).has("ul")) {
						   			$(this).children("ul").hide();
						   		}
						   }
						);
			}
		},
		function (e) {
			var $obj = $(this);
			timeout = setTimeout(function () {
				$obj.children("ul").hide();
			}, 1000);
		}
	);	
	
	$("#language_select").change(function () { 
		$.getJSON($(this).attr("url") + "index.php?component=index&action=changeLanguage&language=" + $(this).val(), function(msg) {
			
			if(msg != null && msg.refresh_url != null) {
				window.location.href = msg.refresh_url.value;
			}				 
		}); 
	});
	
	
	$("#exa_show_fulltext").click(function () {
		$("#introtext").hide();
		$("#fulltext").show();		
	});
	
	$("#exa_hide_fulltext").click(function () {
		$("#fulltext").hide();
		$("#introtext").show();
				
	});
	
	$("#show_all_exa_articles").click(function () {
		$("#exa_10_articles").hide();
		$("#exa_all_articles").show();
	});
	
	$("#hide_all_exa_articles").click(function () {
		$("#exa_10_articles").show();
		$("#exa_all_articles").hide();
	});
	
	
});
