﻿function onload_js() {
	
}
function exportDat(url) {
	window.location.href = url;	
}
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 wOpen(url, velikost, zamknout, sirka, vyska, menubar) {
	if (menubar == undefined) menubar = 'no';
	// velikost okna
	if (velikost == "") {
	
	} else if (velikost == "FULLX") {
		sirka = screen.width;
		vyska = 700;
	} else if (velikost == "FULLY") {
		sirka = 300;
		vyska = 300;
	} else if (velikost == "XXL") {
		sirka = 1250;
		vyska = 700;
	} else if (velikost == "XL") {
		sirka = 1000;
		vyska = 700;
	} else if (velikost == "L") {
		sirka = 950;
		vyska = 700;
	} else if (velikost == "M") {
		sirka = 800;
		vyska = 600;
	} else if (velikost == "LS") {
		sirka = 950;
		vyska = 350;
	} else {
		
	}
	
	// vycentrování okna
	if ( typeof( window.innerWidth ) == 'number' ) { //Non-IE
		browserWidth = window.innerWidth;
	} else if ( document.documentElement && (document.documentElement.clientWidth) ) { //IE 6+ in 'standards compliant mode'
		browserWidth = document.documentElement.clientWidth;
	}
	var leftPosition = ( ( browserWidth ) - parseFloat( sirka ) ) / 2;
	
	if(document.all) var ie = true; else var ie = false;
	
	if (zamknout == 1 && ie == false) showModalDialog (url, null, "status:no;dialogLeft:"+leftPosition+";dialogTop:80;help:no;minimize:no;maximize:no;border:thin;dialogWidth:"+sirka+";dialogHeight:"+vyska); 
	else window.open(url, "_blank", "width="+sirka+",height="+vyska+",toolbar=no,location=no,directories=no,status=no,menubar="+menubar+",scrollbars=yes,resizable=yes,left="+leftPosition+",top=80,fullscreen=no");
}
var tab_current = 0;
function tab2(zalozka, page) {
	// všechny záložky schovám
	for(var i = 0; i < tab_count; i++) {
		getObj(allTabs[i]).style.display = 'none';
		if (i == 0) var trida = 'zalozka1'; else var trida = 'zalozka2';
		getObj('tab-'+allTabs[i]).className = trida;
	}
	// vybranou zobrazím
	if (zalozka != "") {
		getObj(zalozka).style.display = '';
		getObj('tab-'+zalozka).className = getObj('tab-'+zalozka).className+'-active';
	}
	// odešlu "ukládací" ajax
	ajaxWM('/admin/crm/tabs.script.php?akce=tab2&page1='+page+'&tab='+zalozka, null, Array());
}
function is_array(input) {
	return typeof(input)=='object'&&(input instanceof Array);
}
function is_int( mixed_var ) {
 
	if (typeof mixed_var !== 'number') {
		return false;
	}
 
	if (parseFloat(mixed_var) != parseInt(mixed_var, 10)) {
		return false;
	}
	
	return true;
}
function strpos( haystack, needle, offset){
	var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
	return i === -1 ? false : i;
}
function overeni_enteru(eventname, ide, reload_url, div, fce) {
	if (eventname.keyCode == "13") {
		odeslani_strankovani(ide, 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 setCursorPosition(elem, caretPos) {
	if(elem != null) {
		if(elem.createTextRange) {
			var range = elem.createTextRange();
			range.move('character', caretPos);
			range.select();
		}
		else {
			if(elem.selectionStart) {
				elem.focus();
				elem.setSelectionRange(caretPos, caretPos);
			}
		else
			elem.focus();
		}
	}
}

function getCursorPosition(o) {
	if (o.createTextRange) {
		var r = document.selection.createRange().duplicate()
		r.moveEnd('character', o.value.length)
		if (r.text == '') return o.value.length
		return o.value.lastIndexOf(r.text)
	} else return o.selectionStart
}

function only_integer(cislo, e) {
	var pos = getCursorPosition(cislo); // pozice kurzoru
	var re = /[^0-9]/g;
	var textBefore = cislo.value;
	var tab = false;
	
	// zachycení klávesy TAB (SHIFT+TAB)
	if(e != undefined && e != null) {
		if(!(e.keyCode == 16 || (e.keyCode == 9 && e.shiftKey) || (e.keyCode == 9 && !e.shiftKey))) tab = false;
		else tab = true;
	}
	
	if(!tab) {
		cislo.value = cislo.value.replace(re,"");
		var textAfter = cislo.value;
		
		// umístím kurzor
		setCursorPosition(cislo, (textAfter.length < textBefore.length) ? pos-1 : pos);
	}
}
function only_float(cislo, e) {
	var pos = getCursorPosition(cislo);
	var re = /[^0-9\.\,]/g;
	var re2 = /(,)/;
	var textBefore = cislo.value;
	var tab = false;
	
	// zachycení klávesy TAB (SHIFT+TAB)
	if(e != undefined && e != null) {
		if(!(e.keyCode == 16 || (e.keyCode == 9 && e.shiftKey) || (e.keyCode == 9 && !e.shiftKey))) tab = false;
		else tab = true;
	}
	
	if(!tab) {
		cislo.value = cislo.value.replace(re,"");
		cislo.value = cislo.value.replace(re2,"."); // první čárku nahradím za tečku
		
		var textAfter = cislo.value;
		
		// umístím kurzor
		setCursorPosition(cislo, (textAfter.length < textBefore.length) ? pos-1 : pos);
	}
}
function only_chars(cislo) {
	var pos = getCursorPosition(cislo);
	var re = /[^a-žAŽ]/g;
	var textBefore = cislo.value;
	
	cislo.value = cislo.value.replace(re,"");
	
	var textAfter = cislo.value;
	
	// umístím kurzor
	setCursorPosition(cislo, (textAfter.length < textBefore.length) ? pos-1 : pos);
}

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\')';
}
zi = 0;
function showObject(objID, zobraz) {
	if(zobraz == 1) {
		getObj(objID).style.display = '';
		getObj(objID).style.zIndex = '100'+zi;
	} else if(zobraz == 2) {
		getObj(objID).style.display = 'none';
		getObj(objID).style.zIndex = '0';
	} else if(getObj(objID).style.display != 'none') {
		getObj(objID).style.display = 'none';
		getObj(objID).style.zIndex = '0';
	} else {
		getObj(objID).style.display = '';
		getObj(objID).style.zIndex = '100'+zi;
	}
	zi += 1;
}
function showObject2(objID, zobraz) {
	if(zobraz == 1) {
		getObj(objID).style.display = '';
		getObj(objID).style.zIndex = '100'+zi;
		setTimeout("document.body.onclick = function() { showObject2('"+objID+"', 2) }", 10) ;
	} else if(zobraz == 2) {
		getObj(objID).style.display = 'none';
		getObj(objID).style.zIndex = '0';
		document.body.onclick = function() {  } ;
	} else if(getObj(objID).style.display != 'none') {
		getObj(objID).style.display = 'none';
		getObj(objID).style.zIndex = '0';
		document.body.onclick = function() {  } ;
	} else {
		getObj(objID).style.display = '';
		getObj(objID).style.zIndex = '100'+zi;
		setTimeout("document.body.onclick = function() { showObject2('"+objID+"', 2) }", 10) ;
	}
	zi += 1;
}
function showObject3(objID) {
	if(getObj(objID).style.visibility != 'hidden') {
		getObj(objID).style.visibility = 'hidden';
	} else {
		getObj(objID).style.visibility = '';
	}
}
function disable(objID, disable) {
	if(disable == 1) {
		getObj(objID).disabled = true;
	} else if(disable == 2) {
		getObj(objID).disabled = false;
	} else if(getObj(objID).disabled == true) {
		getObj(objID).disabled = false;
	} else {
		getObj(objID).disabled = true;
	}
}
function disableCheckboxes(name, disable) {
	if(is_array(name)) {
		for(var i = 0; i < name.length; i++) {
			document.getElementById(name[i]).disabled = ( (document.getElementById(name[i]).disabled == true || disable == 0) && disable != 1) ? false : true;
		}
	} else {
		for(var i = 0; i < document.getElementsByName(name).length; i++) {
			document.getElementsByName(name)[i].disabled = ( (document.getElementsByName(name)[i].disabled == true || disable == 0) && disable != 1) ? false : true;
		}
	}
}
function checkCheckboxes(name, check) {
	if(is_array(name)) {
		for(var i = 0; i < name.length; i++) {
			document.getElementById(name[i]).checked = ( ((document.getElementById(name[i]).checked == true || check == 0) && check != 1) || (document.getElementById(name[i]).disabled == true)) ? false : true;
		}
	} else {
		for(var i = 0; i < document.getElementsByName(name).length; i++) {
			document.getElementsByName(name)[i].checked = ( ((document.getElementsByName(name)[i].checked == true || check == 0) && check != 1) || (document.getElementsByName(name)[i].disabled == true)) ? false : true;
		}
	}
}
function checkAll(name, podle) {
	var checkboxes = document.getElementsByName(name);
	for(var i = 0; i < checkboxes.length; i++) {
		if(getObj(podle).checked == false) checkboxes[i].checked = false; else checkboxes[i].checked = true;
	}
}
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>';
}

// 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 && div != undefined && div != '' && div != null) 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 (div != undefined && div != '' && div != null && getObj(div).style.display == 'none') getObj(div).style.display = '';
			
			if (div != undefined && div != '' && div != null) 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 number_format(number, decimals, dec_point, thousands_sep) {
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;
        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

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 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 '';
	}
}

