var menuTimeout = 400;
var menuOffsetWidth = 0;
var menuOffsetHeight = -1;

var menuId = 'menu';
var menuTree = new Array();
var menuSections = new Array();
var menuSectionsCountHide = new Array();
var menuSectionsVisible = new Array();

var menuBrowser = navigator.userAgent.toLowerCase();
var menuBrowserIsOpera = menuBrowser.indexOf('opera') != -1;
var menuBrowserIsIE = menuBrowser.indexOf('msie') != -1 && !menuBrowserIsOpera;
//alert(navigator.userAgent);
    
function menuInit() {
    menuMakeIds(document.getElementById(menuId).childNodes, menuTree, menuId, 0, 0, 0);
    for (var i = 0; i < menuSections.length; i++) {
        menuSectionsCountHide[menuSections[i]] = 0;
    }
    for (var i = 0; i < menuSections.length; i++) {
        menuInitSection(menuSections[i], menuGetTreeById(menuSections[i]));
    }
}

function menuMakeIds(nodes, tree, id, lastOW, lastBLW, lastBRW) {
    for (var i = 0; i < nodes.length; i++) {
        switch (nodes[i].className) {
            case "top":
            case "box-right":
                id = id + "-" + tree.length;
                nodes[i].id = id;
                if (menuBrowserIsIE && document.compatMode && document.compatMode != "BackCompat") {
                    if (nodes[i].className == "box-right" && nodes[i].currentStyle) {
                        var tmp;
                        tmp = lastBLW + lastBRW;
                        if (tmp) {
                            tmp = Math.floor(tmp / 2) + 1;
                        }
                        nodes[i].style.width = lastOW - ( parseInt(nodes[i].currentStyle.paddingLeft) + parseInt(nodes[i].currentStyle.paddingRight) ) - tmp;
                    }
                }
                tree[tree.length] = new Array();
                tree = tree[tree.length - 1];
                break;
            case "box":
                nodes[i].id = id + "-" + tree.length;
                tree[tree.length] = new Array();
                break;
        }
        var className = new String(nodes[i].className);
        if (menuBrowserIsIE && !(document.compatMode && document.compatMode != "BackCompat")) {
            if (className == "box" || className == "box-hover") {
                nodes[i].style.width = "100%";
            }
        }
        if (className == "section") {
            if (!menuBrowserIsIE) {
                nodes[i].style.width = "100%";
            }
            nodes[i].style.left = (lastOW + menuOffsetWidth) + "px";
            nodes[i].style.top = menuOffsetHeight + "px";
        }
        if (className.substr(0, 7) == "section") {
            menuSections[menuSections.length] = id;
            nodes[i].id = id + "-section";
            lastOW = nodes[i].offsetWidth;
            if (nodes[i].currentStyle) {
                lastBLW = parseInt(nodes[i].currentStyle.borderLeftWidth);
                lastBRW = parseInt(nodes[i].currentStyle.borderRightWidth);
            }
        }
        if (nodes[i].childNodes) {
            menuMakeIds(nodes[i].childNodes, tree, id, lastOW, lastBLW, lastBRW);
        }
    }
}

function menuInitSection(id_section, tree) {
    eval("document.getElementById('"+id_section+"').onmouseover = function() {"+
        "menuShow('"+id_section+"');"+
        "if (document.getElementById('"+id_section+"').className == 'box-right') {"+
            "document.getElementById('"+id_section+"').className = 'box-right-hover';"+
        "}"+
    "}");
    eval("document.getElementById('"+id_section+"').onmouseout = function() {"+
        "setTimeout(\"menuTryHide('"+id_section+"', \"+menuSectionsCountHide['"+id_section+"']+\")\", menuTimeout);"+
        "if (document.getElementById('"+id_section+"').className == 'box-right-hover') {"+
            "document.getElementById('"+id_section+"').className = 'box-right';"+
        "}"+
    "}");
    for (var i = 0; i < tree.length; i++) {
        var id = id_section + "-" + i;
        if (tree[i].length == 0) {
            eval("document.getElementById('"+id+"').onmouseover = function() {"+
                "menuShow('"+id_section+"');"+
                "document.getElementById('"+id+"').className = 'box-hover';"+
            "}");
            eval("document.getElementById('"+id+"').onmouseout = function() {"+
                "setTimeout(\"menuTryHide('"+id_section+"', \"+menuSectionsCountHide['"+id_section+"']+\")\", menuTimeout);"+
                "document.getElementById('"+id+"').className = 'box';"+
            "}");
        }
    }
}

