sfHover = function() {
  if(document.getElementById("nav")) {
  	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
  	for (var i=0; i<sfEls.length; i++) {
  		sfEls[i].onmouseover=function() {
  			this.className+=" sfhover";
  		}
  		sfEls[i].onmouseout=function() {
  			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
  		}
  	}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function hide_help () {
	$('show').style.display = 'block';
	$('hide').style.display = 'none';
}

function animHandler(carouselID, status, direction) {
  var region = $(carouselID).down(".carousel-clip-region")
  if (status == "before") {
    Effect.Fade(region, {to: 1, queue: { position:'end', scope: "carousel" }, duration: 0.2})
  }
  if (status == "after") {
    Effect.Fade(region, {to: 1, queue: { position:'end', scope: "carousel" }, duration: 0.2})
  }
}

function initCarousel_html_carousel() {
  if(document.getElementById('html-carousel')) {
    carousel = new Carousel('html-carousel', {animHandler:animHandler, animParameters:{duration:0.5}, buttonStateHandler:buttonStateHandler, nextElementID:'next-arrow', prevElementID:'prev-arrow', size:31})
  }

  if(document.getElementById('html-carousel-2')) {
    carousel2 = new Carousel('html-carousel-2', {animHandler:animHandler, animParameters:{duration:0.5}, buttonStateHandler:buttonStateHandler, nextElementID:'next-arrow-2', prevElementID:'prev-arrow-2', size:31})
  }
};

EventQB.observe(window, 'load', initCarousel_html_carousel);

/**
*Funkce pro zmenu obrazku
*
*@param newImgSrc relativni cesta k obrazku
*@param newImgDesc popisek obrazku (zobrazeny pod obrazkem)
*@param width sirka obrazku
*@param height vyska obrazku
*/
function changeImg(newImgSrc, newImgDesc, width, height) {

  var mainImg = new Image(width, height);
  mainImg.src = newImgSrc;

  //maximalni pripustne rozmery pro obrazek na sirku / na vysku
  var wideImgMaxWidth = 500;
  var highImgMaxWidth = 300;

  //nastaveni nove cesty k obrazku
  document.images['mainImg'].src = newImgSrc;

  //nastaveni popisku
  document.images['mainImg'].alt = newImgDesc;

  //nastaveni popisku obrazku
  document.getElementById('photoDescription').innerHTML = newImgDesc;

  //aktualizace sirky bloku s obrazkem podle rozmeru obrazku
  //obrazek je "na sirku"
  if (width == 0) {
    //osetreni, kdyby se nahodou nenacetla spravne velikost
    width = highImgMaxWidth;
  }
  if (width >= height) {
    if (width > wideImgMaxWidth) {
      setDimensions('detailPreviewDiv', 'mainImg', wideImgMaxWidth);
      } else {
        //zachovat stejnou velikost
        setDimensions('detailPreviewDiv', 'mainImg', width);
    }
  } else {
  //obrazek je "na vysku"
    if (width > highImgMaxWidth) {
      setDimensions('detailPreviewDiv', 'mainImg', highImgMaxWidth);
      } else {
        //zachovat stejnou velikost
        setDimensions('detailPreviewDiv', 'mainImg', width);
    }
  }
}

/**
 * nastavi spravne rozmery pro obrazek i odsazeni vedlejsiho sloupce
 */
function setDimensions(divId, imgName, size) {
  document.getElementById(divId).style.width = size + 'px';
  document.getElementsByName(imgName)[0].style.width = size+'px';
  var ddWidth = 730 - size;
  if(ddWidth < 220) {
    ddWidth = 220;
  }
  document.getElementById("detailDescr").style.width = ddWidth + 'px';
}

/**
 * obsluzna fce pro vyhledavani aktivit podle "poctu hvezdicek"
 * @param no pocet hvezdicek zadany uzivatelem
 */
function setStarCount(no) {

 /*nastaveni form. pole*/
 document.EDITOR.ratingCount.value = no;

 var pcWidth;

 /*nastaveni poctu aktivnich hvezdicek po vybrani*/
 switch(no) {
  case 1:
    pcWidth = '20%';
    break
  case 2:
    pcWidth = '40%';
    break
  case 3:
    pcWidth = '60%';
    break
  case 4:
    pcWidth = '80%';
    break
  case 5:
    pcWidth = '100%';
    break
  }
 document.getElementById('starCount').style.width = pcWidth;
}

/**
 * slouzi pro presmerovani obsahu stranky
 * na novy link pro panel rychlych odkazu
 */
function changeLink(id) {
  var select = document.getElementById(id);
  var selected = select.selectedIndex;
  var value = select.options[selected].value;
  
  //z duvodu "nevybrani" pri stisku Zpet v prohlizeci
  select.options[0].selected = true;
  
  window.location = value;
}
