var $zb = jQuery.noConflict();

$zb(function () {
// hover effect
 if ($zb.browser.msie) {// Internet Explorer is a sadist.
 } else {
     $zb('.jqfocus').each(function () {
        var time = 250;
        var hideDelay = 200;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $zb('.trigger', this);
        var info = $zb('.theglowdiv', this).css('opacity', 0);

        $zb([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    display: 'block'
                }).animate({
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });
  }// end msie
  
  /*
  $zb('.featuredthumbnails a').find('img').not('.tnselected').mouseover( function () {
   if ($zb(this).is(':animated')) {
      $zb(this).stop(true,true);
    }
    
    $zb(this).fadeTo('normal',0.9);
  }).mouseout( function () {

    if ($zb(this).is(':animated')) {
      $zb(this).stop(true,true);
    }

    $zb(this).fadeTo('normal',0.5);
  });
  
  
  $zb('.featuredthumbnails a img').mouseover( function () {
  var lol = $zb(this).attr('class');
  alert( lol ); 
  });
  */
  
  // featured
  var currpostimage = 0;
  $zb('.featuredthumbnails a').click ( function (event) {
    $zb('.featuredthumbnails a img').removeClass('tnselected');
    var nthclicked = $zb(this).attr('class');
    nthclicked = nthclicked.replace('fimg_','');
    nthclicked = parseInt(nthclicked);
    
    if (nthclicked != currpostimage) {
    
      if ($zb('.featuredimages').find('.one_featuredimage').is(':animated')) { 
        //something is animating
        $zb('.featuredimages').find('.one_featuredimage').stop(true,true);
      }
    
      $zb('.featuredimages').find('.one_featuredimage').eq(currpostimage).fadeOut('fast', function () {
        $zb('.featuredimages').find('.one_featuredimage').eq(nthclicked).fadeIn('fast');
      });
    
      currpostimage = nthclicked;
    }
    
    $zb(this).children('img').addClass('tnselected');
    event.preventDefault();
  });
  
  if (currpostimage <= 0) {
  $zb('.featuredimages').find('.one_featuredimage:gt('+currpostimage+')').hide().css({visibility: "visible"});
  } else {
  $zb('.featuredimages').find('.one_featuredimage:gt('+currpostimage+')').hide().css({visibility: "visible"});
  $zb('.featuredimages').find('.one_featuredimage:lt('+currpostimage+')').hide().css({visibility: "visible"});
  $zb('.featuredimages').find('.one_featuredimage:eq('+currpostimage+')').show().css({visibility: "visible"});
  $zb('.featuredthumbnails a img').removeClass('tnselected');
  $zb('.featuredthumbnails a').eq(currpostimage).children('img').addClass('tnselected');
  }
  
  // subscribe 1
  if ( $zb('.dontmiss_emailinput').val() == '') {
    $zb('.dontmiss_emailinput').val('Send Updates to Your Email');
  }
  $zb('.dontmiss_emailinput').focus( function () {
    if ( $zb(this).val() == 'Send Updates to Your Email') {
      $zb(this).val('');
    }
  }).blur( function () {
    if ( $zb(this).val() == '') {
      $zb(this).val('Send Updates to Your Email');
    }
  });
  
  // subscribe 2
  if ( $zb('.subs_email').val() == '') {
    $zb('.subs_email').val('Email Address');
    $zb('.subs_email').css('color','#999999');
  }
  $zb('.subs_email').focus( function () {
    if ( $zb(this).val() == 'Email Address') {
      $zb(this).val('');
    }
    $zb('.subs_email').css('color','#333333');
  }).blur( function () {
    if ( $zb(this).val() == '') {
      $zb(this).val('Email Address');
    }
    $zb('.subs_email').css('color','#999999');
  });
  
  
  // sidebar hover
  $zb('.side_subsbutton a img').mouseover( function () {
    if ( $zb(this).is(':animated') ) {
      $zb(this).stop(true,true);
    }
    var thesrc = $zb(this).attr('src');
    thesrc = thesrc.replace('.gif','2.gif');
    $zb(this).hide();
    $zb(this).attr('src',thesrc);
    $zb(this).fadeIn('normal');
  }).mouseout( function () {
    if ( $zb(this).is(':animated') ) {
      $zb(this).stop(true,true);
    }
    var thesrc = $zb(this).attr('src');
    thesrc = thesrc.replace('2.gif','.gif');
    $zb(this).hide();
    $zb(this).attr('src',thesrc);
    $zb(this).fadeIn('normal');
  });
  
  // about zen hidden
  if ($zb('.ishome').length > 0) {//is home
  } else {  
    $zb('.abouthidden').slideUp(800);
    $zb('.aboutzen').find('h5').addClass('abouttoggleloaded');
  
    $zb('.aboutzen').find('h5').eq(0).click( function(event) {
      $zb('.aboutzen').find('.abouthidden').eq(0).slideToggle('fast');
      $zb(this).toggleClass('abouttoggleshown');
    });
    $zb('.aboutzen').find('h5').eq(1).click( function(event) {
      $zb('.aboutzen').find('.abouthidden').eq(1).slideToggle('fast');
      $zb(this).toggleClass('abouttoggleshown');
    });
  }
  
  // logo hover
  $zb('.logo_area').find('img').fadeTo(500,0.8);
  $zb('.logo_area').find('img').mouseover( function() {
    $zb(this).fadeTo(500,1);
  }).mouseout( function() {
    $zb(this).fadeTo(500,0.8);
  });
  
});