function menuShow(id_section) {
    var sections = menuGetIdParentsArrById(id_section, true);
    for (var i = 0; i < sections.length; i++) {
        menuSectionsCountHide[sections[i]]++;
    }
    for (var i = 0; i < menuSectionsVisible.length; i++) {
        if (!menuArrayContains(sections, menuSectionsVisible[i])) {
            menuHide(menuSectionsVisible[i]);
        }
    }
    document.getElementById(id_section + "-section").style.zIndex = 10;
    document.getElementById(id_section + "-section").style.visibility = 'visible';
    menuSectionsVisible = sections;
}

function menuTryHide(id_section, count) {
    if (count == menuSectionsCountHide[id_section]) {
        var sections = menuGetIdParentsArrById(id_section, true);
        if (menuArraysEqual(sections, menuSectionsVisible)) {
            for (var i = 0; i < sections.length; i++) {
                menuHide(sections[i]);
            }
        } else {
            menuHide(id_section);
        }
    }
}

function menuHide(id_section) {
    document.getElementById(id_section + "-section").style.visibility = 'hidden';
    document.getElementById(id_section + "-section").style.zIndex = 10;
}

function menuGetTreeById(id) {
    var a = id.split("-");
    a.shift();
    var s = "";
    for (var i = 0; i < a.length; i++) {
        s += ("[" + a[i] + "]");
    }
    return eval("menuTree" + s);
}

function menuGetIdParentsArrById(id, includeSelf) {
    var a = id.split("-");
    var ret = new Array();
    if (includeSelf) {
        ret[ret.length] = id;
    }
    while (a.length > 2) {
        a.pop();
        ret[ret.length] = a.join("-");
    }
    return ret;
}

function menuArrayContains(a, s) {
    var found = false;
    for (var i = 0; i < a.length; i++) {
        if (a[i] == s) {
            found = true;
            break;
        }
    }
    return found;
}

function menuArraysEqual(a1, a2) {
    if (a1.length != a2.length) {
        return false;
    }
    for (var i = 0; i < a1.length; i++) {
        if (a1[i] != a2[i]) {
            return false;
        }
    }
    return true;
}
var Datum = new Date();
var tt = Datum.getDate();
var btt = tt+7;
var mM = Datum.getMonth() + 1;
var bmM = mM;
var tage31 = true;
if (mM%2==0) tage31 = false;
if (tage31) {
	if (btt > 31) {
		btt = btt-31;
		bmM++; }
	}
else {
	if (btt > 30) {
		btt = btt-30;
		bmM++;
	}
}
var jjjj = Datum.getFullYear();
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//ncm smooth transition slideshow
var slideShowSpeed = 4000
var crossFadeDuration = 3
var Pic = new Array() // don't touch this

//bildchen
Pic[0] = '/images/top_sommer.jpg'; Pic[1] = '/images/top_zimmer.jpg'; Pic[2] = '/images/top_wellness.jpg'; Pic[3] = '/images/top_sommer3.jpg'; Pic[4] = '/images/top_wandern.jpg'; Pic[5] = '/images/dummy.jpg'; Pic[6] = '/images/top_galerie.jpg'; Pic[7] = '/images/top_newsletter.jpg'; Pic[8] = '/images/top_preise.jpg'; Pic[9] = '/images/top_kulinarisch.jpg'; Pic[10] = '/images/top_sommer2.jpg'; Pic[11] = '/images/top_wasser.jpg';
// winter: Pic[0] = '/images/top_winter.jpg'; Pic[1] = '/images/top_zimmer.jpg'; Pic[2] = '/images/top_wellness.jpg'; Pic[3] = '/images/top_alpl.jpg'; Pic[4] = '/images/top_galerie.jpg'; Pic[5] = '/images/top_ski.jpg';

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
 preLoad[i] = new Image()
 preLoad[i].src = Pic[i]
}

function runSlideShow(){
 if (document.all){
 document.images.SlideShow.style.filter='blendTrans(duration=crossFadeDuration)'
 document.images.SlideShow.filters.blendTrans.Apply() 
 }
 document.images.SlideShow.src = preLoad[j].src
 if (document.all){
 document.images.SlideShow.filters.blendTrans.Play()
 }
 j = j + 1
 if (j > (p-1)) j=0
 t = setTimeout('runSlideShow()', slideShowSpeed)
}



function gallery(id,cat,imgs,lang){
	url = "/gallery.php?id="+id+"&cat="+cat+"&imgs="+imgs+"&lang="+lang;
	width = "600";
	height = "465";
	name = "";
	window.open(url,name,'height='+height+',width='+width);
}


function showhide(name) {
	var e = document.getElementById(name);
	e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}