﻿function noSelect(trida) {
	var objs = document.getElementsByClassName('no-select');
	for(var i = 0; i < objs.length; i++) {
		objs[i].onselectstart = function() { return false }
	}
}

document.getElementsByClassName = function(searchClass,tag,node){
	var p = function(){
		if([].push)return function(a,b){a.push(b)};
		return function(a,b){a[a.length]=b}
	}();
 
	node = node || document;
	tag = tag || '*';
 
	if(document.evaluate){
		var xpr = document.evaluate([".//",tag,"[contains(concat(' ',@class,' '),' ",searchClass," ')]"].join(''),node, null, 0, null),
		t = true,
		els = new Array();
		while(t=xpr.iterateNext()) {
			p(els,t);
		}
		return els;
	}

	var els = node.getElementsByTagName(tag),
	pattern = new RegExp(["(^|\\s)",searchClass,"(\\s|$)"].join('')), 
	ce = new Array();

	for (var i = 0, max = els.length; i < max; i++) {
		if(pattern.test(els[i].className))
		p(ce,els[i]);
	}
	return ce;
}

function is_ie6(){
     return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined));
}
function is_ie() {
	return (typeof( window.innerWidth ) == 'number' ) ? false : true;
}
function onload_js() {
	
}
function overeni_enteru(eventname, id, reload_url, div, fce) {
	if (eventname.keyCode == "13") {
		odeslani_strankovani(id, reload_url, div, fce);
	}
}
function odeslani_strankovani(id, reload_url , div, fce) {
	ajaxWM(reload_url+'&r_limit='+document.getElementById(id).value, div, fce);
}
	
function qedit2(zapnout, obj) {
	if (zapnout == 1) {
		document.getElementById(obj).style.display = 'block';
		document.getElementById(obj+'-div').style.display = 'block';
	} else if (zapnout == 2) {
		if (document.getElementById(obj).style.display == 'block') {
			document.getElementById(obj).style.display = 'none';
			document.getElementById(obj+'-div').style.display = 'none';
		} else {
			document.getElementById(obj).style.display = 'block';
			document.getElementById(obj+'-div').style.display = 'block';
		}
	} else {
		document.getElementById(obj).style.display = 'none';
		document.getElementById(obj+'-div').style.display = 'none';
	}
}
function qedit(zapnout, obj) {
	if (zapnout == 1) {
		document.getElementById(obj).style.display = 'block';
		document.getElementById(obj+'-div').style.display = 'block';
	} else if (zapnout == 2) {
		if (document.getElementById(obj).style.display == 'block') {
			document.getElementById(obj).style.display = 'none';
			document.getElementById(obj+'-div').style.display = 'none';
		} else {
			document.getElementById(obj).style.display = 'block';
			document.getElementById(obj+'-div').style.display = 'block';
		}
	} else {
		document.getElementById(obj).style.display = 'none';
		document.getElementById(obj+'-div').style.display = 'none';
	}
}
function only_integer(cislo) {
	var re = /[^0-9]/g;
	cislo.value = cislo.value.replace(re,"");
}
function only_float(cislo) {
	var re = /[^0-9\.\,]/g;
	var re2 = /(,)/; 
	cislo.value = cislo.value.replace(re,"");
	cislo.value = cislo.value.replace(re2,"."); // první čárku nahradím za tečku
}
function only_chars(cislo) {
	var re = /[^a-žAŽ]/g;
	cislo.value = cislo.value.replace(re,"");
}

function color_over (ten, vol) {
	if (vol == 1) return ten.style.backgroundImage='url(\'/images/pozadi_bunky2.gif\')';
	if (vol == 2) return ten.style.backgroundImage='url(\'/images/pozadi_bunky.gif\')';
	if (vol == 3) return ten.style.backgroundImage='url(\'/images/pozadi_bunky3.gif\')';
	if (vol == 4) return ten.style.backgroundImage='url(\'/images/pozadi_bunky4.gif\')';
	if (vol == 5) return ten.style.backgroundImage='url(\'/images/pozadi_bunky5.gif\')';
}

