// Web Application JavaScript
// Created : 29. 10. 2008
// Updated : 29. 10. 2008
// Company : Web Site Design, s.r.o.
// Author  : Peter Širka

var WebPage = new TWebPage();

function TWebPage()
{
    this.BaseMenuId = new Array("ctl00_menuSpolocnost", "ctl00_menuNovinky", "ctl00_menuSkupina", "ctl00_menuZakaznickaZona");
    this.NameSelected = "";
    this.Language = "";

    this.Initialization = function(lng)
    {
        this.Language = lng;
        if (window.location.pathname.length == 1)
            this.SubMenuDown("subTopLink1");        
        if (window.location.pathname.lastIndexOf("/en/") != -1)
            this.SubMenuDown("subTopLink1");

        for (i = 0; i < this.BaseMenuId.length; i++)
        {
            var o = window.document.getElementById(this.BaseMenuId[i]);
            if (!o)
                continue;
            if (o.src.toLowerCase().indexOf("_on") != -1)
                this.NameSelected = o.name;
        }
        if (this.NameSelected != "")
            this.Menu_Reload_GIF(this.NameSelected, true, (lng ? lng : ""));
        window.document.onkeypress = stopRKey;
        this.MailDecoder();

        var messageIndex = QueryString("messageIndex", "");
        if (messageIndex != "")
        {
            if (messageIndex == "1001")
                alert("Zoznam bol úspešne odoslaný na Vami zadanú e-mailovú adresu.\nĎakujeme za využitie našich služieb.");
            if (messageIndex == "1002")
                alert("Informácie boli úspešne odoslané na Vami zadanú e-mailovú adresu.\nĎakujeme za využitie našich služieb.");
            if (messageIndex == "1003")
                alert("Odkaz bol úspešne odoslaný na Vami uvedenú e-mailovú adresu.");
        }
    }

    this.IsEnabled = ((navigator.appName == 'Netscape' && parseFloat(navigator.appVersion) >= 3) ||(parseFloat(navigator.appVersion) >= 4));

    this.Menu_Reload_GIF = function(imgName, selected, lng)
    {
        if (imgName == this.NameSelected)
            selected = true;
        if (this.IsEnabled)
            eval('document.' + imgName + '.src = "/SiteData/Design/' + (lng ? lng + '/' : '') + imgName + '_' +  (selected ? 'on' : 'off') + '.gif"');
    }

    this.Menu_Reload_JPG = function(imgName, selected, lng)
    {
        if (this.IsEnabled)
            eval('document.' + imgName + '.src = "/SiteData/Design/' + (lng ? lng + '/' : '') + imgName + '_' +  (selected ? 'on' : 'off') + '.jpg"');
    }

    this.Search = function()
    {
        if (getID("Search").value.replace(/\s/ig, "") == "")
        {
            getID("Search").style.backgroundColor = "#FFCCCC";
            return;
        }
        this.Redirect((this.Language == "en" ? "/en/search/" : "/vyhladavanie/") + "?q=" + getID("Search").value);
    }

    this.SubMenuDown = function(id)
    {
        if (getID(id))
            getID(id).style.textDecoration = "underline";
    }

    this.VisibleContent = function(index,pageCount)
    {
        for (var i = 0; i <= pageCount; i++)
        {    
            if (getID("pageIndex" + i.toString()))
                getID("pageIndex" + i.toString()).className = (i == index ? "True" : "False");
            if (getID("pageIndexer" + i.toString()))
                getID("pageIndexer" + i.toString()).className = (i == index ? "PagerLinkDown" : "PagerLink");
        }
        return false;
    }

    this.MailDecoder = function()
    {
        for (var i = 0; i < 21; i++)
        {
            var o = getID("adress" + i.toString());
            if (!o)
                continue;
            if (o.innerHTML.replace(/\s/ig, "") == "")
                continue;
            var mail = o.innerHTML.replace(/\[at\]/ig, "@").replace(/\[dot\]/ig, ".");
            o.innerHTML = "<a href=\"mailto:" + mail + "\" class=\"TextLink\">" + mail + "</a>";
        }
    }

    this.ShowPicture = function(FileName)
    {
    }

    this.TrHighlight = function(o,IsHover)
    {
        if (IsHover)
            o.className = "trSelected";
        else
            o.className = "trNormal";        
    }

    this.Redirect = function(Url)
    {
        window.location = Url;
    }
}

