function showAdvert(lNode) {
	if(document.getElementById('banner'+lNode.getAttribute('index'))) {
		if(lNode.getAttribute('swf')=='1'){
			document.getElementById('banner'+lNode.getAttribute('index')).innerHTML=
			'<embed src="'+lNode.getAttribute('img')+'" type="application/x-shockwave-flash" width="'+(lNode.getAttribute('index')=='1'?'906':'450')+'" height="125"/>';
		}else{
			document.getElementById('banner'+lNode.getAttribute('index')).innerHTML=
				'<a href="'+lNode.getAttribute('url')+'" target="_blank"><img src="'+lNode.getAttribute('img')+'" alt="Reklama" width="'+(lNode.getAttribute('index')=='1'?'906':'450')+'px" height="125px"/></a>';
		}
	}
}

function showAction(lNode) {
	var lInfo='', lCode='', lContacts='', lTimes='', lIsReserv=(lNode.getAttribute('restype')!=='0');

	if(lNode.getAttribute('forchildren')=='1') lInfo+='určeno dětem';
	if(lNode.getAttribute('agefrom')!=='0') lInfo+=(lInfo==''?'':', ')+'vstup od '+lNode.getAttribute('agefrom')+' let';
	if(lNode.getAttribute('length')!=='0') lInfo+=(lInfo==''?'':', ')+'délka '+lNode.getAttribute('length')+' min.';
	if(lNode.getAttribute('ismovie')=='1') {
      if(lNode.getAttribute('incz')=='1') lInfo+=(lInfo==''?'':', ')+'česky';
      if(lNode.getAttribute('subtitles')=='1') lInfo+=(lInfo==''?'':', ')+'titulky';
	}
	var xmlTimes=lNode.getElementsByTagName('schedule');
	if(xmlTimes.length>0) {
      lTimes='<div class="restimes">Termíny<select '+(lIsReserv?' onclick="'+"document.getElementById('cmdReserve').href=this.value"+'">':'>');
		for (var myI = 0; myI < xmlTimes.length; myI++) {
			lTimes+='<option '+(xmlTimes.item(myI).getAttribute('id')==lNode.getAttribute('id')?' selected ':'')+
						"value='"+xmlTimes.item(myI).getAttribute('resurl')+"'"+'">';
			lTimes+=actDateFormat(xmlTimes.item(myI).getAttribute('timefrom'), xmlTimes.item(myI).getAttribute('timeto'))
			lTimes+='</option>';
		}
		lTimes+='</select></div>';
	}
	lCode='<div class="actdetail"><h1>'+lNode.getAttribute('title')+'</h1>';
	if (lNode.getAttribute('imgurl')!=='') lCode+='<img class="actimage" src="'+lNode.getAttribute('imgurl')+
						'" alt="Foto" onclick="imgPreview('+"'"+lNode.getAttribute('imgurl')+"'"+')"/>';
	lCode+='<span class="datum">'+actDateFormat(lNode.getAttribute('timefrom'), lNode.getAttribute('timeto'))+'</span>'+
			'<table><tr><td class="descript">'+lNode.getAttribute('tdescript')+'</td></tr>'+
	      '<tr><td class="info">'+lInfo+'</td></tr>'+
	      '<tr><td class="remark">'+lNode.getAttribute('descript')+'</td></tr>'+
	      '<tr><td class="placename">'+lNode.getAttribute('placename')+'</td></tr>'+
	      '<tr><td class="placeaddr">'+lNode.getAttribute('city')+'</td></tr></table>';

	if (lNode.getAttribute('phone')!=='') lCode+='<span class="lblContact">Tel:</span><span class="valContact">'+lNode.getAttribute('phone')+'</span>';
	if (lNode.getAttribute('email')!=='') lCode+='<span class="lblContact">Email:</span><span class="valContact">'+lNode.getAttribute('email')+'</span>';

	lCode+=lTimes;
	if(lIsReserv || lNode.getAttribute('url')!=='') {
		lCode+='<hr/>';
		if(lNode.getAttribute('restype')!=='0')
			lCode+='<a class="buttReserve" id="cmdReserve" href="'+lNode.getAttribute('resurl')+'" target="_blank" onclick="closeBox();">'+(lNode.getAttribute('restype')=='1' ? 'Rezervovat' : 'Objednat')+'</a>';
		if(lNode.getAttribute('url')!=='')
			lCode+='<a class="buttInfo" href="'+lNode.getAttribute('url')+'" target="_blank" onclick="closeBox();">Více informací</a>';
	}
	lCode+='</div>';
	showBox(lCode);
}