var lastvscroll = 0;
function scroll_position() {
	if (window.pageYOffset) vscroll = window.pageYOffset;
    else vscroll = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	
	if (lastvscroll != vscroll) {
		if (vscroll > 0) {
			getObj("scroll-top-active").style.display = '';
			getObj("scroll-top").style.display = 'none';
		} else {
			getObj("scroll-top-active").style.display = 'none';
			getObj("scroll-top").style.display = '';
		}
		lastvscroll = vscroll;
	}
}
function scroll_top() {
	window.scrollTo(0,0);
}
function sentSelect(volba, akce, loc) {
	var volba = document.getElementById(volba);
	var hodnota = volba.options[volba.selectedIndex].value;
	
	if(loc == 0 || loc == undefined || loc == "") {
		if(hodnota != "" && akce != "") window.location.href = '?'+akce+'='+hodnota;
	} else {
		if(hodnota != "" && akce != "") window.location.href = '/'+akce+'&volba='+hodnota;
	}
}
function procenta(zaklad, cast) {
	var procento = parseFloat(zaklad)/100;
	return cast/procento;
}
function is_ie6(){
     return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined));
}
function is_ie() {
	return (typeof( window.innerWidth ) == 'number' ) ? false : true;
}
function dialogBox(obj, zavrit, bezClony, waitCursor) {
	var objDialog = document.getElementById(obj);
	
	if(zavrit == undefined || zavrit == null) var zavrit = 0;
	if(bezClony == undefined || bezClony == null) var bezClony = 0;
	if(waitCursor == undefined || waitCursor == null) var waitCursor = 0;
	
	if(objDialog.style.display == 'none' || objDialog.style.display == '') {
			
		if(getObj('clona') != undefined) document.body.removeChild(getObj('clona'));
		if(getObj('minimalize-'+objDialog.id) != undefined) {
			document.body.removeChild(getObj('minimalize-'+objDialog.id));
			barPosunuti();
		}
		
		objDialog.style.visibility = 'hidden';
		objDialog.style.display = 'block';
		
		// pomocné
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			browserWidth = window.innerWidth;
			browserHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			browserWidth = document.documentElement.clientWidth;
			browserHeight = document.documentElement.clientHeight;
		}
		
		var leftPosition = ( ( browserWidth ) - parseFloat( objDialog.offsetWidth ) ) / 2;
		var topPosition = ( ( browserHeight ) - parseFloat( objDialog.offsetHeight ) ) / 3;
		leftPosition = procenta(browserWidth, leftPosition);
		topPosition = procenta(browserHeight, topPosition);
		
		if(bezClony == 0) {
			// vytvořím element "clona"
			var clona = document.createElement('div');
			clona.setAttribute('id', 'clona');
			
			// nastylování clony
			if(!is_ie6()) {
				clona.style.position = 'fixed';
			} else { // pro IE6
				document.body.style.overflow = 'auto';
				document.body.style.height = '100%';
				document.body.style.margin = '0px';
				clona.style.position = 'absolute';
			}
			
			if(waitCursor == 1) clona.style.cursor = 'wait';
			clona.style.width = '100%';
			clona.style.height = '100%';
			clona.style.zIndex = '1400';
			clona.style.top = '0px';
			clona.style.left = '0px';
			clona.style.backgroundColor = '#000000';
			clona.style.opacity = '0.7';
			clona.style.filter = 'alpha(opacity=70)';
			
			// vložím clonu
			document.body.appendChild(clona);
		}
		
		// zobrazím objekt a nastyluji
		//clona.appendChild(getObj(obj));
		objDialog.style.visibility = '';
		objDialog.style.zIndex = '1500';
		objDialog.style.opacity = '1';
		objDialog.style.top = ((topPosition > 0) ? topPosition : '0')+'%';
		objDialog.style.left = ((leftPosition > 0) ? leftPosition : '0')+'%';
		
		// dragging (posouvání tahem myši)
		var elems = objDialog.getElementsByTagName("*");
		var draggable = false;
		for(var i = 0; i < elems.length; i++) {
			if(elems[i].className == "draggable") {
				elems[i].style.cursor = 'move';
				objDialog.dragged = false;
				draggable = true;
				
				elems[i].onmousedown = function(e) {
					var event = e || window.event;
					
					// průhlednost 40%
					objDialog.style.opacity = '0.4';
					objDialog.style.filter = 'alpha(opacity=40)';
					
					if(objDialog.dragged == false) {
						itemX = ( ( browserWidth ) - parseFloat( objDialog.offsetWidth ) ) / 2;
						itemY = ( ( browserHeight ) - parseFloat( objDialog.offsetHeight ) ) / 3;
					} else {
						itemX = objDialog.style.left.replace('px', '');
						itemY = objDialog.style.top.replace('px', '');
					}
					
					// umístění kurzoru v "tahací" části.
					Xoffset = (event.offsetX) ? event.offsetX : event.pageX - Math.floor(itemX);
					Yoffset = (event.offsetY) ? event.offsetY : event.pageY - Math.floor(itemY);
					
					objDialog.Xoffset = Xoffset;
					objDialog.Yoffset = Yoffset;

					document.body.onmousemove = function(e) {
						var event = e || window.event;
						
						objDialog.dragged = true;
						
						newLeft = ((event.clientX) ? event.clientX : event.pageX) - objDialog.Xoffset;
						newTop = ((event.clientY) ? event.clientY : event.pageY) - objDialog.Yoffset;
						 
						if(newLeft > 0 && newTop > 0) objDialog.style.left = newLeft + 'px';
						if(newLeft > 0 && newTop > 0) objDialog.style.top = newTop + 'px';
						
						objDialog.onselectstart = function() { return false }
						document.body.onselectstart = function() { return false }
						
					}
				}
				objDialog.onmouseup = function() {
					objDialog.style.opacity = '1';
					objDialog.style.filter = 'alpha(opacity=100)';
					document.body.onmousemove = null;	
				}
			}
		}
		
		// resizing (změna velikosti)
		// future
		
		
		// minimalize
		if(bezClony == 1) {
			for(var m = 0; m < elems.length; m++) {
				if(elems[m].className == "minimalize") {
					elems[m].style.cursor = 'pointer';
					elems[m].onclick = function() {
						minimalize(objDialog);
					}
				}
			}
		}
		
		// skrytí clony po kliknutí anebo stisknutí esc
		if (zavrit == 0 && bezClony == 0) clona.onclick = function() { dialogBox(obj) } ;
		if(draggable == false) { // esc pouze pokud není umožněno přesouvání
			document.body.onkeyup = function(e) {
				var kC  = (window.event) ? event.keyCode : e.keyCode; // IE nebo Firefox?
				var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE // IE : Firefox
				if(kC == Esc) dialogBox(obj);
			};	
		}	
	} else {
		if(bezClony == 0) {
			getObj('clona').style.display = 'none';
			getObj('clona').style.zIndex = '0';
		}
		objDialog.style.display = 'none';
	}
}
function minimalize(obj) {
	if(document.getElementById('min-div') != undefined) document.body.removeChild(document.getElementById('min-div'));
	var minDiv = document.createElement('div');
	
	var posLeft = 1;
	var minBar = document.getElementsByClassName('minimalize-bar');
	for(var i = 0; i < minBar.length; i++) {
		posLeft += 203; 	
	}
	
	if(document.getElementById('minimalize-'+obj.id) == undefined) {
		// css
		minDiv.style.position = 'fixed';
		minDiv.style.bottom = 0;
		minDiv.style.left = posLeft+'px';
		minDiv.style.width = '192px';
		minDiv.style.height = '20px';
		minDiv.style.padding = '4px 4px 0 4px';
		minDiv.style.backgroundColor = '#EEEEEE';
		minDiv.style.border = '1px solid #CCCCCC';
		minDiv.style.borderBottom = 'none';
		
		// obsah
		minDiv.innerHTML = '<p class="small">'+obj.getAttribute('title')+' <a href="javascript:void(0)" onclick="zrusitBar(this)" class="krizek"></</p>';
		
		// fce
		minDiv.onclick = function() { maximalize(obj) };
		minDiv.onmouseout = function() { this.style.backgroundColor = '#EEEEEE'; }
		minDiv.onmouseover = function() { this.style.backgroundColor = '#FFFFFF'; }
		
		minDiv.id = 'minimalize-'+obj.id;
		minDiv.className = 'minimalize-bar';
		
		// vytvořím obj
		document.body.appendChild(minDiv);
	}
	
	// skryju dialog
	obj.style.display = 'none';
	obj.style.zIndex = '-1';
}

