
dom = document.layers;
var objScroller;

function encode64(inp){
    var key="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var chr1,chr2,chr3,enc3,enc4,i=0,out="";
    while(i<inp.length){
        chr1=inp.charCodeAt(i++);if(chr1>127) chr1=88;
        chr2=inp.charCodeAt(i++);if(chr2>127) chr2=88;
        chr3=inp.charCodeAt(i++);if(chr3>127) chr3=88;
        if(isNaN(chr3)) {enc4=64;chr3=0;} else enc4=chr3&63
        if(isNaN(chr2)) {enc3=64;chr2=0;} else enc3=((chr2<<2)|(chr3>>6))&63 
        out+=key.charAt((chr1>>2)&63)+key.charAt(((chr1<<4)|(chr2>>4))&63)+key.charAt(enc3)+key.charAt(enc4);
    }
    return encodeURIComponent(out);
}

  var keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";

   function decode64(input) {
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;

      // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
      var base64test = /[^A-Za-z0-9\+\/\=]/g;
      if (base64test.exec(input)) {
         alert("There were invalid base64 characters in the input text.\n" +
               "Valid base64 characters are A-Z, a-z, 0-9, ?, ?, and ?\n" +
               "Expect errors in decoding.");
      }
      input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

      do {
         enc1 = keyStr.indexOf(input.charAt(i++));
         enc2 = keyStr.indexOf(input.charAt(i++));
         enc3 = keyStr.indexOf(input.charAt(i++));
         enc4 = keyStr.indexOf(input.charAt(i++));

         chr1 = (enc1 << 2) | (enc2 >> 4);
         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
         chr3 = ((enc3 & 3) << 6) | enc4;

         output = output + String.fromCharCode(chr1);

         if (enc3 != 64) {
            output = output + String.fromCharCode(chr2);
         }
         if (enc4 != 64) {
            output = output + String.fromCharCode(chr3);
         }

         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";

      } while (i < input.length);

      return output;
   }

function getlayer(param){
   if(dom)
       return document.layers[param];
	else{
	   if( navigator.userAgent.indexOf("MSIE 4.0") != -1)
		    return document.all[param].style;
		else 		    
          return document.getElementById(param).style;
	}
}


layerliste = new Array("subnaviprod","subnavidown","subnavibrand");


function show_layer(param){
    var obj;
	var offset;
    obj = getlayer(param);
	
	// Ermittlung der Position:
	/*
	offset = (window.innerWidth - 1000)/2;
	
	if(offset < 0)
		offset = 0;
	if(param == "subnaviprod")	
		obj.left = (offset + 235);
	if(param == "subnavidown")	
		obj.left = (offset + 420);
	*/	
    obj.visibility = "visible";
}


close_layer_time = false;
downtimeout = false;
uptimeout = false; 

function set_trigger(){
   window.clearTimeout(close_layer_time);  
}

function set_hide_trigger(){
	// Wenn nicht schon gesetzt, dann setzen. sonst nix machen!
    close_layer_time = window.setTimeout("hide_all()",700);
}



function hide_all(param){
	/*
       var obj;
       for(i=0; i<layerliste.length; i++){
          obj = getlayer(layerliste[i]);
	  	obj.visibility = "hidden";

       }
	
	*/
   window.clearTimeout(downtimeout);
   window.clearTimeout(uptimeout);
   
	set_trigger();	
	if(param != "objScroller")
		PerformScroll(objScroller,10);
	if(param != "objScroller2")
		PerformScroll(objScroller2,10);
	if(param != "objScroller3")
		PerformScroll(objScroller3,10);			// DD-NEt Calendar
	if(param != "objScroller4")
		PerformScroll(objScroller4,10);			//Brand Profile
	
}

function Layer_hide(p){
   var show = "visible";
   if(p == "0" && dom)
	   	show = "hide";
	else if(p == "0" && !dom)
	   	show = "hidden";
	else if(p == "1" && dom)
	      show = "show";
	if(dom)
	   this.visibility = show;
	else
	   this.style.visibility = show;
}
     