function actDateFormat(from, to) {
var lRetVal='';
	if(from.substr(0,10)==to.substr(0,10)) {
		lRetVal=from.substr(0,10);
		if(from.substr(11,5)==to.substr(11,5) || to.substr(11,5)=='00:00') {
			if(from.substr(11,5)!=='00:00') lRetVal+=' '+from.substr(11,5);
		} else {
		   lRetVal+=' '+from.substr(11,5)+' - '+to.substr(11,5);
		}
	} else {
		if(from.substr(11,5)=='00:00' && to.substr(11,5)=='00:00') {
			lRetVal=from.substr(0,6)+' - '+to.substr(0,10);
		} else {
			lRetVal=from.substr(0,6)+' '+from.substr(11,5)+' - '+to;
		}
	}
	return lRetVal;
}

function showBox(lHtm, lWindowCaption) {
	closeBox();
	lDiv=document.createElement('div');
	lDiv.setAttribute('id', 'shBox_shadow')
	lDiv.style.position="fixed";
	lDiv.style.top="0px";
	lDiv.style.left="0px";
	lDiv.style.width="100%";
	lDiv.style.height="100%";
   lDiv.style.backgroundColor="black";
   lDiv.style.filter="alpha(opacity=80)";
   lDiv.style.opacity="0.8";

	document.body.appendChild(lDiv);
	lDiv=document.createElement('div');
	lDiv.setAttribute('id', 'shBox_main');
	lDiv.style.position="fixed";
   lDiv.style.backgroundColor="white";
   lDiv.style.padding="20px";
	lDiv.style.border="20px solid #ddd";
	lDiv.style.float="left";
	lDiv.style.fontSize="1.2em";
	lDiv.style.top="50%";

	lDiv.innerHTML='<img src="cm_images/closewindow.png" style="position:absolute;float:right; margin: -55px -55px 0 0; right:25px; cursor:pointer;" onclick="'+
			"closeBox()"+'"/>'+(lWindowCaption?'<h2>'+lWindowCaption+'</h2>':'')
			+lHtm+'<hr style="margin:0;clear:both;visibility:hidden;"/>';
	document.body.appendChild(lDiv);
	lDiv.style.left=((document.documentElement.clientWidth-lDiv.offsetWidth)/2).toString()+'px';
	lDiv.style.top=((document.documentElement.clientHeight-lDiv.offsetHeight)/2).toString()+'px';
	lDiv.style.visibility='visible';
}

function closeBox() {
	if(document.getElementById('shBox_shadow')) {
	   document.body.removeChild(document.getElementById('shBox_shadow'));
		document.body.removeChild(document.getElementById('shBox_main'));
	}
}

function imgPreview(lUrl) {
	lDiv=document.createElement('div');
	lDiv.setAttribute('id', 'shIBox_shadow')
	lDiv.style.position="fixed";
	lDiv.style.top="0px";
	lDiv.style.left="0px";
	lDiv.style.width="100%";
	lDiv.style.height="100%";
   lDiv.style.backgroundColor="black";
   lDiv.style.filter="alpha(opacity=80)";
   lDiv.style.opacity="0.8";

	document.body.appendChild(lDiv);
	lDiv=document.createElement('div');
	lDiv.setAttribute('id', 'shIBox_main');
	lDiv.style.position="fixed";
   lDiv.style.backgroundColor="white";
   lDiv.style.padding="20px";
	lDiv.style.border="20px solid #ddd";
	lDiv.style.float="left";
	lDiv.style.fontSize="1.2em";
	lDiv.style.top="50%";


	lDiv.innerHTML='<img src="cm_images/closewindow.png" style="position:absolute;float:right; margin: -55px -55px 0 0; right:25px; cursor:pointer;" onclick="'+
			"closeIBox()"+'"/>'+
			'<img src="'+lUrl+'" style="; margin: 0px 0px 0 0; cursor:pointer; max-height:600px;" onclick="closeIBox();"/>';
	document.body.appendChild(lDiv);
	lDiv.style.left=((document.documentElement.clientWidth-lDiv.offsetWidth)/2).toString()+'px';
	lDiv.style.top=((document.documentElement.clientHeight-lDiv.offsetHeight)/2).toString()+'px';
	lDiv.style.visibility='visible';
}
function closeIBox() {
   document.body.removeChild(document.getElementById('shIBox_shadow'));
	document.body.removeChild(document.getElementById('shIBox_main'));
}


function removeHTMLTags(htmlString){
if(htmlString){
	var mydiv = document.createElement("div");
		mydiv.innerHTML = htmlString;
	if (document.all) // IE Stuff
		{return mydiv.innerText;}
	else // Mozilla does not work with innerText
		{return mydiv.textContent;}
	}
}
function encodePar (lvalue) {
	lvalue=lvalue.replace(/%/g, '&#37;');
	lvalue=lvalue.replace(/\+/g, '%2B');
	lvalue=lvalue.replace(/&/g, '%26');
//	lvalue=lvalue.replace(/\>/g, '%3E');
//	lvalue=lvalue.replace(/\</g, '&3C;');
	return lvalue;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

