/* Author: Jeffrey R. Gould

*/
$(document).ready(function(){
  
  $fwTop = $('#fw-top');
  $slideArea = $('#slide-area');

  if($fwTop.length && $slideArea.length){//if this is the front page with slides

    $fwTop.html( $slideArea.html() );
    $fwTop.find('div').empty();



    // $('body').prepend('<div id="cyclenav" />');    //JUST FOR JEFF
    $slideArea.cycle({
      // pager: '#cyclenav', //JUSTFORJEFF
      speed: 1000,
      timeout: 6000,
      fx: 'fade',
      sync: true,
      random: false,
      before: function(currSlideElement, nextSlideElement, options, forwardFlag){
        currClass = currSlideElement.className;
        nextClass = nextSlideElement.className;
        speedIn = options.speedIn;
        speedOut = options.speedOut;
      
        if(window.skipFirst){
          $fwTop.find('div.' + currClass).css({display: 'block'}).animate({opacity: 0}, speedIn);
          $fwTop.find('div.' + nextClass).css({display: 'block'}).animate({opacity: 1}, speedOut)
        }
        else{
          window.skipFirst = true;
        }     
      
      },
      after: function(currSlideElement, nextSlideElement, options, forwardFlag){
        currClass = currSlideElement.className;
        nextClass = nextSlideElement.className;
      
        $fwTop.find('div:not(.'+nextClass+')').css({display: 'none', opacity: 0});
        $fwTop.find('div.' + nextClass).css({display: 'block', opacity: 1});
      
      }
      
    });


  }//if this is the front page with slides

  $singleSlides = $(".slides", "#post_slider");


  if($singleSlides.length && $singleSlides.find('.slide').length){

    $singleSlides.before("<div id='slidePager' />");
    
    $singleSlides.cycle({
      speed: 1000,
      timeout: 6000,
      fx: 'fade',
      sync: true,
      random: false,
      pager: '#slidePager',
      pagerAnchorBuilder: function(idx, slide){ return '<a href="#" class="">&nbsp;</a>';}
    });

  }


  $et = $('.entrytext', '.work');
  if($et.length){
    if($et[0].scrollHeight > $et.height()){

      $etScroller = $('<div id="et-scroller" />');
      $et.after($etScroller);

      $etScroller.click(function(e){
        if( ($et[0].scrollTop + $et.height()) < $et[0].scrollHeight ){
          $et.animate({scrollTop: +$et.height()});
        }else{
          $et.animate({scrollTop: 0});
        }
      });// etScroller.click

      $et.scroll(function(e){
        if( ($et[0].scrollTop + $et.height()) < $et[0].scrollHeight ){
          $etScroller.removeClass('up');
        }else{
          $etScroller.addClass('up');
        }
      });// entrytext.scroll


    }//if entrytext is longer than its container
  }//if we're on a work page with entrytext

if($.browser.mozilla && ($.browser.version[0] < 2) ){
  $('html').addClass('oldMoz');
}
  
});//docready






















