
$(document).ready(function(){
	if (document.getElementById("img_rotator")){
		rotate();
		theRotator();
	}
});

function theRotator(){
		setInterval('rotate()',7000);
}

function rotate(){
		$('#img_rotator').animate({opacity: 0.0}, 1000)
		setTimeout('newImage()',1000);
}

function newImage(){
		$.ajax({ 
			type : 'POST',
			url : '/javascript/imagerotate.asp',
			dataType : 'text',
			data: {
			},
			success : function(data){
				document.getElementById("img_rotator").src = "/pam/custom/banners/" + data;
				$('#img_rotator').animate({opacity: 1.0}, 1000)
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
			}
		});
		return false;
}

function DoSlider (ShowID) {
	clearTimeout(SfeerTimer);
	//src_item	= "/pam/front/templates/standaard/grfx/slider_item.png"
	//src_active	= "/pam/front/templates/standaard/grfx/slider_active.png"
	SfeerItems  = $(".object9 .image").size();
	
	if ( $('.object9 .image:visible').size() > 0 ) {
		ActiveID = $('.object9 .image:visible').attr("id").replace("SfeerImage_","");
	}
	else {
		ActiveID = 0;
	}
	
	if ( !ShowID ) {
		ShowID = parseInt(ActiveID)+1;
	}
	if ( ShowID > SfeerItems ) {
		ShowID = 1;
	}
	// alert("Active: "+ActiveID);
	// alert("ShowID: "+ShowID);
	if ( ActiveID == 0 ) {
		//title = $("#SfeerTitel_"+ ShowID).html();
		//$(".top_sfeer .titel h3").html(title);
		//$("#SlideSwitch_"+ ShowID).attr("src",src_active);	
		$("#SfeerImage_"+ ShowID).fadeIn(1000, function() {		
			SfeerTimer=setTimeout("DoSlider()",5000);
		});
	}	
	else if ( ShowID != ActiveID ) {
		//title = $("#SfeerTitel_"+ ShowID).html();
		//$(".top_sfeer .titel h3").html(title);
		//$("#SlideSwitch_"+ ActiveID).attr("src",src_item);
		//$("#SlideSwitch_"+ ShowID).attr("src",src_active);				
		$("#SfeerImage_"+ ActiveID).fadeOut(1000, function() {
			$("#SfeerImage_"+ ShowID).fadeIn(1000, function() {	
				SfeerTimer=setTimeout("DoSlider()",5000);
			});
		});
	}
}