function getID(id)
{
    return document.getElementById(id);
}

// Copyright 2007-2009, Written By Peter Širka
function Redirect(url,posttrue,params,values)
{
    var forma = document.createElement("FORM");
    forma.method = posttrue ? "POST" : "GET";
    forma.action = url;
    document.body.appendChild(forma);
    for(var i = 0; i < params.length; i++)
    {
          if(params[i] == "")
              continue;
          if(values[i] == "")
              continue;
          var input = document.createElement("INPUT");
          input.type = "hidden";
          input.name = params[i];
          input.value = values[i];
          forma.appendChild(input);
    }
    forma.submit();
    document.body.removeChild(forma);
    forma = null;
    input = null;
}

function stopRKey(evt) {
   var evt = (evt) ? evt : ((event) ? event : null);
   var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
   if ((evt.keyCode == 13) && (node.type=="text"))
        return false;
}

function getPageSize()
{	
	var xScroll, yScroll;	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
    return new Array(xScroll, yScroll);
}

function CreateOption(listBox, Text, Value)
{
    var Option = document.createElement("OPTION");
    Option.text = Text;
    Option.value = Value;
    listBox.options.add(Option);
}

/*
 * =========================
 * AJAX LIBRARY
 * =========================
 *
 */

HttpRequest.prototype.MS_PROGIDS = new Array("Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
HttpRequest.prototype.READY_STATE_UNINITIALIZED = 0;
HttpRequest.prototype.READY_STATE_LOADING       = 1;
HttpRequest.prototype.READY_STATE_LOADED        = 2;
HttpRequest.prototype.READY_STATE_INTERACTIVE   = 3;
HttpRequest.prototype.READY_STATE_COMPLETED     = 4;
HttpRequest.prototype.successCallback           = null;
HttpRequest.prototype.failureCallback           = null;
HttpRequest.prototype.url                       = null;
HttpRequest.prototype.username                  = null;
HttpRequest.prototype.password                  = null;
HttpRequest.prototype.requestHeaders            = new Array();
HttpRequest.prototype.status                    = null;
HttpRequest.prototype.statusText                = null;
HttpRequest.prototype.responseXML               = null;
HttpRequest.prototype.responseText              = null;
HttpRequest.prototype.abort                     = HttpRequestAbort;
HttpRequest.prototype.setRequestHeader          = HttpRequestSetRequestHeader;
HttpRequest.prototype.clearRequestHeaders       = HttpRequestClearRequestHeaders;
HttpRequest.prototype.get                       = HttpRequestGet;
HttpRequest.prototype.post                      = HttpRequestPost;
HttpRequest.prototype.initiateRequest           = HttpRequestInitiateRequest;
HttpRequest.prototype.getResponseHeader         = HttpRequestGetResponseHeader;
HttpRequest.prototype.getAllResponseHeaders     = HttpRequestGetAllResponseHeaders;

function HttpRequest(id, tag)
{
    this.tag = tag;
    this.id = id;
	this.xmlHttpRequest = null;

	if (window.XMLHttpRequest != null)
    {
        this.xmlHttpRequest = new window.XMLHttpRequest();
    }
	else if (window.ActiveXObject != null)
    {
	    var success = false;
		for (var i = 0; i < HttpRequest.prototype.MS_PROGIDS.length && !success; i++)
        {
			try
            {
			    this.xmlHttpRequest = new ActiveXObject(HttpRequest.prototype.MS_PROGIDS[i]);
				success = true
            }
			catch (ex) {}
        }
     }

	if (this.xmlHttpRequest == null)
    {
		alert("Chyba vo vytvorení XMLHTTP objektu.\nDoporučujeme Vám nainštalovať internetový prehliadač Mozilla Firefox.");
		return;
    }
}

function HttpRequestAbort()
{
    this.xmlHttpRequest.abort();
}

function HttpRequestSetRequestHeader(name, value)
{
	for (var i = 0; i < this.requestHeaders.length; i++)
    {
	    var pair = this.requestHeaders[i].split("\n");
		if (pair[0].toLowerCase() == name.toLowerCase())
        {
			this.requestHeaders[i] = name + "\n" + value;
			return;
        }
    }
	var n = this.requestHeaders.length;
	this.requestHeaders.push(name + "\n" + value);
}

function HttpRequestClearRequestHeaders()
{
    this.requestHeaders = new Array();
}

function HttpRequestGet()
{
    this.initiateRequest("GET", null);
}
function HttpRequestPost(data)
{
    this.initiateRequest("POST", data);
}

function HttpRequestGetResponseHeader(name)
{
    return this.xmlHttpRequest.getResponseHeader(name);
}

function HttpRequestGetAllResponseHeaders()
{
    return this.xmlHttpRequest.getAllResponseHeaders();
}

function HttpRequestInitiateRequest(method, data)
{
    this.status       = null;
	this.statusText   = null;
	this.responsetext == null;
	this.responseXML  = null;
	var refObj = this;

	this.xmlHttpRequest.onreadystatechange = function()
    {
	    refObj.readyState = refObj.xmlHttpRequest.readyState
		if (refObj.readyState == HttpRequest.prototype.READY_STATE_COMPLETED)
        {
		    refObj.status       = refObj.xmlHttpRequest.status;
		    refObj.statusText   = refObj.xmlHttpRequest.statusText;
			refObj.responseText = refObj.xmlHttpRequest.responseText;
			refObj.responseXML  = refObj.xmlHttpRequest.responseXML;
			if (refObj.status == 200)
            {
                if (refObj.successCallback != null)
                    refObj.successCallback(refObj);
            }
            else
            {
				if (refObj.failureCallback != null)
                    refObj.failureCallback(refObj);
            }
        }
    }

	var url = this.url;
	if (this.queryString != null)
        url = url + "?" + this.queryString;

	this.xmlHttpRequest.open(method, url, true, this.username, this.password);
	for (var i = 0; i < this.requestHeaders.length; i++)
    {
	    var pair = this.requestHeaders[i].split("\n");
		this.xmlHttpRequest.setRequestHeader(pair[0], pair[1]);
    }
	this.xmlHttpRequest.send(data);
}

function ajax_error(httpRequest)
{
   alert("Chyba, HTTP: " + httpRequest.status + " " + httpRequest.statusText + ".");
}

function ajax_call(url,obj)
{
    var ajax_id = new HttpRequest();
    ajax_id.tag = obj;
    ajax_id.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax_id.failureCallback = ajax_error;
    ajax_id.url = url;
    return ajax_id;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    
  }
}

