window.onload = function()
{
	$( '.warning' ).click( function() { return confirm( 'Are you sure? This cannot be undone!' ); } );
	
	$( '#print' ).click( function() { window.print(); } );
	
	$( '#send_friend' ).hide();
	$( '#sendtofriend' ).click( function()
	{
		$( '#send_friend' ).toggle();
		return false;
	});
	
	$( '#bookmark' ).click( function()
		{
			if( window.opera )
			{
				var mbm = document.createElement( 'a' );
				mbm.setAttribute( 'rel','sidebar' );
				mbm.setAttribute( 'href', window.document.location.href );
				mbm.setAttribute( 'title', window.document.title );
				mbm.click();
			}
			else if( document.all )
			{
				window.external.AddFavorite( window.document.location.href, window.document.title );
			}
			else
			{
				window.sidebar.addPanel( window.document.title, window.document.location.href, '' )
			}
		});
	
	/*
		Making the extra colored boxes the same height
	*/
	var max = 0;
	$( '#extra p a' ).each( function( i )
	{
		max = this.offsetHeight > max ? this.offsetHeight : max;
	}).css( 'height', max + 'px' );
	
};
$( document ).ready( function()
{
	$( '#header' ).append( '<a href="/" class="over"><img src="/img/site/h1.gif" width="132" height="37" alt="Logo" title="A plus performance" /></a>' );
	$( '#stripe' ).append( '<div id="mottoover">' + $( '#motto' ).html() + '</div>' );
	fade( '#motto', 10, 40, function() { $( '#mottoover' ).css( 'display', 'block' ); } );
});

function setOpacity( value )
{
	element.style.opacity = value / 10;
	element.style.filters = 'alpha(opacity=' + value * 10 + ')';
}

function fade( el, from, to, callback )
{
	$( el ).each( function()
	{
		to   /= 10;
		from /= 10;
		
		this.style.opacity = from;
		this.style.filter  = 'alpha(opacity=' + ( from * 10 ) + ')';
		this.style.display = 'block';
		
		element = this;
		
		for( var i = from; i <= to; i++ )
		{
			setTimeout( 'setOpacity(' + i + ')', 100 * i );
		}
		
		if( typeof callback == 'function' )
		{
			func = callback;
			setTimeout( 'func()', 100 * i );
		}
	});
}
