

                    //***** EXTEND THE FOOTER ***************************************//

function extendFooter() {
  $('#Form').removeAttr("style");
  var footerHeight = $('#footer').height();
  var pageHeight = $('#wrap').height();
  var windowHeight = $(window).height();
  var difference = windowHeight - pageHeight;
  if (pageHeight < windowHeight) {
    $('#footer').height(footerHeight + difference);
   } else {
     $('#footer').height('auto');
   }
 }


                    //***** REPLACE ALIGN ATTRIBUTE WITH CLASS ************************************************//
                    
function replaceAlign() {
  if (!document.getElementsByTagName('img')) return false;
  $('img[align="left"]').addClass('left').removeAttr('align');
  $('img[align="right"]').addClass('right').removeAttr('align');
$('img[align="middle"]').addClass('middle').removeAttr('align');
}


                    //***** REPLACE TARGET ATTRIBUTE WITH CLASS ***********************************************//

function replaceTarget() {
  if (!document.getElementsByTagName('a')) return false;
  $('a[target]').addClass('newwindow').removeAttr('target');
}


                    //***** WEB STANDARD POPUPS ***************//
                    
function strictNewWindow() {
  if (!document.getElementsByTagName('a')) return false;
  $('a.newwindow').click(function() {
    window.open($(this).attr('href'));
    return false;
  });
}


                    //***** CLEAR SEARCH BOX ON FOCUS *****************************************//
                    
function clearSearchBox() {
  if (!document.getElementById('txtSearch')) return false;
  $('#txtSearch').focus(function() {
    if ($(this).val() == 'SEARCH') {
      $(this).val('');
    }
  });
}


                    //***** NAVIGATION *****************************************************//
                    
function extendNav() {
  $('ul#nav').show();
  $('#navList').hide();
  $('a.readMore').hide();
  $('.navButton').css("width","95px");
  $('ul#nav').hover(function() {
    $(this).stop().animate({"left":"-2px"}, 350);
  }, function() {
    $(this).stop().animate({"left":"-90px"}, 350);
  });
  $('.navButton').hover(function() {
    $(this).stop().animate({"width":"275px"}, 350);
    $(this).children('a.readMore').fadeIn();
  }, function() {
    $(this).stop().animate({"width":"95px"}, 350);
    $(this).children('a.readMore').fadeOut();
  });
  $('#lnkFeaturedWork').css("width","95px");
  $('#lnkFeaturedWork').hover(function() {
    $(this).stop().animate({"width":"322px"}, 350);
    $(this).children('a.readMore').fadeIn();
  }, function() {
    $(this).stop().animate({"width":"95px"}, 350);
    $(this).children('a.readMore').fadeOut();
  });
}


                    //***** FOLLOW ME DROPDOWN **********************************************************//
                    
function followMe() {
  $('#followMe p a').click(function() {
    return false;
  });
  $('#main #followMe ul').show();
  $('#followMeWrap').hide();
  $('#followMeWrap').animate({opacity : 0});
  $('#followMe').hover(function() {
    $('#followMeWrap').show();
    $('#followMeWrap').stop().animate({
        opacity : 1
      }, 500);
  }, function() {
    $('#followMeWrap').stop().animate({
      opacity : 0
    }, 500);
    $('#followMeWrap').hide();
  });
}


                    //***** TOGGLE TUTORIAL SECTIONS **********************************************************//
                    
function toggleTutorials() {
  $('.toggle').hide();
  $('.tutorialSection h4').addClass('inactive');
  $('.tutorialSection h4').click(function () {
    $(this).toggleClass('inactive');
    $(this).toggleClass('active');
    $(this).parent().find('.toggle').slideToggle();
  });
}


                    //***** TOGGLE WORDPRESS RESOURCES ********************************************************//
                    
function toggleWPResources() {
  $('.toggle').hide();
  $('.plugin h4').addClass('inactive');
  $('.plugin h4').click(function () {
    $(this).toggleClass('inactive');
    $(this).toggleClass('active');
    $(this).parent().find('.toggle').slideToggle();
  });
}

                    
                    //******************************** TOOL TIP*********************************//
                    
this.tooltip = function(){  
  /* CONFIG */    
    xOffset = 40;
    yOffset = 0;    
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result    
  /* END CONFIG */    
  $("a.tooltip").hover(function(e){                        
    this.t = this.title;
    this.title = "";                    
    $("body").append("<p id='tooltip'>"+ this.t +"</p>");
    $("#tooltip")
      .css("top",(e.pageY - xOffset) + "px")
      .css("left",(e.pageX + yOffset) + "px")
      .fadeIn("fast");    
    },
  function(){
    this.title = this.t;    
    $("#tooltip").remove();
    });  
  $(".tooltip").mousemove(function(e){
    $("#tooltip")
      .css("top",(e.pageY - xOffset) + "px")
      .css("left",(e.pageX + yOffset) + "px");
  });      
};


                    //******************************** CODE SNIPPETS *********************************//
                    
/* 
function codeSnippets() {
  var $title = $("#snippet-header").text();
  $(".entry pre").each(function() {
    var $preblock = $(this);
    var $codeblock = $preblock.find("code");
    var $snippet = "codaclips://<<**Title:" + $title + "**>>" + encodeURIComponent($codeblock.text());
    $("<a class='coda-clip'>Add Coda Clip</a>").attr("href",$snippet).appendTo($preblock);
    $preblock.hover(function() {
      $preblock.find(".coda-clip").stop().fadeTo(300, 1.0);
    }, function() {
      $preblock.find(".coda-clip").stop().fadeTo(300, 0);
    });
  });
  $(".coda-clip").show().css("opacity","0");
});
*/


//***** Load all functions ****************************************************************//
$(document).ready(function(){
  //bodyBottom();
  replaceAlign();
  replaceTarget();
  strictNewWindow();
  clearSearchBox();
  extendNav();
  extendFooter();
  followMe();
  toggleTutorials();
  toggleWPResources();
  tooltip();
  // codeSnippets();
});