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';
		$(id+'Tab').set('class',"");
	}


	function showTab(id){
		object = document.getElementById(id);
		object.style.display='';
		$(id+'Tab').set('class',"active");
	}

	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 showHide(id){
		object = document.getElementById(id);
		if (object.style.display == "none"){
		object.style.display='';
		}else{
		object.style.display='none';}
	}

	
	function fadeout(div){
		$(div).fade('out');
	}
	
	function getWindowY() {
		  myHeight = 0;
		  if( typeof( window.innerHeight ) == 'number' ) {
		    //Non-IE
		    myHeight = window.innerHeight;
		  } else if( document.documentElement && (  document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myHeight = document.documentElement.clientHeight;
		  } else if( document.body && (  document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myHeight = document.body.clientHeight;
		  }
		  return( myHeight)
	}
	
	function getWindowX() {
		  myWidth = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		  } else if( document.documentElement && (  document.documentElement.clientWidth ) ) {
		    //IE 6+ in 'standards compliant mode'
			  myWidth = document.documentElement.clientWidth;
		  } else if( document.body && (  document.body.clientWidth ) ) {
		    //IE 4 compatible
		    myWidth = document.body.clientWidth;
		  }
		  return( myWidth)
	}
	
	var imgRatio = 0;
	
	function resizeBgImg(){
		var img = $('bgImg');
		var screenX = getWindowX();
		var screenY = (getWindowY()-132);
		var screenRatio = screenX/screenY;
		if(screenRatio<=imgRatio){
			$('bgImg').setStyle('width',Math.round(screenY*imgRatio));
			$('bgImg').setStyle('height',screenY);
			//alert('ratio prohlizece je mensi nez ratio obrazku: '+screenY*imgRatio+' '+screenY);
		}else{
			$('bgImg').setStyle('width',screenX);
			$('bgImg').setStyle('height',Math.round(screenX*(1/imgRatio)));
			
			//alert('o obrazku: '+screenX+' '+Math.round(screenX*(1/imgRatio)));
		}
		$('bg').setStyle('display','block');
		$('bgImgMenuOuter').setStyle('height',screenY+132-25);
	}
	
