// Set default page status variables for the front page navigation
var galleryactive = false;
var portfolioactive = false;
var pricingactive = false;

// JQuery preload images function for front page nagivation items.
jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}
// This function double checks the statuses of the active and inactive menu, it's primary use it to disable once opening an different active item.
function setimages() {
	// Gallery navigation status
			if (galleryactive == false) {
				document.getElementById('togglegallery').src="common/nav-buttons/nav_galleries_inactive.png";
			} else {
				document.getElementById('togglegallery').src="common/nav-buttons/nav_galleries_active.png";
			}
	// Portfolio navigation status		
			
			if (portfolioactive == false) {
				document.getElementById('toggleportfolio').src="common/nav-buttons/nav_portfolio_inactive.png";
			} else {
				document.getElementById('toggleportfolio').src="common/nav-buttons/nav_portfolio_active.png";
			}
	//Pricing navigation status	
			if (pricingactive == false) {
				document.getElementById('togglepricing').src="common/nav-buttons/nav_pricing_inactive.png";
			} else {
				document.getElementById('togglepricing').src="common/nav-buttons/nav_pricing_active.png";
			}
	}

// This is the function for the DIV sliders (one for each div), a little bit of 
// magic in here to set various statuses because we're using the toggle() function
// instead of SlideOut() and SlideIn() individually.

window.addEvent('domready', function(){

	var mySlide = new Fx.Slide('gallery').hide();

	$('togglegallery').addEvent('click', function(e){
		e = new Event(e);
		mySlide.toggle();
		mySlide1.slideOut();
		mySlide2.slideOut();
		e.stop();
		if (galleryactive == false) {
			galleryactive = true;
			portfolioactive = false;
			pricingactive = false;
			} else {
			galleryactive = false;
			}
			setimages(); // Remove nav bugs
	});
	
	var mySlide1 = new Fx.Slide('portfolio').hide();

	$('toggleportfolio').addEvent('click', function(e){
		e = new Event(e);
		mySlide1.toggle();
		mySlide.slideOut();
		mySlide2.slideOut();
		e.stop();
		if (portfolioactive == false) {
			galleryactive = false;
			portfolioactive = true;
			pricingactive = false;
			} else {
			portfolioactive = false;
			}
			setimages(); // Remove nav bugs
	});
	
	var mySlide2 = new Fx.Slide('pricing').hide();

	$('togglepricing').addEvent('click', function(e){
		e = new Event(e);
		mySlide2.toggle();
		mySlide1.slideOut();
		mySlide.slideOut();
		e.stop();
		if (pricingactive == false) {
			galleryactive = false;
			portfolioactive = false;
			pricingactive = true;
			} else {
			pricingactive = false;
			} 
			setimages(); // Remove nav bugs
	});
	 
	
}); 

// Gallery Fancyboxes
$j(document).ready(function() {
	// Start fancybox intialisation - each fancybox is required to be initialised on page load.
				$j("#10-11_lightingexperiment").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});
				
	// End fancybox intialisation
				$j("#10-12_walkem").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

// Portfolio Fancyboxes

	// Start fancybox intialisation - each fancybox is required to be initialised on page load.
				$j("#architecture").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});
	// End fancybox intialisation
				
				$j("#art").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});
				
				$j("#automotive").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

				$j("#commercial").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

				$j("#events").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

				$j("#landscape").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

				$j("#motorsport").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

				$j("#music").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe'
				});

});

// Preload Navigation images (so it doesn't look shit!)
$j.preloadImages("common/nav-buttons/nav_galleries_active.png", "common/nav-buttons/nav_portfolio_active.png", "common/nav-buttons/nav_pricing_active.png");

// This is controls the front page navigation by replacing parts of the filename,
// a little different to how it's usually done but it works none the less.
$j(
	function()
	{
		// set up rollover
		$j("img.rollover").hover(
			function()
			{
				this.src = this.src.replace("_inactive","_active");
			},
			function()
			{
				this.src = this.src.replace("_active","_inactive");
				setimages(); // Remove nav bugs
			}
		);
	}
)
