<!--
function WPos(width,height){
  var width = width;
  var height = height;
  var clientWidth = parseInt( document.body.clientWidth || window.innerWidth );
  var clientHeight = parseInt( document.body.clientHeight || window.innerHeight );
  var scrollLeft = parseInt( window.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft) );
  var scrollTop = parseInt( window.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop) );
  var documentWidth = parseInt( jQuery(document).width() );
  var documentHeight = parseInt( jQuery(document).height() );
  var top = Math.round( ( clientHeight - height ) / 2 + scrollTop );
  var left = Math.round( ( clientWidth - width ) / 2 + scrollLeft );
  if( documentWidth > 0 && documentHeight > 0 ) {
	if( top > ( documentHeight - height ) ) top = documentHeight - height;
	if( left > ( documentWidth - width ) ) left = documentWidth - width;
  }
  if( top < 0 ) top = 0;
  if( left < 0 ) left = 0;
  return { top: top, left: left, width: width, height: height };
}

function AddToBasket(productid){
	$('#tovarquantitywindow').removeClass('hidden');
		var offsets = WPos( 240, 95 );
		$('#tqwhite').css('top', offsets.top );
		$('#tqwhite').css('left', offsets.left );
	$('#tqwhite').removeClass('hidden');
	document.getElementById('formproductid').value = productid;
	document.getElementById('tovaraction').value = "add";
	document.getElementById('tovarquantity').value = "";
	document.getElementById('tovarquantity').focus();
};

function CheckTovarAddQuantityRu(){
	var errstr="";
	var tovarquantity = document.getElementById('tovarquantity').value;
	var tovaraction = document.getElementById('tovaraction').value;
	var productid = document.getElementById('formproductid').value;
	
	if ((!tovarquantity) || (!(tovarquantity.match(/^[0-9]+$/)))) {
		alert("Неправильно указано количество товара!\n");
		return false;
	} else {
		if ((tovarquantity == 0) & (tovaraction == "change")){
			var x = window.confirm("Удалить товар?")
			
			if (x) {
				$('#tovarquantitywindow').addClass('hidden');
				$('#tqwhite').addClass('hidden');
			} else {
				return false;
			};
		} else {
			$('#tovarquantitywindow').addClass('hidden');
			$('#tqwhite').addClass('hidden');
			
			if (tovaraction == "add"){
				document.getElementById('sqcode').select();
			};
		};
	};
};

function CloseTovarQuantityWindow(){
	$('#tovarquantitywindow').addClass('hidden');
	$('#tqwhite').addClass('hidden');
};

function ChangeQuantity(basketid,tovarquantity){
	$('#tovarquantitywindow').removeClass('hidden');
		var offsets = WPos( 240, 95 );
		$('#tqwhite').css('top', offsets.top );
		$('#tqwhite').css('left', offsets.left );
	$('#tqwhite').removeClass('hidden');
	document.getElementById('formbasketid').value = basketid;
	document.getElementById('tovaraction').value = "change";
	document.getElementById('tovarquantity').value = tovarquantity;
	document.getElementById('tovarquantity').select();
};
//-->
