function showLightbox(text,contentStyle,footStyle,textStyle) {

	lightbox = document.getElementById('lightbox');
	if(lightbox) return false;

	contentStyle = contentStyle == '' ? 'style="height: 54px;"' : 'style="'+contentStyle+'"';
	footStyle = footStyle == '' ? 'style="padding-left: 105px;"' : 'style="'+footStyle+'"';
	textStyle = textStyle == '' ? '' : 'style="'+textStyle+'"';
		
	lightbox = document.createElement('div');
	lightbox.setAttribute('id','lightbox');	
	lightbox.innerHTML =								
		'<div class="lightbox-main">'+
			'<div class="lightbox-top"></div>'+	
			'<div class="lightbox-logo"></div>'+	
			'<div class="lightbox-cancel" onclick="cancelLightbox()">'+
				'<img class="cancel" src="'+juri+'/static/images/lightbox/cancel.png"/>'+
			'</div>'+				 								
			'<div class="lightbox-content" '+contentStyle+' ></div>'+
			'<div class="lightbox-foot" '+footStyle+'>'+
				'<p '+textStyle+'>'+text+'</p>'+
			'</div>'+
		'</div>';		
	elements = document.getElementsByTagName('body');
	elements[0].appendChild(lightbox);				
}		
function showConfirmLightbox(link) {
	showConfirm(link,'Opravdu smazat?','ano, smazat &gt&gt','', true);
}

function showConfirmLightboxNoCheck(link) {
	showConfirm(link,'Opravdu smazat?','ano, smazat &gt&gt','', false);
}

function showConfirm(link,text,confirm,cStyle, showCheckBox) {

	lightbox = document.getElementById('lightbox');
	if(lightbox) return false;
	
	if ( showCheckBox && loadConfirm() ){
		window.location=link;
		return;
	}
	var cStyle = cStyle != '' ? 'class="' + cStyle+ '"' : ''; 	
	lightbox = document.createElement('div');
	lightbox.setAttribute('id','lightbox');	
	lightbox.innerHTML =								
		'<div class="lightbox-main">'+
			'<div class="lightbox-top"></div>'+	
			'<div class="lightbox-logo"></div>'+	
			'<div class="lightbox-cancel">'+
				'<img class="cancel" onclick="cancelLightbox()" src="'+juri+'/static/images/lightbox/cancel.png"/>'+
			'</div>'+				 								
			'<div class="confirm-lightbox-content lightbox-content"></div>'+
			'<div class="confirm-lightbox-foot lightbox-foot" >'+
				'<strong '+cStyle+'>'+text+'</strong>'+
				'<a class="cmds deleteStorno" href="javascript:cancelLightbox()"><< storno</a>'+
				'<a class="cmds deleteConfirm" href="'+link+'" >'+confirm+'</a>'+
				(showCheckBox ? 
				'<div class="confirmRemember">'+
					'<input type="checkbox" id="confirm-checkbox" onclick="checkConfirmWindow()"/>'+
					'<label for="confirm-checkbox">Příště nezobrazovat</label>'+
				'</div>' : '') +
			'</div>'+
		'</div>';		
	elements = document.getElementsByTagName('body');
	elements[0].appendChild(lightbox);				
}

function cancelLightbox(){
	elements = document.getElementsByTagName('body');
	lightbox = document.getElementById('lightbox');
	if(lightbox) {
		elements[0].removeChild(lightbox);
	}	
}		
function showErrorWindow(text){
	showLightbox(text,'','','');	
}
function showConfirmWindow(text){
	contentStyle = 'height: 70px;';
	textStyle = 'top: 55px;';
	showLightbox(text,contentStyle,'',textStyle);
}
function showFatalErrorWindow(){
	text = 'Omlouváme se, ale nepodařilo se uložit Váš příspěvek.<br/>'+
		'Na vině mohou být technické problémy na serveru<br/>'+
		'nebo ve Vašem<br/>'+
		'prohlížeči.';
			
	contentStyle = 'height: 150px;';
	textStyle = 'width: 230px; top: 55px; text-align: right; padding-left: 20px;padding-right: 10px;';
	footStyle = 'padding-left: 20px;';
	showLightbox(text,contentStyle,footStyle,textStyle);
}
function checkConfirmWindow()
{
	elements = document.getElementsByTagName('body');
	box = document.getElementById('lightbox');	
	inputs = box.getElementsByTagName('input');	
	saveConfirm(inputs[0].checked != false);
}
function saveConfirm(value)
{
	var vyprs = new Date(); 
	vyprs.setDate(vyprs.getDate() + 365); 
	document.cookie = "lightboxConfirm="+(value ? "checked" : "")+"; expires="+vyprs.toGMTString()+"; path=/"; 
}
function loadConfirm()
{
	var values = document.cookie.split(';');
	if (values.length) for ( var i in values ) if ((typeof values[i] == 'string') && (values[i].search('lightboxConfirm=checked') >= 0)) return true;
	return false;	
}