// JavaScript Document

$(document).ready(function() {
	


//lightbox	

	function formatTitle(title, currentArray, currentIndex, currentOpts) {
	    return '<div id="lightbox-title"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="http://www.dreamco.com/web2/wp-content/themes/toolbox/images/custom_close.gif" /></a></span>' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
	}

	$(".lightbox").fancybox({
		'transitionIn'	:	'elastic', 
		'transitionOut'	:	'fade',
		'speedIn'	:	600,
		'speedOut'	:	100,
		'overlayOpacity'	:	0.8,
		'overlayColor'	:	'#000',
	    'showCloseButton'   : true,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle
	});

	
	 $("a.inline").fancybox({
		'transitionOut'	:	'fade',
		'speedOut'	:	100,
		'overlayOpacity'	:	0.8,
		'overlayColor'	:	'#000',
	    'showCloseButton'   : false,
		'titlePosition' 	: 'inside',
		'titleFormat'		: formatTitle
       }); 
	
$("a.hidelink").removeClass("hidelink");  //shows hidden text links in tabs

//Tabs
//When a tab is clicked, pass it to the updateTabs method
$(".all_tabs .tab a").click(function() {
   updateTabs($(this).attr("href"));

});
 
//Grab hash off URL (default to first tab) and update
$(window).bind("hashchange", function(e) {
   var anchor = $(location.hash);
   if (anchor.length === 0) {
      anchor = $(".all_tabs div:eq(1)"); //sets default tab
   }
   updateTabs(anchor);
});
 
//Pass in the tab and show appropriate contents
function updateTabs(tab) {
   $(".all_tabs .tab a")
      .removeClass("active")
      .filter(function(index) {
         return $(this).attr("href") === '#' + tab.attr("id");
      }).addClass("active");
   $(".all_tabs .tab_content").hide();
   tab.show(); 
}


 
//Fire the hashchange event when the page first loads
$(window).trigger('hashchange');

//if you want to open a tab from a link which is not a tab, make sure you give that link a class of external_link
$(".external_link").click(function() {
//call above function
updateTabs($(this).attr("href"));
});
	

//to show a "hidden tab" without changing the active tab on the nav menu
//set the class of the links that navingates to/from the hidden tab to .toggle_hidden, set the class of the tabs which show/hide to //.toggle_tab, set the href value of *both* links to the id of the tab which should be active in the nav menu i.e. #multimedia
//each subsequent toggle on a page requires it's own class


$(".toggle_hidden").click(function(){
	$(".toggle_tab").toggle();
	event.preventDefault();
});

$(".toggle_hidden_1").click(function(){
	$(".toggle_tab_1").toggle();
	event.preventDefault();
});

$(".toggle_hidden_2").click(function(){
	$(".toggle_tab_2").toggle();
	event.preventDefault();
});


});

