// ********************************************************
// * makeInvisible(object name)                           *
// ********************************************************

			function makeInvisible(obj) {
			
			$(obj).setStyle('opacity', '0'); 

 
			}



// ********************************************************
// * tehFadeIn(object name)                               *
// ********************************************************

			function tehFadeIn(obj) {
			
			var tehEffect = new Fx.Tween($(obj), {
				property: 'opacity',
				duration: 100, 
				transition: Fx.Transitions.Quart.easeInOut
			});
			
			tehEffect.start(0.2,1);
 
			}



// ********************************************************
// * makeFullScreen(theURL)                               *
// ********************************************************

			function makeFullScreen(theURL) {

			if (Browser.Engine.trident) {

				// IE is fine with the pseudo-full-sized window

				var newWin = window.open(
				theURL, 
				'fullScreenWindow', 
				'fullscreen=yes'
				);
				
			} else if (Browser.Engine.gecko) {
				
				// Firefox is fine with the pseudo-full-sized window

				var newWin = window.open(
				theURL, 
				'fullScreenWindow', 
				'fullscreen=yes'
				);
				
			} else {
				
				// With the WebKit engine, you will need to resize the window.
				
				var newWin = window.open(
				theURL, 
				'fullScreenWindow', 
				'fullscreen=yes'
				);
				
				newWin.moveTo(0,0);
				
				newWin.resizeTo(screen.availWidth,screen.availHeight);
				
			};
			
			}



// ********************************************************
// * nada()  [Do Nothing]                                 *
// ********************************************************

			function nada() {
			
			}


// ****************************************************************
// * Change the background image                                  *
// ****************************************************************


			function makeBG(thisImg) {

					// make it invisible

					makeInvisible('bgiPix');
					
					// change out the picture
					
					var newImage = "./pix/bg_0" + thisImg + ".jpg";				
					$('bgiPix').setAttribute('src', newImage);
					
					// fade it back in
					
					tehFadeIn('bgiPix');

					// change the text on the page to reflect the new image

					// var hereImg = $('bgiPix').get('src');
					// var sayThis2 = "Current Image : " + hereImg;				
					// $('mahImage').set('text', sayThis2);


			}


// ****************************************************************
// * What picture is next?                                        *
// ****************************************************************


			function nextUp() {

					// What picture is this?

					var thisHere = $('bgiHolder').retrieve('bGallery').photoNumber;
					
					if ( thisHere == '1') {

						var element = $('bgiHolder');
						var data = element.retrieve('bGallery', {});			
						data.photoNumber = 2;
					
						makeBG('2');
						
					} else if ( thisHere == '2') {
						
						var element = $('bgiHolder');
						var data = element.retrieve('bGallery', {});			
						data.photoNumber = 3;
					
						makeBG('3');
					
					} else if ( thisHere == '3') {
						
						var element = $('bgiHolder');
						var data = element.retrieve('bGallery', {});			
						data.photoNumber = 4;
					
						makeBG('4');
					
					} else if ( thisHere == '4') {
						
						var element = $('bgiHolder');
						var data = element.retrieve('bGallery', {});			
						data.photoNumber = 1;
					
						makeBG('1');
					
					}

			}



// ****************************************************************
// * We need to be constantly aware of the user's screen size    *
// ****************************************************************


			function placeBackground() {
			
				// Let's see what the available screen size is
			
				var sHeight = this.getSize().y;
				var sWidth = this.getSize().x;
				
				// What is the current image ratio?  ...our target is 1.6
				
				var sRatio = sWidth / sHeight;
				


				if ( sRatio >= 1.6 ) {
					
						// if the Image Ratio is higher than 1.6, WIDTH should be our guide
						
						var finalHeight = ( (800 * sWidth) / 1280 );
						var finalWidth = sWidth;

						var adjustMe = 0;
				
				} else {
					
						// if the Image Ratio is lower than 1.6, HEIGHT should be our guide
					
						var finalHeight = sHeight;
						var finalWidth = ( (1280 * sHeight) / 800 );
						
						var adjustMe = ( 0 - ( ( finalWidth - sWidth ) / 2 ) );
											
				}; 
				
				// The Holder should always be the same size as the screen
				
				$('bgiHolder').setStyle('width', sWidth);
				$('bgiHolder').setStyle('height', sHeight);
	
				// The picture won't always be the same size as the screen though
	
				$('bgiPix').setStyle('width', finalWidth);
				$('bgiPix').setStyle('height', finalHeight);
				
				// The final width might be larger than the screen, we should artificially center the image
				
				$('bgiPix').setStyle('margin-left', adjustMe);



				// Let's print that to the DIV we made to display it
				
				// var sayThis = "Available  ( W: " + sWidth + " | H: " + sHeight + " | R: " + sRatio + " ) Resize Image to: ( W: " + finalWidth + " H: " + finalHeight + " ) Left Adjust: " + adjustMe;								
				// $('mahParamaters').set('text', sayThis);
				// var hereImg = $('bgiPix').get('src');
				// var sayThis2 = "Current Image : " + hereImg;
				// $('mahImage').set('text', sayThis2);


				// we should also take the time to position the footer menu
				
				if (Browser.Engine.webkit) {

						// webkit throws up scrollbars if you go to the bottom pixel
					
						var footerHere = sHeight - 32;
						
				} else {
				
						// but trident and gecko are fine with going all the way to the edge
				
						var footerHere = sHeight - 51;
				
				};
				
				$('footerMenu').setStyle('top', footerHere);
								
				// we should also take the time to place logo 1
				
				var logo1_left = sWidth - 320;
				var logo1_top = sHeight - 160;
				
				$('logo1').setStyle('left', logo1_left);
				$('logo1').setStyle('top', logo1_top);
				
				// we should also take the time to place logo 2
				
				var logo2_left = sWidth - 160;
				var logo2_top = sHeight - 160;
				
				$('logo2').setStyle('left', logo2_left);
				$('logo2').setStyle('top', logo2_top);
				

				
			// That's the end of placeBackground()

			}



// ****************************************************************
// * When the DOM is ready, this will fire                        *
// ****************************************************************

window.addEvent("domready", function(){
	
	
			// let's store the current state of our gallery in a place where we can get it from other functions
			
			var element = $('bgiHolder');
			
			var data = element.retrieve('bGallery', {});
			
			data.photoNumber = 1;



			// now we do our background resizing magic

			placeBackground();
			

			// let's preload the next few background images
	
			var preLoad1 = new Asset.images([
		
			'./pix/bg_02.jpg', 
			'./pix/bg_03.jpg',
			'./pix/bg_04.jpg'
		
			], {
				    onComplete: function(){

				// Now that they are loaded, let's start our little slideshow
				
				nextUp.periodical(8000);
	
		    	}
			});



// END OF DOMREADY
	
});



// ****************************************************************
// * If the Window resizes, this will fire                        *
// ****************************************************************

window.addEvent("resize", function(){
	
	
			// if the image is resized, let's do our background magic once more
	
			placeBackground();


// END OF RESIZE
	
});