minZindex = 5000;
function maximalize(obj) {
	document.body.removeChild(document.getElementById('minimalize-'+obj.id));
	obj.style.zIndex = minZindex++;
	obj.style.display = 'inline';
	barPosunuti();
}

function barPosunuti() {
	var posLeft = 1;
	var minBar = document.getElementsByClassName('minimalize-bar');
	for(var i = 0; i < minBar.length; i++) {
		minBar[i].style.left = posLeft+'px';
		posLeft += 203;
	}
}

function zrusitBar(obj) {
	document.body.removeChild(obj);
	barPosunuti();
}

function valueOff(text,id) {
	if(document.getElementById(id).value == '') {
		document.getElementById(id).value = text;
		document.getElementById(id).style.color = '#BBBBBB';
	} else if (document.getElementById(id).value == text) {
		document.getElementById(id).value = '';
		document.getElementById(id).style.color = '#000000';
	}
}

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;
}

function mktime () {
    var no=0, i = 0, ma=0, mb=0, d = new Date(), dn = new Date(), argv = arguments, argc = argv.length;

    var dateManip = {
        0: function (tt){ return d.setHours(tt); },
        1: function (tt){ return d.setMinutes(tt); },
        2: function (tt){ var set = d.setSeconds(tt); mb = d.getDate() - dn.getDate(); d.setDate(1); return set;},
        3: function (tt){ var set = d.setMonth(parseInt(tt, 10)-1); ma = d.getFullYear() - dn.getFullYear(); return set;},
        4: function (tt){ return d.setDate(tt+mb);},
        5: function (tt){
            if (tt >= 0 && tt <= 69) {
                tt += 2000;
            }
            else if (tt >= 70 && tt <= 100) {
                tt += 1900;
            }
            return d.setFullYear(tt+ma);
        }
        // 7th argument (for DST) is deprecated
    };

    for (i = 0; i < argc; i++){
        no = parseInt(argv[i]*1, 10);
        if (isNaN(no)) {
            return false;
        } else {
            // arg is number, let's manipulate date object
            if (!dateManip[i](no)){
                // failed
                return false;
            }
        }
    }
    for (i = argc; i < 6; i++) {
        switch (i) {
            case 0:
                no = dn.getHours();
                break;
            case 1:
                no = dn.getMinutes();
                break;
            case 2:
                no = dn.getSeconds();
                break;
            case 3:
                no = dn.getMonth()+1;
                break;
            case 4:
                no = dn.getDate();
                break;
            case 5:
                no = dn.getFullYear();
                break;
        }
        dateManip[i](no);
    }

    return Math.floor(d.getTime()/1000);
}

