var secs
var timerID = null
var timerRunning = false
var delay = 200
var menumouseover = false;

function setover(state) {
	menumouseover = state;
}

function dropDownMenu(off)
{
	var element = document.getElementById('admin_menu');
	if (off)
		element.style.display = menumouseover ? "block" : "none";
	else if(!menumouseover && element.style.display == "block")
		element.style.display = "none";
	else
		element.style.display =	"block";
	return false;
}


function setDir(form)
{
	var sdiak = "ěščřžýáíéňďťľůúíó ĚŠČŘŽÝÁÍÉŇĎŤĽŮÚÍÓ"; 
	var bdiak = "escrzyaiendtluuio escrzyaiendtluuio";
	tx = ""; 
	txt = form.surename.value; 
	for(p = 0; p < txt.length; p++)  { 
		if (sdiak.indexOf(txt.charAt(p)) != -1) { 
			tx += bdiak.charAt(sdiak.indexOf(txt.charAt(p))); 
		} 
		else tx += txt.charAt(p); 
	} 
	form.directory.value = tx.toLowerCase(); 
}

function show(what) {
	var element = document.getElementById(what);
	if (element.style.display == "block")
		element.style.display = "none";
	else
		element.style.display = "block";
}

function showPhoto(source) {
	document.getElementById('photo').src = source;
}

var intg;
var ori = 1;
var rotelement = ['rotatenews', 'content'];
var rotheight = [340, 375];
var rotwhat = 0;
var rotspeed = 2;


function startup() {
	initLightbox();
	if ( document.getElementById('content-div').clientHeight >= 375 ) {
		show('content-up');
		show('content-down');
	}
	
	if ( document.getElementById('rotatenews-div').clientHeight >= 340 ) {
		show('news-up');
		show('news-down');
	}
}


function rotcycledown() {
	if(document.getElementById(rotelement[rotwhat]).scrollTop >= document.getElementById(rotelement[rotwhat]+'-div').clientHeight - rotheight[rotwhat]) {
		//ori = 0;
		clearInterval(intg);
		//intg=setInterval('rotcycleup();',10);
	}
	else document.getElementById(rotelement[rotwhat]).scrollTop = document.getElementById(rotelement[rotwhat]).scrollTop+rotspeed;
}

function rotcycleup() {
	if(document.getElementById(rotelement[rotwhat]).scrollTop <= 5) {
		//ori = 1;
		clearInterval(intg);
		//intg=setInterval('rotcycledown();',10);
	}
	else document.getElementById(rotelement[rotwhat]).scrollTop = document.getElementById(rotelement[rotwhat]).scrollTop-rotspeed;
}
    
function rotcycle(element, move, direction, speed) {
	rotspeed = speed;
	rotwhat = element;
	ori = direction;
	clearInterval(intg);
	if(move != 0)
		if (ori) intg=setInterval('rotcycledown();', 10);
		else intg=setInterval('rotcycleup();', 10);
}

function InitializeTimer(time)
{
    // Set the length of the timer, in seconds
    secs = time;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        dropDownMenu(1);
    }
    else
    {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

