function newWindow(fileURL,width,height) {
	w = width;
	h = height+110;
	options='width='+w+',height='+h;
	okno=window.open(fileURL,'',options);
}

	var value=0;

	function addF(fId,iType,iName,iValue,resitele) {
	
		var f = document.getElementById(fId);
		value++;
		var div = document.createElement('div');
		div.setAttribute('id',iName+value);
		if (iType == "select") {
		
			var i = document.createElement('select');
			i.setAttribute('name',iName);
			var option = document.createElement('option');
			option.setAttribute("value",0);
			var text = document.createTextNode('Bez řesitele');
			option.appendChild(text);
			i.appendChild(option);
			for ( x=0;x<resitele.length;x++) {
				var option = document.createElement('option');
				option.setAttribute("value",x+1);
				var text = document.createTextNode(resitele[x]);
				option.appendChild(text);
				i.appendChild(option);
			}
		} else {
			var i = document.createElement('input');
			i.setAttribute('type',iType);
			i.setAttribute('name',iName);
			i.setAttribute('value',iValue);
		}
		var a = document.createElement('a');
		a.setAttribute('href','javascript:removeF(\"'+fId+'\",\"'+iName+value+'\")');	
		var linkText = document.createTextNode('Odebrat');
		
		a.appendChild(linkText);
		div.appendChild(i);
		div.appendChild(document.createTextNode(" "));
		div.appendChild(a);
		f.appendChild(div);
		document.getElementById('footer').style.top = document.getElementById("page").scrollHeight+"px";
	}
	function removeF(fId,id) {
		var f = document.getElementById(fId);
		var el = document.getElementById(id);
		if (el) f.removeChild(el);
	}
	
	
	var val=0;
	
	function cloneSelect (fId, iName, elementId, selectedId) {
	
		var f = document.getElementById(fId);
		
		var div = document.createElement('div');
		div.setAttribute('id',iName+val);
		
		var obj = document.getElementById(elementId).cloneNode(true);
		
		obj.name = iName;
		obj.setAttribute('id',iName+val);
		obj.style.display = 'inline';
		if(selectedId!="") obj.options[selectedId].selected  =true;
		else obj.options[0].selected  =true;
		//alert(selectedId);
		
		var a = document.createElement('a');
		a.setAttribute('href','javascript:removeF(\"'+fId+'\",\"'+iName+val+'\")');	
		//var linkText = document.createTextNode(""  border=\"0\" alt=\"\">");
		var oImg=document.createElement("img");
		oImg.setAttribute('src', "/imgs/admin/user_delete.png");
		oImg.setAttribute('alt', "Přidat dalši");
		oImg.setAttribute('border', '0');
		oImg.style.position = 'relative';
		oImg.style.top = '5px';
		oImg.style.marginLeft = '4px';
		a.appendChild(oImg);
		//a.appendChild(linkText);
		
		div.appendChild(obj);
		div.appendChild(a);
		f.appendChild(div);
		document.getElementById('footer').style.top = document.getElementById("page").scrollHeight+"px";
		
		val++;
	}

	function hideTab(id){
		object = document.getElementById(id);
		object.style.display='none';
		}


		function showTab(id){
		object = document.getElementById(id);
		object.style.display='';
		}

		function SetChecked(val,chkName) {
		    dml=document.forms[form];
		    len = dml.elements.length;
		    var i=0;
		    for( i=0 ; i<len ; i++) {
		        if(dml.elements[i].disabled!=1){        
		            dml.elements[i].checked=val;
		        }
		    }
		}

	function addToCart(idZbozi,pocet){
		new Request.HTML({url:'/carthandler',data: { 'pridat_do_kosiku' : idZbozi,'pocet':pocet }, update:'ajaxCartFrame',link:'chain'}).post();
		
	}
	
	function fadeout(div){
		$(div).fade('out');
	}
	