
function objGet(x)
{if (typeof x=='string') with (document){
	if (Boolean(getElementById))	x=getElementById(x);
else	if (Boolean(all))		x=eval('all.'+x);
else	if (Boolean(layers))		x=layers[x];
else	x=null;}return x;}

function objv(x,z) {objGet(x).value=z}
function obji(x,z) {objGet(x).innerHTML=z}
function getv(x) {return objGet(x).value}
function getch(x) {return objGet(x).checked}


function createCookie(name,value,days)
{
var c,d,e; e="";
if (days)
{
	d=new Date();
	d.setTime(d.getTime()+days*86400000);
	e="; expires="+d.toGMTString();
}
c=name+"="+value+e+"; path=/";
document.cookie=c;
}

function readCookie(name)
{var i,c,n,ca;
n=name+"=";
ca=document.cookie.split(';');
for(i=0;i<ca.length;i++)
{
	c=ca[i];
	while (c.charAt(0)==' ') c=c.substring(1,c.length);
	if (c.indexOf(n)==0) return c.substring(n.length,c.length);
}
return null;
}

function eraseCookie(name)
{createCookie(name,"",-1);}



var pole=[0,0,0];
var pole2;
var pocetmax=0;

function kosikadd(a,b)
{var i,j,k,l;l=false;
j=pole[0];if (j>0) for (i=0;i<j;i++)
	{k=1+2*i;if (pole[k]==a) {pole[k+1]=parseInt(pole[k+1])+b;l=true;i=j}}
if (!l) {k=1+2*j;pole[k]=a;pole[k+1]=b;pole[0]=j+1}
}

function kosikminus(a,b)
{var i,j,k,l;
j=pole[0];if (j>0) for (i=0;i<j;i++)
	{k=1+2*i;if (pole[k]==a) {l=parseInt(pole[k+1]);l-=b;if (l>0) pole[k+1]=l;else kosikremove(i);i=j}}
}

function kosikremove(a)
{var i,j,k,m,n,b;n=1;b=1+2*a;
j=pole[0];if (j>0) for (i=0;i<j;i++)
	{k=1+2*i;pole[n]=pole[k];pole[n+1]=pole[k+1];if (k!=b) n+=2;else pole[0]--;}
}

function kosikaddsel()
{var a,i,j;j=pocetmax;if (j>0) for (i=0;i<j;i++) {a=parseInt(getv("i"+i));if (a>0) kosikadd(i,a)}}

function kosikminussel()
{var a,i,j;j=pocetmax;if (j>0) for (i=0;i<j;i++) {a=parseInt(getv("i"+i));if (a>0) kosikminus(i,a)}}

function kosikzmenit()
{var a,i,j,b,c;j=pocetmax;if (j>0) for (i=0;i<j;i++) {a=parseInt(getv("i"+i));
b=pole[2+2*i];c=pole[1+2*i];if (a>b) kosikadd(c,a-b);if (a<b) kosikminus(c,b-a);
}
kosiksave();
location.reload();
}

function kosikread() {pole2=readCookie('testkosik');pole=pole2.split("x")}
function kosiksave() {pole2=pole.join("x");createCookie('testkosik',pole2,0)}

function kosik()
{ window.open("kosik.htm","kosikokenko","scrollbars,resizable,width=350,left=0,top=0") }

var radek=5;	//5 polozek
databaze=[
"kopr3.gif",	"Kleste",	152.50,	52,	"kleste sviraci a rozviraci, na zoubecky i na auta",
"kopr3.gif",	"Hrebiky",	215.00,	15,	"kleste sviraci a rozviraci, na zoubecky i na auta",
"kopr3.gif",	"Kladiva",	415.50,	15,	"kleste sviraci a rozviraci, na zoubecky i na auta",
"kopr3.gif",	"Sveraky",     2415.00,	15,	"kleste sviraci a rozviraci, na zoubecky i na auta",
"kopr3.gif",	"Klice",	515.00,	15,	"kleste sviraci a rozviraci, na zoubecky i na auta",
"kopr3.gif",	"Zamky",	615.50,	15,	"kleste sviraci a rozviraci, na zoubecky i na auta",
"kopr3.gif",	"Umyvadla",	915.00,	15,	"kleste sviraci a rozviraci, na zoubecky i na auta"
]
