var delay = 4000;
var maxImages;
var idName;
var counter=1;

function changeCSS(eid,content){
	
	var c=document.getElementsByTagName("li");
		for(var f=0;f<c.length;f++){
			var d=c[f];
			var id = d.id;
			
			
			if(d.id.substr(0,content.length)==content){
				
				if (d.getElementById) { // DOM3 = IE5, NS6
					document.getElementById(id).className  = 'inactive';
				}
				else {

					if (d.layers) { // Netscape 4
						d.className = 'inactive';
					}else { // IE 4
						d.className = 'inactive';
					}
				}
			}
			
		}
	if (document.getElementById) { // DOM3 = IE5, NS6
		
		document.getElementById(eid).className = 'active';
	} else {
		
		if (document.layers) { // Netscape 4
			document[eid].className = 'active';
		}
		else { // IE 4
			document.all[eid].className = 'active';
		}
	}
}
function init(site){
	switch(site){
		case "start":
			new AdBox("image",5,4000).onloadinit();
			new AdBox("box-1-medium",4,3500).onloadinit();
			new AdBox("box-2-medium",3,3500).onloadinit();
			break;
		case "neuwagen":
			new AdBox("box-1-medium",3,3500).onloadinit();
			new AdBox("box-2-medium",3,3500).onloadinit();
			new AdBox("box-3-medium",3,3500).onloadinit();
			break;
		case "grosskunden":
			new AdBox("image",5,3000).onloadinit();
			break;
		default:
			break;
	}

}

function AdBox(eid,max_images,delay) {
	this.maxImages = max_images;
	this.idName = eid;
	this.delay = delay;
	this.counter = 1;

	this.onloadinit = function() {
		for(var i=2;i<=this.maxImages;i++){
			new Effect.Opacity(this.idName+i, { from: 1.0, to: 0.0, duration: 0.0 });
		}
		var self = this;
		setTimeout(function() { self.nextimage() } ,this.delay);
	}
	
	this.nextimage = function() {
		new Effect.Fade(this.idName + this.counter, { duration: 1.0, delay:0.1 });
		this.counter++;
		if(this.counter > this.maxImages){
			this.counter = 1;
		}	
		new Effect.Appear(this.idName + this.counter, { duration: 1.0 });
		var self = this;
		setTimeout(function() { self.nextimage() } ,this.delay);
		
	}
}
function onloadinit(eid,max_images){
	
}

function nextimage(){
	
}


function switchid(id,content){	
		var c=document.getElementsByTagName("div");
		for(var f=0;f<c.length;f++){
			var d=c[f];
			if(d.id.substr(0,content.length)==content){
				hidediv(d.id);
			}
		}
		showdiv(id);
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
		new Effect.Appear(document.getElementById(id), { from: 0.0, to: 1.0, duration: 0.5 });
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
			new Effect.Appear(document.id, { from: 0.0, to: 1.0, duration: 0.5 });
		}
		else { // IE 4
			document.all.id.style.display = 'block';
			new Effect.Appear(document.all.id, { from: 0.0, to: 1.0, duration: 0.5 });
		}
	}
	
}

