info.sortHeight = function () {
	var content = $("#content");
	if (content.length) {
		content.height("auto");
		var t = content.offset().top, f = $("#footer").outerHeight(true);
		if (content.height() + t + f < info.height) {
			content.height(info.height - t - f);
		}
	}
};
$(function () {
	$('#m_47 .titleA')
		.attr('href', '/HBS/actueelnieuws.aspx')
		.css('cursor', 'pointer');
	/*$('#m_18 .titleA')
		.attr('href', '/HBS/kantoornieuws.aspx')
		.css('cursor', 'pointer'); */
	$('#m_67 .titleA')
		.attr('href', '/HBS/online.aspx')
		.css('cursor', 'pointer');
	$('#m_76 .titleA')
		.attr('href', '/HBS/kantoornieuws.aspx')
		.css('cursor', 'pointer');
});



var _images = ["img1.jpg", "image2.jpg", "imij3.jpg"];
	var gotime = _images.length;
 
	$.each(_images,function(e) {
		$(new Image()).load(function() {
			if (--gotime < 1) begin();
		}).attr('src',this);
	});



$(document).ready(function () {
	$(function () {
		var templateNR = $('#headerAnimation').attr('alt');
		//var templateNR = 3;
		$.get('DesktopModules/hbsFilesInDir.aspx?templatenr='+templateNR+'', function(data)
		{
			$('#counter').html(data);
			var filesNR = $('#lblFileCount').text();
			filesNR = filesNR * 1;
			var currentimage = 1;
			var currentfile = currentimage * 1;
			var imagecounter = currentimage * 1;
			
			
				if(filesNR == 2)
				{
					$('#animationHolder1').css({'background' : 'url(userdata/images/headers/'+templateNR+'/1.jpg)', 'position' : 'absolute'});
					$('#animationHolder2').css({'background' : 'url(userdata/images/headers/'+templateNR+'/2.jpg)', 'position' : 'absolute'});
				
					function fadeHeaderTwoImagesStart()
					{
						$('#animationHolder1').delay(8000).fadeOut(500, 'linear');
						$('#animationHolder2').delay(6000).fadeIn(100, 'linear', function()
						{
							fadeHeaderTwoImagesLoop();
						}
						);
					}
				
					function fadeHeaderTwoImagesLoop()
					{
						$('#animationHolder2').delay(8000).fadeOut(500, 'linear');
						$('#animationHolder1').delay(6000).fadeIn(100, 'linear', function()
						{
							fadeHeaderTwoImagesStart();
						}
						);
					}
				
					fadeHeaderTwoImagesStart();
				}
				
				else if(filesNR > 1 && filesNR != 2)
				{
					$('#animationHolder1').css({'background' : 'url(userdata/images/headers/'+templateNR+'/1.jpg)', 'position' : 'absolute'});
					$('#animationHolder2').css({'background' : 'url(userdata/images/headers/'+templateNR+'/2.jpg)', 'position' : 'absolute'});
				
					function fadeHeaderStart()
					{
						
						$('#animationHolder1').delay(8000).fadeOut(500, 'linear', function()
						{
							currentfile = currentfile+2;
							$('#animationHolder1').css({'background' : 'url(userdata/images/headers/'+templateNR+'/'+currentfile+'.jpg)', 'position' : 'absolute'});
						}
						);
						$('#animationHolder2').delay(6000).fadeIn(100, 'linear', function()
						{
							fadeHeader2();
						}
						);
					}
				
					function fadeHeader2()
					{
						if (currentfile < filesNR-1)
						{
							
							$('#animationHolder2').delay(8000).fadeOut(500, 'linear', function()
							{
								currentfile = currentfile+1;								
								$('#animationHolder2').css({'background' : 'url(userdata/images/headers/'+templateNR+'/'+currentfile+'.jpg)', 'position' : 'absolute'});
							}
							);
							$('#animationHolder1').delay(6000).fadeIn(100, 'linear', function()
							{
								fadeHeaderLoop();
							}
							);
						}
						else
						{
							currentfile = 0;
							fadeHeader2();
						}
					}
				
					function fadeHeaderLoop()
					{
						if (currentfile < filesNR-1)
						{
							
							$('#animationHolder1').delay(8000).fadeOut(500, 'linear', function()
							{
								currentfile = currentfile+1;								
								$('#animationHolder1').css({'background' : 'url(userdata/images/headers/'+templateNR+'/'+currentfile+'.jpg)', 'position' : 'absolute'});
							}
							);
							$('#animationHolder2').delay(6000).fadeIn(100, 'linear', function()
							{
								fadeHeader2();
							}
							);
						}
						else
						{
							currentfile = 0;
							fadeHeaderLoop();
						}
					}
				
					fadeHeaderStart();
				
				}
			
			
				else
				{
					$('#animationHolder1').css({'background' : 'url(userdata/images/headers/'+templateNR+'/1.jpg)', 'position' : 'absolute'});
				}
			
		});
	});
});