function showObject(oID, zobraz) {
	if(zobraz == 0 || getObj(oID).style.display != 'none') {
		getObj(oID).style.display = 'none';
	} else {
		getObj(oID).style.display = '';
	}
}
function opacity(id, opacStart, opacEnd, millisec, obj) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
		}
		if(obj != "") {
			text2value(obj,'');
		}
		Effect.BlindUp(id);; return false;
		//setTimeout("showObject('"+id+"',0)",millisec+150);
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
		Effect.BlindDown(id);; return false;
		//setTimeout("showObject('"+id+"',1)",0);
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
function activeNdeactive(zaktivnit, zneaktivnit) { // aktivní může být pouze jeden
	for(var a = 0; a < zneaktivnit.length; a++) {
		getObj(zneaktivnit[a]).disabled = true;
	}
	getObj(zaktivnit).disabled = false;
	getObj(zaktivnit).focus();
}
// klávesové zkratky
var isAltKeyPressed = false;
var isCtrlKeyPressed = false;
var isShiftKeyPressed = false;
var hotkeyactive = true;
function hotkey(eventname) {
	/*if (eventname.keyCode == 18) isAltKeyPressed = true;
	if (eventname.keyCode == 17) isCtrlKeyPressed = true;
	if (eventname.keyCode == 16) isShiftKeyPressed = true;*/
	
	if (hotkey1[eventname.keyCode] && hotkeyactive) {
		window.location.href = hotkey1[eventname.keyCode];
	}
}
function hotkeysetfocus() {
	for (var i = 0; i < document.forms.length; i++) {
		for (var i2 = 0; i2 < document.forms[i].length; i2++) {		
			if (document.forms[i].elements[i2].type != 'submit' && document.forms[i].elements[i2].type != 'button' && document.forms[i].elements[i2].type != 'reset') {
				document.forms[i].elements[i2].onfocus = fnc_hotkeydeactive;
				document.forms[i].elements[i2].onblur = fnc_hotkeyactive;
			}
		}
	}
}
function fnc_hotkeydeactive() {
	hotkeyactive = false;
}
function fnc_hotkeyactive() {
	hotkeyactive = true;
}

function loading(obj) {
	getObj(obj).style.position = 'relative';
	sirka = getObj(obj).offsetWidth;
	vyska = getObj(obj).offsetHeight;
	// pomocné
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		browserHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		browserHeight = document.documentElement.clientHeight;
	}
	
	if (vyska > browserHeight * 1.5) atributy = ' valign="top" style="padding-top: 50px"'; else atributy = '';
	if (!getObj('loading-div')) getObj(obj).innerHTML += '<div style="width: '+sirka+'px; height: '+vyska+'px;" id="loading-div" class="clona-loading"></div><div style="width: '+sirka+'px; height: '+vyska+'px;" id="loading-div2" class="clona-loading2"><table width="100%" style="height: 100%"><tr><td align="center"'+atributy+'><div class="preloader"><p>Probíhá načítání...</p></div></td></tr></table></div>';
}
function znicDiv() {
	obj = getObj('loading-div');
	obj2 = getObj('loading-div2');
	rodic = document.body;
	rodic.removeChild(obj);
	rodic.removeChild(obj2);
}

