$(document).ready(
	function(){
		$.preloadImages = function() {
			$.each (arguments,function (e) {
			$("<img>").attr("src", this);
			});
		}
		var syf = "/templates/mainpage/images/";
		$.preloadImages(syf+"m-t-1-on.jpg", syf+"m-t-2-on.jpg", syf+"m-t-3-on.jpg", syf+"m-t-4-on.jpg", syf+"m-t-5-on.jpg", syf+"m-t-6-on.jpg", syf+"m-t-7-on.jpg");
		$(".menu-r").find("a").each(function(){
			var c_path =document.location.pathname;
			var c_path_sub = c_path.search("/page/");
			if (c_path_sub!=-1){
				c_path= c_path.substr(0,c_path_sub);
				var l_path = $(this).attr("href");
				l_path = l_path.replace(".html","");
				//alert(l_path);
				if (c_path == l_path){
					
					$(this).addClass("active_aa");
					$(this).parents(".menu-r").attr("id", "ns").addClass("open_hide");
					$(this).parents(".menu-rr").addClass("open_hide");
					$(".open_hide").children("a").addClass("active_a");
				}
			}
			if ($(this).attr("href") == document.location.pathname){
				$(this).addClass("active_aa");
				$(this).parents(".menu-r").attr("id", "ns").addClass("open_hide");
				$(this).parents(".menu-rr").addClass("open_hide"); 
				$(".open_hide").children("a").addClass("active_a");
			}
		});
		//$(".active_aa").parent().addClass("open_hide");
		$("#menu-r div a").click(function(){
			if ($(this).parent().children("div").length>0){
				$("#menu-r div").stop(true, true);
				if ($(this).parents(".menu-r").attr("id")=="ns"){
					$(this).parent().children("div").toggle("slide");
				}else{
					$("#menu-r .menu-r div").slideUp();
					$("#menu-r #ns").attr("id", "opcl");
					$(this).parent().children("div").slideDown();
					$(this).parents(".menu-r").attr("id","ns");
				}
				if ($(this).attr("href") == document.location.pathname)
					$(this).toggleClass("active_a");
				return false;
			}
		});
		$(".jq_form input:text").each(function(){
			if ($(this).attr("value")!="")
				$(this).attr("title", $(this).attr("value"));
		});
		
		$(".jq_form input:text").bind("focus", function(){
			if ($(this).attr("value")==$(this).attr("title"))
				$(this).attr("value", "");
		});
		$(".jq_form input:text").bind("blur", function(){
			if ($(this).attr("value")=="" && $(this).attr("title")!="")
				$(this).attr("value", $(this).attr("title"));
		});

		$(".jq_form .button").click(function(){
			$(this).parent().children("input:text").each(function(){
				if ($(this).attr("title")!="" && $(this).attr("value")==$(this).attr("title"))
					$(this).attr("value","");
			});
			$(this).parent().submit(); 
		});
		$(".content").find("a").each(function(){
			if ($(this).attr("title")=="zoom"){
				$(this).attr("rel","prettyPhoto");
			}
		});
	}
);
