/**
 * @author rocky2000
 */

var photo_counter = 0;

 $(document).ready(function(){

	// hide informational banners
	if ($('#status_msg').length > 0)
	{
		setTimeout(function () { 
		$('#status_msg').fadeOut('slow');
		},3000);
	}
	
	$(".input_login").focus(function() {
		$(this).val("");
	});
	
	$(".act_del").click(function(){
		if(!confirm('Weet je het zeker dat je dit wilt verwijderen?'))
			return false;
	});
	
	$(".photo_element").mouseenter(showPhoto);

	// Rotate the images
	setTimeout(rotatePhotos, 1000);
	
	ddsmoothmenu.init({
		mainmenuid: "navigation_bar", //menu DIV id
		orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		classname: 'ddsmoothmenu', //class added to menu's outer DIV
		contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	})

});


function rotatePhotos()
{
		
	$(".begin_slogan").hide();
	$(".slogan").hide();
	
	// No image, so show the first one
	$("#background").attr("rel", photo_counter + 1);
	$("#background").fadeOut('slow', function () {
		if($("#background").hasClass("subpage"))
			$("#background").css("background-image", "url('/images/layout/subpage_photo_"+($("#background").attr("rel"))+".jpg')");
		else
			$("#background").css("background-image", "url('/images/layout/photo_"+($("#background").attr("rel"))+".jpg')");
		$("#background").fadeIn('slow');
	});


	$(".photo_element").removeClass("active_element");
	$("#menu_elements > .photo_element").eq(photo_counter).addClass("active_element");
	
	$("#slogan_"+ (photo_counter+1)).show();
	$("#slogan_"+ (photo_counter+1)).css("display", "block");
	
	
	if(photo_counter == ($("#menu_elements > .photo_element").length -1 ))
		photo_counter = 0;
	else
		photo_counter++;
	
	
	
	setTimeout(rotatePhotos, 10000);
}

function showPhoto()
{
	$(".begin_slogan").hide();
	
	$("#background").attr("rel", $(this).attr("rel"));
	$("#background").fadeOut('slow', function () {
		if($("#background").hasClass("subpage"))
			$("#background").css("background-image", "url('/images/layout/subpage_photo_"+($(this).attr("rel"))+".jpg')");
		else
			$("#background").css("background-image", "url('/images/layout/photo_"+($(this).attr("rel"))+".jpg')");
		$("#background").fadeIn('slow');
	});
	$(".photo_element").removeClass("active_element");
	$(this).addClass("active_element");
	$(".slogan").hide();
	$("#slogan_"+$(this).attr("rel")).show();
	
}
