﻿$(document).ready(function() {
	
	if ($("#s").val()=="Поиск") {
		$("#s").addClass('search_free');
	}


	$("#s").focus(function(){
		if ($(this).val()=="Поиск") {
			$(this).val('').removeClass('search_free');
		}
	})
	.blur(function(){
		if ($(this).val()=="") {
			$(this).val('Поиск').addClass('search_free');;
		}
	});
	;
	
	// Menus Java fix (explode submenu)
	$(".sub-menu").each(function(){
		var showSubMenu = false;
		$("li", this).each(function() {
			if ($(this).hasClass('current-menu-item') || $(this).hasClass("current-post-parent")) {
				showSubMenu = true;
			}
		});
		if (!$(this).parent().hasClass("current-menu-item") && !showSubMenu) {
			$(this).hide();
			// show on mouseover and hide on mouseout

				//.bind('mouseleave', function(){$("ul",this).hide(300);});
		}
		
		$(this).parent().find("a:first")
			//.bind('mouseenter', function(){$("ul",this).show(150);})
			.bind('click', function(){
				if ($("ul",$(this).parent()).css("display")=="none") {
					$("ul",$(this).parent()).show(150);
				} else if (!showSubMenu) {
					$("ul",$(this).parent()).hide(300);
				}
				return false;
			});
	});
});

