jQuery(function() {
	jQuery("a.title").cluetip({
		splitTitle: "|",
		dropShadowSteps: 4,
		fx: {open: 'show'}
	});
	jQuery("a.tablink").click(function() {
		toggleContent(jQuery(this).attr("id").substring(5),"true");
		return false;
	});
});
jQuery.history.callback = function ( reinstate, cursor ) {
	// reinstate is the actual object to reinstate
	if (typeof(reinstate) == 'undefined') {
        toggleContent("home","false");
	} else {
    	toggleContent(reinstate.historydiv,"false");
	}
}
function initGallery() {
	jQuery("a[rel^='lightbox']").slimbox({loop: true,imageFadeDuration: 300});
};
function initCuwindow() {
	jQuery('.cuwindow').addClass('nyroModal');
	jQuery('.cuwindowcontainer').addClass('nyroModalContainer');
	jQuery('a.nyroModal').nyroModal({
		debug: false,
		modal: false,
		minWidth: 440,
		autoSizable: false,
		minHeight: 500,
		resizeable: false,
		bgcolor: '#000000'
	});
};
function toggleContent(showDivId,addHistory) {
	currActive = jQuery(".tab-active").attr("id").substring(4);
	jQuery("#tab-"+currActive).removeClass("tab-active");
	jQuery("#tab-"+currActive).addClass("tab-inactive");
	jQuery("#tab-"+showDivId).removeClass("tab-inactive");
	jQuery("#tab-"+showDivId).addClass("tab-active");
	jQuery("#departmenttext").css("background-color", "ffffff").fadeOut("fast",function() {
		if (addHistory == "true") {
			jQuery.history( {historydiv:showDivId} );
		}
		jQuery("#loading").show();
		jQuery("#departmenttext").load("tabs/"+showDivId+".cfm #tabcontent",function() {
			jQuery("#loading").hide();
			if (showDivId == 'photos') {
				initGallery();
			} else if (showDivId == 'media') {
				initCuwindow();
			};
			jQuery("#departmenttext").css("background-color", "ffffff").fadeIn("fast");
		});
	});
}