
window.onload = function() {
 //  try{nastavTaby();}catch(e){}
  
  // clearPage();
  
}







var topMenuTimer = null;

function topMenu(co) {  
  // pri prvnim najeti     
  if(!topMenuTimer) {
    var time = 1;
  }else {
    // a dalsich najeti
    var time = 400;
  
    clearTimeout(topMenuTimer);
  }
  // Pustime fci
  topMenuTimer = setTimeout(function() {topMenuDo(co)}, time);
}

function topMenuDo(co) {
  ulka = co.parentNode.getElementsByTagName('ul');
  for(i=0; i< ulka.length; i++){
    if(ulka[i].className=="sub") { ulka[i].style.visibility = 'hidden';}
  }
  licka = co.parentNode.getElementsByTagName('li');
  
  for(i=0; i< licka.length; i++){
    if(licka[i].className=="subactive") { licka[i].className="subactive"; }
    else { licka[i].className=""; } 
  }  
  co.className="active"
  
  try {
    ulka = co.getElementsByTagName('ul');
    for(i=0; i< ulka.length; i++){
      if(ulka[i].className=="sub") { ulka[i].style.visibility = 'visible';}
    } 
    
  } catch(e) {}
}

var duration = 0.3;
var fromV = 0;
var toV = 0.8;
var flashHeight = 390;
var flashWidth = 400;

var tempvideofile = null;


function StartVideo(videofile, popiska) {
  tempvideofile = videofile;
  
  var windowWidth, windowHeight, showWidth, showHeight ;
  // var temp = getPageSize();
  
  
  windowWidth = getScrollSize().x;
  windowHeight = getScrollSize().y;
  showinWidth = getSize().x;
  showinHeight = getSize().y;   
  
  // var temp = getPageScroll();
  scrLeft = getScroll().x;
  scrTop = getScroll().y;
  
  //alert(window.innerHeight);
  var container = $('videocontainer');
  container.style.height = windowHeight+'px';
  container.style.width = windowWidth+'px';
  
  
  var player = $('videoObal');
  // vycentrovani playeru
  
  
  player.style.top = Math.ceil(scrTop + ((showinHeight - flashHeight) / 2) ) + 'px'; // ( 
  player.style.left = Math.ceil(scrLeft + ((showinWidth - flashWidth) / 2)) + 'px';
  
  // preneseme popis videa do hlavicky
  $('videoHeaderName').innerHTML = popiska;
  
  
  // vypneme FLASHE na strance
  FlashSet('hidden');
  
  
  
  // zobrazime
  // Effect.Appear('videocontainer', { duration: duration, from : fromV, to : toV});
   $('videocontainer').setStyle('opacity', fromV);
   $('videocontainer').setStyle('display', 'block');
   $('videocontainer').fade(toV);
  
  
  
  // Tady je funkce pro zavreni
  $('videoCloseButt').onclick = function() {
    this.onclick = function(){return;}
    $('videoplayer').innerHTML = '';
    $('videocontainer').fade(fromV);
    $('videocontainer').setStyle('opacity', toV);
    
    window.setTimeout('FlashSet(\'visible\');', duration * 1000)
    // window.setTimeout('FlashSet(\'visible\');', duration * 1000);
    // $('videocontainer').setStyle('display', 'none');
  }
  
  window.setTimeout(showVideo, duration * 1000);
}




function showVideo() {

  var so = new SWFObject('/graphics/flash/mediaplayer.swf','videoplayer','400','300','8');
  so.addVariable('file',tempvideofile);
  so.addParam('allowscriptaccess','always');
  so.addParam('allowfullscreen','true');
  so.addVariable('height','300');
  so.addVariable('width','400');
  so.addVariable('searchbar','false');
  so.addVariable('overstretch','true');
  so.addVariable('showstop','true');
  so.addVariable('autostart','true');
  so.write('videoplayer');
}

function FlashSet(to) {
  // Napred vypnem objekty a embedy
  var temps = document.getElementsByTagName('embed');
  for(var i=0;i<temps.length;i++) {
    temps[i].style.visibility = to;
  }
  var temps = document.getElementsByTagName('object');
  for(var i=0;i<temps.length;i++) {
    temps[i].style.visibility = to;
  }
}


function clearPage() {
  
  taby = $$('.tabLong .tab_inner');
  if(taby != '') {
    tablong = 80;
    var delkaTabu = Array();

    $each(taby,
      function(value, key) {
        if(value.style.display == 'none') {
          value.setStyle('display', 'block');
          delkaTabu.push(value.getSize().y);
          value.setStyle('display', 'none');
        } else {
          delkaTabu.push(value.getSize().y);
        } 
      }
    );
    
    $each(delkaTabu, function(value) { if(value > tablong) { tablong = value; }   }  );
    
    if (Browser.Engine.trident) {
      $$('.tabMain .tabLong')[0].setStyle('height', tablong+'px' );
    } else {
      $$('.tabMain .tabLong')[0].setStyle('min-height', tablong+'px' );
    }
  }
  
  lmheight = $('leftmenu').getSize().y;
  mainheight = $$('#main div.cont')[0].getSize().y;
  
  if(lmheight > mainheight ) { // kdyz je delsi levy sloupec - prodlouzime pravy
    if (Browser.Engine.trident) {
      $$('#main div.long')[0].setStyle('height', (lmheight - 135)+'px' );
    } else {
      $$('#main div.long')[0].setStyle('min-height', (lmheight - 135)+'px' );
    }
  } else { // nebo prodlouzime ten levy
    var dopDef = $('doporucene').getSize().y; 
    
    $('doporucene').setStyle('height',( dopDef + (mainheight - lmheight) + 25  )+'px' );
    
    var dopRozdil = $('doporucene').getSize().y - dopDef;
    
    if (dopRozdil > 80) {
      var docist = Math.floor(dopRozdil / 77);
      var notin = '';
      
      $each($$('#doporucene a.tipthumb'), function(value) { notin = notin+','+value.rel; } );
      if(notin.length > 1) {
        notin = notin.substr(1)
      }
      var readurl = '/dalsidoporucene/'+ docist +'/'+ notin +'/';
      
      var htmlReq = new Request(
                      { method : 'get',
                        url : readurl,
                        onSuccess : function(response) {
                          $('doporucene').set('html', $('doporucene').get('html') + response );                         
                        }
                      
                      }
                    );
      htmlReq.send();
      
      
        
      
      
      

      
       
    }
    
    
    
    /*if (Browser.Engine.trident && (Browser.Engine.version < 5)) {
    
    } else {
      $('doporucene').setStyle('height',( $('doporucene').getSize().y + (mainheight - lmheight) + 16  )+'px' );
      $$('#main div.long')[0].setStyle('min-height', $$('#main div.long')[0].getSize().y+'px' );
    }*/
  } 
}




// function FlashSet(to) {
  // Napred vypnem objekty a embedy
  // $each( $$('embed') , function(co) { co.setStyle('visibility', to); }  ); // flash enable
	// $each( $$('object') , function(co) { co.setStyle('display', 'none'); }  );
// }



