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

	$("a[rel$='external']").click(function(){
	  this.target = "_blank";
	});

	$("img.rollover").hover(
	function(){
		this.src = this.src.replace("-off","-on");
	}, function() {
		this.src = this.src.replace("-on","-off");
		}
	);


    $('body').append('<div id="sscontainer"><div id="gallery"></div></div>');
    
    function loadPage(page){
    	$('#gallery').load('/pages/'+page+'.php', function(){
			loadGallery();
    	});
    }
    
    $('#galleryClick').click(function() {
		$("#sscontainer").lightbox_me({
			overlayCSS: {
				background: 'black', 
				opacity: .9
				},
			centered: true,
			onLoad: function() { 
            	loadPage('gallery');
            },
            onClose: function(){
            	$('#gallery').html('');
            }
        });       
        return false;
    });
	
	function loadGallery(){
        $("#gallery").galleria({
	        transition: 'fade',
	        autoplay: 7000,
	        showInfo: false,
	        showCounter: false,
            width: 950,
            height: 550
        });
	}

})(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);