function show_help(title, text) { 
    document.getElementById('help').style.display = 'block';
    document.getElementById('title').innerHTML = title;
    document.getElementById('text').innerHTML = text; 
}

function hide_help() { 
    //document.getElementById('help').style.display = 'none';    
}

function check_cena(textbox) {
    var cena = document.getElementById(textbox).value

    if (cena=='' || isNaN(cena)) { 
        document.getElementById('error_div').style.display = 'block';        
    } else {
        document.getElementById('error_div').style.display = 'none';
    }
}

function check_cenapoistenie(textbox) {
    var cena = document.getElementById(textbox).value

    if (cena=='' || isNaN(cena)) { 
        document.getElementById('error2_div').style.display = 'block';
    } else {
        document.getElementById('error2_div').style.display = 'none';
    }
}

function checkEmail(email) {    
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email.value)) {                
        return '0';
    } else {
        return '1';
    }
}

function red_input(input_name) {
    document.getElementById(input_name).style.borderColor = '#FF0000'; 
}

function blue_input(input_name) { 
    document.getElementById(input_name).style.borderColor = '#00ACEC';
}

function check_form_calc() {   
    var error_stat = 0;   
    var error_stat2 = 0;
    var frm = document.aspnetForm;
        
    if (document.getElementById('ctl00_pageBody_zTYPPREDMETU').value=='') { 
        red_input('ctl00_pageBody_zTYPPREDMETU');
        error_stat = 1;         
    } else {
        blue_input('ctl00_pageBody_zTYPPREDMETU');
    }
    if (document.getElementById('ctl00_pageBody_zZNACKA').value=='') { 
        red_input('ctl00_pageBody_zZNACKA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zZNACKA');                    
    }
    if (document.getElementById('ctl00_pageBody_zCENA').value=='') {
        red_input('ctl00_pageBody_zCENA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCENA');                
    }   
    if (document.getElementById('ctl00_pageBody_zCENAPOISTENIE').value=='') {
        red_input('ctl00_pageBody_zCENAPOISTENIE');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCENAPOISTENIE');                
    }
    if (document.getElementById('ctl00_pageBody_zDLZKASPLACANIA').value=='') {
        red_input('ctl00_pageBody_zDLZKASPLACANIA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zDLZKASPLACANIA');                
    }  
    if (document.getElementById('ctl00_pageBody_zCOMPANY').value=='') {
        red_input('ctl00_pageBody_zCOMPANY');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCOMPANY');                
    }    
    if (document.getElementById('ctl00_pageBody_zKONTAKTNAOSOBA').value=='') {
        red_input('ctl00_pageBody_zKONTAKTNAOSOBA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zKONTAKTNAOSOBA');                
    }
    if (document.getElementById('ctl00_pageBody_zULICA').value=='') {
        red_input('ctl00_pageBody_zULICA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zULICA');                
    }
    if (document.getElementById('ctl00_pageBody_zMESTO').value=='') {
        red_input('ctl00_pageBody_zMESTO');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zMESTO');                
    }   
    if (document.getElementById('ctl00_pageBody_zPSC').value=='') {
        red_input('ctl00_pageBody_zPSC');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zPSC');                
    }   
    if (document.getElementById('ctl00_pageBody_zSTAT').value=='') {
        red_input('ctl00_pageBody_zSTAT');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zSTAT');                
    }     
   
    if (document.getElementById('ctl00_pageBody_zEMAIL').value=='') {
        red_input('ctl00_pageBody_zEMAIL');
        error_stat = 1;
        error_stat2 = 0;
    } else {
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
        
    if (document.getElementById('ctl00_pageBody_zPRVASPLATKA_1').checked==true) {  
        if (document.getElementById('ctl00_pageBody_zVYSKA').value=='') {
            red_input('ctl00_pageBody_zVYSKA');
            error_stat = 2;            
        } else {
            blue_input('ctl00_pageBody_zVYSKA');        
            error_stat = 0;
        }
    }            
    if (error_stat==2) { 
        document.getElementById('et2').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et2').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et2').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }           
}

