function winop(width, height)	
{
	height = height+100;
	im = window.open('', 'addcart', 'top=40,left=40,width='+width+',height='+height+', scrollbars=yes, menu=no,status=yes,resizable=no');
	im.focus();
}

function winop2(imgurl, width, height)
{
    title = "window";
    im = window.open('', 'win','top=40,left=40,width='+width+',height='+height+', scrollbars=no, menu=no,status=no,resizable=no');
    im.focus();
    im.document.open ("text/html");
    im.document.write ('<html><title>'+title+'</title><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 bgcolor=#ffffff><table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td align=center><img src='+imgurl+' width='+width+' height='+height+'></td></tr></table></body></html>');
    im.document.close ();
}

function cart(url, width, height) 
{
	w = window.open(url,'addcart','height='+height+',width='+width+', scrollbars=yes, menu=no,status=yes,resizable=no');
	w.focus();
} 

function prepareNumber8(n)
{
	var s = Number(n).toFixed(12);
	s = s.substr(0, s.length - 10);
	for (var i = s.length - 6, j = n < 0 ? 1 : 0; i > j; i -= 3) s = s.substr(0, i) + "" + s.substr(i);
	return s;
}

var tOut;
var lastMenu = null;
var lastPluse = null;
var fClick = null;

function hideIt(s)
{
	punkt = document.getElementById('sub-'+s);
	
    punkt.style.visibility = "hidden";
    punkt.style.position='absolute';
}
function showObject (s, y)
{
	if (s != y && y != '' && fClick == null)
	{
		lastMenu = document.getElementById('sub-'+y);
		lastPluse = document.getElementById('pluse-'+y);
		
		lastMenu.className = "list-submenu-none";
    	lastMenu.style.display = "none";
    	lastMenu.style.position = 'absolute';
    	lastPluse.src = "/images/cat-pluse.png";
		
		fClick = 1;
	}

    if (lastMenu != null) 
    {
    	lastMenu.className = "list-submenu-none";
    	lastMenu.style.display = "none";
    	lastMenu.style.position = 'absolute';
    	lastPluse.src = "/images/cat-pluse.png";
    }
    
    if (s != '')
    {
    	punkt = document.getElementById('sub-'+s);
    	pluse = document.getElementById('pluse-'+s);
    	
    	//alert(punkt.className);
    	
    	if (lastMenu != punkt)
    	{
    		//if (punkt.className == "list-submenu-display")
    		//{
    		//	punkt.className = "list-submenu-none";
    		//	punkt.style.display = "none";
    		//	punkt.style.position = 'absolute';
    		//	pluse.src = "/images/cat-pluse.png";
   			//}
   			//else
   			//{
   				punkt.className = "list-submenu-display";
    			punkt.style.display = "inline";
    			punkt.style.position = 'static';
    			pluse.src = "/images/cat-minus.png";		
   			//}
    	
    	lastMenu = punkt;
    	lastPluse = pluse;
    	}
    	else
    	{
    		lastMenu = null;
    		lastPluse = null;
    	}
    }
    else
    {
    	lastMenu = null;
    	lastPluse = null;
    }
}
function setLastMenu(s)
{
	lastMenu = document.getElementById('sub-'+s);
}
function hideObject(s)
{   
    tOut = window.setTimeout('this.hideIt(' + s + ');', 300);
}

function cart_pluse(form, id)
{
	// Получаем кол-во товаров в корзине
	var quant = form.elements['quant['+id+']'].value - 0;
	// Увеличиваем кол-во на 1
	quant++;
	
	// Получаем цену за товар
	var price = form.elements['price['+id+']'].value - 0;
	
	// Вставляем полную стоимость за наименование
	document.getElementById('cart'+id+'_price').innerHTML = prepareNumber8(quant*price);
	
	// Полная стоимость заказа
	var el_fullprice = form.elements['full_price'].value - 0;
	
	// Увеличеваем ее на цену товара
	el_fullprice += price;
	
	// Сохраняем результат
	form.elements['full_price'].value = el_fullprice;
	// Показываем на сайте полную стоимость
	document.getElementById('cart_fullprice').innerHTML = prepareNumber8(el_fullprice);
		
	// Показываем кол-во товара в корзине
	document.getElementById('cart'+id+'_quant').innerHTML = quant;
	// Сохраняем результат
	form.elements['quant['+id+']'].value = quant;
	//alert('pluse '+id+' qty='+form.elements['quant['+id+']'].value);
}

function cart_minus(form, id)
{
	var quant = form.elements['quant['+id+']'].value - 0;
	
	var price = form.elements['price['+id+']'].value - 0;
	
	if (quant > 1)
	{
		quant--;
		
		document.getElementById('cart'+id+'_price').innerHTML = prepareNumber8(quant*price);
		
		var el_fullprice = form.elements['full_price'].value - 0;
		
		el_fullprice -= price;
		
		form.elements['full_price'].value = el_fullprice;
		document.getElementById('cart_fullprice').innerHTML = prepareNumber8(el_fullprice);
				
		document.getElementById('cart'+id+'_quant').innerHTML = quant;
		form.elements['quant['+id+']'].value = quant;
	}
	
	//alert('pluse '+id+' qty='+form.elements['quant['+id+']'].value);
}
function setdeliver(form, id, price)
{
	if (id == 1)
	{
		form.elements['deliver_price'].value = price;
	}
	else
	{
		form.elements['deliver_price'].value = price;
	}
	
	document.getElementById('cart_deliver0').innerHTML = price;
	document.getElementById('cart_deliver1').innerHTML = price;
	document.getElementById('cart_deliver2').innerHTML = price;
	
	var el_fullpriceusd = form.elements['full_price_usd'].value - 0;
	var nal = form.elements['nal'].value - 0;
	var bnal = form.elements['bnal'].value - 0;
	var deliver_price = form.elements['deliver_price'].value - 0;
	
	document.getElementById('cart_fullpricerunal').innerHTML = nal*el_fullpriceusd;
	document.getElementById('cart_fullpricerubnal').innerHTML = bnal*el_fullpriceusd;
	
	document.getElementById('cart_fullpricerunald').innerHTML = nal*el_fullpriceusd+deliver_price;
	document.getElementById('cart_fullpricerubnald').innerHTML = bnal*el_fullpriceusd+deliver_price;
}
function cart_delete(form, id)
{
	form.elements['delete'].value = id;
	form.elements['action'].value = 'delete';
	form.submit();
}

function fnOnClick( form )
{
	var idCat = form.elements['ct'].value;
	xajax_getfunc(idCat);
}


