		function getTumbs(aTumbs){

			if(aTumbs.length == 1)
				return $('\<div style="position: absolute; display: none;"\>\<\/div\>');
		
			tumbsDiv = '<span style="z-index: 10; margin: 3px 0 0 -10px; padding: 3px 0 0 5px; position: absolute; opacity: 0; background-color: #BCCFEE; border: 1px solid #8EAEDE;">\n';
			
			if(aTumbs.length > 5)
				delimiter = 3;
			else
				delimiter = 2;
			
			tumbsDiv += '<table border="0" style="margin: 3px 5px 3px 0"><tr>';
			for(i=1; i<aTumbs.length; i++){
				if(aTumbs[i] != '')
					tumbsDiv += '<td><img src="' + aTumbs[i] + '" style="height: 85px; border: 0; padding: 0 0 0 0"></td>\n';
					if(i%delimiter == 0)
						tumbsDiv += '</tr><tr>';
			}
			
			tumbsDiv += '</tr></table>';
			tumbsDiv += '</span>\n';
			
			return $(tumbsDiv);
		}
		
		function getProductTumbs(product_id){
			
			imgContainer = new Object();
			imgContainer = $("#prod_" + product_id);
			imgContainer.unbind('mouseover', initTumb);

				tumbsSrc = $.get("/inc/get_tumbs.php", { id: product_id } );
				tumbsSrc.onreadystatechange = function() {
					if (tumbsSrc.readyState == 4) {
						if(tumbsSrc.status == 200) {
							aTumbs = tumbsSrc.responseText.split('\n');
							tumbsDivSrc = new Object();
							tumbsDivSrc = getTumbs(aTumbs);
							tumbsDivSrc.attr("id", "preview_" + product_id);

							imgContainer.children("a:first").append(tumbsDivSrc);
							
							$("#preview_" + product_id).animate({opacity: 1, marginLeft: "5px"}, 100);
							
							$("#prod_" + product_id + " img:first").mouseleave( 
								function() {
									$("span[id^='preview_'][id!='preview_' + product_id]").hide().stop();
									$("#preview_" + product_id).animate({opacity: 0, marginLeft: "-10px"}, 100);
									$("span[id^='preview_'][id!='preview_' + product_id]").animate({opacity: 0, marginLeft: "-10px"}, 100);
								} 
							);
							
							$("#prod_" + product_id + " img:first").mouseenter(
								function () {
									$("#preview_" + product_id).show();
									$("span[id^='preview_'][id!='preview_' + product_id]").animate({opacity: 0, marginLeft: "-10px"}, 100);
									$("#preview_" + product_id).animate({opacity: 1, marginLeft: "5px"}, 300)
								}				
							);
					
						}
					}
				}
		}
		
		function MM_goToURL() { //v3.0
	      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	    }

		function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);
		}
		
		
		function saveOrder(){
			var inp = $('#email');
			if(inp.val().length < 7){
				$('#error').html('*пожалуйста, введите корректную контактную информацию');
			}
			else{
				$.post('/inc/order.php', { title: $('h1:first').html(), email: inp.val() });
				$('#error').hide();
				$('#order_form').html('Ваш заказ принят. Мы свяжемся с Вами в ближайшее время!');
				yaCounter5745007.reachGoal('ORDER'); return true;
			}
		}
