$(document).ready(function() {	
	$("#block-menu-secondary-links li ul").css("display", "none");
	$("#block-menu-secondary-links li.active-trail ul").css("display", "block");
	
	$("#block-menu-secondary-links a").toggle(function() {
		$(this).parent().children("ul").slideDown();
		if ($(this).parent().parent().parent().parent().attr("class") == "menu" || $(this).parent().children("ul").length == 0) {
			if ($(this).parent().attr("class").indexOf("expanded") == -1) {
				window.location = $(this).attr("href");
			}
			else {
				return false;
			}
		}
	},
	function() {
		$(this).parent().children("ul").slideUp();
	});
	
	$("#navlist li").css( {backgroundPosition: "1px -30px"} );
	$("#navlist li.active").css( {backgroundPosition: "1px 0"} );
	
	$("#navlist li").hover(function() {
		$(this).stop().animate({backgroundPosition:"(1px 0)"}, {duration:500})
		//$(this).css("background-image", "url(/sites/all/themes/eulita/img/bg-menu-active.jpg)");
	},
	function() {
		if ($(this).attr("class").indexOf("active") == -1) {
			$(this).stop().animate({backgroundPosition:"(1px -30px)"}, {duration:500})
		}
	});
	
	$("#edit-search-theme-form-1").click(function() {
		$(this).attr("value", "");
	});
	$("#edit-name").click(function() {
		$(this).attr("value", "");
	});
	$("#edit-pass").click(function() {
		$(this).attr("value", "");
	});
	
	$(".view-FAQ .views-field-body").css("display", "none");
	
	$(".view-FAQ .views-field-title").hover(function() {
		$(this).css("color", "#666666");
	},
	function() {
		$(this).css("color", "#3A76E5");
	});
	
	$(".view-FAQ .views-field-title").toggle(function() {
		$(this).next().slideDown();
	},
	function() {
		$(this).next().slideUp();
	});
	
	$("#block-menu-secondary-links li li ul").css("display", "none");
	$("#block-menu-secondary-links li li.active-trail ul").css("display", "block");
	
	/* TOP NAV */
	$("#block-menu-menu-tools").hide();
	$("#block-locale-0").hide();
	
	// REMOVE WHEN OUT
	$("#navlist li").bind("mouseenter", function(){
		$(".menu-1449, .menu-1450, .menu-1451, .menu-1452").css("background-color", "transparent");
		$(".menu-1449, .menu-1450, .menu-1451, .menu-1452").find("a").css("color", "#3A76E5");
		$(".menu-1453, .menu-1454, .menu-1455, .menu-1456").css("background-color", "transparent");
		$(".menu-1453, .menu-1454, .menu-1455, .menu-1456").find("a").css("color", "#3A76E5");
		$("#block-menu-menu-tools").hide();
		$("#block-locale-0").hide();
		return false;
	});
	
	// TOOLS
	$(".menu-1449, .menu-1450, .menu-1451, .menu-1452").bind("mouseenter", function(){
		$(this).css("background-color", "#fff");
		$(this).find("a").css("color", "#666");
		$("#block-menu-menu-tools").show();
		return false;
	});
	
	$("#block-menu-menu-tools").bind("mouseleave", function(){
		$(".menu-1449, .menu-1450, .menu-1451, .menu-1452").css("background-color", "transparent");
		$(".menu-1449, .menu-1450, .menu-1451, .menu-1452").find("a").css("color", "#3A76E5");
		$("#block-menu-menu-tools").hide();
		return false;
	});
	
	$(".menu-1449, .menu-1450, .menu-1451, .menu-1452").click( function(){
		return false;
	});

	// LANGUAGE
	$(".menu-1453, .menu-1454, .menu-1455, .menu-1456").bind("mouseenter", function(){
		$(this).css("background-color", "#fff");
		$(this).find("a").css("color", "#666");
		$("#block-locale-0").show();
		return false;
	});
	
	$("#block-locale-0").bind("mouseleave", function(){
		$(".menu-1453, .menu-1454, .menu-1455, .menu-1456").css("background-color", "transparent");
		$(".menu-1453, .menu-1454, .menu-1455, .menu-1456").find("a").css("color", "#3A76E5");
		$("#block-locale-0").hide();
		return false;
	});
	
	$(".menu-1453, .menu-1454, .menu-1455, .menu-1456").click( function(){
		return false;
	});
	

});

/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);