//-------------------------------------------------------------------------------------------

function docElem(strID)
{
  if (document.all) return(document.all(strID));
  if (document.getElementById) return(document.getElementById(strID));
  return false;
}

//-------------------------------------------------------------------------------------------

function switchDiv(idDiv)
{
  var paragraph = docElem('idDiv'+idDiv);
  if (paragraph)
  {
    if (paragraph.style.display != 'none')
    {
      paragraph.style.display = 'none';
//      document.images['img'+idDiv].src = imgDivShow.src;
    }
    else
    {
      paragraph.style.display = 'block';
//      document.images['img'+idDiv].src = imgDivHide.src;
    }
  }
}

//-------------------------------------------------------------------------------------------

function SetCookie(sName, sValue)
{
  document.cookie = sName + '=' + escape(sValue) + '; expires=Mon, 31 Dec 2010 23:59:59 UTC;';
}

//-------------------------------------------------------------------------------------------

function GetCookie(sName)
{
  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 IEBrowserVer()
{
  if (window.navigator.userAgent.indexOf('MSIE') == -1) return 0;
  return eval(window.navigator.userAgent.substr(window.navigator.userAgent.indexOf('MSIE')+5,1))
}

//-------------------------------------------------------------------------------------------

function setPage(newAddress){
  if (newAddress != "") window.location.href = newAddress;
}

//-------------------------------------------------------------------------------------------

function setOpener(newAddress){
  if (newAddress != "") window.opener.location.href = newAddress;
}

//-------------------------------------------------------------------------------------------

function changeImg(imageName,isOn)
{
  if (document.images)
  {
    if (isOn==true) document.images[imageName].src = eval(imageName + "on" + ".src");
    else document.images[imageName].src = eval(imageName + "off" + ".src");
  }
}

//-------------------------------------------------------------------------------------------

function setPos(picWidth,picHeight)
{  
  mwidth = picWidth + 20;
  mheight = picHeight + 20;
  mtop = (window.screen.height - mheight) / 2;
  mleft = (window.screen.width - mwidth) / 2;
  return ('height=' + mheight + ',width=' + mwidth + ',top=' + mtop + ',left=' + mleft);
}

//-------------------------------------------------------------------------------------------

function openObr(cesta,jmenowin,picWidth,picHeight)
{  
  window.open(cesta,jmenowin,setPos(picWidth,picHeight) + ',status=no,toolbar=no,menubar=no,location=no,resizable=no');
}

//-------------------------------------------------------------------------------------------

function openInNewWin(cesta,jmenowin,winWidth,winHeight)
{  
  window.open(cesta,jmenowin,setPos(winWidth,winHeight) + ',status=no,toolbar=no,menubar=no,location=no,resizable=no');
}
//-------------------------------------------------------------------------------------------

function setPosHTML(picWidth,picHeight)
{  
  if (navigator.appName.substring(0,9) == 'Microsoft')
  {
    mwidth = picWidth;
    mheight = picHeight;
  }
  else
  {
    mwidth = picWidth + 20;
    mheight = picHeight + 20;
  }
  mtop = (window.screen.height - mheight) / 2;
  mleft = (window.screen.width - mwidth) / 2;
  return ('height=' + mheight + ',width=' + mwidth + ',top=' + mtop + ',left=' + mleft);
}

//-------------------------------------------------------------------------------------------

function openObrHTML(jmenowin,picWidth,picHeight)
{  
  wndObr=window.open('',jmenowin,setPosHTML(picWidth,picHeight) + ',scrollbars=no,status=no,toolbar=no,menubar=no,location=no,resizable=no');
  window.wndObr.focus();
}

//-------------------------------------------------------------------------------------------

function openObrHTMLRes(jmenowin,picWidth,picHeight)
{  
  wndObr=window.open('',jmenowin,setPosHTML(picWidth,picHeight) + ',scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,resizable=yes');
  window.wndObr.focus();
}

//-------------------------------------------------------------------------------------------

function openInvoice(IDInvoice)
{
  wndObj=window.open('printinvoice.asp?IDInvoice='+IDInvoice,'Invoice',setPos(770,400) + ',scrollbars=yes,status=no,toolbar=no,menubar=yes,location=no,resizable=yes')
  window.wndObj.focus();
}

//-------------------------------------------------------------------------------------------
