/**
 * Otevirani odkazu (s rel="external") do noveho okna
 */
function externalLinks() {
	var anchors = document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute('rel') == 'external') {
			anchor.target = '_blank';
		}
	}
}

/**
 * Prednastaveni hodnot form. poli
 */
function innerHelp(defaults) {
	for (var id in defaults) {
		var el = document.getElementById(id);
		if (el !== null) {
			el.value = defaults[id];
			el.className = 'innerhelp';
			el.onfocus = function(id) {
				return function() {
					if (this.value == defaults[id]) {
						this.value = '';
						this.className = '';
					}
				}
			}(id);
			el.onblur = function(id) {
				return function() {
					if (this.value == '') {
						this.value = defaults[id];
						this.className = 'innerhelp';
					}
				}
			}(id);
		}
	}
}

/**
 * Osetreni hlavniho sloupce aby nebyl kratsi nez postranni sloupce
 */
function layoutCoordination() {
  var leftcol = document.getElementById('leftcol');
  var maincol1 = document.getElementById('maincol1');
  var maincol2 = document.getElementById('maincol2');
  var rightcol = document.getElementById('rightcol');
  maincol1.style.height='';
  maincol2.style.height = Math.max(leftcol.offsetHeight, maincol1.offsetHeight, maincol2.offsetHeight, rightcol.offsetHeight) + 'px';
  
	/* původní funkce (obsahovala chybu)
  var leftcol = document.getElementById('leftcol');
	var maincol = document.getElementById('maincol2');
	var rightcol = document.getElementById('rightcol');
	maincol.style.height = Math.max(leftcol.offsetHeight, maincol.offsetHeight, rightcol.offsetHeight) + 'px';
	*/
}

swfobject.embedSWF('/templates/velkyhrac/images/flash.swf', 'flash', '790', '201', '9.0.0', 'expressInstall.swf', {}, {menu: 'false', wmode: 'transparent'});

window.onload = function() {
	externalLinks();

	innerHelp({
		'name': 'E-mail',
		'pswd': 'Heslo',
		'q': 'Hledaný výraz…'
	});

	/**
	 * Naplneni vypisu

	var list = document.getElementById('vypis');

	var item = list.getElementsByTagName('li')[0];

    for (var i = 1; i < 10; i++) {
		var temp = item.cloneNode(true);
		if (i%3 === 0) {
			temp.className = 'last';
		}
		list.appendChild(temp);
    }

	list.removeChild(item);
    */
	/**
	 * Koordinace vysky hlavniho sloupce
	 */
	layoutCoordination();
}
