$(document).ready(function(){
	$(".navlev1>div:first-child, .navlev1-current>div:first-child, .navlev1-selected>div:first-child, .navlev2>div:first-child, .navlev2-current>div:first-child, .navlev2-selected>div:first-child, .navlev3>div:first-child, .navlev3-current>div:first-child, .navlev3-selected>div:first-child, .navlev4>div:first-child, .navlev4-current>div:first-child").hover(
		function () {	
			$(this).find("span:first").css("visibility", "visible");
			$(this).find("span:last").css("visibility", "visible");
		}, 
		function () {
			$(this).find("span:first").css("visibility", "hidden");
			$(this).find("span:last").css("visibility", "hidden");
		}
	);
	
	
	
	$(".viewer .editdel a:first-child").click(
		function() {
			var dateobject=$(this).parent().parent().parent();
			dateobject.find(".viewer").hide();
			dateobject.find(".editor").show();
			
			var textobject=dateobject.next();
			textobject.find(".viewer").hide();
			textobject.find(".editor").show();
		}
	);		
	
	$(".editor input:button").click(
		function() {
			var dateobject=$(this).parent().parent().parent();
			dateobject.find(".viewer").show();
			dateobject.find(".editor").hide();
			
			var textobject=dateobject.next();
			textobject.find(".viewer").show();
			textobject.find(".editor").hide();
		}
	);
	
	
/*-Счетчики-*/
	$("#counters .element .viewer div:first-child a").click(
		function() {
			var obj=$(this).parent().parent().parent();
			obj.find(".viewer").hide();
			obj.find(".editor").show();
		}
	);
	$("#counters .element .editor input:button").click(
		function() {
			var obj=$(this).parent().parent().parent();
			obj.find(".viewer").show();
			obj.find(".editor").hide();
		}
	);	
	
	/*-добавить-*/
	$("#counters .addblock input:submit").attr("disabled", "disabled")
	
	$("#counters .addblock textarea").focus(
		function() {
			if($(this).val()=="Добавить новый") {
				$(this).val("");
				$("#counters .addblock input:submit").removeAttr("disabled")
			}
		}
	);
	
	
	/*-Превьюшки для продуктов-*/
	$(".preView a").click(
		function() {
			
			var newimgfull=$(this).find("img").attr("src");
			var temp = new Array();
			temp=newimgfull.split("/");
			newimgname=temp[4]
			//alert(temp[4]);
			$(".fullView").find("img").attr("src", "/uploads/productimgs/"+newimgname);
		}
	);
	
	/* Filter */	
	
	$(".filtertextblock").keyup(
		function(){
			var filterblock=$(this);
			
			filterblock.parent("div").children("div[class*='navlev']").children("div").filter(
				function(index){
					$(this).hide();
					
					var str=$(this).find("a").text().toLowerCase();
					return str.search(filterblock.val().toLowerCase()) != -1;
				}
			)
			.show();
		}
	)
});






function delconf() {
	if(confirm('Удалить раздел?')) return true;
	else return false;
}

function delnewsconf() {
	if(confirm('Удалить?')) return true;
	else return false;
}
function delcountconf() {
	if(confirm('Удалить счетчик?')) return true;
	else return false;
}
