function zobraz(id)
{
if(document.getElementById(id))
document.getElementById(id).style.display="block";
}
function zobraz_in(id)
{
if(document.getElementById(id))
document.getElementById(id).style.display="inline";
}
function odzobraz(id)
{
if(document.getElementById(id))
document.getElementById(id).style.display="none";
}
function zobraz_nebo_odzobraz(id) {
if(document.getElementById(id).style.display == "block")
document.getElementById(id).style.display="none";
else
document.getElementById(id).style.display="block";
}
function zobraz_nebo_odzobraz_jq(id,time) {
if($('#'+id).css('display') == "block")
$('#'+id).hide(time);
else
$('#'+id).show(time);
}
function zobraz_nebo_odzobraz_in(id) {
if(document.getElementById(id).style.display == "inline")
document.getElementById(id).style.display="none";
else
document.getElementById(id).style.display="inline";
}
function check_or_uncheck(id) {
if(document.getElementById(id).checked == true)
document.getElementById(id).checked = false;
else
document.getElementById(id).checked = 'checked';
}
function check(id) {
if(document.getElementById(id))
document.getElementById(id).checked = 'checked';
}
function uncheck(id) {
if(document.getElementById(id))
document.getElementById(id).checked = false;
}
function podbarvi(id,barva)
{
if(document.getElementById(id))
document.getElementById(id).style.background=barva;
}
function odbarvi(id,barva)
{
if(document.getElementById(id))
document.getElementById(id).style.background=barva;
}
function vyber_panel(id,no,pocet) {
for(i=1;i<=pocet;i++) {
if(document.getElementById(id + i)){
if(i != no)
document.getElementById(id + i).style.display="none";
else
document.getElementById(id + i).style.display="block";
}
}
}
function zaktivni(id,no,pocet) {
for(i=1;i<=pocet;i++) {
if(document.getElementById(id + i)){
if(i != no)
document.getElementById(id + i).className="normal";
else
document.getElementById(id + i).className="active";
}
}
}
function posun_pozici(x) {
document.getElementById('mapa').style.backgroundPosition = "0px -" + (x*333) + "px";
}
function posun_zpet() {
document.getElementById('mapa').style.backgroundPosition = "0px 0px";
}
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if (!Object.keys) {
Object.keys = (function () {
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
dontEnumsLength = dontEnums.length;
return function (obj) {
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
throw new TypeError('Object.keys called on non-object');
}
var result = [], prop, i;
for (prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop);
}
}
if (hasDontEnumBug) {
for (i = 0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) {
result.push(dontEnums[i]);
}
}
}
return result;
};
}());
}
if (!Array.prototype.forEach)
{
Array.prototype.forEach = function(fun /*, thisArg */)
{
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++)
{
if (i in t)
fun.call(thisArg, t[i], i, t);
}
};
}
function formControl(formular, model, lang) {
$('div.error-message-form-inline-control').remove();
$('#' + formular + ' .error-input').removeClass('error-input');
if (typeof lang != 'undefined') {
var targetUrl = root_home_adress + 'page/ajax.php?skript=formControl&language=' + lang+'&model=' + model;
} else {
var targetUrl = root_home_adress + 'page/ajax.php?skript=formControl&model=' + model;
}
$.ajax({
type: "POST",
url: targetUrl,
data: $('#' + formular).serialize(),
async: true,
dataType: 'json',
success: function (returnedData) {
if (Object.keys(returnedData).length > 0) {
Object.keys(returnedData).forEach(function (key) {
$('#' + key).after('');
$('#' + key).addClass('error-input');
});
return false;
} else {
document.getElementById(formular).submit();
return true;
}
},
fail: function(e){
document.getElementById(formular).submit();
}
});
return false;
}
function odesli(formular, model, lang) {
model = model || false;
if (model != false){
return formControl(formular, model, lang);
}
document.getElementById(formular).submit();
}
function zkontroluj_silu_hesla(heslo) {
zaklad = /^.*([a-z]+.*[0-9]+)|([0-9]+.*[a-z]+).*$/;
adv = /^.*[^a-zA-Z0-9].*$/;
exp = /^.*[^a-zA-Z0-9].*[^a-zA-Z0-9].*[^a-zA-Z0-9].*$/;
if((heslo.length > 10)&&(zaklad.test(heslo))&&(exp.test(heslo))) {
sila = '100/100';
} else if((heslo.length > 8)&&(zaklad.test(heslo))&&(exp.test(heslo))) {
sila = '90/100';
} else if((heslo.length > 6)&&(zaklad.test(heslo))&&(adv.test(heslo))) {
sila = '70/100';
} else if((heslo.length > 5)&&(zaklad.test(heslo))) {
sila = '50/100';
} else if((heslo.length > 4)&&(zaklad.test(heslo))) {
sila = '40/100';
} else if(heslo.length > 3) {
sila = '30/100';
} else if(heslo.length > 2) {
sila = '20/100';
} else if(heslo.length > 1) {
sila = '10/100';
} else {
sila = '0/100';
}
return(sila);
}
function zkontroluj_shodu_hesel(heslo1,heslo2) {
if(heslo1 == heslo2)
return(true);
else
return(false);
}
function omez_pocet_znaku(areaid,znaku,zbyvaid) {
area = document.getElementById(areaid);
if(area.value.length > znaku)
area.value = area.value.substr(0,znaku);
document.getElementById(zbyvaid).innerHTML = znaku-area.value.length;
}
function goto(target,interval) {
if(interval == false)
interval = 'slow';
if($(target))
$("html, body").animate({ scrollTop: $(target).offset().top - (($(window).height()-$(target).height())/2) }, interval);
return false;
}
function ajaxhandler(locationcfg,url,lang,replaceCallback) {
locationcfg.url = url;
window.success = false;
window.successReturn = new Array();
$.ajax({
type: "POST",
url: root_home_adress + "page/ajax.php?skript=ajaxhandler&language=" + lang,
data: locationcfg,
async: false,
dataType: 'json',
success: function (data) {
var replace = locationcfg.replace;
if (replace.length == 0)
window.success = false;
$.each(replace, function (index, item) {
if (data[item] == '') {
window.success = false;
} else {
var html_to_replace = data[item];
if (typeof replaceCallback != "undefined") {
window.successReturn[item] = html_to_replace;
window.success = true;
} else {
$('div#' + item).html(html_to_replace);
window.success = true;
}
}
});
}
});
if (window.success === true)
return true;
else if (window.successReturn.length > 0) {
return true;
} else
return false;
}
function odesli_ajax(form, lang) {
url = prepare_ajax_form(form, lang);
window.location = url;
}
function prepare_ajax_form(form, lang) {
window.returnUrl = '';
var values = {};
$.each($('#'+form).serializeArray(), function(i, field) {
values[field.name] = field.value;
});
values['id_form'] = form;
var redirect_url = $('#'+form).attr('action');
if (typeof lang != 'undefined') {
var targetUrl = root_home_adress + 'page/ajax.php?skript=ajaxForm&language=' + lang;
} else {
var targetUrl = root_home_adress + 'page/ajax.php?skript=ajaxForm';
}
$.ajax({
type: "POST",
url: targetUrl,
data: values,
async: false,
success: function(data) {
window.returnUrl = redirect_url + (redirect_url.indexOf('?') !== -1 ? '&' : '?') + "q=" + data;
}
});
return window.returnUrl;
}