$( function() {

	// Titles
	$( ".title" ).each( function( i )
	{
		$( this ).css( "backgroundImage", "url(/static/images/headers/index.php?t=" + escape( this.innerHTML ) + ")" );
	});
	$( ".title" ).addClass( "title-replaced" );

	// Banners
	$( ".banner" ).fadeIn( 5000 );

	// Login form
	$( "#user_email_top" ).focus( function(){ if( this.value == 'E-mail' ){ this.value = ''; }});
	$( "#user_email_top" ).blur( function(){ if( this.value == '' ){ this.value = 'E-mail'; }});
	$( "#password_top" ).focus( function(){ if( this.value == 'Password' ){ this.value = ''; this.type='password'; }});
	$( "#password_top" ).blur( function(){ if( this.value == '' ){ this.value = 'Password'; this.type='text'; }});

	// Image Lazy Loader
	$("img").lazyload();

	// Lightbox
	$( "a.lightbox" ).lightBox();

	// Scrollable
	$( "#scrollable" ).scrollable( {items:'.items',horizontal:true} );


	// Scrollable support for the screenshots page
	$( ".items a" ).click( function(){

		$(this).find( "h2" ).each( function(i){
			$( "#screen_info h1" ).html($(this).html());
		});
		$(this).find( "p" ).each( function(i){
			$( "#screen_info p" ).html($(this).html());
		});

		$( ".title" ).each( function( i )
		{
			$( this ).css( "backgroundImage", "url(/static/images/headers/index.php?t=" + escape( this.innerHTML ) + ")" );
		});

		$( "#screen_current img" ).attr( 'src', '/static/images/screens/' + this.name + '.png' );
		$( "#screen_current img" ).attr( 'alt', $(this).html() );

	});
});
