﻿(function() {
  var $ = jQuery;

  $(window).bind('load', function() {
    $('#hideContent').remove();
    $('.content').hide();
    setTimeout(function() {
      $('.content').fadeOut(0).fadeIn();
    }, 100);
  });

  document.write("<style id=\"hideContent\">.content{visibility: hidden;}</style>");

  jQuery(function($){
    if($(document.body).attr('class').split(/ /).length == 1) 
      $('.sub:visible').hide().slideDown('slow');

    $('.header-menu a').click(function(e) {
      e.preventDefault();
      var location = $(this).attr('href');
      $('.content').fadeOut(function() {
        window.location = location;
      });
    });
        
    $('.header-menu > li > a').click(function(e) {
      e.preventDefault();
      var sub = $('.sub-wrapper:visible');
      var location = $(this).attr('href');
      

      sub.slideUp(function() {
        window.location = location;
      });
      
      if(sub.length) return false;
    });
  
    $('.jointeam .temp h1').retainRandomChild().show();
   
    $('body').prepend('<div id="status-text">');
    $.preloadCssImages();
  });
  
  $.fn.retainRandomChild = function() {
    var children = this.children();
    var child = $(children.get(Math.floor(Math.random() * children.length)));
    if(child[0] == document) return $([]);
    child.siblings().remove();  
    return child;
  }
})();
