﻿// zde funkce prompt ziskani id radku ulozeneho var name buttonu
// start superloading script
// loading script

// MESSAGE BOXY

// ASPxUloadPanel provadi upload pomoci iframe a historie iframe je treba eliminovat
// historie na frontendu pocita pouze iframe volani 

var clientBackCount = 0; 

// odstranuje problem  ASPxUloadPanelu ktery zacne do historie pridavat az po druhem opetnem nahrani                           
// je dost mozne ze pristi verze jiz budou ok
var applyClientBack = false; 



function AtonPrompt(message)
{
    return prompt(message,"");
}

function AtonAlert(message)
{
    alert(message);
}

function AtonConfirm(message)
{
    return confirm(message)   
}

// loading funkce
var FStartLoading = false;

function AtonDisabledStartLoading()
{
    FStartLoading = true;
}

function AtonPageLoadingFinish()
{
    FStartLoading = false;
    var popupDivElement = document.getElementById("LoadingPanelPopupDiv");
    popupDivElement.style.display="none";
    var popupDivElementAlpha = document.getElementById("LoadingPanelPopupDivAlpha");
    popupDivElementAlpha.style.display="none";
}


function StartLoading()
{    
    if (!FStartLoading)
    {
    if (document.all) 
    {
        var width = document.body.clientWidth;
        var height = document.body.clientHeight;
    }
    else 
    {
        width = window.innerWidth;
        height = window.innerHeight;
    }
   
   
    var popupDivElement = document.getElementById("LoadingPanelPopupDiv");
    popupDivElement.style.display="block";
    var popupDivElementAlpha = document.getElementById("LoadingPanelPopupDivAlpha");
    popupDivElementAlpha.style.height=height+'px';
    popupDivElementAlpha.style.width=width+'px';
    popupDivElementAlpha.style.display="block";
    }
    FStartLoading = true;
}


function AtonCallMethod(method,param1,param2,interval)
{
    var timeout = 300;
    if (interval) timeout = interval;
    var strMethod = method+"(";
    if (param1 != null) strMethod += param1;
    if (param2 != null) strMethod += ','+param2;
    strMethod += ")";
    setTimeout(strMethod,timeout);
}

function AtonGetParameter(data,name)
{
    var data = data.split('_');
    for (var i = 0;i < data.length;i+=2)
    {
        if (data[i] == name) return data[i+1];    
    }
    return null;
}

// pomocna funkce pro zavreni okna
function AtonClosePopupWindow(popupVarName)
{
    var imgWin = eval(popupVarName).GetWindow(0);
    eval(popupVarName).HideWindow(imgWin);
}


// Funkce pro praci s Cookie
function AtonGetCookie(sName)
{
  if (document.cookie.length == 0) return null;  
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  return null;
}

function AtonDelCookie(sName)
{
  document.cookie = sName + "=; expires=Fri, 21 Dec 1976 04:31:24 GMT;";
}

function AtonSetCookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 2099 23:59:59 GMT;";
}
//-----------

//validace emailu
function AtonCheckEmail(email)
{
 var filter=/^.+@.+\..{2,3}$/;
 if (filter.test(email)) return true
 return false
}

//string Trim()
function AtonStringTrim(txt)
{
return txt.replace(/^\s*|\s*$/g, "");
}

function AtonIsNumeric(sText)
{
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

// odstrani elementy IFRAME
function AtonDeleteIframe()
{
    var pole = document.getElementsByTagName("iframe");
    for (var i = 0;i < pole.length;i++)
    {        
       var el = pole[i];
       var id = el.getAttribute("id");
       if (id.indexOf("FCKeditor") == -1)
       {
            el.parentNode.removeChild(el);
       }       
    }
}

// zjisteni absolutni pozice elementu na strance
function getAbsPos(element, side)
{
    var position = 0;
    while (element != null) {
       position += element["offset" + side];
       element = element.offsetParent;
    }
    return position;
}

// zjisteni souradnice mysi X
function getMouseX(e) 
{
     var IE = document.all?true:false;
    if (IE) {
        mouseX = event.clientX + document.documentElement.scrollLeft;
    }
    else { 
        mouseX = e.pageX;
    }
    if (mouseX < 0){mouseX = 0;}
    return mouseX;
}

// zjisteni souradnice mysi Y
function getMouseY(e) 
{
    var IE = document.all?true:false;
    if (IE) { 
        mouseY = event.clientY + document.documentElement.scrollTop;       
    }
    else {  
        mouseY = e.pageY;
    }
    if (mouseY < 0){mouseY = 0;}
    return mouseY;
}


// zobrazeni obrazku v plne velikosti z nahledu
var showFullFotoTimeout = false;
function showFullFoto(obj)
{       
    hideFullFoto();
    var newImage = document.createElement("img");
    newImage.setAttribute("src", obj.src);
    newImage.setAttribute("id", "showFullFoto");
    newImage.setAttribute("oldWidth", obj.width);
    newImage.setAttribute("oldHeight", obj.height);
    newImage.style.left = getAbsPos(obj,"Left")+"px";        
    newImage.style.top = getAbsPos(obj,"Top")+"px";       
    newImage.className = "ShowImageFullFoto";
    newImage.onmousemove = function(e)
    {               
        clearTimeout(showFullFotoTimeout);
        var x = this.getAttribute("oldWidth");
        var y = this.getAttribute("oldHeight");
        if (getMouseX(e)-this.offsetLeft-10 > x) hideFullFoto();
        else if (getMouseY(e)-this.offsetTop-10 > y) hideFullFoto();       
        showFullFotoTimeout = setTimeout("hideFullFoto()",5000);
    }    
    newImage.onmouseout = function()
    {        
        hideFullFoto();
    }
    
    if ((newImage.width < obj.width) || (newImage.height < obj.height))
    {
        newImage.width = obj.width;
        newImage.height = obj.height;
    }    
    document.body.appendChild(newImage);
    showFullFotoTimeout = setTimeout("hideFullFoto()",5000);
}

// zruseni obrazku v plne velikosti z nahledu - vola se automaticky
function hideFullFoto()
{
   clearTimeout(showFullFotoTimeout);
   var newImage = document.getElementById("showFullFoto");
   if (newImage) document.body.removeChild(newImage); 
}
