$(document).ready(function(){
	$('.packet').bind('mouseenter', function() {
	  	showPopup(this);
	});
	$('.packet').bind('mouseleave', function() {
	  	closePopup(this);
	});

	$("ul#topnav li").hover(function() { //Событие наведения на элемент списка
		$("li.menu_sep span").hide();
		$("#sub_menu3").hide();
		
		if($(this).find(".menu_selected").size() == 0){ 
			$(".menu_selected").parent().parent().find("span").stop(false,true).hide();
		} else {
			if( $(".menu_selected").parent().parent().find(".menu3").size() > 0 ){
				$('#sub_menu3').show();//fadeIn('fast');
			}
			
		}

		$(this).find("span").fadeIn('fast'); //Показать подменю
		$(".menu_selected > strong").css({'background-image':'none'}); //

		
		if($(this).find("span").size() > 0 ){
			$(this).find('>a').css({ 'background-image' : 'url(/static/images/submenu_na.gif)','background-repeat': 'no-repeat','background-position': 'center bottom'});  
			$('#sub_menu2').fadeIn('fast');
			if($(this).find(".menu3").size() > 0 ){
				$('#sub_menu3').fadeIn('fast');
				
			}
			
			if($(this).find(".menu_selected").size()>0){
				$(".menu_selected > strong").css({'background-image':'url(/static/images/submenu_active.gif)','background-repeat': 'no-repeat','background-position': 'center bottom'});
				//$(".menu_selected").parent().parent().find("span").fadeIn('fast');
			} else { 
				$(".menu_selected").parent().parent().find("span").hide();
			}
					
		} else {
			// нет подменю
			$('#sub_menu2').fadeOut('fast');
			$('#sub_menu3').fadeOut('fast');
			$(".menu_selected").parent().parent().find("span").fadeOut('fast');
		}
		
	} , function() { //отсутсвие наведения...
		if($(this).find(".menu_selected").size() == 0){
			$(this).find('a').css({ 'background-image' : 'none'}); //Убрать фон
			$(this).find("span").hide(); //Скрыть подменю
			$("#sub_menu3").hide();
		}
	});	
	
	$("ul#topnav").mouseleave(function() { 
		if($(".menu_selected").size() > 0 ){
			if( $(".menu_selected").parent().parent().find("span").size() > 0 ){
				$('#sub_menu2').fadeIn('fast');
				
				if( $(".menu_selected").parent().parent().find(".menu3").size() > 0 ){
					$('#sub_menu3').fadeIn('fast');
				}
				$(".menu_selected > strong").css({'background-image':'url(/static/images/submenu_active.gif)','background-repeat': 'no-repeat','background-position': 'center bottom'});
				$(".menu_selected").parent().parent().find("span").stop(false,true).fadeIn('fast');
			} else {
				$(".menu_selected > strong").css({'background-image':'none'});
				$('#sub_menu2').fadeOut('fast');
				$('#sub_menu3').fadeOut('fast');
			}
		} else {
			$('#sub_menu2').fadeOut('fast');
			$('#sub_menu3').fadeOut('fast');
		}
	})
	$("#sub_menu2").hide();
	$("#sub_menu3").hide();
	
	if($(".menu_selected").size() > 0 ){
		if( $(".menu_selected").parent().parent().find("span").size() > 0 ){
				$('#sub_menu2').show();// fadeIn('fast');
				if( $(".menu_selected").parent().parent().find(".menu3").size() > 0 ){
					$('#sub_menu3').show();//fadeIn('fast');
				}
				$(".menu_selected > strong").css({'background-image':'url(/static/images/submenu_active.gif)','background-repeat': 'no-repeat','background-position': 'center bottom'});
				$(".menu_selected").parent().parent().find("span").show();//fadeIn('fast');
		} else {
			$(".menu_selected > strong").css({'background-image':'none'});
		}
	}
	
	//for ie 6	
	 $("ul#topnav li").hover(function() { //Событие наведения на элемент списка
		$(this).find("li>a").css({'background-repeat': 'no-repeat', 'background-position': 'center bottom'});
	 } , function() { //отсутсвие наведения...
	 });
         if($("ul#topnav li").length == 10){ //rus
	 	 $("ul#topnav li").each(function(index) {
			 if(index == 1) { $(this).css('width','100px');  };
			 if(index == 2) { $(this).css('width','111px');  };
			 if(index == 3) { $(this).css('width','95px');  };
			 if(index == 4) { $(this).css('width','100px');  }; //проекты
			 if(index == 5) { $(this).css('width','103px');  };  // клиенты
			 if(index == 6) { $(this).css('width','125px');  };//технологии
			 if(index == 7) { $(this).css('width','154px');  };
			 if(index == 8) { $(this).css('width','79px');  };
			 if(index == 9) { $(this).css('width','103px');  };
		 });
	} else {
	     	 // en   
	 	 $("ul#topnav li").each(function(index) {
			 if(index == 1) { $(this).css('width','110px');  };
			 if(index == 2) { $(this).css('width','121px');  };
			 if(index == 3) { $(this).css('width','110px');  };
			 if(index == 4) { $(this).css('width','110px');  }; //проекты
			 if(index == 5) { $(this).css('width','113px');  };  // клиенты
			 if(index == 6) { $(this).css('width','140px');  };//технологии
			 if(index == 7) { $(this).css('width','150px');  };
			 if(index == 8) { $(this).css('width','115px');  };
		 });
	}
	  

});
function showPopup(el){
	$(el).addClass('activeProject');
	$(el).find('.popup_packet_hide').fadeIn('fast');
}
function closePopup(el){
	$(el).removeClass('activeProject');
	$(el).find('.popup_packet_hide').fadeOut('fast');
}
function showHideVac(id){
    if($("#vacb_"+id).hasClass('vac_down')){
        $("#vacb_"+id).removeClass('vac_down').addClass('vac_up');
        $("#vac_"+id).show('fast');
    } else {
        $("#vacb_"+id).removeClass('vac_up').addClass('vac_down');
        $("#vac_"+id).hide('fast');
    }
}
