$(document).ready(function(){
	
	
	if(navigator.userAgent.indexOf("IE")==-1){	 
		HTMLElement.prototype.contains = function(node)
		{
			if (node == null)
			{
				return false;
			}
			else if (node == this)
			{
				return true;
			}		
			return this.contains(node.parentNode);
		}		
	}

	$(".menu").mouseout(function(e){
		
		if($.browser.msie){
		
			if (!this.contains(e.relatedTarget || e.toElement)) {
				$(this).children(".submenu").fadeOut(150);
				$(".submenu > div").css("display","none");
				$(this).children(".m01").css("background","url('tpl/gfx/m01.gif') no-repeat");
				$(this).children(".m02").css("background","url('tpl/gfx/m02.gif') no-repeat");
			}
		
		}else{
		
			if (!this.contains(e.relatedTarget || e.toElement)) {
				$(this).children(".submenu").fadeOut(150);
				$(".submenu > div").css("display","none");
				$(this).children(".m01").css("background","url('tpl/gfx/m01.gif') no-repeat");
				$(this).children(".m02").css("background","url('tpl/gfx/m02.gif') no-repeat");
			}
		
		}
		
		
	});	

	$(".menu").mouseover(function(e){
		
		if($(this).children(".submenu").css("display")!="block"){
	
			e.preventDefault();
			this.blur();
			var method1 = 'easeOutBounce';
			//$(".submenu").stop();
			$(this).children(".submenu").slideDown(150);
			//$(this).children(".submenu").animate({height: 'toggle'},{duration: 500, easing: method1});
			jQuery(this).children(".m01").css("background","url('tpl/gfx/m01h.gif') no-repeat");
			jQuery(this).children(".m02").css("background","url('tpl/gfx/m02h.gif') no-repeat");
		}
	});
	
	$(".submenu > a").mouseover(function(e){		
		
		if ($(this).prev("div").html()!=null) {
			if($(this).prev("div").css("display")!="block"){
				$(".submenu > div").fadeOut(150);
			}			
			$(this).prev("div").animate({width: 'show'},{duration: 250});
		}else{
			$(".submenu > div").fadeOut(150);
		}
		
	});
	
	
	
});
