// ***********************************************************************************
// Copyright (C) Radek HULAN and Aleto
// http://hulan.cz/ and http://aleto.ch/
// ***********************************************************************************

// This work is licensed under the Creative Commons Attribution License. To  view a
// copy of this license, visit http://creativecommons.org/licenses/by/1.0/  or send
// a letter to Creative Commons, 559 Nathan Abbott Way, Stanford,  California 94305,
// USA.

// use like onclick="return openwin(this.href)"
function openwin(url) {
  if( window.open(url,'','width=800,height=600,left=0,top=0,scrollbars=yes,location=yes,resizable=yes') ) return false; else return true;
}
 
// hideH2
function hideH2(itemtext,totalitems){
  var ele;
  for (var i = 1; i<=Number(totalitems); i++) 
	  if (ele=document.getElementById(itemtext+i+String("h2"))) ele.style.display="none";
}


// helper functions
var isXHTML;
function createNewEle(ele){
	if(isXHTML) 
		{ return document.createElementNS('http://www.w3.org/1999/xhtml', ele); }
	else 
		{ return document.createElement(ele); };
};	

function statMenu(menuStats,itemtext,desc,tid) {
	isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
	var ele=document.getElementById(itemtext+'1');
	if (!ele) return;
	if (desc) ele.parentNode.insertBefore(createNewEle('h2'),ele).appendChild(document.createTextNode(desc));
	ele.previousSibling.style.display="block";
	var base=ele.parentNode.insertBefore(createNewEle('div'),ele);
	base.className='nav';
	if (tid) base.id=tid;
	for(var i=0; i<menuStats.length; i++) {
		var aEle;
		(aEle=base.appendChild(createNewEle('div')).appendChild(createNewEle('a'))).appendChild(document.createTextNode(menuStats[i]));
		aEle.id=itemtext+(i+1)+'a';
		aEle.href='javascript:switchCells('+(i+1)+',\''+itemtext+'\','+menuStats.length+')';
		aEle.title='Show '+menuStats[i]+' - without page reload';
	};
	hideH2(itemtext,menuStats.length);
	switchCells(1,itemtext,menuStats.length);
}




// ***********************************************************************************
// XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        
// Code licensed under Creative Commons Attribution-ShareAlike License     
// http://creativecommons.org/licenses/by-sa/2.0/                           
// ***********************************************************************************
// ***********************************************************************************
// BLOG:CMS comments - (c) Radek Hulan, http://hulan.cz                    
// Code licensed under Creative Commons Attribution-ShareAlike License      
// http://creativecommons.org/licenses/by-sa/2.0/                           
// ***********************************************************************************



// ***********************************************************************************
// script (c) and written by aleto and Radek Hul�n
// http://aleto.ch/ | http://hulan.cz/
// ***********************************************************************************

// This work is licensed under the Creative Commons Attribution License. To  view a
// copy of this license, visit http://creativecommons.org/licenses/by/1.0/  or send
// a letter to Creative Commons, 559 Nathan Abbott Way, Stanford,  California 94305,
// USA.

// rev 13/09/2004 | rev 20/01/2007


// ***********************************************************************************
// Copyright (C) Radek HULAN
// http://hulan.cz/contact/
// ***********************************************************************************

// This work is licensed under the Creative Commons Attribution License. To  view a
// copy of this license, visit http://creativecommons.org/licenses/by/1.0/  or send
// a letter to Creative Commons, 559 Nathan Abbott Way, Stanford,  California 94305,
// USA.

function setSelectionRange(input, selectionStart, selectionEnd) {
  if (input.setSelectionRange) {
    input.focus();
    input.setSelectionRange(selectionStart, selectionEnd);
  }
  else if (input.createTextRange) {
    var range = input.createTextRange();
    range.collapse(true);
    range.moveEnd('character', selectionEnd);
    range.moveStart('character', selectionStart);
    range.select();
  }
}

function ct(textpre,textpost){ 
 var ele;
 if (ele=document.getElementById('nucleus_cf_body')) {
 	if (ele.setSelectionRange) {
 		var start = ele.selectionStart;
 		var end = ele.selectionEnd; 
 		ele.value = ele.value.substring(0, start) + textpre + ele.value.substring(start, end) + textpost + ele.value.substring(end);
 		var pos = start + textpre.length + textpost.length + (end-start)+1;
 		setSelectionRange(ele, pos, pos);
 	} else if (document.selection) {
 		ele.focus();
 		document.selection.createRange().text = textpre + document.selection.createRange().text + textpost;
	}
 }
}

function commentFormExtras(){
	isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
	var ele=document.getElementById('nucleus_cf_body');
	if (!ele) return;
	var base=ele.parentNode.insertBefore(createNewEle('div'),ele);
	base.id='toolbar';
	var toolbar=['bold','italic'];
	var href1=['[strong]write text here','[cite]write text here'];
	var href2=['[/strong]','[/cite]'];
	var title=['bold text','citation','emphasized text','short quotation','abbreviation','source code','unordered list','link/anchor'];
	for(var i=0; i<toolbar.length; i++) {
		var aEle;
		(aEle=base.appendChild(createNewEle('a'))).appendChild(document.createTextNode(toolbar[i]));
		aEle.href='javascript:ct(\''+href1[i]+'\',\''+href2[i]+'\')';
		aEle.title=title[i];
	};
}

function isValidComment(f) {
	if (f.body.value == "") {
		alert('Please enter your comment!');
		return false;
	}
	if (f.user.value == "") {
		alert('Please enter your name and/or nickname!');
		return false;
	}
	if(f.security_code.value==""){
		alert('Please copy the check code');
		return false;	
	}
	return true;
}

// Otevirani novych oken pro obrazky

function nic() {}


function NoveOkno(url) {
	 window.open(url,'','width=800,height=600,left=0,top=0,scrollbars=yes,location=no,menubar=no,resizable=yes');
	//alert(url);	
	
}

function IdReply(idreply,idname,re_date) {
	document.getElementById('id_reply').value=idreply;
    document.getElementById('id_name').value=idname;
	document.getElementById('re_date').value=re_date;
	//alert (re_date);
	
}

