
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// all code done by Stefan Mateescu <stefan@mateescu.net>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

function showob(n)
{
	eval('if (ns4) '+n+'.visibility = "show";');
	eval('if (ie4) '+n+'.visibility = "visible";');
	eval('if (dom) '+n+'.visibility = "visible";');
}

function hideob(n)
{
	if (ns4) n.visibility = "hide";
	if (ie4) n.visibility = "hidden";
	if (dom) n.visibility = "hidden";
}

function makeob(n)
{ 
	eval("if (ns4) "+n+"ob = document."+n+";");
	eval("if (ie4) "+n+"ob = "+n+".style;");
	eval("if (dom) "+n+"ob = document.getElementById(\""+n+"\").style;");
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// settings
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

var btnwidths = new Array(186,10);

var xOffFrame =         168;
var xOffSpacer =        0;
var xOffLayer =         0;
var xOffOwn =           367-xOffFrame; // 227// 380
var yOffOwn =           0;
var xNSLayerAdd =       0;
var minLayerWidth =     100;
var layer_bgcolor =     "#59A5D9";
var repositionDelay =   500;
var anzlayers =         2;
var maxtime =           11;
var debug =             0;              // debug-level 0:nothing, 3:warnings, 7:all, 9:timeouts

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// global variables
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

var timerID = 0;
var loaded = false;
var layersloaded = false;
var timers = new Array(20);
var stopped = false;
var actSelected = -1;
var debuglines = 0;
var navimgbuf = new Array(20);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// navigation-data (predefined arrays)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

var smSessionID = 0;
if ( parent.smSessionID )
	smSessionID = parent.smSessionID;

var navi_0 = null;
var navi_1 = null;

if ( (parent.SSLflag) == 'on' ) 
{
navi_0 = new Array(
"BADER Vorteile",			"http://www.bader.ch/dl.asp?origin=ssl&other=adv&smSessionID=" + smSessionID, "_parent",
"Bestellvorgang",				"http://www.bader.ch/dl.asp?origin=ssl&other=bestvg&smSessionID=" + smSessionID, "_parent",
"Kontakt",				"http://www.bader.ch/dl.asp?origin=ssl&other=contact&smSessionID=" + smSessionID, "_parent",
"Adresse ändern",			"/content/address_modification/adressaenderung.asp?smSessionID=" + smSessionID, "view",
"Ratentabelle",		"http://www.bader.ch/dl.asp?origin=ssl&other=ratentab&smSessionID=" + smSessionID, "_parent",
"Ratenrechner",			"http://www.bader.ch/dl.asp?origin=ssl&other=ratenrech&smSessionID=" + smSessionID, "_parent",
"Grössenberatung/<br>Maßtabellen",				"http://www.bader.ch/dl.asp?origin=ssl&other=size&smSessionID=" + smSessionID, "_parent",
"Farb- und Typberatung",			"http://www.bader.ch/dl.asp?origin=ssl&other=color&smSessionID=" + smSessionID, "_parent",
"Tipps zur Textilpflege",			"http://www.bader.ch/dl.asp?origin=ssl&other=tips&smSessionID=" + smSessionID, "_parent",
"Sammelbesteller",				"http://www.bader.ch/dl.asp?origin=ssl&other=sammel&smSessionID=" + smSessionID, "_parent",
"AGB",				"http://www.bader.ch/dl.asp?origin=ssl&other=agb&smSessionID=" + smSessionID, "_parent",
//"Gewinnspiel",				"http://www.bader.ch/dl.asp?origin=ssl&other=gewinn&smSessionID=" + smSessionID, "_parent",
"","","");

navi_1 = new Array(
"Das Unternehmen",				"http://www.bader.ch/dl.asp?origin=ssl&other=company&smSessionID=" + smSessionID, "_parent",
"Kontakt",				"http://www.bader.ch/dl.asp?origin=ssl&other=contact&smSessionID=" + smSessionID, "_parent",
"E-Mail",				"/content/feedback/feedback.asp?smSessionID=" + smSessionID, "view",
" ",				"http://www.bader.ch/dl.asp?origin=ssl&other=press&smSessionID=" + smSessionID, "_parent",
"BADER vor Ort",			"http://www.bader.ch/dl.asp?origin=ssl&other=vorort&smSessionID=" + smSessionID, "_parent",
"Qualitätssicherung",				"http://www.bader.ch/dl.asp?origin=ssl&other=quality&smSessionID=" + smSessionID, "_parent",
"Impressum",			"http://www.bader.ch/dl.asp?origin=ssl&other=impressum&smSessionID=" + smSessionID, "_parent",
"","","");
}
else
{
navi_0 = new Array(
"BADER Vorteile",			"/content/advantages/bader_vorteile.asp?smSessionID=" + smSessionID, "view",
"Bestellvorgang",				"/content/order_transaction/bestellvorgang.asp?smSessionID=" + smSessionID, "view",
"Kontakt",				"/content/contact/kontakt.asp?smSessionID=" + smSessionID, "view",
"Adresse ändern",			"https://www.bader.ch/dl.asp?origin=ssl&other=adrupdate&smSessionID=" + smSessionID, "_parent",
"Ratentabelle",		"/content/installments_table/ratentabelle.asp?smSessionID=" + smSessionID, "view",
"Ratenrechner",			"/content/installments_calculator/ratenrechner_HW09.asp?smSessionID=" + smSessionID, "view",
"Grössenberatung/<br>Maßtabellen",				"/content/sizes/einstieg_groessen.asp?smSessionID=" + smSessionID, "view",
"Farb- und Typberatung",			"/content/color_type_advice/start.asp?smSessionID=" + smSessionID, "view",
"Tipps zur Textilpflege",			"/content/textile_care/textilpflege.asp?smSessionID=" + smSessionID, "view",
"Sammelbesteller",				"/content/sammelbestellung/sammelbestellung.asp?smSessionID=" + smSessionID, "view",
"AGB",				"/content/agb/agb.asp?smSessionID=" + smSessionID, "view",
//"Gewinnspiel",				"/content/riddle/gewinnspiel.asp?smSessionID=" + smSessionID, "view",
//" ",				"/content/ops/start.asp?smSessionID=" + smSessionID, "view",
//" ",			"/content/newsletter/subscribtion.asp?smSessionID=" + smSessionID, "view",
"","","");

navi_1 = new Array(
"Das Unternehmen",				"/content/company/unternehmen.asp?smSessionID=" + smSessionID, "view",
"Kontakt",				"/content/contact/kontakt.asp?smSessionID=" + smSessionID, "view",
"E-Mail",				"https://www.bader.ch/dl.asp?origin=ssl&other=mail&smSessionID=" + smSessionID, "_parent",
" ",				"/content/public_relations/public_relations.asp?smSessionID=" + smSessionID, "view",
"BADER vor Ort",			"/content/on_location/dirketkauf.asp?smSessionID=" + smSessionID, "view",
"Qualitätssicherung",				"/content/quality/qualitaet.asp?smSessionID=" + smSessionID, "view",
"Impressum",			"/content/corporate_info/impressum.asp?smSessionID=" + smSessionID, "view",
//" ",			"/content/newsletter/subscribtion.asp?smSessionID=" + smSessionID, "view",
"","","");
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// functions for debugging
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

if (debug>0)
{
    top.OpenWindow();
    top.DropLine("Frame <b>"+self.name+"</b> loaded!");
}

function trace(str, level)
{
    if (++debuglines>10 && debug>0)
    {
        top.dumpwnd.document.close();
        top.dumpwnd.document.clear();
        top.dumpwnd.document.open();
        debuglines=0;
    }
    if (debug==0) return;
    if (level<=debug) top.DropLine("&lt;Frame <b>"+self.name+"</b>&gt; "+str);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// functions for the upper navi-frame
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

function showobL1(n)
{
    if (parent.view && parent.view.layersloaded) { trace("Show Obj "+(n)+" in Content Frame",7); parent.view.showobCont(n); return; }
}

function hideobL1(n)
{
    if (parent.view && parent.view.layersloaded) { trace("HideEx Obj "+(n+1)+" in Content Frame",7); parent.view.hideobEx(n); return; }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// functions for the lower content-frame
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

function showobCont(n)
{
    if (!layersloaded)
    {
        trace("trying to hide object "+n+" but frame was not loaded, yet!",3);
        return;
    }
    
    // remove all !!!
    for (i=0;i<anzlayers;i++)
    {
	    eval("hideob(nav"+i+"ob);");
        timers[i]=0;
    }
    
    clearTimeout(timerID);
    
    if (ns4) offY = window.pageYOffset;
    if (ie4 || dom) offY = document.body.scrollTop;

	eval("obj = nav"+n+"ob;");
	if (ns4) obj.visibility = "show";
	if (ie4 || dom) obj.visibility = "visible";
}

function hideobEx(n)
{
    trace("hideobEx: tID:"+timerID+"; n:"+n+"; timers[n]:"+timers[n],9);

    clearTimeout(timerID);
    if (!stopped)
    {
        if (++timers[n]==maxtime)
        {
            timers[n]=0;
            eval("hideob(nav"+n+"ob);");
        }
        else
        {
            timerID = setTimeout("hideobEx("+n+");", "100");
        }
    }
    else
    {
        timers[n] = 0;
        timerID = setTimeout("hideobEx("+n+");", "100");
    }
}

function makenavob(n)
{
	eval("if (ns4) nav"+n+"ob = document.menu_"+n+";");
	eval("if (ie4) nav"+n+"ob = menu_"+n+".style;");
	eval("if (dom) nav"+n+"ob = document.getElementById(\"menu_"+n+"\").style;");
}

function initLayersInContent()
{
	// MH //
	// removed because of problems with deeplinks (evita)
    //if (top.location.href==this.location.href) return;

    trace("InitLayersInContent",7);

	loaded = true;

    for (i=0;i<anzlayers;i++)
    {
        timers[i]=0;
        makenavob(i);
	}

    layersloaded = true;
    repositionItems();
}

function repositionItems()
{
    trace("repositioning items...",9);
    setTimeout("repositionItems();", repositionDelay);
    if (ns4) { offY = window.pageYOffset; offX = window.pageXOffset;}
    if (ie4) { offY = document.body.scrollTop; offX = document.body.scrollLeft;}
    if (dom) { offY = self.pageYOffset; offX = self.pageXOffset;}

	if (ns4)
	{
	    nsfix = xOffFrame-parent.nav.window.innerWidth-4;
    	if (navigator.userAgent.indexOf("Mac") != -1) nsfix+=4;
	}
	else
		nsfix = 0;
		
    postmp = xOffOwn-xOffLayer+nsfix+offX;
    for (i=0;i<anzlayers;i++)
    {
    	eval("obj = nav"+(i)+"ob;");
        obj.left = postmp;
        obj.top = offY+yOffOwn;
        postmp += btnwidths[i]+xOffSpacer;
    }
}

function docwrite_layers()
{
	trace("docwrite_layers",9);

	// MH //
	// removed because of problems with deeplinks (evita)
    //if (top.location.href==this.location.href) return;
    
    for (var j=0;j<anzlayers;j++)
    {
        outbuf = "";
        outbuf += '<div id="menu_'+(j)+'" class="stddiv" onmouseover="stopped=true;" onmouseout="stopped=false;">';
        outbuf += '<table width="162" cellspacing="0" cellpadding="0" border="1" bordercolor="#B8DADA" bgcolor="'+layer_bgcolor+'"><tr><td bgcolor="'+layer_bgcolor+'">';
        outbuf += '<table cellspacing="0" cellpadding="0" border="0">';
        eval ('outbuf += docwrite_layersAdd(navi_'+(j)+');');
        outbuf += '</table>';
        outbuf += '</td></tr></table>';
        outbuf += '</div>';
        document.write(outbuf);
    }
}

function docwrite_layersAdd(submenu)
{
    out = "";
    for (i=0;i<submenu.length/3-1;i++)
    {
		// MH //
		// do not show empty menu topics (new line: if...) //
		if ( (submenu[i*3]).length>1 )
			out += "<tr><td valign=\"top\"><font class=\"laynavtxt\">&nbsp;&#0149;&nbsp;</font></td><td><a class=\"laynav\" target=\""+submenu[i*3+2]+"\" href=\""+submenu[i*3+1]+"\" onmouseover=\"stopped=true;\" onmouseout=\"stopped=false;\">"+submenu[i*3]+"</a></td></tr>\n";
    }
    return out;
}

