/*
===================================================
By Xploïse,  http://www.xploise.nl

Fade function from: http://www.liquidpulse.net/code/javascript/styles/thealphaeffect
Adjusted to crossbrowser (gecko) functionality

getObj from: http://www.quirksmode.org/js/dhtmloptions.html

slide funtion from: http://home.arcor.de/michaels.interface/dhtml.htm
Completely rebuild to slide multiple layers... Basically changed to a DHTML slide menu
===================================================
*/

/* 
array idle and wait needed to reset the timeout by a new onmouse over
array busy to avoid slide starts before slide back is finished
*/

var DHTML = (document.getElementById || document.all || document.layers);
var idle=new Array();
var wait=new Array();
var busy=new Array();
var scrolling=0;
var prev_fadobj='';
var fading=0;

/*
parameters fade function
i: start opacity
j: end opacity
fadeObject: the object which will be faded :)
*/

function fadeIn(i,j,fadeObject){
fading=1;
	if (navigator.appName == "Microsoft Internet Explorer") {
		document.getElementById(fadeObject).filters.alpha.opacity=i;
		i=i+5;
		if (i<j){ setTimeout("fadeIn("+i+","+j+",'"+fadeObject+"')",0);
}else{
fading=0;}

	}else{
                o=i/100;
                document.getElementById(fadeObject).style.Opacity=o;
                i=i+5;
                if (i<j){ setTimeout("fadeIn("+i+","+j+",'"+fadeObject+"')",0);
}else{
fading=0;}
	}
}

function fadeOut(i,j,fadeObject){
fading=1;
	if (navigator.appName == "Microsoft Internet Explorer") {
		document.getElementById(fadeObject).filters.alpha.opacity=i;
		i=i-5;
		if (i>j){ setTimeout("fadeOut("+i+","+j+",'"+fadeObject+"')",0);
}else{
fading=0;}
	}else{
                o=i/100;
                document.getElementById(fadeObject).style.Opacity=o;
		i=i-5;
                if (i>j){ setTimeout("fadeOut("+i+","+j+",'"+fadeObject+"')",0);
}else{
fading=0;}
	}
}

/* 
general function to get object and style info of a layer
*/

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

/*
slide function parameters
slides and timers (which time before starting the timer): (i,sp,ed,'name')
i: number of pixels to move
sp: start position (also needed in CSS!)
ep: end position
name: id of the div in the menu folder which will slide
*/

function scroll_y(i,ep,layer,fadobj){
		if (!DHTML) return;
		scrolling=1;
		var y = new getObj(''+layer+'');
		if((ep-(parseInt(y.style.top)) >= 120) || ((parseInt(y.style.top)-ep) >= 120)){
		i=12;
		}else if((ep-(parseInt(y.style.top)) >= 80) || ((parseInt(y.style.top)-ep) >= 80)){
		i=8;
		}else if((ep-(parseInt(y.style.top)) >= 40) || ((parseInt(y.style.top)-ep) >= 40)){
		i=4;
		}else if((ep-(parseInt(y.style.top)) >= 20) || ((parseInt(y.style.top)-ep) >= 20)){
		i=2;
		}else{
		i=1;
		}
		if(parseInt(y.style.top) < ep){
		y.style.top=parseInt(y.style.top) + i + "px";
		setTimeout("scroll_y("+i+","+ep+",'"+layer+"','"+fadobj+"')",0);
		}
		else if(parseInt(y.style.top) > ep){
                y.style.top = parseInt(y.style.top) - i + "px";
		setTimeout("scroll_y("+i+","+ep+",'"+layer+"','"+fadobj+"')",0);
		}else if(parseInt(y.style.top)== ep){
		fadeIn(20,100,fadobj)
		prev_fadobj=fadobj;
		setTimeout("scrolling=0;",100);
		}
         }

function slideDown(i,sp,ep,layer){
	if (busy[layer]==1){ // timeout to wait for slideUp to finish 
	setTimeout("slideDown("+i+","+sp+","+ep+",'"+layer+"')",100);
        return;
	}
		if (!DHTML) return;
		var y = new getObj(''+layer+'');
		if(y.style.top==''){ // the first slide getObj does not get correct top info from CSS. Workaround
		y.style.top=sp+"px";
		}
		if(parseInt(y.style.top) < ep){
		y.style.top=parseInt(y.style.top) + i + "px";
			setTimeout("slideDown("+i+","+sp+","+ep+",'"+layer+"')",5);
                }
        }



function slideUp(i,sp,ep,layer){
        	if (!DHTML) return;
        	busy[layer]=1; // set busy variable
		var y = new getObj(''+layer+'');
		if(y.style.top==''){
		y.style.top=sp+"px";
		}
                if(parseInt(y.style.top) > ep){
                        y.style.top = parseInt(y.style.top) - i + "px";
                        setTimeout("slideUp("+i+","+sp+","+ep+",'"+layer+"')",5);
                }else{
                busy[layer]=0; // unset busy variable
                }
        }
        
function slideRight(i,sp,ep,layer){
	if (busy[layer]==1){
	setTimeout("slideRight("+i+","+sp+","+ep+",'"+layer+"')",100);
	return;
	}
        	if (!DHTML) return;
        	var x = new getObj(''+layer+'');
		if(x.style.left==''){
		x.style.left=sp+"px";
		}
                if(parseInt(x.style.left) < ep){
                        x.style.left = parseInt(x.style.left) + i + "px";
                        setTimeout("slideRight("+i+","+sp+","+ep+",'"+layer+"')",5);
                }
        }


function slideLeft(i,sp,ep,layer){
        	if (!DHTML) return;
        	busy[layer]=1;
        	var x = new getObj(''+layer+'');
		if(x.style.left==''){
		x.style.left=sp+"px";
		}
                if(parseInt(x.style.left) > ep){
                        x.style.left = parseInt(x.style.left) - i + "px";
                        setTimeout("slideLeft("+i+","+sp+","+ep+",'"+layer+"')",5);
                }else{
                busy[layer]=0;
                }
        }
        
function ShowHide(id, visibility) {
		if (!DHTML) return;
        	var x = new getObj(''+id+'');
    		x.style.visibility = visibility;
}

function expand(id){
		if (!DHTML) return;
		var x = new getObj(''+id+'');
         if(x.style.display == 'none')
 {
  x.style.display = 'block';
 }
}

function exchange(id){
		if (!DHTML) return;
		var img = 'img_' + id;
        	var x = new getObj(''+id+'');
        	var y = new getObj(''+img+'');
 if(x.style.display == 'none')
 {
  x.style.display = 'block';
  y.obj.src='image/open.gif';
 } else
 {
  x.style.display = 'none';
  y.obj.src='image/closed.gif';
 }

}

function timerUp(i,sp,ep,layer) {
idle[layer]=setTimeout("slideUp("+i+","+sp+","+ep+",'"+layer+"')",600);
}

function timerLeft(i,sp,ep,layer) {
wait[layer]=setTimeout("slideLeft("+i+","+sp+","+ep+",'"+layer+"')",600);
}

function althref(link) {
window.location=link;
}

function calc(id,i,layer,fadobj){
if (scrolling!=0 || fading!=0 || prev_fadobj==fadobj){
return;
}else{
if(prev_fadobj!=''){
		fadeOut(100,20,prev_fadobj);
  }
ep=(1-id)*125+10;
setTimeout("scroll_y("+i+","+ep+",'"+layer+"','"+fadobj+"')",350);
}
}

