//inicializace Shadowboxu

Shadowbox.init({
		  language: 'cs',
		  players:  ['img', 'html', 'iframe']
		});
//, 'qt', 'wmp', 'swf', 'flv'
window.onload=function(){ 
    if(!document.getElementById && !document.createTextNode){return;} //zabezpečí u elementů a s atributem rel="external" otevření v novém okně
    externallinks(); //zabezpečí u elementů a s atributem rel="external" otevření v novém okně
    //getBox('html','<div style="margin-top:15px;margin-left:15px"><a href="/detail-kurzu/Adobe/certifikovany-kurz/adobe-creative-suite-x4-prakticky-seminar"><img src="/images/bannery/adbcs4.jpg" alt="praktické semináře na vyzkoušení Photoshop CS4, Flash CS 4 a Lightroom 2" title="praktické semináře na vyzkoušení Photoshop CS4, Flash CS 4 a Lightroom 2" width="500" height="500" style="border:0;"></a></div>','NICOM, a. s., Vás zve na praktický seminář','',500,500,120,'adobe',1200); // uvítání
}



function checkAll(f,el)
{
  for (var i=0;i<f.elements.length;i++)
  {
    var e=f.elements[i];
    if (e.name==el) e.checked=f.check_all.checked;
  }
}

function showHide(id)
{
  el=document.getElementById(id).style;
  el.display=(el.display == 'block')?'none':'block';
}

function showAll(count)
{
  for (var i=1;i<=count;i++)
  {     
    el=document.getElementById('tab'+i).style;
    el.display = 'block';
  }
}

function hideAll(count)
{
  for (var i=1;i<=count;i++)
  { 
    el=document.getElementById('tab'+i).style;
    el.display = 'none';
  }
}

function displayWindow(theURL,winName,width,height,features) { //v3.1
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
    newWindow.focus();
}


function checkFormFile(puvodni,kam,co){ //kontola formulářů a jejich úprava
  hodnota = document.getElementById(puvodni).value;
  switch (co){
  case 'uzavrit':
    if (!hodnota){
      document.getElementById(kam).style.backgroundColor = 'white';
      document.getElementById(kam).disabled = '';
    }
    else {
      document.getElementById(kam).style.backgroundColor = '#DDD';
      document.getElementById(kam).value = '';
      document.getElementById(kam).disabled = 'disabled';
  hodnota = document.getElementById(puvodni).value;
    }
    break;
    case 'cervena':
    if (!hodnota){
      document.getElementById(kam).style.color = 'black';
    }
    else {
      document.getElementById(kam).style.color = '#8E0000';
    }
    break;
    case 'cerna':
    if (!hodnota){
      document.getElementById(kam).style.color = '#8E0000';
    }
    else {
      document.getElementById(kam).style.color = 'black';
    }
    break;
    case 'cena':
      switch (hodnota){
        case '10000':
        document.getElementById(kam).innerHTML = '8 300';
        break;
        case '7500':
        document.getElementById(kam).innerHTML = '6 500';
        break;
        case '5000':
        document.getElementById(kam).innerHTML = '4 500';
        break;
        default:
        document.getElementById(kam).innerHTML = '-';
        break;
      }
  }
}

function externallinks() //zabezpečí u elementů a s atributem rel="external" otevření v novém okně
{
    var c=document.getElementById('content');
    if(c)
    {
        var ls=c.getElementsByTagName('a');
        for(var i=0;i<ls.length;i++){
            if(ls[i].getAttribute('rel')=='external')
            {
                ls[i].className+=ls[i].className?' extlink':'extlink';
                ls[i].title+=' (otevře v novém okně)';
                ls[i].onclick=function(){window.open(this.href);return false}
            }
        }
    }
    var d=document.getElementById('technetblog');
    if(d)
    {
        var ls=d.getElementsByTagName('a');
        for(var i=0;i<ls.length;i++){
            if(ls[i].getAttribute('rel')=='external')
            {
                ls[i].className+=ls[i].className?' extlink':'extlink';
                ls[i].title+=' (otevře v novém okně)';
                ls[i].onclick=function(){window.open(this.href);return false}
            }
        }
    }
}

//lightbox okno

//window.onload = Shadowbox.init({skipSetup: true});
function getBox(typ,src,nadp,zprava,sirka,vyska,cas,kukina,trvani){
  if (!getCookie(kukina)) {
      //alert('byla nastavena nová kukina');
      cas *= 1000;
      switch (typ) {
        case "html":
          vyska += 30;
          sirka += 30; 
          if (zprava)
          {
            obsah = '<div>' + src + '</div><div id="zprava">' + zprava + '</div>'
          }
          else
          {
            obsah = src;
          }
          var proms = {
            player: 'html',
            title: nadp,
            content: obsah,
            height: vyska,
            width: sirka
          };
          break;
        case "img":
          var proms = {
            player: 'img',
            title: nadp,
            content: src,
            height: vyska,
            width: sirka
          };
          break;
      }
      
      setCookie(kukina,kukina,trvani,'/')
      Shadowbox.open(proms);
      window.setTimeout("Shadowbox.close()",cas);
  }
}

function setCookie(key, value, sec, path) {
  value = encodeURIComponent(value); // hodnota value by měla být minimálně escapována pomocí funkce escape()
  //value+='; domain='+domain;
  value+='; path='+path;
  // expirace
  var date = new Date();
  date.setTime(date.getTime() + sec * 1000);
  value+='; expires=' + date.toGMTString();
  // secure
  //if (secure) value+='; secure';
  document.cookie = key + '=' + value;
}

// this function gets the cookie, if it exists
// don't use this, it's weak and does not handle some cases
// correctly, this is just to maintain legacy information
function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
  {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}
