<!--
function showWindow(width, height, url, toolbar) {
if (toolbar) {
window.open(url, "", "left=" + ((screen.width - width) / 2) + ",top=" + ((screen.height - height) / 2) + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height);
}
else {
window.open(url, "", "left=" + ((screen.width - width) / 2) + ",top=" + ((screen.height - height) / 2) + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height);
}
}

$.ajaxSetup ({ 
cache: false 
});

 
$(document).ready(function(){

//Ловим скролл

function setpos()
{
	try{
	yy=$(window).scrollTop()+10;
	xx=parseInt(screen.width/2-parseInt($("#chcolor").css("width"))/2, 10);
    $("#chcolor").css("top", yy+"px");   
	$("#chcolor").css("left", xx+"px"); 
	}
	catch(e) {
	}
}

function getmatlist()
{
	
	$("#chcolor").html("");
	$("#chcolor").css("width", "604px"); 
	$("#chcolor").css("visibility", "visible");
	setpos();
	
	$.getJSON(pth+"icms/listmat.php",
        function(json){
		for(n in json.mat.names)
			{
			$('#chcolor').append('<img id="pc'+json.mat.ids[n]+'" src="'+json.mat.names[n]+'" class="chimg">');		
			}
		$('#chcolor').append('<br><div style="width:100%;clear:both;"></div><span id="cllist">Закрыть окно</span>');	
		$("#cllist").click(function() {
									$("#chcolor").css("visibility", "hidden");
									});	
		
		$(".chimg").click(function() {
		$("#chcolor").html("");
		id_el=$(this).attr("id").substr(2);
		for(d in json.mat.ids)
			{
			if(json.mat.ids[d]==id_el) num=d;
			}
		$("#chcolor").html('<img id="closech" src="'+pth+'docs/images/de'+id_el+'_b.jpg"><br><span>'+json.mat.titles[num]+'</span>');
			
		$('#chcolor').animate({
			opacity: 1,
			left: '+=140',
			width: '320'
		  }, 500, function() {
			// Animation complete.
		  });	
			
		$("#closech").click(function() {
									
									getmatlist();
									});	
		
		});
		
		});
}

	$(window).scroll(function () { 
	setpos()
	 });

	$(".gcolor").click(function() {
	
	
	getmatlist();
	
	});

});
//-->
