var i, thisItem, thisLink, thisInput, timer;
var js_id = 0;
var domena = document.location + '';

domena = domena.indexOf("www.divcihokej.cz") != -1 ? 'www.divcihokej.cz' : 'w.divcihokej.cz'

// partneri
var timerScroll = null;
var timerPos = 400;
var timerMove = 2;
var scrollPause = false;
var scrollHMTL = true;

function _showPartners () {
	var thisScroll = myGet('scroll');
	
	if (thisScroll && scrollHMTL) {
		thisScroll.innerHTML = thisScroll.innerHTML + thisScroll.innerHTML;
		//thisScroll.innerHTML = thisScroll.innerHTML + thisScroll.innerHTML;
		//thisScroll.innerHTML = thisScroll.innerHTML + thisScroll.innerHTML;
		//thisScroll.innerHTML = thisScroll.innerHTML + thisScroll.innerHTML;
		scrollHMTL = false;
	}
	
	if (thisScroll && !scrollPause) {
		if (thisScroll.scrollHeight < Math.abs(timerPos)) {
			timerPos = 400;
		}
		timerPos = timerPos - timerMove;
		thisScroll.style.top = timerPos + 'px';
	}
	
	clearTimeout(timerScroll);
	timerScroll = window.setTimeout("_showPartners()", 30);
}

// menu - zobraz
function _menuShowSub () {
	if (this.getElementsByTagName('ul').length > 0) {
		for (i = 0 ; i < this.getElementsByTagName('ul').length ; i++) {
			//this.getElementsByTagName('ul')[i].style.visibility = 'visible';
			this.getElementsByTagName('ul')[i].style.display = 'block'; 
		}
	}
}

// menu - skryj
function _menuHideSub () {
	if (this.getElementsByTagName('ul').length > 0) {
		for (i = 0 ; i < this.getElementsByTagName('ul').length ; i++) {
			//this.getElementsByTagName('ul')[i].style.visibility = 'hidden';
			this.getElementsByTagName('ul')[i].style.display = 'none'; 
		}
	}
}

// menu - inicializace
function _menuInit (id) {
	var thisMenu = myGet(id);

	if (thisMenu && thisMenu.getElementsByTagName('ul').length > 0){
		if (thisMenu.getElementsByTagName('ul').length > 0) {
			for (i = 0 ; i < thisMenu.getElementsByTagName('ul').length ; i++) {
				//thisMenu.getElementsByTagName('ul')[i].style.visibility = 'hidden'; 
				thisMenu.getElementsByTagName('ul')[i].style.display = 'none'; 
			}
		}
	
		var li = thisMenu.firstChild;
		while (li) {
			li.onmouseover = _menuShowSub;
			li.onmouseout  = _menuHideSub;
			li = li.nextSibling;
		}
	}
}

// zmena jazyka formulare
function _formular_jazyk (id, lang) {
	document.location = '/prihlasky/?jazyk=' + lang + '&prihlaska_id=' + id;
}

// business point
function _business_point (id) {
	var thisButton = myGet('button_' + id);
	var thisInfo = myGet('info_' + id);
	var thisTable = myGet('tabulka_' + id);
	var thisFoto = myGet('foto_' + id);
	
	if (thisButton && thisInfo && thisTable && thisFoto) {
		thisButton.style.display = 'none';
		thisInfo.className = 'pt8';
		thisTable.className = 'info';
		thisFoto.className = 'visible';
	}
}

// burza turnaju
function _turnaj (thisInput, pridej, zavri) {
	thisItem = myGet('turnaj');
	
	if (thisItem) {
		if (thisItem.className == "hidden") {
			thisItem.className = 'visible';
			thisInput.value = zavri;
		} else {
			thisItem.className = 'hidden';
			thisInput.value = pridej;
		}
	}
}

// ptejte se
function _dotaz (thisInput, pridej, zavri) {
	thisItem = myGet('dotaz');
	
	if (thisItem) {
		if (thisItem.className == "hidden") {
			thisItem.className = 'visible';
			thisInput.value = zavri;
		} else {
			thisItem.className = 'hidden';
			thisInput.value = pridej;
		}
	}
}

/*
// hlasovani do ankety
function _anketa (item) {
	document.location = item.href;
}*/

// hlasovani do ankety
function _anketa (uri) {
	document.location = uri;
}

// AJAX
function _load_JS (url) {
	var script = document.createElement('script');
	var thisHead = document.getElementsByTagName('head')[0];

	if (js_id > 0) {
		thisHead.removeChild(thisHead.lastChild);
	}
	
	js_id++;
	script.id = 'scriptLoader';
	script.src = url;

	if (typeof(thisHead.appendChild(script)) != "undefined") {
		return true;
	} else {
		return false;
	}
}

// nove vokno
function _new_window (object) {
	window.open(object.href);
	
	return false;
}

// ziskani elementu
function myGet (name) {
	if (document.getElementById)
		return document.getElementById(name);
	else if (document.all)
		return document.all(name);
	else
		return null;
}
