// JavaScript Document

function cur()
{

        $rel = $('#cur').attr('rel');

        $('.fb').hide();
        $('#fb'+$rel).show();
        
	$("#cur").addClass("on");
	tmp = $("#hid_div").val();
        
	$("#div_"+tmp).hide();
	$("#link_"+tmp).removeClass("on");
	$("#hide_content").show();
	tmp = $("#hid_div").val('');
}

function show_text_div(id)
{

    
        $rel = $('#link_'+id).attr('rel');
        $('.fb').hide();
        $('#fb'+$rel).show();

	tmp = $("#hid_div").val();
	
	if(tmp == id)
	{
		$("#link_"+id).removeClass("on");
		$("#div_"+id).hide();
		$("#hid_div").val('');
	}else{
		$("#cur").removeClass("on");
		$("#link_"+id).addClass("off on");
		$("#link_"+tmp).removeClass("on");
		$("#div_"+tmp).hide();
		$("#div_"+id).show();
		$("#hid_div").val(id);
		$("#hide_content").hide();
	}
}

if (window.addEventListener)
{
  window.addEventListener("resize", width, false);
  window.addEventListener("load", width, false);
} else if (window.attachEvent) { // fucking IE
  window.attachEvent("onresize", width);
  window.attachEvent("onload", width);
}


function obpage(page, type)
{
	$.ajax({
		url: "/application/views/vyatskidom/files/catalog/catalogsystem/ajax.php",
		type: "POST",
		dataType: "html",
		data: "page="+page+"&type="+type,
		beforeSend: function (){
			$("#page_"+type+"_"+page).remove();
			$("#divpage_"+type+"_"+page).html("<strong id='page_"+type+"_"+page+"'>"+page+"</strong>");
			tmp = $("#"+type+"_tmp").val();
			$("#"+type+"_tmp").val(page)
			$("#page_"+type+"_"+tmp).remove();
			$("#divpage_"+type+"_"+tmp).html("<a href='' onclick=\"obpage('"+tmp+"', '"+type+"'); return false;\" id='page_"+type+"_"+tmp+"'>"+tmp+"</a>");	
			
			$("#"+type+"_span_list").fadeOut("fast", 
				function()
				{
					$("#"+type+"_stat").show();
				}
			);
		},
		complete: function (){
		},
		success: function(msg){
			$("#"+type+"_stat").hide();
			$("#"+type+"_span_list").html(msg);
			$("#"+type+"_span_list").fadeIn("fast");
		},
		error: function(){
		}
	});	
	
	
}

function width()
{
	var width = document.body.clientWidth;
	if(width>999)
	{
	var left=(1680-width)/2;
	document.getElementById("head_bg").style.left=-left+"px";	
	}
	else if(width>1679)
	{
	var left=(width-1680)/2;
	document.getElementById("head_bg").style.left=left+"px";	
	}
	else
	document.getElementById("head_bg").style.left=-340+"px";
	var height=parseInt(document.getElementById('wrapper_int').offsetHeight);     
	document.getElementById('head_bg').style.height=height+"px";
	
}
function piclineright(type)
{
	iTOTAL = $("#itotal").val();
	iTOTALperPage = $("#iperpage").val();
	if(type=='next')
	{
		showID = $("#next").val();
		if(showID == iTOTAL)
			$("#nextS").hide();
			
		hideID = showID-iTOTALperPage;
		if(hideID == 1)
			$("#backS").show();
		$("#"+hideID).hide("fast");
		$("#"+showID).show("fast");
		$("#next").val(++ showID);
	}else if(type == 'back'){
		if(showID != iTOTAL)
			$("#nextS").show();
		nextID = $("#next").val();
		hideID = -- nextID;
		showID = hideID - iTOTALperPage;
		if(showID == 1)
			$("#backS").hide();
		$("#next").val(hideID);
		$("#"+hideID).hide("fast");
		$("#"+showID).show("fast");
	}
}








function piclineright_35(type)
{
	iTOTAL = $(".itotal").val();
	iTOTALperPage = $("#iperpage").val();
	if(type=='next')
	{
		showID = $(".next").val();
		if(showID == iTOTAL)
			$(".nextS").hide();

		hideID = showID-iTOTALperPage;
		if(hideID == 1)
			$(".backS").show();
		$("."+hideID).hide("fast");
		$("."+showID).show("fast");
		$(".next").val(++ showID);
	}else if(type == 'back'){
		if(showID != iTOTAL)
			$(".nextS").show();
		nextID = $(".next").val();
		hideID = -- nextID;
		showID = hideID - iTOTALperPage;
		if(showID == 1)
			$(".backS").hide();
		$(".next").val(hideID);
		$("."+hideID).hide("fast");
		$("."+showID).show("fast");
	}
}









function showpic(id, file)
{
	$("#pic").hide(1, 
		function()
		{
			$("#bigPicture").attr("src", file);
		}
	);
	$("#preloader").fadeIn("fast");
	$("#bigPicture").load(
		function()
		{
			//alert("test");
			$("#preloader").hide();
			$("#pic").fadeIn("slow");
		}
	);
	//$("#pic").fadeIn("slow");
	tmp = $("#tmpa").val();
	$("#pic"+tmp).removeClass("as");
	$("#pic"+id).addClass("as");
	$("#tmpa").val(id);
}


function showpic_37(id, file)
{
	$(".pic").hide(1,
		function()
		{
			$(".bigPicture").attr("src", file);
		}
	);
	$(".preloader").fadeIn("fast");
	$(".bigPicture").load(
		function()
		{
			//alert("test");
			$(".preloader").hide();
			$(".pic").fadeIn("slow");
		}
	);
	//$("#pic").fadeIn("slow");
	tmp = $(".tmpa").val();
	$(".pic"+tmp).removeClass("as");
	$(".pic"+id).addClass("as");
	$(".tmpa").val(id);
}


function showbigpic(img,verybig)
{
//	alert(verybig);
	$("#picbig").hide(1, 
		function()
		{
			$("#bigPicture").attr("src", "/application/views/vyatskidom/files/catalog/"+img);
			if (verybig!='NULL') {
				$("#verybigpic").attr("href", "/application/views/vyatskidom/files/catalog/"+verybig);	
			} else {
				$("#verybigpic").attr("href", "");
			}
			
			//$("#preloader").fadeIn("fast");
		}
	);
	$("#preloader").fadeIn("fast");
	$("#bigPicture").load(
		function()
		{
			$("#preloader").hide();
			$("#picbig").fadeIn("slow");
		}
	);
	//$("#picbig").fadeIn("slow");
}

function showverybigpic() {
	$hrefval=$("#verybigpic").attr("href");
//	alert($hrefval);
	if ($hrefval) {
		return true;
	} else {
		return false;
	}
//	$(document).ready(function() {
//		$("#verybigpic").click(function(){
//			alert();
//		})
//	})

}

function counter()
{
	counter = "<a href='http://www.liveinternet.ru/click' "+ 
				"target=_blank><img src='http://counter.yadro.ru/hit?t25.1;r"+ 
				escape(document.referrer)+((typeof(screen)=="undefined")?"": 
				";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth? 
				screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+ 
				";"+Math.random()+ 
				"' alt='' title='LiveInternet: показано число посетителей за сегодня' "+ 
				"border=0 width=88 height=15></a>";					
	document.getElementById('cc').innerHTML = counter;
}