//var GLOBAL_HOST_PREFIX = "http://69.50.193.83/";
var GLOBAL_HOST_PREFIX = "http://www.schwechater.at/";
var GLOBAL_ENTRY_PAGE  = GLOBAL_HOST_PREFIX + "home.html"; // fixxxx: set entry page
var MAINWINDOW_NAME    = "SCHWECHATER_HAUPTSEITE";

var GLOBAL_SUBMENU_TIMEOUT = 1500;
var GLOBAL_SUBMENU_TIMER = null;

var GLOBAL_CURRENT_MENU = "";

// version on customers/studio-isser/
//var PATH_TO_ROOT = "/schwechater";

// version on schwechater/studio-isser
var PATH_TO_ROOT = "";
var GLOBAL_MENUES = {"sortiment":  {
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_sor0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_sor1.gif"
                                   },
                     "brauerei":   {
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_bra0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_bra1.gif"
                                   },
                     "geschichte": {
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_ges0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_ges1.gif"
                                   },
                     "engagements":{
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_eng0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_eng1.gif"
                                   },
                     "werbung":    {
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_wer0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_wer1.gif"
                                   },
                     "ecards":     {
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_eca0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_eca1.gif"
                                   },
                     "kontakt":    {
                                     off:PATH_TO_ROOT+"/system/graphics/ge/but_kon0.gif",
                                     on :PATH_TO_ROOT+"/system/graphics/ge/but_kon1.gif"
                                   }
                    };


function showMenuEntry(theMenu)
{
  window.document.images["image_"+theMenu].src = GLOBAL_MENUES[theMenu].on;
  if (document.getElementById)
  {
    var obj = document.getElementById(theMenu);
    obj.style.visibility = "visible";
  }
}

function hideMenuEntry(theMenu)
{
  if (GLOBAL_CURRENT_MENU != theMenu)
  {
    // do not switch back to off-image
    window.document.images["image_"+theMenu].src = GLOBAL_MENUES[theMenu].off;
  }
  if (document.getElementById)
  {
    var obj = document.getElementById(theMenu);
    obj.style.visibility = "hidden";
  }
}

function hideAllMenues()
{
  for (var menu in GLOBAL_MENUES)
  {
    hideMenuEntry(menu);
  }
}
function showMenu(theMenu)
{
  for (var menu in GLOBAL_MENUES)
  {
    if (menu == theMenu)
    {
      showMenuEntry(menu);
    }
    else
    {
      hideMenuEntry(menu);
    }
  }
}

function startHideMenuTimer()
{
  GLOBAL_SUBMENU_TIMER = setTimeout('hideAllMenues()',GLOBAL_SUBMENU_TIMEOUT);
}

function stopHideMenuTimer()
{
  if (GLOBAL_SUBMENU_TIMER != null)
  {
    clearTimeout(GLOBAL_SUBMENU_TIMER);
  }
}

function setBoxSizeDelayed()
{
  if (typeof(GLOBAL_BOX_RESIZE)=="undefined")
  {
    GLOBAL_BOX_RESIZE = false;
  }
  if ( ! GLOBAL_BOX_RESIZE)
  {
    GLOBAL_BOX_RESIZE = true;
    setTimeout('setBoxSize()',100);
  }
}

function setBoxSize()
{
  GLOBAL_BOX_RESIZE = false;

  var offset_box_height = -10;
  var offset_text_height = -10;

  var window_height = 0;
  var window_width = 0;
  if (document.all)
  {
    window_height = document.body.clientHeight;
    window_width  = document.body.clientWidth;
  }
  else
  {
    window_height = top.content.innerHeight;
    window_width  = top.content.innerWidth;
  }

  if (window_height > 0)
  {
    // set box size
    var box_top = getAbsoluteTop("box_top_reference");
    var box_height = window_height-box_top+offset_box_height;
    if (box_height < 150)
    {
      box_height = 150;
    }
    document.getElementById("box").style.height=box_height+"px";

    // set text size
    var text_top = getAbsoluteTop("text_top_reference");
    var text_height = window_height-text_top+offset_text_height+offset_box_height;
    if (text_height < 100)
    {
      text_height = 100;
    }
    document.getElementById("text").style.height=text_height+"px";
  }
}

function reloadFrame()
{
  window.location.reload();
}

function setOnResizeMethod()
{
  if (document.getElementById)
  {
    if (document.all)
    {
      // ie
      window.onresize = setBoxSizeDelayed;
    }
    else
    {
      // netscape
      window.onresize = reloadFrame;
    }
  }
}

function getAbsoluteLeft(objectId)
{
  var o = document.getElementById(objectId);
  var oLeft = o.offsetLeft;
  while(o.offsetParent!=null)
  {
    var oParent = o.offsetParent;
    oLeft += oParent.offsetLeft;
    o = oParent;
  }
  return oLeft;
}

function getAbsoluteTop(objectId)
{
  var o = document.getElementById(objectId);
  var oTop = o.offsetTop;
  while(o.offsetParent!=null)
  {
    var oParent = o.offsetParent;
    oTop += oParent.offsetTop;
    o = oParent;
  }
  return oTop;
}

//check for embedded frame set
function isEmbeddedFrameset()
{
  if (parent.name == MAINWINDOW_NAME)
  {
    return true;
  }
  else
  {
    return false;
  }
}

//load frame set
function loadFrameset()
{
  window.location.href = GLOBAL_ENTRY_PAGE + "?LoadUrl=" + window.location.href;
}

if (!isEmbeddedFrameset())
{
  loadFrameset();
}