// AJAX FUNCTIONS
// metoda GET s intervalem opakování 1/1000
function ajaxWMrefresh(url, div, interval) {
	setInterval('ajaxWM(\''+url+'\', \''+div+'\')', interval);
}
// metoda GET
function ajaxWM(url, div, fce, clona) {
	if (clona == null || clona == undefined || clona == '') clona = 0;
	if (clona == 1 && div != undefined && div != '' && div != null) {
		loading(div);
	}
	var ajaxWMhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));

	ajaxWMhttp.open("get", url, true);
	ajaxWMhttp.onreadystatechange = function () {
		if (ajaxWMhttp.readyState == 4 && (ajaxWMhttp.status == 200 || ajaxWMhttp.status == 304)) {
			if (div != undefined && div != '' && div != null) {
				document.getElementById(div).innerHTML = ajaxWMhttp.responseText;
				if (clona == 1) getObj(div).style.position = 'inherit';
			}
			if (fce != undefined) {
				try {
					for(var i = 0; i < fce.length; i++) {
						eval(fce[i]);
					}
				} catch(e) {
					
				}
			}
		}
	};
	ajaxWMhttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
	ajaxWMhttp.send(null);
}
// metoda POST
function ajaxWMpost(oForm, div, fce) {
	var sBody = getRequestBody(oForm);
	var ajaxWMhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
	
	ajaxWMhttp.open("post", oForm.action, true);
	ajaxWMhttp.onreadystatechange = function () {
		if (ajaxWMhttp.readyState == 4 && (ajaxWMhttp.status == 200 || ajaxWMhttp.status == 304)) {
			if (getObj(div).style.display == 'none') getObj(div).style.display = '';
			
			document.getElementById(div).innerHTML = ajaxWMhttp.responseText;
			
			if (fce != undefined) {
				try {
					for(var i = 0; i < fce.length; i++) {
						eval(fce[i]);
					}
				} catch(e) {
					
				}
			}
		} else {
			// 1 - loading - metoda open() byla zavolána, ale požadavek nebyl odeslán
			// 2 - loaded - poažadavek byl odeslán
			// 3 - interactive - část odpovědi byla přijata
			// 4 - všechna data byla přijata a spojení bylo uzavřeno
			// alert(ajaxWMhttp.readyState);
		}
	};
	ajaxWMhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajaxWMhttp.send(sBody);
}

var hledani_stopky = '';
function hledani(form,div){ // funkce, která zajišťuje volání ajaxu až po uběhnutí určitého času
	clearInterval(hledani_stopky);
	hledani_stopky = setInterval("hledani_ajax('"+form+"','"+div+"')", 0.25 * 1000);
}
function hledani_ajax(form,div) { // zavolá funkci, která znovu odešle data a načte nový výsledek hledání
	clearInterval(hledani_stopky);
	ajaxWMpost(getObj(form), div, Array("initCheckBoxes('seznam-seznamu')"));
}
function encodeNameAndValue(sName, sValue) {
	var sParam = encodeURIComponent(sName);
	sParam += "=";
	sParam += encodeURIComponent(sValue);
	return sParam;
}
function getRequestBody(oForm) {
	var aParams = new Array();
	for (var i=0; i < oForm.elements.length; i++) {
		var oField = oForm.elements[i];
		switch (oField.type) {
			case "button":
			case "submit":
			case "reset":
				break;
			
			case "checkbox":
				if (!oField.checked) {
					break;
				}
			case "radio":
				if (!oField.checked) {
					break;
				}
				
			case "text":
			case "hidden":
			case "password":
				aParams.push(encodeNameAndValue(oField.name, oField.value));
				break;
			default:
				switch(oField.tagName.toLowerCase()) {
					case "select":
						aParams.push(encodeNameAndValue(oField.name, oField.options[oField.selectedIndex].value));
						break;
					default:
						aParams.push(encodeNameAndValue(oField.name, oField.value));
				}
		}
	}
	return aParams.join("&");
}
// KONEC AJAX FUNCTIONS
// číslo na tisíce
function number_format(cislo) { // -1000.10 - 1001
	var str = "";
	var str2 = "";
	var cislo_des = "";
	var pos = 0;
	
	cislo_des = cislo + "";
	pos = cislo_des.lastIndexOf(".");
	if (pos > 0) {
		cislo_des = "." + cislo_des.slice(pos + 1);
	} else {
		cislo_des = "";
	}
	
	if (cislo < 0) { // ošetření zaokrouhlení na celá čísla
		cislo = Math.ceil(cislo);
	} else {
		cislo = Math.floor(cislo);
	}
	
	str = cislo + "";
	if (str.length > 3 && str.length < 7) {
		str2 = str.substr(0, 0 + str.length - 3) + " " + str.substr(0 + str.length - 3);
		str2 = str2 + cislo_des; if (cislo_des.length == 2) str2 = str2 + "0";
		return str2;
	} else if (str.length > 6 && str.length < 10) {
		str2 = ( str.substr(0, 0 + str.length - 6) + " ");
		str = str.substr(str.length - 6);
		
		str2 = str2 + "" + ( str.substr(0, 0 + str.length - 3) + " " + str.substr(0 + str.length - 3) );
		str2 = str2 + cislo_des; if (cislo_des.length == 2) str2 = str2 + "0";
		return str2;
	} else if (str.length > 9 && str.length < 13) {
		str2 = ( str.substr(0, 0 + str.length - 9) + " ");
		str = str.substr(str.length - 9);
		
		str2 = str2 + "" + ( str.substr(0, 0 + str.length - 6) + " ");
		str = str.substr(str.length - 6);
		
		str2 = str2 + "" + ( str.substr(0, 0 + str.length - 3) + " " + str.substr(0 + str.length - 3) );
		str2 = str2 + cislo_des; if (cislo_des.length == 2) str2 = str2 + "0";
		return str2;
	}
	
	str = str + cislo_des; if (cislo_des.length == 2) str = str + "0";
	return str;
}

