jQuery(function($) {		
	//показ картинок и контуров для вставок	
	$(".set").click(function(){		
		var scrl = $(document).scrollTop();
		$.get(window.location.href + $(this).attr("href"), function(data){		
			var tdata = data.split("][");
			$("#fixed-block-img").html(tdata[0]);
			$("#fixed-block-kontur").css("background", "url("+tdata[1]+") no-repeat bottom center");			
			var fixedBlock = $("#fixed-block");
			if(scrl > 160) fixedBlock.css("top", scrl + 20 + "px");
			fixedBlock.show();
		});
		return false;
	});
	
	
	function kubok_main(width)
	{
		//alert(width);
		var w = $(".kubok_main");
		/*if(width <= 1440)
		{
			w.css("background-image", "url(/bin/img/new/kubok_main.png)");
			w.css("height", "877px");
			w.css("width", "350px");
		}
		else if(width <= 1600)
		{
			w.css("background-image", "url(/bin/img/new/kubok_main1600.png)");
			w.css("height", "1753px");
			w.css("width", "700px");
		}
		else if(width <= 2560 || width > 2560)
		{
			w.css("background-image", "url(/bin/img/new/kubok_main1900.png)");
			w.css("height", "2430px");
			w.css("width", "1000px");
		}*/
	}

	kubok_main($("body").width());
	
	$(".line_cat").mouseover(function(){
		$(this).css("background-image", "url(/bin/img/new/line_cat_hover.jpg)");
	});
	
	$(".line_cat").mouseout(function(){
		$(this).css("background-image", "url(/bin/img/new/line_cat.jpg)");
	});
	
	
	
	
	$(window).resize(function(){
		kubok_main($("body").width());
	});
	
	
	$(".catLink").click(function(){
		var id = $(this).parent().next();
		var cooord = $(this).offset();
		id.css("left", cooord.left);		
		if(id.css("display") == "none") id.show();
		else id.hide();
		
		return false;
	});
	
	$(window).resize(function(){
		$(".catLink").each(function(){
			var id = $(this).parent().next();
			var cooord = $(this).offset();
			id.css("left", cooord.left);	
		});
	});
	
	
})
	



function newW3(path) 
{
	w1 = window.open(path,"wwww","toolbar=0, status=1, width = 390, height = 390, resizable=1, scrollbars=1");
	w1.focus();
}

function newW1() 
{
	w1 = window.open("","wwww","toolbar=0, status=1, width = 700, height = 650, resizable=1, scrollbars=1");
	w1.focus();
}

function newW2() 
{
	w1 = window.open("","wwww","toolbar=0, status=1, width = 600, height = 650, resizable=1, scrollbars=1");
	w1.focus();
}

function cl() 
{ 
	for(var i=1; i<=4; i++) 
	{
		document.getElementById('sub'+i).style.visibility='hidden';
	}
}
function show(num) 
{
	cl();
  	document.getElementById('sub'+num).style.visibility='visible';
} 

/*
function cl() { 
	for(var i=1; i<=4; i++) {
		eval('sub'+i+'.style.visibility="hidden"');
	}
}
function show(num) {
	cl();
  	eval('sub'+num+'.style.visibility="visible"');
} 
*/

function Hide(ttt)
{
	var on = document.getElementById(ttt).style.display;
	if(on == '') {
		document.getElementById(ttt).style.display = 'none';
	} else {
		document.getElementById(ttt).style.display = '';
	}
}

//сперто с яндекса
document.onkeydown = register;
function register(e) 
{
	var nextUrl = document.getElementById("nextUrl");
	var backUrl = document.getElementById("backUrl");

	if (!e) e = window.event;
	var k = e.keyCode;
	
	if (e.ctrlKey) 
	{
		var tagName = (e.target || e.srcElement).tagName;
		if (tagName != 'INPUT' && tagName != 'TEXTAREA') 
		{
			if (k == 37) 
			{
				if(backUrl.value != "") window.location.href = backUrl.value;
			}
			if (k == 39) 
			{
				if(nextUrl.value != "") window.location.href = nextUrl.value;
			}
		}
	}
}
