var or = ol = 0;
$(document).ready(function(){
	resetMenu();
	$("#menuMain a").each(function(index){
		$(this).bind("mouseenter",function(){
			resetMenu();
			if(index == 0){
				ol = 5;
				or = 0;
				move('417');
			} else if(index == 1){
				ol = 3;
				or = -18;
				move('362');
			} else if(index == 2){
				ol = 25;
				or = -35;
				move('287');
			} else if(index == 3){
				ol = 27;
				or = -53;
				move('167');
			} else if(index == 4){
				ol = 0;
				or = -71;
				move('57');
			} else if(index == 5){
				ol = 5;
				or = -88;
				move('-25');
			}
			$(this).children("span").css("background-position",(-223+ol)+"px "+or+"px");
		})
	});
	$("#menu").bind("mouseleave",function(index){
		$("#menu .current").mouseenter();
	});
	$("#menu .current").mouseenter();
	
	$("#subMenuMain").bind("mouseleave",function(index){
		$("#subMenu .current").mouseenter();
	});
	$("#subMenu .current").mouseenter();
});
function resetMenu(){
	$("#menuMain a").each(function(index){
		if(index == 0){
			or = 0;
		} else if(index == 1){
			or = -18;
		} else if(index == 2){
			or = -35;
		} else if(index == 3){
			or = -53;
		} else if(index == 4){
			or = -71;
		} else if(index == 5){
			or = -88;
		}
		$(this).children("span").css("background-position","0px "+or+"px");
	});
}
function move(rig){
	rig = parseInt(rig);
	var type = parseInt($("#menuType").val());
	if(type == 1){
		rig += 55;
	}
	$("#lightMenu").animate({right: rig+'px'}, 100);
}

function move1(lef){
	$("#lightSubmenu").animate({left: lef+'px'}, 100);
}
function move2(lef){
	$("#lightBswitch").animate({left: lef+'px'}, 100);
}
