function $(id) { 
    return document.getElementById(id); 
}

function getHttpRequest( link ) { 
    
    var xmlhttp = null; 
    // Mozilla 
    if (window.XMLHttpRequest) { 
        xmlhttp = new XMLHttpRequest(); 
    } 
    // IE 
    else if (window.ActiveXObject) { 
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    
    xmlhttp.open("GET", link, true); 
    xmlhttp.onreadystatechange = function() { 
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
            $('frame').innerHTML = xmlhttp.responseText; 
        } 
    } 
    xmlhttp.send(null); 
}

function hoverProducts( box, id ) {
	
	getHttpRequest('http://www.phoenixsystems.de/xeonlab3/boxes/'+box+'.php');
	
	var navi = $('navigation').childNodes;		
	var max = navi.length;
	
	for ( var i = 0; i < max; i++ )
		navi[i].className = "";
		
	$( id ).parentNode.className = "aktiv";
	
}

/* Faderklasse */
function Fader( name, step, tick, display ) {
	this.Name = name;
	this.Step = step;
	this.Display = display;
	if (step)
		this.Target = true;
	else {
		this.Target = false;
		$( name ).style.opacity = 0;
		$( name ).style.filter = "alpha(opacity=0)";
	}
	this.Tick = tick;
	this.FadeIn = FaderFadeIn;
	this.FadeOut = FaderFadeOut;
	this.Activate = FaderActivate;
}

function Faderfade( Obj ) {
	if ( Obj.Target )
		Obj.Step = Obj.Step + Obj.Tick;
	else
		Obj.Step = Obj.Step - Obj.Tick;
		
	$( Obj.Name ).style.opacity = Obj.Step/100;
	$( Obj.Name ).style.filter = "alpha(opacity=" + Obj.Step + ")";
	
	if ( Obj.Display ) {
		if ( Obj.Step == 0 )
			$( Obj.Name ).style.display = "none";
		else
			$( Obj.Name ).style.display = "block";
	}
		
	if ( ( Obj.Step > 0 && !Obj.Target )||( Obj.Step < 100 && Obj.Target ) )
		window.setTimeout( function() { Faderfade( Obj ); }, 1 );				
}

function FaderFadeIn() {
	if (!this.Target) {
		this.Target = true;
		Faderfade( this );
	}
}

function FaderFadeOut() {
	if (this.Target) {
		this.Target = false;
		Faderfade( this );
	}
}

function FaderActivate( enable ) {
	if ( enable )
		this.FadeIn();
	else
		this.FadeOut();
}

/* Diashow */

var i = 0;

function switchToNext( max ) {

	old = i;
	i++;
	if ( i > max ) i = 0;
	
	oldf = new Fader( 'news'+old, 100, 5, true );
	newf = new Fader( 'news'+i, 0, 5, true );
	
	oldf.FadeOut();
	newf.FadeIn();
	
}