function selTextil(itemId, textilId, defSize, colorId, totalPrice, HTMLcode, NoShop) {

	lastsel=document.forms.motiv.produkt.value;
	if(lastsel!='') {
		lastsel=lastsel.split('/');
		document.images['i'+lastsel[3]].src='img/barva-blok.gif';
		}
	if(NoShop!=1) document.getElementById('price-low').innerHTML='<div class="sekce-r">Cena produktu: '+totalPrice+' CZK</div><input class="objednat" type="submit" value="Přidat do košíku" />';
		else document.getElementById('price-low').innerHTML='<div class="sekce-r">Cena textilu: '+totalPrice+' CZK</div>';
	document.forms.motiv.produkt.value=itemId+'/'+textilId+'/'+defSize+'/'+colorId;

	document.images['i'+colorId].src='img/barva-blok-sel.gif';

	// document.getElementById('preview').style.backgroundColor='#'+HTMLcode;

}


function makeupload(formvalue) {
	dt = new Date()
	uniqid = dt.getTime();
	filename=document.forms.upform.motiv.value.split('\\');
	fname=filename[filename.length-1];
	loaderdiv = document.createElement('li');
	loaderdiv.setAttribute('id','i'+uniqid);
//	loaderdiv.setAttribute('class','loadfile');
	loaderdiv.innerHTML = '<div class="imgtextil"><img src="img/progress-small.gif" width="42" height="42" /></div>'+fname+'<p>Nahrávám</p>';
	
	document.forms.upform.uniqid.value = uniqid;
	document.forms.upform.submit();
	document.forms.upform.motiv.disabled = true;

	document.getElementById('files').appendChild(loaderdiv);

	}

function recomputecart() {
	curline=1; total=0;
	while(document.getElementById('pr'+curline)) {
		if(isNaN(document.getElementById('nm'+curline).value)) document.getElementById('nm'+curline).value='1';
		total+=document.getElementById('pr'+curline).innerHTML*document.getElementById('nm'+curline).value;
		curline++;
		}
	document.getElementById('total').innerHTML=total;
	}

function checkOrderForm() {
	var missing='';
	docfrm=document.forms.orderform;
	if(docfrm.jmeno.value=="") missing+="- Jméno\n";
	if(docfrm.ulice.value=="") missing+="- Ulice, číslo\n";
	if(docfrm.mesto.value=="") missing+="- Město\n";
	if(docfrm.psc.value=="") missing+="- PSČ\n";
	if((docfrm.telefon.value=="")&&(docfrm.telefon.value.length<9)) missing+="- Telefon\n";
	if((docfrm.email.value=="")&&(docfrm.email.value.indexOf('@')<1)) missing+="- E-mail\n";

	if(missing) alert('Následující položky byly zadány špatně\nnebo nebyly zadány vůbec:\n'+missing);
	
	if(missing=='') docfrm.submit();
	}


function checkMotivForm() {
	var missing='';
	docfrm=document.forms.motiv;
	if(docfrm.jmeno.value=="") missing+="- Jméno\n";
	if(docfrm.ulice.value=="") missing+="- Ulice, číslo\n";
	if(docfrm.mesto.value=="") missing+="- Město\n";
	if(docfrm.psc.value=="") missing+="- PSČ\n";
	if((docfrm.telefon.value=="")&&(docfrm.telefon.value.length<9)) missing+="- Telefon\n";
	if((docfrm.email.value=="")&&(docfrm.email.value.indexOf('@')<1)) missing+="- E-mail\n";
	if(docfrm.produkt.value=="") missing+="- Požadovaný textil\n";
	if(document.getElementById('files').childNodes.length==0) missing+="- Nebyly nahrány motivy\n"

	if(missing) alert('Následující položky byly zadány špatně\nnebo nebyly zadány vůbec:\n'+missing);
	
	if(missing=='') docfrm.submit();
	}


function getOffsetX(domel) {
	pos = 0;
	if(domel.offsetParent)
		while(domel.offsetParent) {
			pos+=domel.offsetLeft;
			domel=domel.offsetParent;
			}
	return pos;
	}


function getOffsetY(domel) {
	pos = 0;
	if(domel.offsetParent)
		while(domel.offsetParent) {
			pos+=domel.offsetTop;
			domel=domel.offsetParent;
			}
	return pos;
	}

