var tx_cabagmundartheaderimg_random = 1;
var tx_cabagmundartheaderimg_pointer = -1;

/* animates to the next image */
function tx_cabagmundartheaderimg_imageAnimation(){
	var divs = $('headerImage').getElementsByTagName('div');
	
	tx_cabagmundartheaderimg_pointer++;
	
	if(divs[tx_cabagmundartheaderimg_pointer]){
		var newId = 'startimage' + tx_cabagmundartheaderimg_pointer;
		divs[tx_cabagmundartheaderimg_pointer].id = newId;
		
		new Effect.Appear(newId, {duration: 5, from: 0, to:  1, afterFinish: tx_cabagmundartheaderimg_imageAnimation});
	} else {
		tx_cabagmundartheaderimg_pointer = -1;
		tx_cabagmundartheaderimg_startImageAnimation();
	}
}

/* initializes the animation */
tx_cabagmundartheaderimg_startImageAnimation = function(){
	var divs = $('headerImage').getElementsByTagName('div');
	
	do {
		tx_cabagmundartheaderimg_pointer = Math.floor(divs.length*Math.random());
	} while(tx_cabagmundartheaderimg_pointer % 2 == 0);
	
	for(i=0; i<divs.length; i++){
		divs[i].style.display = 'none';
	}
	
	$('headerImage').style.display = 'block';
	
	tx_cabagmundartheaderimg_imageAnimation();
}

/* start animation function after page is loaded */
if (window.attachEvent) {
	window.attachEvent("onload", tx_cabagmundartheaderimg_startImageAnimation);
} else {
	window.addEventListener("load", tx_cabagmundartheaderimg_startImageAnimation, false);
}

