jQuery(document).ready(function() {

 $('#preorder').hover(
    function() {
        $(this).animate({'margin-right': '0'}, 800); },
    function() {
        $(this).stop().animate({'margin-right':'-82'}, 400);
 });


// moving layers
    $(document).bind('mousemove', function(e) {
        $winwidth = $(window).width();
        $winheight = $(window).height();
          //$('#fg_dune').css({
         //    'margin-left': ((e.pageX/$winwidth)*-20) + 'px',
        //     'margin-top' : ((e.pageY/$winheight)*-10) + 370 + 'px'
        //  });
       //   $('#tree').css({
      //       'margin-right': ((e.pageX/$winwidth)*50) -50 + 'px',
     //        'margin-top': ((e.pageY/$winheight)*-15) + 15 + 'px'
     //     });
      //    $('#mg_left_dune').css({
    //          'margin-left': ((e.pageX/$winwidth)*-8) + 'px',
    //          'margin-top': ((e.pageY/$winheight)*-5) + 5 + 'px'
    //      });
     //     $('#mg_right_dune').css({
    //        'margin-right': ((e.pageX/$winwidth)*5) -15 + 'px',
     //       'margin-top': ((e.pageY/$winheight)*-2) + 84 +'px'
     //     });
      });

   
    
    //beam
    //first pass
 
       //loading
       $('#loading').delay(6000).animate({ 'opacity':'0' },
            {  'duration': 4000, 'easing': 'swing', complete: animatomaton() });

    function reset_dark() {
        $('img.beam_left').animate({'opacity':'.1'}, 'fast');
    }

    function reset_light() {
        $('img.beam_right').animate({'opacity':'1'}, 'fast');
    }

         function animatomaton() {
         //clouds
        $('#clouds > img ').delay(10000).animate({'margin-top': '15px','margin-left': '-35px'
            },{'duration' : 60000, 'easing' : 'swing'} ),
        
        
        //initial state 12 o-clock //6000
        $('img.beam_left').delay(6000).animate({ 'width': '817', 'height': '126', 'margin-left': '-20', 'margin-top': '48',  'opacity': '.3', 'filter': 'alpha(opacity=30)'
        	}, { 'easing': 'easeOutCubic','duration': 4000 } ), //10000

        //$('img.beam_source').animate({'margin-left': '797'
        //   }, { 'duration': 4000, 'easing': 'easeOutCubic' } ), //4000

        $('img.beam_glow').delay(6000).animate({ 'opacity': '0', 'margin-left':'350', 'width':'242','height':'200','filter': 'alpha(opacity=0)'
        	}, { 'duration': 2000,'easing': 'easeOutCubic'} ), //8000

         $('#lighthouse img').delay(6000).animate({'opacity' : '0', 'filter' : "alpha(opacity=0)" }, 4000), //10000
        	
        	//first pass 10000
         $('img.beam_left').animate({ 'width': '0', 'height': '200', 'margin-top': '5', 'opacity': '1', 'margin-left':'805','filter': 'alpha(opacity=100)'
                 }, { 'duration': 4000, 'easing': 'easeInCubic' } ).animate({'opacity':'.1','filter': 'alpha(opacity=10)'}, 'fast'), //14000

        $('img.beam_source').delay(10000).animate({'width': '7', 'margin-left': '800'
                }, { 'duration': 4000, 'easing': 'easeInCubic' } ), //14000

        $('img.beam_glow').delay(4000).animate({ 'opacity': '1', 'margin-left':'575', 'width':'450', 'height':'350','filter': 'alpha(opacity=100)'
                }, { 'duration': 2000,'easing': 'easeInCubic'} ), //14000


                  //flash 14000
        $('#flash').delay(13900).animate({'opacity':'1', 'filter': 'alpha(opacity=100)' }, 100),
        $('img.prints').delay(13950).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, 100), //14050
        $('#flash').delay(100).animate({ 'opacity':'0', 'filter': 'alpha(opacity=0)' }, 100),  //14100

         //first pass - halfway //14000

         $('#lighthouse img').delay(4000).animate({'opacity' : '1', 'filter' : "alpha(opacity=100)" }, 4000), //18000

          $('img.beam_right').delay(14000).animate({ 'width': '817','height': "126", 'margin-top':'48','margin-left':'808','opacity': '.3','filter': 'alpha(opacity=30)'
                 },{'duration': 4000,'easing': 'easeOutCubic' } ), //18000

           $('img.beam_source').animate({ 'width': '0','margin-left': '806'
                },{'duration':4000, 'easing':'easeOutCubic' } ), //18000

          $('img.beam_glow').animate({ 'opacity':'0', 'filter':'alpha(opacity=0)', 'margin-left':'984', 'width':'242','height':'200'
               }, { 'duration':2000,'easing': 'easeOutCubic' } ), //18000


          //first pass back //18000
          
          $('img.beam_right').animate({'width': '0', 'height': '200','margin-top': '5','margin-left': '805','opacity': '.1','filter': 'alpha(opacity=10)'
                 }, {'easing': 'easeInCubic', 'duration': 4000 } ).animate({'opacity':'1', 'filter': 'alpha(opacity=100)'}, 'fast'), //22000

        $('img.beam_source').animate({'width': '7', 'margin-left': '800'
                }, {'duration': 4000,'easing': 'easeInCubic' } ), //22000

        $('img.beam_glow').delay(4000).animate({'opacity': '.1','filter':'alpha(opacity=10)','margin-left':'590', 'width':'400','height':'248'
                }, {'duration': 2000, 'easing': 'easeInCubic' } ), //22000


          //first pass - halfway back //22000
           $('img.beam_left').delay(8000).animate({ 'width': '817', 'height': '126', 'margin-left': '-20', 'margin-top': '48',  'opacity': '.3','filter': 'alpha(opacity=30)'
                 }, { 'easing': 'easeOutCubic','duration': 4000 } ), //26000

        $('img.beam_source').animate({'width': '0','margin-left': '794'
                }, { 'duration': 4000, 'easing': 'easeOutCubic' } ), //26000

        $('img.beam_glow').animate({ 'opacity': '0', 'filter':'alpha(opacity=0)', 'margin-left':'350', 'width':'242','height':'200'
                }, { 'duration': 2000,'easing': 'easeOutCubic'} ), //26000

	   
          //***********************************************************
          //***********************************************************second pass 26000
          //***********************************************************
           $('#lighthouse img').delay(8000).animate({'opacity' : '0', 'filter' : 'alpha(opacity=0)'}, 4000), //30000
      

         $('img.beam_left').animate({'width': '0',  'height': '200', 'margin-left': '803','margin-top': '5', 'opacity': '1','filter': 'alpha(opacity=100)'
                }, {'easing': 'easeInCubic', 'duration': 4000 } ).animate({'opacity':'.1','filter': 'alpha(opacity=10)'}, 'fast'),  //30000

        $('img.beam_source').animate({'width': '7', 'margin-left': '800'
                }, { 'duration': 4000, 'easing': 'easeInCubic' } ), //30000

        $('img.beam_glow').delay(4000).animate({ 'opacity': '1', 'margin-left':'590', 'width':'400','height':'248','filter': 'alpha(opacity=100)'
                }, { 'duration': 2000, 'easing': 'easeInCubic' } ), //30000


               //flash  30000
       $('#flash').delay(15800).animate({'opacity':'1' }, 100),
       $('img.girl_wolf').delay(30150).animate({'opacity':'1','filter': 'alpha(opacity=100)'}, 100),
        $('#flash').delay(100).animate({ 'opacity':'0' }, 100),  //30100


          //second pass - halfway  30000
            $('#lighthouse img').animate({'opacity' : '1' }, 4000), //34000

          $('img.beam_right').delay(8000).animate({'width': '817','height': "126", 'margin-top':'48', 'margin-left':'808', 'opacity': '.3','filter': 'alpha(opacity=30)'
                }, { 'duration': 4000,'easing': 'easeOutCubic'} ), //34000

           $('img.beam_source').animate({ 'width': '0','margin-left': '806'
                }, {'duration':4000, 'easing':'easeOutCubic' } ), //34000

          $('img.beam_glow').animate({'opacity':'0', 'filter':'alpha(opacity=0)', 'margin-left':'984','width':'242','height':'200'
                }, {'duration':2000,'easing': 'easeOutCubic'} ), //32000


          //second pass back 34000
        
           $('img.beam_right').animate({'width': '0','height': '200', 'margin-top': '5', 'margin-left': '805',  'opacity': '.1','filter': 'alpha(opacity=10)'
                 }, {'easing': 'easeInCubic','duration': 4000 } ).animate({'opacity':'1','filter': 'alpha(opacity=100)'}, 'fast'),//38000

        $('img.beam_source').animate({'width': '7', 'margin-left': '800'
                }, {'duration': 4000, 'easing': 'easeInCubic'} ), //38000
                
        $('img.beam_glow').delay(4000).animate({ 'opacity': '.1', 'margin-left':'590', 'width':'400', 'height':'289','filter': 'alpha(opacity=10)'
                }, { 'duration': 2000,  'easing': 'easeInCubic' } ), //38000


          //second pass - halfway back //38000
           $('img.beam_left').delay(8000).animate({ 'width': '817', 'height': '126', 'margin-left': '-20', 'margin-top': '48', 'opacity': '.3','filter': 'alpha(opacity=30)'
                 }, { 'easing': 'easeOutCubic', 'duration': 4000 } ), //42000

        $('img.beam_source').animate({'width': '0','margin-left': '794'
                }, { 'duration': 4000, 'easing': 'easeOutCubic' } ), //42000
                
        $('img.beam_glow').animate({ 'opacity': '0', 'filter':'alpha(opacity=0)', 'margin-left':'350', 'width':'242','height':'200', 'margin-top':'0'
                }, { 'duration': 2000,  'easing': 'easeOutCubic' } ), //40000


          //***********************************************************
         //*********************************************************** third pass 42000
          //***********************************************************

        $('#lighthouse img').delay(8000).animate({'opacity' : '0', 'filter' : 'alpha(opacity=0)'}, 4000), //46000

         $('img.beam_left').animate({'width': '0',  'height': '200', 'margin-left': '803','margin-top': '5', 'opacity': '1','filter': 'alpha(opacity=100)'
                }, {'easing': 'easeInCubic', 'duration': 4000 } ).animate({'opacity':'1','filter': 'alpha(opacity=100)'}, 'fast'), //46000

        $('img.beam_source').animate({ 'width': '7', 'margin-left': '800'
                }, { 'duration': 4000, 'easing': 'easeInCubic' } ), //46000

        $('img.beam_glow').delay(4000).animate({ 'opacity': '.8', 'filter': 'alpha(opacity=80)', 'margin-left':'590', 'width':'400','height':'248'
                }, { 'duration': 2000, 'easing': 'easeInCubic' } ), //46000


               //flash
       //$('#flash').delay(15700).animate({'opacity':'1', 'filter': 'alpha(opacity=100)' }, 100),
        //$('#flash').delay(100).animate({ 'opacity':'0', 'filter': 'alpha(opacity=0)' }, 100),  //36000


        // end
        $('#wash').delay(40000).animate({'opacity':'1','filter':'alpha(opacity=100)'}, {'duration':4000, 'easing':'swing'}),
        $('img.letter_v').delay(32000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':4000}),
        $('img.letter_i').delay(32500).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':4000}),
        $('img.letter_r').delay(33000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':4000}),
        $('img.letter_a').delay(33500).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':4000}),
        $('img.letter_l').delay(34000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':4000}),
        $('img.letter_s').delay(34500).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':4000}),
   $('#virals_spelled_out').delay(44000).animate({'opacity':'0', 'filter':'alpha(opacity=0)'}, {'duration':2000}),
    $('span.skip_to_site').delay(44000).animate({'opacity':'0', 'filter':'alpha(opacity=0)'}, {'duration':2000}),
   $('#eyes_and_red').delay(44000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':8000}),
   $('#eyes_and_red img').delay(44000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':2000}),
   $('img.kathy_reichs').delay(47000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':2000}),
    $('img.coming_this_fall').delay(48000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, {'duration':2000}),
    $('.red_line').delay(47000).animate({'opacity': '1', 'width':'850', 'margin-left':'-32', 'filter': 'alpha(opacity=100)'}, 3000),
    $('#preorder img').delay(49000).animate({'opacity':'1', 'filter':'alpha(opacity=100)'}, 1000),


          //third pass - halfway 46000

          $('#lighthouse img').animate({'opacity' : '1', 'filter' : "alpha(opacity=100)" }, 4000), //50000

          $('img.beam_right').delay(8000).animate({'width': '817','height': "126", 'margin-top':'48', 'margin-left':'808', 'opacity': '.3','filter': 'alpha(opacity=30)'
                }, { 'duration': 4000,'easing': 'easeOutCubic'} ), //50000

           $('img.beam_source').animate({ 'width': '0','margin-left': '806'
                }, {'duration':4000, 'easing':'easeOutCubic' } ), //50000

          $('img.beam_glow').animate({'opacity':'0', 'filter':'alpha(opacity=0)', 'margin-left':'984','width':'242','height':'200'
                }, {'duration':2000,'easing': 'easeOutCubic'} ), //48000


          //third pass back 50000

           $('img.beam_right').animate({'width': '0','height': '200', 'margin-top': '5', 'margin-left': '805',  'opacity': '.1', 'filter':'alpha(opacity=10)'
                 }, {'easing': 'easeInCubic','duration': 4000 } ).animate({'opacity':'1'}, 'fast'), //54000

        $('img.beam_source').animate({'width': '7', 'margin-left': '800'
                }, {'duration': 4000, 'easing': 'easeInCubic'} ), //54000

        $('img.beam_glow').delay(4000).animate({ 'opacity': '.1', 'filter':'alpha(opacity=10)',  'margin-left':'590', 'width':'400', 'height':'289'
                }, { 'duration': 2000,  'easing': 'easeInCubic' } ), //54000


          //third pass - halfway back 54000
           $('img.beam_left').delay(8000).animate({ 'width': '817', 'height': '126', 'margin-left': '-20', 'margin-top': '48', 'opacity': '1', 'filter':'alpha(opacity=100)'
                 }, { 'easing': 'easeOutCubic', 'duration': 4000 } ), //58000

        $('img.beam_source').animate({'width': '0','margin-left': '794'
                }, { 'duration': 4000, 'easing': 'easeOutCubic' } ), //58000

        $('img.beam_glow').animate({ 'opacity': '0', 'filter':'alpha(opacity=0)', 'margin-left':'350', 'width':'242','height':'200', 'margin-top':'0'
                }, { 'duration': 2000,  'easing': 'easeOutCubic' } ); //58000
 
         }



});



       