function vypsat_video(sirka, vyska, nazev, typ) {
	//if (typ == 0) {
		//document.write('<object id="WMPlay" ' + sirka + ' ' + vyska + ' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,70" standby="Loading ..." type="application/x-oleobject">');
		//document.write('<param name="url" value="/video/' + nazev + '">');
		/*document.write('<param name="displaysize" value="0">');
		document.write('<param name="allowchangedisplaysize" value="1">');
		document.write('<param name="showcontrols" value="1">');
		document.write('<param name="windowlessvideo" value="0">');
		document.write('<param name="showdisplay" value="1">');
		document.write('<param name="showstatusbar" value="1">');
		document.write('<param name="autostart" value="1">');
		document.write('<param name="Invokeurls" value="0">');*/
	//}
	//if (typ == 1) {
		document.write('<embed name="WMplay" ' + sirka + ' ' + vyska + ' src="/video/' + nazev + '" loop="0" autoplay="0"></embed>');
	//}
	//if (typ == 0) { 
		//document.write('</object>');
	//}
}
function otevri(url, sirka, vyska) {
	window.open(url, "_blank", "width="+sirka+", height="+vyska+", menubar=1, directories=no, toolbar=no, location=no, status=yes, scrollbars=yes, resizable=yes");
}
function img_nahled(adresa, sirka_okna, vyska_okna) {
	window.open("/img_nahled.php?foto="+adresa, "_blank", "width="+sirka_okna+", height="+vyska_okna+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars=no, resizable=no");
}
function img_nahled2(foto) {
	window.open("/img_nahled2.php?foto="+foto, "_blank", "width=1024, height=768, menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars=yes, resizable=yes");
}
function img_nahled_galerie(adresa, foto, strana, sirka_okna, vyska_okna) {
	window.open("/img-nahled.php?adresa="+adresa+"&foto="+foto+"&strana="+strana, "_blank", "width="+sirka_okna+", height="+vyska_okna+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars=yes, resizable=yes");
}
function spam_email(vol1, vol2, vol3, vol4) {
	var vol = vol4 + vol2 + vol3 + vol1; 
	document.write("<a href=\"mailto:"+ vol +"\">" + vol + "</a>");
}
function vypsat_flash(adresa,sirka,vyska,pozadi) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+sirka+'" height="'+vyska+'" id="flashik" align="middle"><param name="wmode" value="opaque"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+adresa+'"><param name="quality" value="high"><param name="bgcolor" value="'+pozadi+'">');
	document.write('<embed wmode="opaque" src="'+adresa+'" quality="high" bgcolor="'+pozadi+'" width="'+sirka+'" height="'+vyska+'" name="flash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	document.write('</object>');
}
function AddFavorite(linkObj,addUrl,addTitle) 
{ 
  if (document.all && !window.opera) 
  { 
    window.external.AddFavorite(addUrl,addTitle); 
    return false; 
  } 
  else if (window.opera && window.print) 
  { 
    linkObj.title = addTitle; 
    return true; 
  } 
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) 
  { 
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?')) 
    { 
      window.sidebar.addPanel(addTitle,addUrl,''); 
      return false; 
    } 
  } 
  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.'); 
  return false; 
}

function getObj(name)
{
 if (document.getElementById) {
   return document.getElementById(name);
 } else
		if (document.all) {
			return document.all[name];
		} else
			if (document.layers) {
				return document.layers[name];
			} else return false;
}

function doBox() {
	var state = doBox.arguments[0];
	var i;
	for (i=1; i<doBox.arguments.length; i++) {
		switch(state) {
			case 'on':
				doEnableItem( doBox.arguments[i] );
			break;
			case 'off':
				doDisableItem( doBox.arguments[i] );
			break;
			default:
			;
		}
	}
}

function doCheck() {
	var i;
	for (i=0; i<doCheck.arguments.length; i++) {
		var obj = document.getElementById(doCheck.arguments[i]);
		if (obj!='undefined' && obj!=null) {
				obj.checked = true;
		}
	}
}

function doEnableItem(id) {
	var obj = document.getElementById(id);
	if (obj!='undefined' && obj!=null) {
			obj.disabled = false;
	}
	var obj = getObj(id+'T');
	if (obj!='undefined' && obj!=null) {
		getObj(id+'T').style.color = '#000000';
	}

}

function doDisableItem(id) {
	var obj = document.getElementById(id);
	if (obj!='undefined' && obj!=null) {
		obj.disabled = true;
	}
	var obj = getObj(id+'T');
	if (obj!='undefined' && obj!=null) {
		getObj(id+'T').style.color = '#888888';
	}
}

function selectAll(id) {
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function hvezdicky(num, stav, produkt) {
	var zbytek = 5 - stav;
	zbytek = 6 - zbytek;
	if(stav == 0 && num > 0) {
		for(i = 1; i <= 5; i++) {
			getObj('hvezdicka'+produkt+i).src = '/images/icons/star-blank.gif';	
		}
		for(j = 1; j <= num; j++) {
			getObj('hvezdicka'+produkt+j).src = '/images/icons/star.gif';	
		}
	} else if(stav > 0 && num == 0) {
		for(k = 1; k <= stav; k++) {
			getObj('hvezdicka'+produkt+k).src = '/images/icons/star.gif';	
		}
		for(k2 = zbytek; k2 <= 5; k2++) {
			getObj('hvezdicka'+produkt+k2).src = '/images/icons/star-blank.gif';	
		}
	} else if(stav == 0 && num == 0) {
		for(i = 1; i <= 5; i++) {
			getObj('hvezdicka'+produkt+i).src = '/images/icons/star-blank.gif';	
		}
	}
}

function trim(str) {
	return ltrim(rtrim(str));
}

function ltrim(str) {
	if (typeof(str) == 'string'){
		chars = "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	} else{
		return '';
	}
}

function rtrim(str) {
	if (typeof(str) == 'string'){
		chars = "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	} else{
		return '';
	}
}
function checkIt(box) {
	if(getObj(box).checked == false && getObj(box).disabled == false) getObj(box).checked = true;
	else getObj(box).checked = false;
}
function procenta(zaklad, cast) {
	var procento = parseFloat(zaklad)/100;
	return Math.round(cast/procento)-1;
}

function dialogBox(obj,zavrit) {// if (zavrit == 1) clona se nezavře po kliknutí mimo div
	if(zavrit == undefined) var zavrit = 0;
	
	if(getObj(obj).style.display == 'none') {
			
		if(getObj('clona') != undefined) {
			document.body.removeChild(getObj('clona'));
		}
		// pomocné
		var browserWidth = document.body.scrollWidth;
		var leftPosition = ( browserWidth - parseFloat( getObj(obj).style.width.replace('px', '') ) ) / 2;

		// vytvořím element "clona"
		var clona = document.createElement('div');
		clona.setAttribute('id', 'clona');
		
		// nastylování clony
		clona.style.width = '100%';
		clona.style.height = '100%';
		clona.style.backgroundColor = '#000000';
		clona.style.opacity = '0.7';
		clona.style.filter = 'alpha(opacity=70)';
		clona.style.position = 'fixed';
		clona.style.top = '0px';
		clona.style.left = '0px';
		clona.style.zIndex = '2000';
		
		// skrytí clony po kliknutí
		if (zavrit == 0) clona.onclick = function() { dialogBox(obj) } ; 
		
		// vložím clonu
		document.body.appendChild(clona);
		
		// zobrazím objekt a nastyluji
		//clona.appendChild(getObj(obj));
		getObj(obj).style.display = '';
		getObj(obj).style.zIndex = '2002';
		getObj(obj).style.opacity = '1';
		getObj(obj).style.top = '30%';
		getObj(obj).style.left = procenta(browserWidth, leftPosition)+'%';
	} else {
		getObj('clona').style.display = 'none';
		getObj('clona').style.zIndex = '0';
		getObj(obj).style.display = 'none';
	}
}

var checkedValue = null;
var globalKeyCode = 0;
function initCheckBoxes(obj, byCtrlKey, tag, classOver, classOut) { // tag - td nebo tr
	if(byCtrlKey == undefined || byCtrlKey == null || byCtrlKey == '') byCtrlKey = 0;
	if(tag == undefined) tag = 'tr';
	if(is_ie()) document.getElementById(obj).onselectstart = function() { return false }
	var cells = document.getElementById(obj).getElementsByTagName(tag);
	for(var i = 0; i < cells.length; i++) {
		var checkbox = cells[i].getElementsByTagName('input');
		if (checkbox.length > 0 && checkbox[0].type.toLowerCase() == 'checkbox') {
			cells[i].checkBoxObj = checkbox[0];
			cells[i].onmousedown = tdOnMouseDown;
			cells[i].onmouseover = tdOnMouseOver;
			cells[i].tableCells = cells;
			cells[i].ctrlKey = byCtrlKey;
			cells[i].classOver = (classOver != undefined) ? classOver : 'tr2_border7';
			cells[i].classOut = (classOut != undefined) ? classOut : 'tr2_border';
			checkbox[0].onclick = function() { this.checked = (this.checked == true) ? false : true; }
			
			// na míru
			if(obj == "seznam-seznamu") {
				if(checkbox[0].checked == true) cells[i].className = "tr2_border7";
				else cells[i].className = "tr2_border";
			}
		}
	}
}

function tdOnMouseDown(ctrlKey) {
	window.onkeydown = function(e) {
		globalKeyCode = e.keyCode;
	}
	window.onkeyup = function() {
		globalKeyCode = 0;
	}
	//if ((this.checkBoxObj && tlacitko == undefined) || (this.checkBoxObj && tlacitko == 'ctrl' && ev.ctrlKey)) {
	if ((this.checkBoxObj && this.ctrlKey == 0) || (this.ctrlKey == 1 && globalKeyCode != 17)) {
		if(this.ctrlKey == 1) {
			for(var i = 0; i < this.tableCells.length; i++) {
				var checkbox = this.tableCells[i].getElementsByTagName('input');
				if (checkbox.length > 0 && checkbox[0].type.toLowerCase() == 'checkbox') {
					checkbox[0].checked = false;
					this.tableCells[i].className = this.classOut;
				}
			}
		}
		checkedValue = (this.checkBoxObj.disabled == false) ? this.checkBoxObj.checked = !this.checkBoxObj.checked : false;
		document.onmouseup = function() {
			document.onmouseup = null;
			document.onselectstart = null;
			checkedValue = null;	
		};
		if(this.checkBoxObj.checked == true && this.checkBoxObj.disabled == false) this.className = this.classOver;
		else this.className = this.classOut;
		document.onselectstart = function() { return false; }; // for IE
	} else if(this.checkBoxObj && this.ctrlKey == 1) {
		(this.checkBoxObj.disabled == false) ? this.checkBoxObj.checked = !this.checkBoxObj.checked : false;
		if(this.checkBoxObj.checked == true && this.checkBoxObj.disabled == false) this.className = this.classOver;
		else this.className = this.classOut;
	}
}

function tdOnMouseOver(ev) {
	if (checkedValue != null && this.checkBoxObj.disabled == false && this.checkBoxObj) this.checkBoxObj.checked = checkedValue;
	
	if (this.checkBoxObj.checked == true && this.checkBoxObj.disabled == false) this.className = this.classOver;
	else this.className = this.classOut;
}