function check_form_ziadost() {   
    var error_stat = 0;   
    var error_stat2 = 0;

    if (document.getElementById('ctl00_pageBody_zEMAIL').value=='') {
        red_input('ctl00_pageBody_zEMAIL');
        error_stat = 1;
        error_stat2 = 0;
    } else {
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost2() {   
    var error_stat = 0;   
    var error_stat2 = 0;

    if (document.getElementById('ctl00_pageBody_zOBCHODNYNAZOV').value=='') {
        red_input('ctl00_pageBody_zOBCHODNYNAZOV');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zOBCHODNYNAZOV');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zADRESA').value=='') {
        red_input('ctl00_pageBody_zADRESA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zADRESA');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zZMLUVA').value=='') {
        red_input('ctl00_pageBody_zZMLUVA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zZMLUVA');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zVYPOCET').value=='') {
        red_input('ctl00_pageBody_zVYPOCET');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zVYPOCET');                
    }     

    if (document.getElementById('ctl00_pageBody_zTELEFON').value=='') {
        red_input('ctl00_pageBody_zTELEFON');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zTELEFON');                
    }     

    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost3() {
    var error_stat = 0;   
    var error_stat2 = 0;

    if (document.getElementById('ctl00_pageBody_zOBCHODNYNAZOV').value=='') {
        red_input('ctl00_pageBody_zOBCHODNYNAZOV');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zOBCHODNYNAZOV');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zADRESA').value=='') {
        red_input('ctl00_pageBody_zADRESA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zADRESA');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zZMLUVA').value=='') {
        red_input('ctl00_pageBody_zZMLUVA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zZMLUVA');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zDOVOD').value=='') {
        red_input('ctl00_pageBody_zDOVOD');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zDOVOD');                
    }     

    if (document.getElementById('ctl00_pageBody_zPOPIS').value=='') {
        red_input('ctl00_pageBody_zPOPIS');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zPOPIS');                        
    }     
    
    if (document.getElementById('ctl00_pageBody_zTELEFON').value=='') {
        red_input('ctl00_pageBody_zTELEFON');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zTELEFON');                
    }     

    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost4() {
    var error_stat = 0;   
    var error_stat2 = 0;

    if (document.getElementById('ctl00_pageBody_zOBCHODNYNAZOV').value=='') {
        red_input('ctl00_pageBody_zOBCHODNYNAZOV');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zOBCHODNYNAZOV');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zADRESA').value=='') {
        red_input('ctl00_pageBody_zADRESA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zADRESA');                
    }  
    
    if (document.getElementById('ctl00_pageBody_zICO').value=='') {
        red_input('ctl00_pageBody_zICO');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zICO');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zZMLUVA').value=='') {
        red_input('ctl00_pageBody_zZMLUVA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zZMLUVA');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zDOVOD').value=='') {
        red_input('ctl00_pageBody_zDOVOD');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zDOVOD');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zTELEFON').value=='') {
        red_input('ctl00_pageBody_zTELEFON');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zTELEFON');                
    }     

    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost5() {
    var error_stat = 0;   
    var error_stat2 = 0;

    if (document.getElementById('ctl00_pageBody_zOBCHODNYNAZOV').value=='') {
        red_input('ctl00_pageBody_zOBCHODNYNAZOV');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zOBCHODNYNAZOV');                
    }  
    
    if (document.getElementById('ctl00_pageBody_zADRESA').value=='') {
        red_input('ctl00_pageBody_zADRESA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zADRESA');                
    }     
    
    if (document.getElementById('ctl00_pageBody_zZMLUVA').value=='') {
        red_input('ctl00_pageBody_zZMLUVA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zZMLUVA');                
    }        
   
    if (document.getElementById('ctl00_pageBody_zPOPIS').value=='') {
        red_input('ctl00_pageBody_zPOPIS');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zPOPIS');                
    }     
    if (document.getElementById('ctl00_pageBody_zPOISTOVNA').value=='') {
        red_input('ctl00_pageBody_zPOISTOVNA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zPOISTOVNA');                
    }     
    if (document.getElementById('ctl00_pageBody_zMIESTO').value=='') {
        red_input('ctl00_pageBody_zMIESTO');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zMIESTO');                
    }  
    if (document.getElementById('ctl00_pageBody_zLIKVIDATORTELEFON').value=='') {
        red_input('ctl00_pageBody_zLIKVIDATORTELEFON');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zLIKVIDATORTELEFON');                
    }     
    if (document.getElementById('ctl00_pageBody_zSKODA').value=='') {
        red_input('ctl00_pageBody_zSKODA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zSKODA');                
    }     
    if (document.getElementById('ctl00_pageBody_zTELEFON').value=='') {
        red_input('ctl00_pageBody_zTELEFON');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zTELEFON');                
    }  
     
    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost6() {
    var error_stat = 0;   
    var error_stat2 = 0;
   
     if (document.getElementById('ctl00_pageBody_zMENO').value=='') {
        red_input('ctl00_pageBody_zMENO');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zMENO');                
    }  
    
     if (document.getElementById('ctl00_pageBody_zOBSAH').value=='') {
        red_input('ctl00_pageBody_zOBSAH');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zOBSAH');                
    }      
     
    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost7() {
    var error_stat = 0;   
    var error_stat2 = 0;
   
     if (document.getElementById('ctl00_pageBody_zSPOLOCNOST').value=='') {
        red_input('ctl00_pageBody_zSPOLOCNOST');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zSPOLOCNOST');                
    }  
    if (document.getElementById('ctl00_pageBody_zSTE').value=='') {
        red_input('ctl00_pageBody_zSTE');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zSTE');                
    }  
    if (document.getElementById('ctl00_pageBody_zKONTAKTNAOSOBA').value=='') {
        red_input('ctl00_pageBody_zKONTAKTNAOSOBA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zKONTAKTNAOSOBA');                
    }  
    if (document.getElementById('ctl00_pageBody_zULICA').value=='') {
        red_input('ctl00_pageBody_zULICA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zULICA');                
    }  
    if (document.getElementById('ctl00_pageBody_zPSC').value=='') {
        red_input('ctl00_pageBody_zPSC');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zPSC');                
    }  
    if (document.getElementById('ctl00_pageBody_zCISLOZMLUVY').value=='') {
        red_input('ctl00_pageBody_zCISLOZMLUVY');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCISLOZMLUVY');                
    }      
    if (document.getElementById('ctl00_pageBody_zMODEL').value=='') {
        red_input('ctl00_pageBody_zMODEL');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zMODEL');                
    }  
     if (document.getElementById('ctl00_pageBody_zCENA').value=='') {
        red_input('ctl00_pageBody_zCENA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCENA');                
    }  
     if (document.getElementById('ctl00_pageBody_zAKONTACIA').value=='') {
        red_input('ctl00_pageBody_zAKONTACIA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zAKONTACIA');                
    }  
     if (document.getElementById('ctl00_pageBody_zSPLATKA').value=='') {
        red_input('ctl00_pageBody_zSPLATKA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zSPLATKA');                
    }  
     if (document.getElementById('ctl00_pageBody_zUHRADENE').value=='') {
        red_input('ctl00_pageBody_zUHRADENE');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zUHRADENE');                
    }  
      if (document.getElementById('ctl00_pageBody_zDLZKA').value=='') {
        red_input('ctl00_pageBody_zDLZKA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zDLZKA');                
    }  
      if (document.getElementById('ctl00_pageBody_zODSTUPNE').value=='') {
        red_input('ctl00_pageBody_zODSTUPNE');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zODSTUPNE');                
    }       
     
    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}

function check_form_ziadost8() {
    var error_stat = 0;   
    var error_stat2 = 0;
   
     if (document.getElementById('ctl00_pageBody_zOBCHODNYNAZOV').value=='') {
        red_input('ctl00_pageBody_zOBCHODNYNAZOV');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zOBCHODNYNAZOV');                
    }  
    if (document.getElementById('ctl00_pageBody_zADRESA').value=='') {
        red_input('ctl00_pageBody_zADRESA');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zADRESA');                
    }  
    if (document.getElementById('ctl00_pageBody_zCISLOZMLUVY').value=='') {
        red_input('ctl00_pageBody_zCISLOZMLUVY');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCISLOZMLUVY');                
    }  
    if (document.getElementById('ctl00_pageBody_zCISLOPOISTUDALOSTI').value=='') {
        red_input('ctl00_pageBody_zCISLOPOISTUDALOSTI');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zCISLOPOISTUDALOSTI');                
    }  
    if (document.getElementById('ctl00_pageBody_zMIESTOLIKVID').value=='') {
        red_input('ctl00_pageBody_zMIESTOLIKVID');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zMIESTOLIKVID');                
    }  
    if (document.getElementById('ctl00_pageBody_zTELEFONLIKVID').value=='') {
        red_input('ctl00_pageBody_zTELEFONLIKVID');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zTELEFONLIKVID');                
    }      
    if (document.getElementById('ctl00_pageBody_zVYSKASKODY').value=='') {
        red_input('ctl00_pageBody_zVYSKASKODY');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zVYSKASKODY');                
    }  
     if (document.getElementById('ctl00_pageBody_zTELEFON').value=='') {
        red_input('ctl00_pageBody_zTELEFON');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zTELEFON');                
    }  
     if (document.getElementById('ctl00_pageBody_zFAX').value=='') {
        red_input('ctl00_pageBody_zFAX');
        error_stat = 1;
    } else {
        blue_input('ctl00_pageBody_zFAX');                
    }  
     
    if (document.getElementById('ctl00_pageBody_zEMAIL').value!='') {        
        if (checkEmail(document.getElementById('ctl00_pageBody_zEMAIL'))=='1') {
            blue_input('ctl00_pageBody_zEMAIL');        
            error_stat2 = 0;
        } else {
            red_input('ctl00_pageBody_zEMAIL');
            error_stat2 = 1;
        }
    }   
    
    if (error_stat==1) { 
        document.getElementById('et1').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';                
    } else {
        document.getElementById('et1').style.display = 'none';                
    }
    if (error_stat2==1) {
        document.getElementById('et3').style.display = 'block';
        document.getElementById('error_div').style.display = 'block';
    } else {
        document.getElementById('et3').style.display = 'none';
    }
    
    if (document.getElementById('et1').style.display=='none' && document.getElementById('et3').style.display=='none') {
        document.getElementById('error_div').style.display = 'none';                           
        document.getElementById('ctl00_pageBody_form_submit').click();
    }   
}


function calc_help() { 
    document.getElementById('calc_help').style.display = 'block';   
}
function calc_help_hide() {
    document.getElementById('calc_help').style.display = 'none';
}

function SearchKeyPress(e)
{
    if (e.keyCode==13)
    {
        WebPage.Search();
        return false;
    }
}

function Printer()
{        
  WindowOpen("/Printer.html",800,550,"scrollbars=yes,toolbar=no,resizable=yes,status=no,location=no");
}

function WindowOpen(URL, dialogWidth, dialogHeight, CommandPlus)
{
    if (CommandPlus == '') CommandPlus='scrollbars=no,toolbar=no,resizable=no,status=no,location=no';
	var iTop  = (screen.height - dialogHeight) / 2 ;
	var iLeft = (screen.width  - dialogWidth)  / 2 ;
    return window.open(URL, '', 'width='+dialogWidth+',height='+dialogHeight+',left='+iLeft+',top='+iTop+','+CommandPlus);
    if (WindowOpen.focus) WindowOpen.focus();
}


function check_integer(n){return RegExp ( "^[-+]?[0-9]+$" ).test(n)}
function check_string(s){return RegExp ( "^[a-zA-Z]+$" ).test(s)}
function check_alfanum_string(s){return RegExp ( "^[a-zA-Z0-9]+$" ).test(s)}
function check_date(s){return RegExp ( "[0-9]{2,2}.[0-9]{2,2}.[0-9]{4,4}$" ).test(s)}
function check_time(s){return RegExp ( "^[012][0-9]:[0-5][0-9]$" ).test(s)}
function check_email(s){return RegExp ( "^[a-zA-Z0-9-_.]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$" ).test(s)}
function check_url(s){var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; return regexp.test(s)}
function check_sqldate(s){reg_date = /^\d{4}-\d{2}-\d{2}$/; return reg_date.test(s)}
function check_hex(n) {return (n<16 ? '0' : '' ) + n.toString(16)}

function QueryString(Item,Default)
{
    var url=window.location.href;
    var value;
    var index=url.indexOf('?');
    if (!Default)
        var Default="";

    if (index>0)
    {
        url=url.substr(index+1,url.length-index).split("&");
        for (var i=0; i<url.length; i++)
        {
            value=url[i].split("=");
            if (value[0].toLowerCase() == Item.toLowerCase())
                return value[1];
        }
    } 
    return Default;
}

function ThisPageSendAsLink()
{
    var Param = new Array(1);
    var Value = new Array(1);
    Value[0] = window.location.pathname;
    Param[0] = "zURL";
    Redirect("/Site/Poslanie-odkazu-znamemu.aspx", true, Param, Value);        
}

var cX = 0; var cY = 0; var rX = 0; var rY = 0;function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }else { document.onmousemove = UpdateCursorPosition; }function AssignPosition(d) {if(self.pageYOffset) {rX = self.pageXOffset;rY = self.pageYOffset;}else if(document.documentElement && document.documentElement.scrollTop) {rX = document.documentElement.scrollLeft;rY = document.documentElement.scrollTop;}else if(document.body) {rX = document.body.scrollLeft;rY = document.body.scrollTop;}if(document.all) {cX += rX;cY += rY;}d.style.left = (cX+10) + "px";d.style.top = (cY+10) + "px";}

function ReverseContentDisplay(d) {
  if(d.length < 1) { return; }
  var dd = document.getElementById(d);
  AssignPosition(dd);
  if(dd.style.display == "none") { dd.style.display = "block"; } else { dd.style.display = "none"; }
}

function show_tooltip(d) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	AssignPosition(dd);
	dd.style.display = "block";	
}

function hide_tooltip(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}