function setCookie(name, value)
{
	document.cookie = name + '=' + value + "; path=/";
//	document.cookie = name + '=' + value + "; path=/; expires=Monday, 14-Nov-05 10:10:10 GMT;";
}
function getCookie(name)
{
	var flag = document.cookie.indexOf(name+'=');
	if(flag != -1) 
	{
		flag += name.length + 1;
		end = document.cookie.indexOf("; ", flag);
		if(end == -1) end = document.cookie.length;
		return document.cookie.substring(flag, end);
	}
}

function setSubCookie(uName, name, value)
{
	uValue = getCookie(uName);
	if(uValue) 
	{
		uCookies = uValue.split('&');
		var found = -1;
		for(c=0; c < uCookies.length; c++)
		{
			t = uCookies[c].split('=');
			if( t[0] == name )
			{
				found = 1;
				t[1] = value;
				uCookies[c] = t.join('=');
			}
		}
		if(found == -1)
			uCookies[uCookies.length] = name + '=' + value;
		uValue = uCookies.join('&');
	} else {
		uValue = name + '=' + value;
	}
	setCookie(uName, uValue);
}

function delSubCookie(uName, name)
{
	uValue = getCookie(uName);
	if(!uValue) return; 
	uCookies = uValue.split('&');
	var found = -1;
	for(c=0; c < uCookies.length; c++)
	{
		t = uCookies[c].split('=');
		if(t[0] == name)
		{ found = 1;
		  uCookies.splice(c,1);
		  break;
		}
	}
	uValue = uCookies.join('&');
	setCookie(uName, uValue);
}
function getSubCookie(uName, name)
{
	uValue = getCookie(uName);
	if(!uValue) return "";
	var flag = uValue.indexOf(name+'=');
	if(flag != -1) 
	{
		flag += name.length + 1;
		end = uValue.indexOf('&', flag);
		if( end == -1) end = uValue.length;
		str = uValue.substring(flag, end);
		return str;
	}
}

lmCache= new Array(1);
lmCache[0] =new Image();
lmCache[0].src="/images/basket1.gif";

function SwapIm(name,cache)
{
id = new String(name);
if(!cache[id.charAt(id.length-1)].complete) return false;
var temp;
if (docom) 
{
temp=document.getElementById(id).src;
document.getElementById(id).src=cache[id.charAt(id.length-1)].src;
cache[id.charAt(id.length-1)].src=temp;
}
else if (ie4) 
{
eval('temp=document.all.' + id + '.src');
eval('document.all.' + id + '.src=cache[id.charAt(id.length-1)].src');
eval('cache[id.charAt(id.length-1)].src=temp');
}
return true;
}

function changeAmount(gid, inp)
{
if (inp.value < 1 || isNaN(inp.value))
{ 
  delSubCookie("order", gid);
  inp.value = '';
}
else
  setSubCookie("order", gid, inp.value);
if (ie && document.all.order)
	{
	o = getCookie("order");
	if (o==null || o.length < 1)
      document.all.order.style.display = "none";
	else
	document.all.order.style.display = "block";
	}
if (ie && document.all.sum)
	changeSum();
}

function decr(gid)
{
  inp = document.goods[gid];
  inp.value--;
  changeAmount(gid, inp); 
}
function incr(gid)
{
  inp = document.goods[gid];
  inp.value++;
  changeAmount(gid, inp); 
}