function date ( format, timestamp ) {
    var that = this;
    var jsdate=(
        (typeof(timestamp) == 'undefined') ? new Date() : // Not provided
        (typeof(timestamp) == 'object') ? new Date(timestamp) : // Javascript Date()
        new Date(timestamp*1000) // UNIX timestamp (auto-convert to int)
    ); // , tal=[]
    var pad = function (n, c){
        if ( (n = n + "").length < c ) {
            return new Array(++c - n.length).join("0") + n;
        } else {
            return n;
        }
    };
    var _dst = function (t) {
        // Calculate Daylight Saving Time (derived from gettimeofday() code)
        var dst=0;
        var jan1 = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0);  // jan 1st
        var june1 = new Date(t.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st
        var temp = jan1.toUTCString();
        var jan2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1));
        temp = june1.toUTCString();
        var june2 = new Date(temp.slice(0, temp.lastIndexOf(' ')-1));
        var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
        var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60);

        if (std_time_offset === daylight_time_offset) {
            dst = 0; // daylight savings time is NOT observed
        } else {
            // positive is southern, negative is northern hemisphere
            var hemisphere = std_time_offset - daylight_time_offset;
            if (hemisphere >= 0) {
                std_time_offset = daylight_time_offset;
            }
            dst = 1; // daylight savings time is observed
        }
        return dst;
    };
    var ret = '';
    var txt_weekdays = ["Neděle", "Pondělí", "Úterý", "Středa",
        "Čtvrtek", "Pátek", "Sobota"];
    var txt_ordin = {1: "st", 2: "nd", 3: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"};
    var txt_months =  ["", "Leden", "Únor", "Březen", "Duben",
        "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad",
        "Prosinec"];

    var f = {
        // Day
            d: function (){
                return pad(f.j(), 2);
            },
            D: function (){
                var t = f.l();
                return t.substr(0,3);
            },
            j: function (){
                return jsdate.getDate();
            },
            l: function (){
                return txt_weekdays[f.w()];
            },
            N: function (){
                //return f.w() + 1;
                return f.w() ? f.w() : 7;
            },
            S: function (){
                return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th';
            },
            w: function (){
                return jsdate.getDay();
            },
            z: function (){
                return (jsdate - new Date(jsdate.getFullYear() + "/1/1")) / 864e5 >> 0;
            },

        // Week
            W: function (){

                var a = f.z(), b = 364 + f.L() - a;
                var nd2, nd = (new Date(jsdate.getFullYear() + "/1/1").getDay() || 7) - 1;

                if (b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b){
                    return 1;
                } 
                if (a <= 2 && nd >= 4 && a >= (6 - nd)){
                    nd2 = new Date(jsdate.getFullYear() - 1 + "/12/31");
                    return that.date("W", Math.round(nd2.getTime()/1000));
                }
                
                var w = (1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >> 0);

                return (w ? w : 53);
            },

        // Month
            F: function (){
                return txt_months[f.n()];
            },
            m: function (){
                return pad(f.n(), 2);
            },
            M: function (){
                var t = f.F();
                return t.substr(0,3);
            },
            n: function (){
                return jsdate.getMonth() + 1;
            },
            t: function (){
                var n;
                if ( (n = jsdate.getMonth() + 1) == 2 ){
                    return 28 + f.L();
                }
                if ( n & 1 && n < 8 || !(n & 1) && n > 7 ){
                    return 31;
                }
                return 30;
            },

        // Year
            L: function (){
                var y = f.Y();
                return (!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0;
            },
            o: function (){
                if (f.n() === 12 && f.W() === 1) {
                    return jsdate.getFullYear()+1;
                }
                if (f.n() === 1 && f.W() >= 52) {
                    return jsdate.getFullYear()-1;
                }
                return jsdate.getFullYear();
            },
            Y: function (){
                return jsdate.getFullYear();
            },
            y: function (){
                return (jsdate.getFullYear() + "").slice(2);
            },

        // Time
            a: function (){
                return jsdate.getHours() > 11 ? "pm" : "am";
            },
            A: function (){
                return f.a().toUpperCase();
            },
            B: function (){
                // peter paul koch:
                var off = (jsdate.getTimezoneOffset() + 60)*60;
                var theSeconds = (jsdate.getHours() * 3600) +
                                 (jsdate.getMinutes() * 60) +
                                  jsdate.getSeconds() + off;
                var beat = Math.floor(theSeconds/86.4);
                if (beat > 1000) {
                    beat -= 1000;
                }
                if (beat < 0) {
                    beat += 1000;
                }
                if ((String(beat)).length == 1) {
                    beat = "00"+beat;
                }
                if ((String(beat)).length == 2) {
                    beat = "0"+beat;
                }
                return beat;
            },
            g: function (){
                return jsdate.getHours() % 12 || 12;
            },
            G: function (){
                return jsdate.getHours();
            },
            h: function (){
                return pad(f.g(), 2);
            },
            H: function (){
                return pad(jsdate.getHours(), 2);
            },
            i: function (){
                return pad(jsdate.getMinutes(), 2);
            },
            s: function (){
                return pad(jsdate.getSeconds(), 2);
            },
            u: function (){
                return pad(jsdate.getMilliseconds()*1000, 6);
            },

        // Timezone
            e: function () {

                return 'UTC';
            },
            I: function (){
                return _dst(jsdate);
            },
            O: function (){
               var t = pad(Math.abs(jsdate.getTimezoneOffset()/60*100), 4);
               t = (jsdate.getTimezoneOffset() > 0) ? "-"+t : "+"+t;
               return t;
            },
            P: function (){
                var O = f.O();
                return (O.substr(0, 3) + ":" + O.substr(3, 2));
            },
            T: function () {

                return 'UTC';
            },
            Z: function (){
               return -jsdate.getTimezoneOffset()*60;
            },

        // Full Date/Time
            c: function (){
                return f.Y() + "-" + f.m() + "-" + f.d() + "T" + f.h() + ":" + f.i() + ":" + f.s() + f.P();
            },
            r: function (){
                return f.D()+', '+f.d()+' '+f.M()+' '+f.Y()+' '+f.H()+':'+f.i()+':'+f.s()+' '+f.O();
            },
            U: function (){
                return Math.round(jsdate.getTime()/1000);
            }
    };

    return format.replace(/[\\]?([a-zA-Z])/g, function (t, s){
        if ( t!=s ){
            // escaped
            ret = s;
        } else if (f[s]){
            // a date function exists
            ret = f[s]();
        } else {
            // nothing special
            ret = s;
        }
        return ret;
    });
}

/*function nacistIC(obj, jazyk, crm, wopen) {
	if(obj == "") obj = 'ic';
	if(getObj(obj).value.length > 7) {
		if (crm == 1 && wopen == 1) wOpen('/admin/crm/'+jazyk+'/subjekty/novy-subjekt/?ic='+getObj(obj).value,'L');
		else if (crm == 1) window.location.href = '/admin/crm/'+jazyk+'/subjekty/novy-subjekt/?ic='+getObj(obj).value;
		else window.location.href = '/admin/'+jazyk+'/subjekty/novy-subjekt/?ic='+getObj(obj).value;
	} else {
		alert("Číslo IČ musí být vyplněno ve správném tvaru bez mezer!");
	}
}*/

function novaFirmaRejstrik(obj, jazyk, crm) {
	if(obj == "") obj = 'ic';
	if(getObj(obj).value.length > 7) {
		if (crm == 1) wOpen('/admin/crm/'+jazyk+'/subjekty/novy-subjekt/?ic='+getObj(obj).value,'L');
		else window.location.href = '/admin/'+jazyk+'/subjekty/novy-subjekt/?ic='+getObj(obj).value;
	} else {
		alert("Číslo IČ musí být vyplněno ve správném tvaru bez mezer!");
	}
}

function nacistIC(obj, jazyk, volba, crm, wopen) {
	if(obj == "") obj = 'ic';
	if(getObj(obj).value.length > 7) {
		getObj("reload").style.display = 'none';
		getObj("loading").style.display = '';
		ajaxWM("/admin/subjekty.script.php?akce=nacist-ic&ic="+getObj(obj).value+"&volba="+volba, "ares-vysledek", Array("vypsatIC("+crm+")"));
	} else {
		alert("Číslo IČ musí být vyplněno ve správném tvaru bez mezer!");
	}
}

function vypsatIC(crm) {
	getObj("reload").style.display = '';
	getObj("loading").style.display = 'none';

	if (getObj('chyba_ares').value == 1) {
		alert("Omlouváme se, ale server ARES nemohl být kontaktován, zkuste prosím data načíst později. Pokud tento problém přetrvává, obraťte se na správce systému. Děkujeme za pochopení!");
	} else {
		if (crm == 1) var frm = document.form1; else var frm = document.frm_subjekt;
		frm.ic.value = getObj('ic_ares').value;
		frm.dic.value = getObj('dic_ares').value;
		frm.nazev.value = getObj('nazev_ares').value;
		frm.obec.value = getObj('obec_ares').value;
		frm.ulice.value = getObj('ulice_ares').value;
		frm.cp.value = getObj('cp_ares').value;
		frm.psc.value = getObj('psc_ares').value;
		if (getObj('ic_duplicita').value == 1) alert("Upozornění!\nV databázi se již nachází subjekt s tímto IČ.");
	}
	
}

function zaskrtni(identifikator) {
	if(getObj(identifikator).checked == true) getObj(identifikator).checked = false; else getObj(identifikator).checked = true;
}
function roletka(obj, overColor, outColor) {
	var roletka = getObj(obj);
	var hodnoty = roletka.getElementsByTagName("p");
	roletka.className = roletka.className+" no-select";
	
	if (overColor == '' || overColor == undefined) overColor = '#EEEEEE';
	if (outColor == '' || outColor == undefined) outColor = '#FFFFFF';
	
	if(roletka.style.display == "none" || roletka.style.display == "") {
		setTimeout('document.body.onclick = function() { roletka("'+obj+'", "'+overColor+'", "'+outColor+'") }', 100);
		$("#"+obj).slideDown();
		roletka.style.zIndex = '100'+zi;
		zi++;
	} else {
		document.body.onclick = function() { false };
		$("#"+obj).slideUp();
	}
	
	for(var i = 0; i < hodnoty.length; i++) {
		if(overColor != null) hodnoty[i].onmouseover = function() { bgChange(this, overColor); }
		if(outColor != null) hodnoty[i].onmouseout = function() { bgChange(this, outColor); }
	}
}
function roletkaVyber(obj, rolObj, valueShow, valueTarget, targetShow, targetHidden, fce) {
	roletka(rolObj);
	obj.style.backgroundColor = '#3399FF';
	
	if(getObj(targetShow) != null) getObj(targetShow).innerHTML = valueShow;
	if(getObj(targetHidden) != null) getObj(targetHidden).value = valueTarget;
	
	if(fce != null || fce != undefined || fce != "") eval(fce); 
}
function bgChange(obj, color) {
	obj.style.backgroundColor = color;
}
function gmdate (format, timestamp) {
    // Format a GMT date/time  
    // 
    // version: 910.813
    // discuss at: http://phpjs.org/functions/gmdate
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +   input by: Alex
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // -    depends on: date
    // *     example 1: gmdate('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400); // Return will depend on your timezone
    // *     returns 1: '07:09:40 m is month'
    var dt=(
        (typeof(timestamp) == 'undefined') ? new Date() : // Not provided
        (typeof(timestamp) == 'object') ? new Date(timestamp) : // Javascript Date()
        new Date(timestamp*1000) // UNIX timestamp (auto-convert to int)
    );
    timestamp = Date.parse(dt.toUTCString().slice(0, -4))/1000;
    return this.date(format, timestamp);
}


function fillHour(datum) {
	var pom = datum.split(",");
	var den = pom[0].split(".");
	var cas = pom[1].split(":");
	
	return gmdate("d.m.Y, H:i:s", gmmktime(parseFloat(cas[0])+1, cas[1], cas[2], den[1], den[0], den[2]));
	//return gmmktime(cas[0], cas[1], cas[2], den[1], den[0], den[2]);
}
function lessHour(datum) {
	var pom = datum.split(",");
	var den = pom[0].split(".");
	var cas = pom[1].split(":");
	
	return gmdate("d.m.Y, H:i:s", gmmktime(parseFloat(cas[0])-1, cas[1], cas[2], den[1], den[0], den[2]));
	//return gmmktime(cas[0], cas[1], cas[2], den[1], den[0], den[2]);
}
function vlozitJmeno(volba, jmeno, input1, input2, obj, odkaz) {
	var velikost = 'L';
	if (input1 != null) {
		if (odkaz != null) getObj(input1).innerHTML = '<a onclick="wOpen(\''+odkaz+'\',\''+velikost+'\')" href="javascript:void(0)" title="'+jmeno+'">'+jmeno+'</a>';
		else getObj(input1).innerHTML = jmeno;
	}
	if (input2 != null) getObj(input2).value = volba;
	if (obj != null) getObj(obj).style.display = '';
	if (input1 != null && input2 != null && obj != null) wopen_change();
}
function vyprazdnit(obj1, obj2, obj3) {
	if (obj1 != null) getObj(obj1).value = '';
	if (obj2 != null) getObj(obj2).innerHTML = '';
	if (obj3 != null) getObj(obj3).style.display = 'none';
}

function systemoveUpozorneniPrecteno(volba, adresa) {
	ajaxWM('/admin/index.script.php?akce=systemove-upozorneni-precteno&volba='+volba, null, Array("seznamSystemovychUpozorneni()"));
	wOpen(adresa, 'L', '0');
}

var systemovePovolit = 1;
function seznamSystemovychUpozorneni() {
	if (systemovePovolit == 1) ajaxWM('/admin/index.script.php?akce=systemove-upozorneni-seznam', 'systemove-upozorneni', Array("pocetNeprectenychSystemovychUpozorneni()","systemoveZnovuPovolit()"));
	systemovePovolit = 0;
}

function systemoveZnovuPovolit() {
	systemovePovolit = 1;	
}

var intervalBlikani = '';
function pocetNeprectenychSystemovychUpozorneni() {
	clearInterval(intervalBlikani);
	if (getObj('pocet-neprectenych-systemovych-upozorneni').value > 0) {
		udalostiUpozorneni();
		getObj('pocet-systemovych-upozorneni').innerHTML = getObj('pocet-neprectenych-systemovych-upozorneni').value;
		intervalBlikani = setInterval("showObject3('ukazatel-systemovych-upozorneni')", 0.75 * 1000);
	} else {
		getObj('pocet-systemovych-upozorneni').innerHTML = '';
		getObj('ukazatel-systemovych-upozorneni').style.visibility = '';
	}
}

function showUpozorneni () {
	if (getObj('systemove-upozorneni').style.display == 'none') {
		showObject('systemove-upozorneni', 1);
		setTimeout('document.body.onclick = function() { showUpozorneni() }', 100);
	} else {
		showObject('systemove-upozorneni', 0);
		document.body.onclick = function() { false };
	}
}

function overeniZmen() {
	var frm = document.form1;
	var inputs = frm.getElementsByTagName('input');
	var inputOnchange = '';
	for(var i = 0; i < inputs.length; i++) {
		inputOnkeyup = inputs[i].getAttribute('onkeyup');
		inputs[i].setAttribute('onkeyup', 'wopen_change();'+inputOnkeyup);
		inputOnchange = inputs[i].getAttribute('onchange');
		inputs[i].setAttribute('onchange', 'wopen_change();'+inputOnchange);
	}
	var inputs = frm.getElementsByTagName('textarea');
	for(var i = 0; i < inputs.length; i++) {
		inputOnchange = inputs[i].getAttribute('onkeyup');
		inputs[i].setAttribute('onkeyup', 'wopen_change();'+inputOnchange);
	}
	
	var inputs = frm.getElementsByTagName('select');
	for(var i = 0; i < inputs.length; i++) {
		inputOnchange = inputs[i].getAttribute('onchange');
		inputs[i].setAttribute('onchange', 'wopen_change();'+inputOnchange);
	}
}

// funkce pro spuštění dané funkce s časovým spožděním
var wm_timeout = '';
// příklad na inputu(bez array, s array):
// onKeyUp="wmTimeout('check_seo_url(\'input-seo-url-cz\',\'cz\',\'input-seo-url-cz-status\')', 0)"
// onKeyUp="wmTimeout('Array(\'check_seo_url(\'input-seo-url-cz\',\'cz\',\'input-seo-url-cz-status\')\')', 0)"
function wmTimeout(fce, cas) { 
	if (cas == undefined || cas == '' || cas == 0) cas = 500;
	clearTimeout(wm_timeout);
	wm_timeout = setTimeout('wmTimeoutSpust("'+fce+'")', cas);
}

function wmTimeoutSpust(fce) {
	clearTimeout(wm_timeout);
	if (fce != undefined && fce != '') {
		try {
			fce = eval(fce);
			try {
				for(var i = 0; i < fce.length; i++) {
					eval(fce[i]);
				}
			} catch(e) {
				
			}
		} catch(e) {
			
		}
	}
}

function hledani_zalozka(zalozka, pamatovat) {
	// deaktivace všech záložek
	for(i = 0; i < hledani_zalozky.length; i++) {
		getObj('hledani-zalozky-' + hledani_zalozky[i]).style.borderBottomColor = "silver";
		getObj('hledani-zalozky-' + hledani_zalozky[i]).style.backgroundColor = "#EAEAEA";
	}
	
	// schování všech dat
	for(i = 0; i < hledani_zalozky.length; i++) {
		getObj('hledani-' + hledani_zalozky[i] + '-blok').style.display = "none";
		if (hledani_zalozky[i] == 'stranky') getObj('hledani-stranky2-blok').style.display = "none";
	}
	
	// aktivace záložky
	obj_div = getObj('hledani-zalozky-' + zalozka);
	obj_div.style.borderBottomColor = "#FFFFFF";
	obj_div.style.backgroundColor = "#FFFFFF";
	
	// aktivace určitého bloku dat
	getObj('hledani-' + zalozka + '-blok').style.display = "block";
	if (zalozka == 'stranky') getObj('hledani-stranky2-blok').style.display = "block";
	
	if(pamatovat == 1 || pamatovat == undefined) {
		ajaxWM("/pages.script.php?akce=hledat-zalozka&zalozka="+zalozka, null);
	}
}
function hledani_zalozka_pocet(zalozka, pocet) {
	getObj('hledani-'+zalozka+'-pocet').innerHTML = pocet;
	getObj('hledani-zalozky-'+zalozka).style.display = (pocet > 0) ? '' : 'none';
}
function showObjectAnimate(obj) {
	if(document.getElementById(obj).style.display == 'none') {
		$('#'+obj).slideDown('fast');
	} else {
		$('#'+obj).slideUp('fast');
	}
}
