var $jjj = jQuery.noConflict();
$jjj(document).ready(function(){
	//var obj;
	var flag = 0;
	var start = new Date();
	var end = new Date();
	var pause = 800; //задержка
	function ff() {
		//alert(start+" "+flag);
		ok = 0;
		if (start != 0) {
			var end = new Date();
			time = (end.getTime() - start.getTime());
			if (time >= pause)
				ok = 1;
			else
				ok = 0;
		}
		else
			ok = 0;
		if (flag) {
			if (ok == 1) {
				start = 0;
				flag = 0;
				$jjj(obj).children("ul").show();
			}
		}
	}
	$jjj("#menu_new li.top_link ul, li.top_link ul li, #menu_new li.top_link ul li ul").hover( function(){
		$jjj(this).children("ul").show();
	},
	function(){
		$jjj(this).children("ul").hide();
	});
	$jjj("li.top_link").hover( function(){
		//$jjj(this).children("ul").show();
		//$jjj(this).children("ul").show();
		obj = $jjj(this);
		start = new Date();
		flag = 1;
		setTimeout(ff, pause);
	},
	function(){
		//$jjj(this).children("ul").hide();
		/*start = 0;
		flag = 0;*/
		start = 0;
		flag = 0;
		$jjj(this).children("ul").hide();
	});
	$jjj("li.top_link").hover( function(){
		var temp = $jjj(this).find(".img_top").attr("src");
		re = /menu\/([0-9]*).gif/;
		if (re.exec(temp) != null) {
			$jjj(this).find(".img_top").attr({src:"menu/"+re.exec(temp)[1] + "a.gif"});
		}
		
	},function(){
		var temp = $jjj(this).find(".img_top").attr("src");
		re = /menu\/([0-9]*)(\S*).gif/;
		if (re.exec(temp) != null) {
			if ($jjj(this).find(".img_top").attr('rel') != 'active')
				$jjj(this).find(".img_top").attr({src:"menu/"+re.exec(temp)[1] + ".gif"});
		}
		
	});
	$jjj("#menu_new li.top_link ul li").hover( function(){
		$jjj(this).addClass("on");
	},
	function(){
		$jjj(this).removeClass("on");
	});
	$jjj("li.top_link a, li.top_link ul li a, li.top_link ul li ul li a").click(function(){
		a = $jjj(this).attr('href');
		if (a == undefined)
			return false;
	});
	$jjj("li.top_link ul li, li.top_link ul li ul li").click(function(){
		a = $jjj(this).children("a").attr('href');
		if (a != undefined)
			location.href = a;
	});
});