jQuery(document).ready(function() {
	
	// maximise content box
	// (not for IE6)
	if(! /msie|MSIE 6/.test(navigator.userAgent)) {
		(function() {
			var contentObj = jQuery('div.page-body-content');
			var bodyRelatedHeight = jQuery('body').outerHeight() * 0.75;
			if(contentObj.height() < bodyRelatedHeight) contentObj.height(bodyRelatedHeight);
		})();
	}
	
	
	// initialise collapsible lists
	// (not for IE6)
	if(! /msie|MSIE 6/.test(navigator.userAgent)) {
	   /*
		jQuery('dl.collapsible dd').slice(1).each( function() {
			var ddObj = jQuery(this);
			ddObj.hide();
		});
		jQuery('dl.collapsible dt').each( function() {
			var dtObj = jQuery(this);
			var linkObj;
			var containerObj = dtObj.parents('div.page-body-content');
			var scrollY = dtObj.position().top - containerObj.position().top;
		
			dtObj.wrapInner('<a href="#"></a>');
			linkObj = dtObj.find('a')
			if(dtObj.prev('dd').length > 0) dtObj.addClass('collapsed');
			linkObj.click( function() {
				if(dtObj.hasClass('collapsed')) {
					dtObj.next('dd').slideDown();
					containerObj.animate({ scrollTop:scrollY }, 500, function() { 
						dtObj.removeClass('collapsed');
					});
				} else {
					dtObj.next('dd').slideUp();
					dtObj.addClass('collapsed');
				}
				linkObj.blur();
				return false;
			});
		});
		*/
	}
	
	// initialise slideshows
	jQuery('ul.slideshow').each( function() {
		var ulObj = jQuery(this);
		var liObjColl = ulObj.children('li');
		var firstLiObj = liObjColl.eq(0);
		var zIndex = 3;
		
		if(!(liObjColl.length > 1)) return;
		
		// local method to fade out the single list items, 
		// move them to the end of the list and then call
		// the method again on the now first item
		jQuery.fn.slideOut = function() { 
			var liObj = jQuery(this);
			liObj.next('li').css('z-index', 3);
			liObj.animate( { 'opacity': 1.0 }, 5000, function() { 
				liObj.fadeOut(2000, function() {
					var ulObj = liObj.parent('ul.slideshow');
					liObj.appendTo(ulObj).css('z-index', 0).show();
					ulObj.children('li').eq(0).css('z-index', 4).slideOut();
				});
			});
		};
		
		liObjColl.slice(1).each( function() {
			jQuery(this).css( { 'position': 'absolute', 'top': 0, 'left':0, 'z-index': zIndex-- } );
		});
		
		firstLiObj.animate( { 'opacity': 1.0 }, 600, function() { 
			ulObj.height(firstLiObj.height());
			ulObj.width(firstLiObj.width());
			firstLiObj.css( { 'position': 'absolute', 'top': 0, 'left':0, 'z-index': 4 } );
			firstLiObj.slideOut();
		});
	});
	
});

