window.addEvent('domready',function(){
	
	// Navigation
    if( $('reorder_menu') )
    	$('reorder_menu').addEvent('change',function(){
    		if( this.value != '' ) document.location = this.value;
    	});
	
	$$('#features li').each(function(el,i){
		
		el.addClass("row_off");
		el.initClass = this.className; // Capture init
		
		el.addEvents({
			mouseover: function(){ this.addClass("row_on"); }
			,mouseout: function(){ this.className = this.initClass; }
		});
	});
	
	// If on IFRAME shopping cart page
	/*if( $('iframe_togglers') )
	{		
		$('shopping_cart').defHeight = $('shopping_cart').getStyle('height').toInt();
		var myEffects = new Fx.Styles('shopping_cart', {duration: 500, transition: Fx.Transitions.sineInOut});
				
		$$('#iframe_togglers .grow').addEvent( 'click', function(){
			myEffects.start({ 'height': ( $('shopping_cart').getStyle('height').toInt() + 1500 ) }); }	
		);
		
		$$('#iframe_togglers .shrink').addEvent( 'click', function(){			
			grow_height = ( $('shopping_cart').getStyle('height').toInt() - 1500 );
			new_height = ( grow_height > $('shopping_cart').defHeight ) ? grow_height : $('shopping_cart').defHeight;
			myEffects.start({ 'height': new_height }); }	
		);
	}*/
	
	// Smooth Scrolling
    new SmoothScroll(null, window);    
    
    // Window scroll effect
    //winScroll = new Fx.Scroll( window );
	
	// Moo Tools stuff
	var subTabs = $$('#nav a');

	// Sub nav color fade
	subTabs.each(function(tab){
		// Grab the initial color	    
	    tab.initColor = tab.getStyle('color');

	    tab.addEvents({
	        'mouseover': function(event){
				if( !this.getParent().hasClass('on') )
	            {
                    this.setStyle('color','#ffffff');
                    tab.tween('color', '#ffffff' );
				}
	        },    
	        'mouseout': function(event){	        	
	            //if( this.getParent().hasClass('on') ) this.setStyle('color','#fff5a6');
				if( !this.getParent().hasClass('on') ){	            

                    tab.set('tween', {transition: Fx.Transitions.Elastic.sineOut});
                    tab.tween('color', this.initColor );
                
                }
	        },    
	        'click': function(event){
                
				if( !this.hasClass('foxycart') ){
                    
    				// Remove current active class
    				$$('#nav li.on').removeClass('on');
    				
    	        	// Set current class to active
    	            this.getParent().addClass('on');
                }
	        }
	    });    
	});

    thumbs = $$('a[rel=lightbox]');

    if( thumbs ){
    
        thumbs.each(function(thumb,i){

            thumb.addEvent('click', function (e) {
                e.stop();
                
                ThumbImage = new Asset.image( thumb.getProperty('href'), {id: 'LargeImage', title: 'LargeImage', onload: function() {                        
                    new QuickBox( ThumbImage );

                }});
            });
        
        });
    
    }


    function free_report(delay){
        if(!delay) delay = 0;

        // If must show report or no delay requested
        if( ( showFreeReport == 1 ) || !delay )
        ( function(){
        
            var clone = document.id('optin_form').removeClass('hide').addClass('loading');
            (function(){        
                new QuickBox( clone, null, { 'duration':350,    
                    'delay': 0,
                    //'autodropif': function(){ return ( ( showFreeReport == 1 ) || !delay ); },
                    'showCallback': function(){
                       //document.id('category2').focus();
                       delay = 0;
                    },
                    'onHide': function(){
                       this.el.addClass('hide').inject(document.body,'bottom');
                    }
                } );        
            }).delay( 250 );    
        
        } ).delay( delay );

    };

    free_report( 10000 ); // 2000
               
    // Free Report (DropBox)
    freeReport = $$('.free_report a');
    freeReport.setProperties({
        href:'javascript:void(0);'                    
    });
    freeReport.addEvent('click',function(){
        if( document.id('optin_form').hasClass('hide') ) free_report(0);
    });

});

function setAtTop( obj ){
    if(typeof winScroll == 'undefined') winScroll = new Fx.Scroll( window );
    winScroll.set( 0, 0 );

}    