var html4u = {
	start : function() {
		this.slideshow();
		this.insertSep();
		this.replaceHeaders();
	},
	
	slideshow: function(){
		$('ul#image-rotator').innerfade({
			speed: 'slow',
			timeout: 2000,
			type: 'sequence',
			containerheight: '245px'
		});
	},
	
	equalLi : function(){
		var max = 0;
		$('ul.eq4 li').each(function(i){
			if($(this).height() > max) max = $(this).height();
			if((i+1) % 4 == 0){
				$(this).parent().find('li:gt('+(i-4)+'):lt('+i+')').height(max);
				max = 0
			}
		});
	},
	
	insertSep : function(){
		$('ul.col4').each(function(){
			$(this).find('> li').each(function(i){
				if((i+1) % 4 == 0) $(this).after('<li class="separate"><a href="#header">Back to top</a></li>');
			});
		});
		$('ul.col3').each(function(){
			$(this).find('> li').each(function(i){
				if((i+1) % 3 == 0) $(this).after('<li class="separate"><a href="#header">Back to top</a></li>');
			});
		});
	},
	
	replaceHeaders : function(){
		$('#content h2').not('.pure').flash(
			{
				src: '/jfr.swf',
				wmode : 'transparent',
				flashvars: { 
					css: [
						'* { color: #ffffff; }',
						'a { color: #ffffff; text-decoration: none; }',
						'a:hover { text-decoration: underline; }'
					].join(' ')
				}
			},
			{ version: 7 },
			function(htmlOptions) {
				htmlOptions.flashvars.txt = this.innerHTML;
				this.innerHTML = '<div>'+this.innerHTML+'</div>';
				var $alt = $(this.firstChild);
				htmlOptions.height = $alt.height();
				htmlOptions.width = $alt.width();
				$alt.addClass('alt');
				$(this)
					.addClass('flash-replaced')
					.prepend($.fn.flash.transform(htmlOptions));						
			}
		).css('visibility','visible');
	}
}

function initialize() {
	html4u.start();
}

$().ready(initialize);

document.write('<link rel="stylesheet" type="text/css" media="screen" href="/templates/style/javascript.css" />');
