<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	
	var flagEnlargement = false;
	var imgPos, picTotal;
	var splashDelay = 3000;
	
	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function showEnlargementImage(type, id)
	{
		var div = $('container_enlargement');
		var url = "get_enlargement.asp";
		var data = "type=" + type + "&imageID=" + id
		var images;
		
		if (type == "gallery")
		{
			data = data + "&prevID=" + getGalleryPrevImageID(id) + "&nextID=" + getGalleryNextImageID(id)
		}		
				
		var req = new Request( {url: '' + url,

			onSuccess: function(txt) {
			
				$(div).set('html', txt);

				showEnlargement();

				if (type == "gallery")
				{
					var img_path = $('gallery_image_address').get('text');
								
					/* preloading */  			
					images = [ img_path ];

					//create the asset.images
					assetImages = new Asset.images(images, {  
						onComplete: function() { 							
							images.each(function(imgsrc) {  
								new Element('img',{ src: imgsrc, height: 445, style: 'width:auto; height:445px;' }).inject($('enlargement_image')); 
								
								var w = window.getWidth() / 2 - 445;
								var h = window.getHeight() / 2 - 225;
								var top;

								if (h < 0) {
									top = 0;
								}
								else
								{
									top = h + window.getScrollTop();
								}
								
								$('container_enlargement').setStyle('top', top + 'px');
								$('container_enlargement').setStyle('left', (w + 210) + 'px');
							});		
						}				
					});
				}
				
			},

			onFailure: function() {
				$(div).set('html', '<div class="ajax_white">Error loading... Please refresh the browser</div>');
			}

		}).send(data);
	}	
	
	//================================================================================================
	// FORM FUNCTIONS
	//================================================================================================

	
	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================			
	initBackgrounds = function()
	{
		var container = 'background-image';
		var path = 'images/page/';
		var images;
		
		if ($chk($(container)))
		{
			var bg = $(container).getChildren('div')[0];
			var bg_id = bg.get('id');
			
			/* preloading */  			
			images = [ path + bg_id ];
								
			//create the asset.images
			assetBackgrounds = new Asset.images(images, {  
			
				onComplete: function() { 
					images.each(function(imgsrc) {  
						new Element('img',{ src: imgsrc, width: 1200, height: 725, style: 'width:1200px; height:725px;' }).inject($(bg)); 
					});					
					
					$(container).setStyle('opacity', 0);
					
					$(container).removeClass('bg_hide');
					new Fx.Tween($(container)).start('opacity', 0, 1).chain(function() {
						begin();
					});
				}  
				
			});					
		}
	}
	
	function showPicture(id)
	{
		new Fx.Scroll('pictures').toElement('picture_' + id);	
		imgPos = id;
	}
	
	function prevPicture()
	{
		imgPos--;
		if (imgPos < 1) imgPos = picTotal;
		new Fx.Scroll('pictures').toElement('picture_' + imgPos);	
	}	
	function nextPicture()
	{
		imgPos++;
		if (imgPos > picTotal) imgPos = 1;
		new Fx.Scroll('pictures').toElement('picture_' + imgPos);	
	}	
	
	function begin()
	{
		if (!$chk($$('.no_animation')[0]))
		{
			animateTopNav();
			//initDivs();
		}	
	}
	
	function getGalleryPrevImageID(imageID)
	{
		var idx = galleryImageIDs.indexOf('' + imageID);

		idx--;
		if (idx < 0) 
		{
			idx = galleryImageIDs.length - 1;
		}
		return galleryImageIDs[idx];		
	}
	
	function getGalleryNextImageID(imageID)
	{
		var idx = galleryImageIDs.indexOf('' + imageID);
		
		idx++;
		if (idx >= galleryImageIDs.length) 
		{
			idx = 0;
		}
		return galleryImageIDs[idx];		
	}	
	
	function showEnlargement()
	{
		if (!flagEnlargement)
		{
			$('container_enlargement').setStyle('display', 'block');
			flagEnlargement = true;
		}
	}
	
	function hideEnlargement()
	{
		if (flagEnlargement)
		{
			$('container_enlargement').setStyle('display', 'none');
			flagEnlargement = false;
		}
	}	

	function toggleEnlargement()
	{
		if (!flagEnlargement)
		{
			showEnlargement();
		}
		else
		{
			hideEnlargement();
		}
	}	
	
	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupActions()
	{
		if ($chk($$('.thumb_box')[0])) 
		{				
			$$('.thumb_box').setStyle('opacity', 0.8);
			$$('.thumb_box').addEvents({
			
				'mouseover' : function(e) {
					this.setStyles({ 'opacity' : 1, 'background-color' : '#ff0099' });
				},
			
				'mouseout' : function(e) {
					this.setStyles({ 'opacity' : 0.8, 'background-color' : 'transparent' });
				}
				
			});					
		}		
		
		if ($chk($$('.img_hover')[0])) 
		{				
			$$('.img_hover').setStyle('opacity', 0.7);
			$$('.img_hover').addEvents({
			
				'mouseover' : function(e) {
					this.setStyle('opacity', 1);
				},
			
				'mouseout' : function(e) {
					this.setStyle('opacity', 0.7);
				}
				
			});					
		}
		
		if ($chk($$('.image_protect')))
		{
			$$('.image_protect').addEvents({
			
				'contextmenu' : function(e) {
					e.stop();
				}
				
			});
		}		
		
	}	
	
	function setupCufon()
	{
		Cufon.replace('.bodoni', { fontFamily: 'Bodoni Postscript Italic' });
		Cufon.replace('.din_bold', { fontFamily: 'DIN Bold' });
		Cufon.replace('.din_regular', { fontFamily: 'DIN Regular' });
	}	
	
	function setupDraggableDivs()
	{
		if ($chk($('container_enlargement')))
		{
			var dragEnlargement = new Drag('container_enlargement');
		}
	}		
	
	function setupSplashScreen()
	{
		if ($chk($$('.home_splash')[0]))
		{
			var flashvars = {	}

			var params = {
				bgcolor : "#000000",
				allowfullscreen : "false", 
				allowscriptaccess : "always",
				wmode : "opaque"
			}

			var attributes = {
				id : "fl_intro", 
				name : "fl_intro"
			}		
			swfobject.embedSWF("common/swf/fl_intro.swf", "splash-content", "300", "300", "8", false, flashvars, params, attributes);
			var splash = new SplashScreen('splash', {'delay': splashDelay,'showOnce': false});
			/*
			$('btCloseSplash').addEvent('click',function(){
				splash.closeSplash();
			});
			*/
		}
	}
	
	animateTopNav = function()
	{
		if ($chk($('header_box')))
		{
			new Fx.Tween($('header_box'), { duration: 'long' }).start('top', -180, 0).chain(function () {
				animateMainNav();
				animateFooterNav();
			});
		}
	}

	animateMainNav = function()
	{
		if ($chk($('container_main')))
		{			
			new Fx.Tween($('container_main'), { duration: 'long' }).start('opacity', 0, 1); 
		}
	}
	
	animateFooterNav = function()
	{
		if ($chk($('container_footer')))
		{
			new Fx.Tween($('container_footer'), { duration: 'long' }).start('opacity', 0, 1); 
		}
	}	
	
	function initDivs()
	{
		if ($chk($('header_box')))
		{
			$('header_box').setStyle('top', -180); 
		}		
		
		if ($chk($('container_main')))
		{
			setupCufon();
			$('container_main').setStyle('opacity', 0); 
		}		
		
		if ($chk($('container_footer')))
		{
			$('container_footer').setStyle('opacity', 0); 
		}			
	}
	
	//================================================================================================
	// START THIS WHEN PAGE DOM READY
	//================================================================================================		
	window.addEvents({
	
		'domready' : function(e) {
			
			// if (!$chk($$('.no_animation')[0]))
			// {
				// initDivs();
			// }
			// else
			// {
				// setupCufon();
			// }
			
			if ($chk($('content_home')))
			{
				initDivs();
			}
			else
			{
				setupCufon();
			}
						
			if ($chk($('splash')))
			{
				initBackgrounds.delay(splashDelay + 1000);
			}
			else
			{
				initBackgrounds();			
			}
			
			if ($chk($('thumbs_view')))
			{
				galleryImageIDs = $$('.img_thumb').get('id');
			}
			
			// if ($chk($('tbl_pictures')))
			// {
				// picTotal = $$('.picture_box').length;
				// showPicture(1);
			// }
			
			setupActions();
			setupDraggableDivs();
			setupSplashScreen();
		},
		
		'resize' : function() {

		}
		
	});
	

//-->
