Boost.include( URI + '_public/_js/facebook.js' );
Boost.include( URI + '_public/_js/facebook/connect.js' );
Boost.include( URI + '_public/_js/twitter.js' );

Boost.index = new (Class.create( Boost, {
	
	SLIDES_TIMEOUT: 5,
	SLIDES_CURRENT: 1,
	SHOWING:		false,
	
	initialize: function() {
		
		this.domReady(function() {
		
			this.inputs();
			this.slides();
			this.facebook();
			this.twitter();
			
			$( 'FULL-header-search-keywords' ).focus();
		
		}.bind(this));
				
	},
	
	inputs: function() {
	
		$$( 'div.HEADER-login div.FORM-text-input' ).each( function( element ) {
		
			var input = element.select( 'input' )[ 0 ];
		
			input.observe( 'focus', function( event ) {
			
				element.addClassName( 'FORM-focus' );
			
			}.bind(element));

			input.observe( 'blur', function( event ) {
			
				element.removeClassName( 'FORM-focus' );
			
			}.bind(element));
						
		});
		
	},
	
	slides: function() {
	
		if( $$( 'ul#HP-show-slides li' ).length > 0 ) {
			
			$$( 'ul#HP-show-slides li' ).each( function( element ) {
			
				element.setStyle({
				
					position:	'absolute',
					top:		0,
					left:		0,
					width:		'930px'
				
				});
			
			}.bind(this));
	
			(function() { setInterval( function( e ) {
				
				this.changeSlide();
				
			}.bind(this), ( this.SLIDES_TIMEOUT * 1000 ) ) }.bind(this).defer());		
		
		}
		
	},
	
	changeSlide: function() {

		var newId	= ( this.SLIDES_CURRENT + 1 );
		var current	= $$( 'ul#HP-show-slides li#HP-show-slides-' + this.SLIDES_CURRENT )[ 0 ];
		var next	= $$( 'ul#HP-show-slides li#HP-show-slides-' + newId );
		
		if( !next[ 0 ] ) {
		
			next	= $$( 'ul#HP-show-slides li#HP-show-slides-1' )[ 0 ];
			newId	= 1;
			
		} else {
		
			next	= next[ 0 ];
		
		}
		
		this.SLIDES_CURRENT = newId;
		
		current.fade({
			
			duration: 0.5
		
		});

		next.appear({
			
			duration: 0.5
			
		});
	
	},

	facebook: function() {
	
		var twit = $$( 'div.INDEX-signin-join-connect-facebook' )[ 0 ];
			twit.observe( 'click', function( e ) {
	
			Boost.facebook.connect.login();
			
			e.stop();
		
		}.bind(this));
		
	},
		
	twitter: function() {
	
		var twit = $$( 'div.INDEX-signin-join-connect-twitter' )[ 0 ];
			twit.observe( 'click', function( e ) {

			e.stop();
			
			Boost.twitter.connect();
		
		}.bind(this));
		
	},
		
	doConnect: function( e ) {
	
		if( e ) {
		
			e.stop();
		
		}
		
		new Ajax.Request( AJAX, {
			
			parameters: { 'action': 'services.facebook.connect' },
			onSuccess: function( e ) {
			
				var data = e.responseText.evalJSON();
				
				if( data.status == 'ok' ) {
				
					eval( data.eval );
					
				} else if( data.status == 'redirect' ) {
					
					window.location.href = data.redirect;
				
				} else {
				
					console.log(data);
					
				}
			
			}
		
		});
	
	}

}));