function gallery(category_id, id, offset, top_anons)
{
	new Ajax.Request('/ajax.php',
			{method: 'post',
			parameters:'action=gallery&C='+category_id+'&block_id=' + id+'&offset='+offset+"&top_anons="+top_anons,
			onSuccess:function(req)
			{
				var i;
				if($('gallery'+id))
				{
					i = $('gallery'+id);
					i.innerHTML = req.responseText;
					Lightbox.initialize();
				}
				
		  	}, 
			onFailure:function()
			{
				alert('Ошибка: ' + t.status + ' -- ' + t.statusText);
		}}); 
}



function mark_region(map_id, image)
{
	$(map_id).src=image;
}

var timer = '';

function redraw_door(obj)
{
	clearTimeout(timer);
	if (obj.checked)
		$(obj.name).value=obj.value;
	else
		$(obj.name).value = 0;
		
	if (obj.name == 'glass')
	{
		var a = 'vitr' + $('vitr').value;  
		if ($(a) && ($(a) != undefined))
			$(a).checked=false;
		$('vitr').value=0;
	}
	if (obj.name == 'vitr')
	{
		var a = 'glass' + $('glass').value;
		if ($(a) && ($(a) != undefined))
			$(a).checked=false;
		$('glass').value=0;
	}
	
	var c = $('color').value;
	if (!c || (c == undefined))
		c = 0;
		
	var g = $('glass').value;
	if (!g || (g == undefined))
		g = 0;
		
	var v = $('vitr').value;
	if (!v || (v == undefined))
		v = 0;
		
	var f = $('furniture').value;
	if (!f || (f == undefined))
		f = 0;
		
	ajax_door(c, g, v, f, $('product_id').value, 0);
	
}



function redraw_door2(objid)
{
	clearTimeout(timer);
	
	var obj = $(objid);
	//alert(obj.checked);
	
	if (obj.checked==true)
	{
		obj.checked = false;
	//	alert('bil true');
	}
	else
	{
		obj.checked = true;
		//alert('bil false');
	}
	if (obj.checked)
		$(obj.name).value=obj.value;
	else
		$(obj.name).value=0;
	
	//alert(obj.name + 'checked = ' + obj.checked);
	
	if ((obj.name == 'glass') && (obj.checked == true))
	{
		var a = 'vitr' + $('vitr').value;  
		if ($(a) && ($(a) != undefined))
			$(a).checked=false;
		$('vitr').value=0;
	}
	if ((obj.name == 'vitr') && (obj.checked == true))
	{
		var a = 'glass' + $('glass').value;
		if ($(a) && ($(a) != undefined))
			$(a).checked=false;
		$('glass').value=0;
	}
	
	var c = $('color').value;
	if (!c || (c == undefined))
		c = 0;
		
	var g = $('glass').value;
	if (!g || (g == undefined))
		g = 0;
		
	var v = $('vitr').value;
	if (!v || (v == undefined))
		v = 0;
		
	var f = $('furniture').value;
	if (!f || (f == undefined))
		f = 0;
		
	ajax_door(c, g, v, f, $('product_id').value, 0);
	
}

function ajax_door(c, g, v, f, product_id, prio)
{
	if (prio)
		var str = "&prio=" + prio;
	else 
		var str = "";
		
	new Ajax.Request('/ajax.php',
		{method: 'post',
		parameters:'action=door&color='+c+'&glass='+g+'&vitr='+v+"&furniture="+f+"&product_id="+product_id+str,
		onSuccess:function(req)
			{
				var i;
				if($('door_info_place'))
				{
					i = $('door_info_place');
					i.innerHTML = req.responseText;
					
					
					var a = $('compl_prio');
					
					if (a && (a!=undefined))
					{
						var val = a.value;
						
						timer = setTimeout("if ($('compl_prio') && ($('compl_prio')!=undefined)){"+"ajax_door("+c+", "+g+", "+v+", "+f+", "+product_id+", $('compl_prio').value);"+"}", 3000);
						 
					}
					
									
				}
				
		  	}, 
			onFailure:function()
			{
				alert('Ошибка: ' + t.status + ' -- ' + t.statusText);
		}}); 

}

function onm(obj)
{
	obj.className='white_bordered_nb2 menu_table whbg';
}
function offm(obj)
{
	obj.className='white_bordered_b2 menu_table whbg';
}


function start_gal(tid)
{
 
	jQuery(function() {
	    jQuery(".gal_class"+tid).jCarouselLite({
	      btnNext: ".nnext"+tid,
     	   btnPrev: ".pprev"+tid,
      	visible: 5,
        	hoverPause: true,
        	auto:1000
	    });
	});

	

}

