// remap jQuery to $
(function($){

    $(document).ready(function() {
    
        var activeItem;
        var activeTab;
    
    	// When page loads...
    	$(".tab_content").hide(); //Hide all content
    	
    	// Look for a hash in the URL, set that to the active item
    	if (window.location.hash) {
    	   activeItem = $('.tabs a[href="'+window.location.hash+'"]');
    	   activeTab = $(window.location.hash);
    	}
    	// Or just choose the first item
    	else {
    	   activeItem = $(".tabs a:first");
    	   activeTab = $(".tab_content:first");
    	}
    	
    	activeItem.addClass("active").show(); //Activate first tab
    	activeTab.show(); //Show first tab content
    
    	//On Click Event
    	$(".tabs a").click(function() {
    	
            var link = $(this), activeTabId;
            
    		$(".tab_content").hide(); //Hide all tab content
            $(".tabs a").removeClass("active"); //Remove all "active" classes
    	
    	
            link.addClass("active"); //Add "active" class to selected tab
    		
    		activeTabId = link.attr("href"); //Find the href attribute value to identify the active tab + content
    		$(activeTabId).fadeIn(); //Fade in the active ID content... ref includes "#"
    
    	    return false;
    		
    	});
    });
    
})(this.jQuery);



// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};



// catch all document.write() calls
(function(doc){
  var write = doc.write;
  doc.write = function(q){ 
    log('document.write(): ',arguments); 
    if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments);  
  };
})(document);



