//увеличение картинки
function imgOpen(url, title, w, h) {
	imgWindow=window.open("","imgw","width="+w+",height="+h+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no")
	imgWindow.document.open();
	imgWindow.document.write('<html><head><title>'+title+'</title></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#000000" vlink="#000000" alink="#000000" bgcolor="#ffffff"><div align=center><a href="javascript:window.close();"><img src="'+url+'" border="0" alt="Закрыть"></a>');
	imgWindow.document.write("</body></html>");
	imgWindow.document.close();
	}

//маленькое окно
function wopen(wurl,wname) {
	window.open('',wname,'width=650,height=450,resizable=yes,scrollbars=yes,menubar=no,status=yes');
}

function getCookieVal(offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

function SetCookie(name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
                ((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
		
		
}

function puttobasket(id, count, price)
{
	var cname = "";
	var cval = 0;
	
	
	
	cname = 'GOODS'+id;
	cval = GetCookie(cname)*1;
	cval += count*1;
	//cval = 0;
	SetCookie(cname, cval);
	
	/*
	cname = 'COUNTGOODS';
	cval = GetCookie(cname)*1;
	cval += count*1;
	SetCookie(cname, cval);
	
	cname = 'TOTALPRICE';
	cval = GetCookie(cname)*1;
	cval += count*price;
	SetCookie(cname, cval);
	
	
	displayOrderValues();
	*/
	
	document.location.reload();
	
	
	//document.location = '?IID=268274&'+'GOODS'+id+'='+count+'';
}

function displayOrderValues()
{
	displayCountGoods(GetCookie('COUNTGOODS')*1);
	displayTotalPrice(GetCookie('TOTALPRICE')*1);
}

function displayCountGoods(val)
{
	obj = document.all.OrderCountGoods;
	setValue(obj, val);
}

function displayTotalPrice(val)
{
	obj = document.all.OrderTotalPrice;
	setValue(obj, val);
}

function setValue(obj, val)
{
	obj.innerHTML = val;
}

