var $j = jQuery.noConflict();
var $ = {};
// PageLoad function
// This function is called when:
// 1. after calling $.historyInit();
// 2. after calling $.historyLoad();
// 3. after pushing "Go Back" button of a browser
function pageload(hash) {
	// hash doesn't contain the first # character.
	if(hash) {
		// restore ajax loaded state
		var path = $j(".gallery_container").attr("data-path");
		$j(".gallery_container").empty().html('<img src="'+path+'/img/ajax-loader.gif" />');
		$j('.gallery_container').load(""+path+"/ajaxrequest.php",{directory:hash}, function(){
			$j('.gallery_photos a').lightBox();
		});
	}
}		
		
		$j(document).ready(function(){
			
			$j.history.init(pageload);
		
			$j('.gallery_photos a').lightBox();
			
			// set onlick event for buttons
			$j("a[rel='history']").click(function(){
				// 
				var hash = this.href;
				hash = hash.replace(/^.*?gid=/, '');
				// moves to a new page. 
				// pageload is called at once. 
				$j.history.load(hash);
				return false;
			});

			$j("a#example1, #youtube").fancybox({
				'titleShow'		: true
			});
			 
			
			$j("#menu-nav").lavaLamp({
				fx: "backout",
				speed: 700
			});
		
			$j('#logo, #folder, #agendamento').bt({
				padding: 20,
				width: 100,
				spikeLength: 20,
				spikeGirth: 20,
				cornerRadius: 25,
				fill: 'rgba(0, 0, 0, .8)',
				strokeWidth: 3,
				strokeStyle: '#67b021',
				cssStyles: {color: '#67b021', fontWeight: 'bold', fontSize: '16px'}
			});
			
			$j('#footer a img').bt({
				padding: 10,
				width: 100,
				spikeLength: 20,
				spikeGirth: 20,
				cornerRadius: 10,
				fill: 'rgba(0, 0, 0, .8)',
				strokeWidth: 3,
				strokeStyle: '#67b021',
				cssStyles: {color: '#67b021', fontWeight: 'bold', fontSize: '16px'}
			});
			
			
});

