//==========================| FIX PNG |==========================//
function fixPNG(element) {
	  
	  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	  {
		var src;
		
		if (element.tagName=='IMG') 
		{
		  if (/\.png$/.test(element.src)) 
		  {
			src = element.src;
			element.src = "images/blank.gif"; 
		  }
		}
		else 
		{
		 
		  src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
		  if (src)
		  {
			src = src[1]; 
			element.runtimeStyle.backgroundImage="none"; 
		  }
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	  }
	}
//==========================| END FIX PNG |==========================//	

//==========================| RIGHT MENU |==========================//
$(document).ready(function() {
	$('ul#my-menu ul').each(function(i) { // Check each submenu:
		if ($.cookie('submenuMark-' + i)) {  // If index of submenu is marked in cookies:
			$(this).show().prev().removeClass('collapsed').addClass('expanded'); // Show it (add apropriate classes)
		}else {
			$(this).hide().prev().removeClass('expanded').addClass('collapsed'); // Hide it
		}
		$(this).prev().addClass('collapsible').click(function() { // Attach an event listener
			var this_i = $('ul#my-menu ul').index($(this).next()); // The index of the submenu of the clicked link
			if ($(this).next().css('display') == 'none') {
				$(this).next().slideDown(200, function () { // Show submenu:
					$(this).prev().removeClass('collapsed').addClass('expanded');
					cookieSet(this_i);
				});
			}else {
				$(this).next().slideUp(200, function () { // Hide submenu:
					$(this).prev().removeClass('expanded').addClass('collapsed');
					cookieDel(this_i);
					$(this).find('ul').each(function() {
						$(this).hide(0, cookieDel($('ul#my-menu ul').index($(this)))).prev().removeClass('expanded').addClass('collapsed');
					});
				});
			}
		return false; // Prohibit the browser to follow the link address
		});
	});
});
function cookieSet(index) {
	$.cookie('submenuMark-' + index, 'opened', {expires: null, path: '/'}); // Set mark to cookie (submenu is shown):
}
function cookieDel(index) {
	$.cookie('submenuMark-' + index, null, {expires: null, path: '/'}); // Delete mark from cookie (submenu is hidden):
}
//==========================| END RIGHT MENU |==========================//

//==========================| TOP MENU |==========================//
$(document).ready(function(){
	$('#top_menu ul li').css( {backgroundPosition:"0 19px"} );
	$('#top_menu ul li').mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300});
		//$('#top_menu ul li a').stop().animate({height:"7px"}, {duration:300})
	});
	$('#top_menu ul li').mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(0 19px)"}, {duration:300, complete:function(){
			$(this).css({backgroundPosition:"0 19px"});
		}});
	});

	$('#top_menu ul li').mouseover(function(){
		$(this).find('a').stop().animate({paddingTop: "1px"}, {duration:300});
	});
	$('#top_menu ul li').mouseout(function(){
		$(this).find('a').stop().animate({paddingTop: "7px"});
	});
//==========================|  |==========================//	
	/*$("ul#my-menu li").click(function()
    {
		$(this).next("ul#my-menu li ul").slideToggle(300).siblings("ul").slideUp("slow");
       	$(this).siblings();
		return false;
	});*/
//==========================|  |==========================//	
});
//==========================| END TOP MENU |==========================//

$(function(){
	$('#right_menu ul li ul li a')
		.css( {backgroundPosition:"0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-220px 0)"}, {duration:300})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300, complete:function(){
				$(this).css({backgroundPosition:"0 0"})
			}})
		})
});
