function show_image(file_name) {
	window.scrollTo(0,0);
	var img = document.getElementById("big_image");
	var holder = document.getElementById("big_image_holder1");
	var text = document.getElementById("big_image_text");

	holder.className = "loading";

	holder.style.visibility = "visible";
	img.setAttribute("src", "/pictures/empty.gif");
	img.setAttribute("src", "/images/"+file_name);
				
	//text.innerHTML=out_text[name];
}

function hide_pic() {
	var holder = document.getElementById("big_image_holder1");
	holder.style.visibility = "hidden";

}



$(document).ready(function() {		
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask, .window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
});


function addToCart(id) {
	var qty = parseInt($("#buy_"+id).val());
	if (qty>0)
	{
	
	var m=Math.random();
	
	var req = new JsHttpRequest();

	req.onreadystatechange = function() {
		if (req.readyState == 4) {			
			
			var maskHeight = $(document).height();
			var maskWidth = $(window).width();
			$('#mask').css({'width':maskWidth,'height':maskHeight});
		
			$('#mask').fadeIn(1000);	
			$('#mask').fadeTo("slow",0.8);	
	
			var winH = $(window).height();
			var winW = $(window).width();
              
			$("#dialog").css('top',  winH/2-$("#dialog").height()/2);
			$("#dialog").css('left', winW/2-$("#dialog").width()/2);
	
			$("#dialog").fadeIn(2000); 


			if (req.responseJS) {
				$("#items_qty").html(req.responseJS.str_qty||'');
				$("#items_price").html((req.responseJS.str_price+' руб.')||'');
				$("#basket_mess").html('Товар &quot;'+(req.responseJS.str_name||'')+'&quot; добавлен в корзину!');
			}
			$('#debug').html(req.responseText);
		}
	}

	req.caching = false;
	req.loader = '';
	
	method='GET';
	req.open(method, '/send.php', true);

	var data = { 
	    'do': 'addToCart',
		'id': id,
		'qty': qty,
		'rnd': m
	};

	req.send(data);

	} else {
		alert('Укажите количество товара.');
	}
}



