
if (window.location.host != 'localhost') {
	dokumentenroot = "";
} else {
	dokumentenroot = 'http://localhost/vauman'; 
}

/****	
		Description: loads images into an array
		from: -
		to: -
		objects: -
		variable: -
****/
images = new Array ();
function loadImage( number ) {
	if (!images[ number ]) {
		images[ number ] = new Image();
		images[ number ].src = dokumentenroot + source [ number ];
		// alert(images[ number ].src);
	}
}

/****	
		Description: changes images, checks first if the image was loaded
		from: -
		to: -
		objects: -
		variable: -
****/
function changeImage(index) {
	stopTimeout( index );
	// Checks if the browser has loaded the image:
	if (images[ index ].complete == true) {
		// Change image
		document.getElementById( "campaign" ).src = images[ index ].src;
		changeClass ( index );
		// Set next index number
		if (index < source.length - 1) {
			index = index + 1;
		} else {
			index = 0;
		}
		loadImage( index );
		startTimeout( index );
	} else {
		start = window.setTimeout("changeImage(" + index + ")", 1000);
	}
}

/****	
		Description: delete classname, a class to slide menu
		from: -
		to: -
		objects: -
		variable: -
****/
function changeClass ( index ) {
	var x = 0;
	while(document.getElementById( "slide_" + x )) {
		document.getElementById( "slide_" + x ).className = "";
		x = x + 1;
	}
	document.getElementById( "slide_" + index ).className = "active";
}

function startTimeout( index ) {
	start = window.setTimeout("changeImage(" + index + ")", 3000);
	document.getElementById( "campaign" ).onmouseover = function () {stopTimeout( index );};
}

function stopTimeout( index ) {
	window.clearTimeout(start);
	document.getElementById( "campaign" ).onmouseout = function () {startTimeout( index );};
}

function startSlides() {
	index = 0;
	loadImage( index );
	startTimeout( index );
}
