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

	// Data Table
	if($('#example').length >=1){
		oTable = $('#example').dataTable({ "bJQueryUI": true });
		oTable.fnFilter( 'Amplifier Racks' );	
	}
	
	if($('#ul#categories li').length >=1){
		$('ul#categories li a').click(function() {
			category = $(this).attr('href');
			oTable.fnFilter( category );		
			return false;
		});	
	};
	
	// Misc
	// ------------------------------------------------------------------------------------------------	

	/* jquery paginate */
	if($('#page_container').length >=1){
		$('#page_container').pajinate({
			items_per_page : 5
		});
	};
	
	// Nivo slider
	if($('#gallery').length >=1){
		$('#gallery').nivoSlider({
			effect: 'sliceDown', //slice, random, fade 
			slices: 15,
			animSpeed: 500,
			pauseTime: 4000,
			startSlide: 0,
			directionNav: true,
			directionNavHide: true,
			controlNav: true,
			controlNavThumbs: false,
			controlNavThumbsFromRel: false,
			controlNavThumbsSearch: '.jpg',
			controlNavThumbsReplace: '_thumb.jpg',
			keyboardNav: true,
			pauseOnHover: true,
			manualAdvance: false,
			captionOpacity: 0.8,
		});	
	};
	
	// jQuery Scrollable
	if($('.scrollable').length >=1){
		$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true });
	}
	
})(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);



