// http://www.drupalcoder.com/story/500-cross-browser-sticky-footer-with-fluid-height-using-jquery

$(document).ready(function() {
  $("#footer").stickyFooter();
});

//sticky footer plugin
(function($){
 var footer;

 $.fn.extend({
   stickyFooter: function(options) {
     footer = this;
    
     positionFooter();

     $(window)
       .scroll(positionFooter)
       .resize(positionFooter);

     function positionFooter() {
       var docHeight = $(document.body).height() - $("#sticky-footer-push").height();
       if(docHeight < $(window).height()){
         var diff = $(window).height() - docHeight;
         if (!$("#sticky-footer-push").length > 0) {
           $(footer).before('<div id="sticky-footer-push"></div>');
         }
         $("#sticky-footer-push").height(diff);
       }
     }
   }
 });
})(jQuery);


$(document).ready(function(){

  var hash = window.location.hash.substr(1);
  var href = $('#project-menu a').each(function(){
      var href = $(this).attr('href');
      if(hash==href.substr(0,href.length)){
          var toLoad = hash+'?ajax=1';
          $('#project-content > .pane-content').load(toLoad)
      } 
  });


  $('#project-menu a').click(function(){
  
    var toLoad = $(this).attr('href') + '?ajax=1';  
         
      if ($('#project-content #load').size() == 0) {
        $('#project-content').prepend('<span id="load">LOADING</span>');
      }
      $('#project-content #load').fadeIn('normal');
      
   // $('body').css('overflow', 'hidden');
    $('#project-content > .pane-content').hide('slide', {direction: 'left'}, 400, loadContent);
    
    function loadContent() {
	    $('#project-content > .pane-content').load(toLoad,'',showNewContent);
    }

    function showNewContent() {
      hideLoader();
	    $('#project-content > .pane-content').show('slide', {direction: 'left'}, 400);
	    Drupal.attachBehaviors($('#project-content > .pane-content'));
    }

    function hideLoader() {
	    $('#project-content #load').fadeOut('normal');
    }

    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length);
    
    return false;
  });
  

  $('#website-menu a').click(function(){
  
    var toLoad = $(this).attr('href') + '?ajax=1';  
    
      if ($('#website-content #load').size() == 0) {
        $('#website-content').prepend('<span id="load">LOADING</span>');
      }
      $('#website-content #load').fadeIn('normal');
      
    $('#website-content > .pane-content').hide('slide', {direction: 'left'}, 400, loadContent);
    
    function loadContent() {

	    $('#website-content > .pane-content').load(toLoad,'',showNewContent)
    }

    function showNewContent() {
      hideLoader();
	    $('#website-content > .pane-content').show('slide', {direction: 'left'}, 400);
	    Drupal.attachBehaviors($('#website-content > .pane-content'));
    }

    function hideLoader() {
	    $('#website-content #load').fadeOut('normal');
    }

    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length);
    
    return false;
  });

});



$(document).ready(function(){
  $.fn.preload = function() {
    this.each(function(){
      $('<img/>')[0].src = this;
    });
  }
  $([
    '/sites/kirkdesigns.co.uk/themes/swish/images/icons/home-blue-50.png',
    '/sites/kirkdesigns.co.uk/themes/swish/images/icons/home-blue-75.png',
    '/sites/kirkdesigns.co.uk/themes/swish/images/icons/gears-blue-50.png',
    '/sites/kirkdesigns.co.uk/themes/swish/images/icons/gears-blue-75.png'
  ]).preload();
});



