// JavaScript Document
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
var rotate_time = 5000;		//time in milliseconds

// Google Analytics
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function confirm_delete() {
	return confirm("Weet U zeker dat U dit wilt verwijderen?");
}

function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count; 
	$("#headlines li.headline:eq(" + old_headline + ")").animate({top: -130},"slow", function() {
		$(this).css('top','130px');
	});
	$("#headlines li.headline:eq(" + current_headline + ")").show().animate({top: 0},"slow");  
	old_headline = current_headline;
}

function delete_photo(photo_type, object_id, object_number) {
	if (confirm("Weet U zeker dat U dit wilt verwijderen?")) {
		// alert("deleting photo: " + photo_type + ", id=" + object_id + ", number=" + object_number + "...");
		$(".result_" + object_number).html("<label>&nbsp;</label>De foto wordt verwijderd...");
		$(".photo_" + object_number + " img").hide("slow");
		$(".photo_" + object_number).hide("slow");
		$(".result_" + object_number).load("/forms/photo_delete.php?photo_type=" + photo_type + "&object_id=" + object_id + "&object_number=" +  object_number);
	}
}

$(document).ready(function() {
	// define sections
	headline_count = $("#headlines li.headline").size();
	if (headline_count < 1) {
		$("#headlines").hide();
	} else {
		$("#headlines li.headline:eq("+current_headline+")").css('top','0px');
		headline_interval = setInterval(headline_rotate,rotate_time);
	}
	
	$("a[rel^='lightbox']").slimbox({ loop: true }, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
	
	// labels in p: align with longest
    var max_width = 0;
    $("p label").each(function(){
        if ($(this).width() > max_width)
            max_width = $(this).width();   
    });
    $("p label").width(max_width);
	
	// set height of labels
    $("p label").each(function(){
		paragraph_height = $(this).parent().height();
        $(this).height(paragraph_height);
		paragraph_height = $(this).parent().height();
        $(this).height(paragraph_height);
    });
	
	// labels in li: set height of labels
	/*
    $("li label").each(function(){
		paragraph_height = $(this).parent().height() - 3;
        $(this).height(paragraph_height);
    });
	*/
	
	// labels in li: align with longest
	/*
    var max_width = 0;
    $(".project_data label").each(function(){
        if ($(this).width() > max_width)
            max_width = $(this).width();   
    });
    $(".project_data label").width(max_width);
	*/
	
	/* news items in scroller */
	$('#headlines').hover(function() {
		 clearInterval(headline_interval);
	}, function() {
		 headline_interval = setInterval(headline_rotate,rotate_time);
	});
	
	try {
		var pageTracker = _gat._getTracker("UA-6033135-41");
		pageTracker._trackPageview();
	} catch(err) {}

});

