// JavaScript Document

function showMenu(id){
  if(document.getElementById("menu"+id) != null)
    if(document.getElementById("menu"+id).style.display=="none")
      Effect.BlindDown("menu"+id, { duration: 1 });
}

function show_hide(id){
  if (document.getElementById(id).style.display=="none"){
    Effect.BlindDown(id, { duration: 0.3 });
  }
  else{ 
    Effect.BlindUp(id, { duration: 1 });
  }
}

function show_hide_slide(id){
  if (document.getElementById(id).style.display=="none"){
    Effect.SlideDown(id, { duration: 0.3 });
  }
  else{ 
    Effect.SlideUp(id, { duration: 1 });
  }
}

function hideInputText(item, text){
  if(item.value==text){
    item.value="";
    item.style.color="black";
  }         
}

function setMenuHeight(){
  if(winH() != null) document.getElementById("verticalMenu").style.height = (winH() - 130) + "px";
}


function winH() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}


function autoGrowField(f, max) {
   /* Default max height */
   var max = (typeof max == 'undefined')?300:max;
   /* Don't let it grow over the max height */
   if (f.scrollHeight > max) {
      /* Add the scrollbar back and bail */
      if (f.style.overflowY != 'scroll') { f.style.overflowY = 'scroll' }
      return;
   }
   /* Make sure element does not have scroll bar to prevent jumpy-ness */
   if (f.style.overflowY != 'hidden') { f.style.overflowY = 'hidden' }
   /* Now adjust the height */
   var scrollH = f.scrollHeight;
   if( scrollH > f.style.height.replace(/[^0-9]/g,'') ){
      f.style.height = scrollH+'px';
   }
}


function setAdvertData(group, randId, id){
  data = document.getElementById('adData-'+group+'-'+randId+'-'+id).innerHTML.split("^"); 
  item = document.getElementById('adForm-'+group+'-'+randId);

  item.advert_id.value= data[0];
  item.advert_name.value= data[2];
  item.advert_from.value= data[3];
  item.advert_to.value= data[4];
  
  for(var i = 0; i < item.advert_filename.length; i++){
    if(item.advert_filename.options[i].value == data[1]){
      item.advert_filename.selectedIndex = i;
      break;
    }
  }
  
  setAdvertSwf(group, randId, data[1])

  table = document.getElementById('adTable-'+group+'-'+randId);
  for(var i = 1; i < table.rows.length; i++){
    table.rows[i].setAttribute("class", "");
  }  
}


function setAdvertSwf(group, randId, filename){
  var dim = new Array();
  dim[1] = new Array(728,90);
  dim[2] = new Array(468,60);
  dim[3] = new Array(728,90);
  dim[4] = new Array(120,600);
  
  swfobject.embedSWF("public/reklama/"+filename, "ad-"+group+"-"+randId, dim[group][0], dim[group][1], "9.0.0");  
}
