$(document).ready(function(){
	
	var settings = { start:0, change:false };
	$('#menu').idTabs(function(id){ 			
		switch(id){ 
			case "#about": 
				getAjaxContent('#content', '/ajaxshow/page/about'); 
				break; 
			case "#gallery": 
				getAjaxContent('#content', '/ajaxshow/gallery'); 
				galleryPagination();
				break;
			case "#contacts":
				getAjaxContent('#content', '/ajaxshow/page/contacts');
				break; 
		} return true; 
	},settings,true);
});	


function ajaxLoader(updSection) {
	$(updSection).append('<div id="ajaxloader" class="big"><h3>Loading…</h3></div>');
};

function galleryAjaxLoader(updSection){
	$(updSection).block({
		message: '<div id="ajaxloader"><h3>Loading…</h3></div>',
		css: {
			backgroundColor:'#000', 
			border: 'none'
		},
		overlayCSS:{ 
			backgroundColor: '#000',
			opacity:1
		}
	});
}

function getAjaxContent(updSection, link){
	$.ajax({
		url: link,
		type: "GET",
		dataType: "html",
		cache: true,
		beforeSend: function(){
			ajaxLoader(updSection);
		},	
	  	success: function(html) {
	    	updatePage(updSection, html);
	 	}
	});			
}

function getGalleryAjaxContent(updSection, link){
	$.ajax({
		url: link,
		type: "GET",
		dataType: "html",
		cache: true,
		beforeSend: function(){
			galleryAjaxLoader(updSection);
		},	
	  	success: function(html) {
	    	updatePage(updSection, html);
	 	}
	});			
}

function updatePage(updSection, html){
	window.setTimeout( function(){
		$(updSection).html(html);
		loadsuperbox(updSection);
	}, 1000)		
}

function galleryPagination() {
	$('#pagination a').live('click', function(eve){
		eve.preventDefault();
		var link = $(this).attr('href');
		getGalleryAjaxContent('#ajax-section',link);
	});	
};

function loadsuperbox(divName){
	$.superbox.settings = {
		closeTxt: "[×] Close", // "Close" button text
		prevTxt: "← Prev", // "Previous" button text
		nextTxt: "Next →", // "Next" button text
		loadTxt: "Loading…",
		divName: divName
	};
	$.superbox();
};