function Layer_setPos(x,y){
   if(dom){
		this.left = x;
		this.top = y;
	}
	else{
		this.style.left = x;
		this.style.top = y;
	}
}
function pop_up_spiel(param){
   a= window.open(param,'','width=720,height=490');
}
function pop_up(param){
   a= window.open(param,'','width=690,height=540');
}



function change(id, inhalt){
      document.all.naviunten.innerHTML = inhalt;
}


function imgover(imgname,neu){
      document[imgname].src = neu;
}

function imgout(imgname,neu){
       document[imgname].src = neu;       
}


function hilfe_popup(param){

     a = window.open(param, "","width=440,height=400,scrollbars=yes");

}

// begin absolutely positioned scrollable area object scripts
function verifyCompatibleBrowser(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;

    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
}

bw=new verifyCompatibleBrowser()
var speed=10
var loop, timer


function ConstructObject(obj,nest){

    nest=(!nest) ? '':'document.'+nest+'.'

    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
        this.el = document.getElementById(obj);


    this.thecss=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;

    this.scrollHeight=bw.ns4?this.thecss.document.height:this.el.offsetHeight
    this.clipHeight=bw.ns4?this.thecss.clip.height:this.el.offsetHeight

   // this.scrollHeight=this.el.offsetHeight;
    //this.clipHeight=this.el.offsetHeight;

    this.up=MoveAreaUp;
    this.down=MoveAreaDown;
    this.MoveArea=MoveArea;
    this.x;
    this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function MoveArea(x,y){
//    alert(x);
//    alert(y);
//    alert(this.x);


    this.x=x;
    this.y=y

    this.thecss.left=this.x
    this.thecss.top=this.y
}

function MoveAreaDown(move){
        //alert(this.y + " " + (-this.scrollHeight) + " " +objContainer.clipHeight);

        //if(this.y > -this.scrollHeight+objContainer.clipHeight){
       if(this.y > -(objContainer.clipHeight)){
      
            this.MoveArea(this.x,this.y-move);
            if(loop)
            	downtimeout = setTimeout(this.obj+".down("+move+")",speed);
        }
}
function MoveAreaUp(move){

        if(this.y<0){
            this.MoveArea(this.x,this.y-move);
            if(loop)
            	uptimeout = setTimeout(this.obj+".up("+move+")",speed);
        }
}

function PerformScroll(scrolldiv,speed){
        if(initialised){

                loop=true;
                if(speed>0)
                        scrolldiv.down(speed)
                else
                        scrolldiv.up(speed)
        }
}

function CeaseScroll(){
    loop=false
    if(timer) clearTimeout(timer)
}
var initialised;
function InitialiseScrollableArea(){
	
    objContainer=new ConstructObject('subnaviprod');
    objScroller=new ConstructObject('divContentprod','subnaviprod');
    objScroller.MoveArea(0,-250);
    objContainer.thecss.visibility='visible';
    
    objContainer2=new ConstructObject('subnavidown');
    objScroller2=new ConstructObject('divContentdown','subnavidown');
    objScroller2.MoveArea(0,-140);
    objContainer2.thecss.visibility='visible';
	
	// Calendar Pulldown im DD-net:
    objContainer3=new ConstructObject('subnavicalendar');
    objScroller3=new ConstructObject('divContentcalendar','subnavicalendar');
    objScroller3.MoveArea(0,-40);
    objContainer3.thecss.visibility='visible';	
    
    objContainer4=new ConstructObject('subnavibrand');
    objScroller4=new ConstructObject('divContentbrand','subnavibrand');
    objScroller4.MoveArea(0,-60);
    objContainer4.thecss.visibility='visible';	
    
    initialised=true;
}


function showTable(layID){
	if (document.getElementById(layID).style.display == "none") {
		document.getElementById(layID).style.display = "";
		document.getElementById(layID + "_0").style.display = "";
		document.getElementById(layID + "_1").style.display = "none";
	} else {
		document.getElementById(layID).style.display = "none";
		document.getElementById(layID + "_0").style.display = "none";
		document.getElementById(layID + "_1").style.display = "";
	}
}



function open_presentation(param){
	url = "/flash/dd_presentation.php?param=" + param;
	a = window.open(url,"DanishDesign","width=740,height=600,scrollbars=no");
}
