/*
    Initialize Events
    -------------------------------------------------------------------*/
    $(document).ready(function(e){
    	$('#component_navigation li a').bind('mouseenter',toggle_navigation);
    	$('#component_navigation li.first a kbd').animate({'opacity':'0'},0);
    	$('#component_navigation li:not(.first) kbd').animate({'opacity':'.70'},0);


        $component_slideshow        = setInterval("component_navigation()",5500);
        $component_slideshow_i      = 0;
        $prev_speed                 = 800;
        $next_speed                 = 800;

		// IE6 WARNING
		if (jQuery.browser.msie && jQuery.browser.version < 7) { 
			alert("This website is optimized for Internet Explorer 7 or newer. To view this website as it was intended, please upgrade your browser. ");
		}

    });





/*
    Site Functions
    -------------------------------------------------------------------*/
    
    
    /* Component Navigation
    -------------------------------------------------------------------*/
    function component_navigation(e){
        var $prev_component         = $('#component_navigation li.current');
        var $prev_imagery           = $('#component_imagery li.current');

        $next_component         	= $prev_component.next();
        $next_imagery           	= $prev_imagery.next();


        $prev_component.find('em').animate({'left':'0px'},$prev_speed);
        $prev_component.find('span').animate({'right':'0px'},$prev_speed);
        $prev_component.find('kbd').stop().animate({'opacity':'.70'},500);
        $prev_imagery.find('h1').animate({'left':'-220px'},$prev_speed);
        $prev_imagery.find('h2').animate({'bottom':'-100px'},$prev_speed);
        $prev_imagery.find('img').animate({'left':'750px'},$prev_speed);
        
        $prev_component.removeClass('current');
        $prev_imagery.removeClass('current');


        $next_component.find('em').animate({'left':'100px'},$next_speed);
        $next_component.find('span').animate({'right':'150px'},$next_speed);
        $next_component.find('kbd').stop().animate({'opacity':'0'},500);
        $next_imagery.find('h1').animate({'left':'0px'},$next_speed);
        $next_imagery.find('h2').animate({'bottom':'0px'},$next_speed);
        $next_imagery.find('img').animate({'left':'0px'},$next_speed);

        $next_component.addClass('current');
        $next_imagery.addClass('current');


        if($component_slideshow_i  == 3){
            clearInterval($component_slideshow);
            
            setTimeout(function(e){
                $next_component.find('em').animate({'left':'0px'},$prev_speed);
                $next_component.find('span').animate({'right':'0px'},$prev_speed);
                $next_component.find('kbd').stop().fade_in();
                $next_imagery.find('h1').animate({'left':'-220px'},$prev_speed);
                $next_imagery.find('h2').animate({'bottom':'-100px'},$prev_speed);
                $next_imagery.find('img').animate({'left':'750px'},$prev_speed);
                
                $next_component.removeClass('current');
                $next_imagery.removeClass('current'); 
            },5500);
        } else {
            $component_slideshow_i ++;
        }
    }

    
    
    /* Component Navigation
    -------------------------------------------------------------------*/
    function toggle_navigation(e){
    	clearInterval($component_slideshow);


    	if(!$(this).parent().hasClass('current')){
    		var $prev_component         			= $('#component_navigation li.current');
        	var $prev_imagery           			= $('#component_imagery li.current');
        	
        	var $next_component         			= $(this).parent();
        	var $next_imagery           			= $('#component_imagery li.'+$(this).attr('rel'));
        	
    		
    		$prev_component.find('em').stop().animate({'left':'0px'},$prev_speed);
        	$prev_component.find('span').stop().animate({'right':'0px'},$prev_speed);
        	$prev_component.find('kbd').stop().animate({'opacity':'.70'},500);
        	$prev_imagery.find('h1').stop().animate({'left':'-220px'},$prev_speed);
        	$prev_imagery.find('h2').stop().animate({'bottom':'-100px'},$prev_speed);
        	$prev_imagery.find('img').stop().animate({'left':'750px'},$prev_speed);
        	
        	$prev_component.removeClass('current');
        	$prev_imagery.removeClass('current');
        	    
        	    
        	$next_component.find('em').stop().animate({'left':'100px'},$next_speed);
        	$next_component.find('span').stop().animate({'right':'150px'},$next_speed);
        	$next_component.find('kbd').stop().animate({'opacity':'0'},500);
        	$next_imagery.find('h1').stop().animate({'left':'0px'},$next_speed);
        	$next_imagery.find('h2').stop().animate({'bottom':'0px'},$next_speed);
        	$next_imagery.find('img').stop().animate({'left':'0px'},$next_speed);
        	
        	$next_component.addClass('current');
        	$next_imagery.addClass('current');
    		
    	
    		return false;
    	}    	
    }
