if(typeof String.prototype.trim !== 'function')
{
  String.prototype.trim = function() 
  {
    return this.replace(/^\s+|\s+$/g, ''); 
  }
}


jQuery(document).ready(
  function()
  {
    var undefined;

    //alert(window.location.href);
    
    if( window.location != undefined && window.location != null && window.location.hash != undefined && window.location.hash != null && window.location.hash.trim() != '#' && window.location.hash.trim() != '' )
    {
      var obj = jQuery(window.location.hash);
      if( obj.length > 0 )
      {
        (jQuery.browser.opera ? jQuery('html') : jQuery('html, body'))
          .scrollTop(0)
          .animate({scrollTop: obj.offset().top}, 500, 'swing');
      }
    }

    var onAnchor = function()
    {
      var obj = jQuery(this.hash);
      if( obj == null )
        return;
        
      (jQuery.browser.opera ? jQuery('html') : jQuery('html, body'))
        .animate({scrollTop: obj.offset().top}, 500, 'swing');
    };
    
    var thisPageUrl = window.location.href.substring(0, (window.location.href.lastIndexOf(window.location.hash)));
    
    jQuery('a').each(
      function()
      {
        if( this.hash != undefined && this.hash != null && (this.hash.trim() == '#' || this.hash.trim() == '') )
          return;
        
        if( this.href.substring(0, (this.href.lastIndexOf(this.hash))) != thisPageUrl )
          return;
        
        jQuery(this).click(onAnchor);
      }
    );
  
  
    jQuery('#navigation > ul > li > ul > li ul')
      .parent()
      .addClass('hasChildren');
  
    jQuery('#navigation li > ul').each(
      function()
      {
        var ul = jQuery(this);
        var li = ul.parent();
        if( ul.outerWidth() > 0 )
          li.css({ width: ul.outerWidth()+1});
        ul.css({display: 'none'});
      }
    );
  
  
  
    jQuery('#navigation > ul > li').hover(
      function()
      {
        jQuery(this)
          .find(' > ul')
          .stop(true, true)
          .slideDown(200, 'swing');
      },
      function()
      {
        jQuery(this)
          .find(' > ul')
          .slideUp(300, 'swing');
      }
    );
    
    
    
    jQuery('#navigation li li').hover(
      function()
      {         
        jQuery(this)
          .find(' > ul')
          .stop(true, true)
          .animate({width: 'show'}, 200, 'swing');
      },
      function()
      {
        jQuery(this)
          .find(' > ul')
          .animate({width: 'hide'}, 300, 'swing');
      }
    );
        
        
        
    jQuery('#navigation li').hover(
      function()
      {         
        var li = jQuery(this);
      
        if( li.hasClass('current_page_item') || li.hasClass('current_page_ancestor') )
          return;
      
        var a = li.find(' > a');
        
        a.stop(true, true)
          .animate({color: '#f00'}, 300, 'swing');
      },
      function()
      {
        var li = jQuery(this);
      
        if( li.hasClass('current_page_item') || li.hasClass('current_page_ancestor') )
          return;
      
        var a = li.find(' > a');
        
        a.stop(true, true)
          .animate({color: '#c00'}, 350, 'swing');
      }
    );  
    
    
    
    jQuery('#body a, #footer a').hover(
      function()
      {         
        jQuery(this)
          .stop(true, true)
          .animate({color: '#f00'}, 300, 'swing');
      },
      function()
      {
        jQuery(this)
          .stop(true, true)
          .animate({color: '#b00'}, 350, 'swing');
      }
    );   
    
    
    jQuery('.hentry .postMeta.autoHide').each(
      function()
      {
        var temp = jQuery(this);
        temp.css('right', -temp.outerWidth());
      }
    );
    
    jQuery('.hentry').hover(
      function()
      {         
        jQuery(this)
          .find('.postMeta.autoHide')
          .stop(true, false)
          .animate({right: '0'}, 150, 'swing'); 
/*
        jQuery(this)
          .find('.postTitle')
          .stop(true, false)
          .animate({marginTop: '15'}, 150, 'swing'); 
*/
      },
      function()
      {
        var temp = jQuery(this).find('.postMeta.autoHide')
          temp.animate({right: -temp.outerWidth()}, 100, 'swing');

/*
        jQuery(this)
          .find('.postTitle')
          .animate({marginTop: '0'}, 100, 'swing');
*/
      }
    );
  }
);

