//absolutni cesta pro potreby obrazku
var host = (document.location.hostname == "localhost")?"http://localhost/rapid":"http://www.rapid.cz";

function okno(url) {
window.open(url,"","menubar=no,resizable=yes,status=yes,scrollbars=yes,location=yes,toolbar=yes,width=800,height=600,top=1,left=1");
}

function eshop_obrazek(url) {
  obrazek_big(url);
  return false;
}

function obrazek_big(url) {
  nPopUp = window.self.open(host+"/fotka.php?url="+url,"okno","width=100,height=100,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
}

function panorama_big(url) {
  nPopUp = window.self.open(host+"/data/panoramata.php?url="+url,"okno","width=100,height=100,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no");
}

function menu_zobraz (menu) {
  
  if (!checkUserAgentOS('windows') && menu == 'menu_fotogalerie' && document.getElementById('flashOrGif1')) {
    hideFlash(document.getElementById('flashOrGif1'));
  }

  objekt=document.getElementById(menu);
  objekt.style.visibility="visible";
}

function menu_skryj (menu) {
  
  if (!checkUserAgentOS('windows') && menu == 'menu_fotogalerie' && document.getElementById('flashOrGif1')) {
    showFlash(document.getElementById('flashOrGif1'));
  }
  
  objekt=document.getElementById(menu);
  objekt.style.visibility="hidden";

}



function menu_start()
{
 oldid=cookie("submenu");
 posun=cookie("posun");
 if (oldid!="0") submenu_ukaz(oldid,posun);
}

function cookie(string)
{
  var cookies=document.cookie;
  var pos=cookies.indexOf(string);
  if (pos!=-1) 
    {
    var start=pos+string.length+1;
    var end=cookies.indexOf(";",start);
    if (end ==-1) end=cookies.length;
    var value=cookies.substring(start, end)
    value=unescape(value);
    return value;
    }
    else return 0;
}

function submenu (id,posun)
{
  oldid=cookie("submenu");
  if (oldid!="0") {
    submenu_skryj(oldid,posun);
  }
  if (oldid!=id) {
    submenu_ukaz(id,posun);
  }
  
  return true;
}

function submenu_ukaz(id,posun)
{
  objekt=document.getElementById("submenu_"+id);
  document.cookie="posun="+posun+"; path=/";
  document.cookie="submenu="+id+"; path=/";
  objekt.style.display="block";
  objekt_li=document.getElementById("submenu_li_"+id);
  objekt_li.style.backgroundImage="url("+host+"/data/img/sidemenu_a_active.jpg)";

  objekt_content=document.getElementById("content");
  posun=480+34*posun;
  if (navigator.userAgent.indexOf('Opera') != -1) opera=true; 
  else opera=false;
  if (!document.all) objekt_content.style.minHeight=posun+'px';
  else if (opera) objekt_content.style.minHeight=posun+'px';
  else objekt_content.style.height=posun+'px';
  
  
}

function submenu_skryj (id,posun)
{
  
  objekt=document.getElementById("submenu_"+id);
  objekt.style.display="none";
  objekt_li=document.getElementById("submenu_li_"+id);
  
  if (id == 12) {
     objekt_li.style.backgroundImage="url("+host+"/data/img/sidemenu_bottom_a.jpg)";
  } else if (id == 1) {
     objekt_li.style.backgroundImage="url("+host+"/data/img/sidemenu_top_a.jpg)";
  } else {
     objekt_li.style.backgroundImage="url("+host+"/data/img/sidemenu_a.jpg)";
  }   
  
  objekt_content=document.getElementById("content");
  if (navigator.userAgent.indexOf('Opera') != -1) opera=true; 
  else opera=false;
  if (!document.all) objekt_content.style.minHeight='480px';
  else if (opera) objekt_content.style.minHeight='480px';
  else objekt_content.style.height='480px';
  id="0";
  document.cookie="submenu="+id+"; path=/";
  
  
}


/** obsahuje hodnotu flashe po jeho skryti */
var flashWrap;

/** schova flash */
function hideFlash(el) {
  flashWrap = el.getElementsByTagName('div')[0];
  el.className += ' noFlash';
  el.removeChild(flashWrap);
  
}

/** zobrazi flash */
function showFlash(el) {
  el.className.replace(' noFlash', '');
  el.appendChild(flashWrap);
  return true;
}


/** fce pro rozpoznani OS na kterem bezi browser */
function checkUserAgentOS(string) {
  var detect = navigator.userAgent.toLowerCase();
  if (detect.indexOf(string) == -1) {
    return false;
  }
  return true;
  
} 
