var currentNews = 0;

$(document).ready(function() {
	// Register mouseover event handler to hide/show news items and images
	$('.newsItem').mouseover(function() {
		var i = this.id.substr(8);
		if (i != currentNews) {
			$(this).addClass('newsItemActive');
			$('#newsItem' + currentNews).removeClass('newsItemActive');
			$('#news' + currentNews).css('display', 'none');
			$('#news' + i).css('display', 'block');
			currentNews = i;
		}
	});
	
	/* Define properties for the movable content within the defined areas */
	/*$('.customColumn').sortable({
		items: '.homeContent',
		handle: '.contentHeader',
		placeholder: 'moveItem',
		forcePlaceholderSize: 'true',
		connectWith: '.customColumn',
		cursor: 'move',
		helper: 'clone',
		revert: 'true'
	});*/
	
	/* Register mouseover event handler for the movable content */
	/*$('.homeContent .contentHeader').mouseover(function() {
		// If JS is enabled, change the CSS cursor property to show the move pointer
		$(this).css('cursor', 'move');
	});*/
	
	/* Register mouseout event handler for the movable content */
	/*$('.homeContent .contentHeader').mouseout(function() {
		// Revert the previous CSS property changes from the mouseover
		$(this).css('cursor', 'auto');
	});*/
	
	/* Add a minimise and close icons to the movable content areas */
	/*$('.homeContent .contentHeader').append(
		'<img class="windowButton close" src="/includes/images/close.gif" alt="close" /><img class="windowButton min" src="/includes/images/minimise.gif" alt="minimise" />'
	);
	$('.homeContent .contentHeader .windowButton').css('float', 'right');
	$('.homeContent .contentHeader .close').css('margin-left', '2px');*/
	
	/* Register mouseover event handler for the minimise icon */
	/*$('.homeContent .contentHeader .windowButton').mouseover(function() {
		// If JS is enabled, change the CSS cursor property to show the move pointer
		$(this).css('cursor', 'pointer');
	});*/
	
	/* Register mouseout event handler for the minimise icon */
	/*$('.homeContent .contentHeader .windowButton').mouseout(function() {
		// Revert the previous CSS property changes from the mouseover
		$(this).css('cursor', 'auto');
	});*/
	
	/*$('.homeContent .contentHeader .min').click(function() {
		var attr = $(this).attr('src');
		
		$(this).parent().next().toggle();
		if (attr.match('minimise')) {
			$(this).attr({
				src: '/includes/images/maximise.gif',
				alt: 'maximise'
			});
		} else {
			$(this).attr({
				src: '/includes/images/minimise.gif',
				alt: 'minimise'
			});
		}
	});*/
	
	/* Register onclick event handler for the close icon */
	/*$('.homeContent .contentHeader .close').click(function() {
		$(this).parents('.homeContent').remove();
	});*/
	
	/* Datepickker */
	$('.datepicker').datepicker({
		dateFormat: 'dd/mm/yy'
	});
	
	$('.button').button();
	
	/* Add new file upload control on LDP form */
	var file = 1;
	$('#addFile').click(function() {
        if (file < 4) {
            $('.file:last').after('<dt>Choose a file to upload:</dt><dd class="file"><input name="file[]" type="file" /></dd>'); 
            file++;
        } else {
            alert("You can only upload a maximum of 4 documents");
        }
	});
});
