<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	
	var MAX_HEIGHT = 650;
	var MIN_HEIGHT = 440;
	var image_h, photo;
	var galleryImageIDs;
	var assetBackgrounds, assetImages;
	
	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function showEnlargementImage(id)
	{
		var div = $('content_gallery');
		var url = "get_photo.asp";
		var data = "type=gallery&imageID=" + id
		var images;
		
		data = data + "&prevID=" + getGalleryPrevImageID(id) + "&nextID=" + getGalleryNextImageID(id)
		
		var req = new Request( {url: '' + url,

			onSuccess: function(txt) {
			
				$(div).set('html', txt);

				//showEnlargement();

				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) {  
							image_h = window.getHeight() - 100;

							//if (image_h > MAX_HEIGHT) image_h = MAX_HEIGHT;
							if (image_h < MIN_HEIGHT) image_h = MIN_HEIGHT;
							$('content_gallery').hide();
							
							photo = new Element('img',{ src: imgsrc, height: image_h, style: 'width: auto; height:' + image_h + 'px;' })
							photo.addClass('resizeable');
							photo.inject($('picture_box'));
							
							if ($('picture_details').get('html') != '')
							{
								new Fx.Reveal($('picture_details')).reveal();
							}
							else
							{
								$('picture_details').setStyle('display', 'none');
							}
							
							(function() {
								$('content_gallery').show();
								$('content_gallery').position({relativeTo: 'container_gallery'});
								$$('.btn_nav').show();
							}).delay(100);
						});		
					}
					
				});
				
			},

			onFailure: function() {
				$(div).set('html', '<div class="ajax_white">Error loading... Please refresh the browser</div>');
			}

		}).send(data);
	}	
	
	//================================================================================================
	// FORM FUNCTIONS
	//================================================================================================

	
	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================			
	function initBackgrounds()
	{
		var container = 'background';
		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: $('background').getWidth(), style: 'width:auto;height:auto;' }).inject($(bg));  				
					});					
					
					$(container).setStyle('opacity', 0);
					bgFull(container, 300);
					
					$(container).removeClass('bg_hide');
					new Fx.Tween($(container)).start('opacity', 0, 1);
				}  
				
			});					
		}
	}
	
	function initHeight()
	{
		var w_h = window.getHeight();
		$('wrapper_content').setStyle('height', w_h - 100);
	}
	
	function showAboutSGP()
	{		
		if ($chk($('container_about')))
		{
			showModalBox('wrapper_black');
			showModalBox('container_about');
		}
	}
	
	function hideAboutSGP()
	{		
		if ($chk($('container_about')))
		{
			hideModalBox('wrapper_black');
			hideModalBox('container_about');
		}
	}
	
	function showServiceBox()
	{		
		if ($chk($('container_service')))
		{
			showModalBox('wrapper_black');
			showModalBox('container_service');
		}
	}
	
	function hideServiceBox()
	{		
		if ($chk($('container_service')))
		{
			hideModalBox('wrapper_black');
			hideModalBox('container_service');
		}
	}	
	
	function showGallery(id)
	{		
		if ($chk($('container_gallery')))
		{
			hideAboutSGP();
			hideServiceBox();
			
			showModalBox('wrapper_gallery');
			showModalBox('container_gallery');
			
			showEnlargementImage(id);
		}
	}
	
	function hideGallery()
	{		
		if ($chk($('container_about')))
		{
			hideModalBox('wrapper_gallery');
			hideModalBox('container_gallery');
		}
	}	
	
	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 showModalBox(id)
	{
		if ($chk($(id)))
		{
			$(id).setStyles({ 'display' : 'block' });
		}	
	}
	
	function hideModalBox(id)
	{
		if ($chk($(id)))
		{
			$(id).setStyles({ 'display' : 'none' });
		}	
	}	
	
	function resizeImages()
	{
		if ($chk($('content_category')))
		{
			image_h = window.getHeight() - 100;

			//if (image_h > MAX_HEIGHT) image_h = MAX_HEIGHT;
			if (image_h < MIN_HEIGHT) image_h = MIN_HEIGHT;
			
			$$('.resizeable').setStyle('height', image_h);
			$('content_gallery').position({relativeTo: 'container_gallery'});
		}
	}	
	
	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupActions()
	{
		if ($chk($$('.nav_box')))
		{
			$$('.nav_box').setStyle('opacity', 0.5);
			$$('.nav_selected').setStyle('opacity', 1);
			$$('.nav_box').addEvents({
			
				'mouseover' : function(e) {
				
					if (!this.hasClass('nav_selected'))
					{
						//this.fade('in');
						this.setStyle('opacity', 1);
					}
				},
			
				'mouseout' : function(e) {
				
					if (!this.hasClass('nav_selected'))
					{
						//this.fade(0.5);
						this.setStyle('opacity', 0.5);
					}
					
				}
				
			});
		}			
		
		// if ($chk($$('.photo_image')))
		// {
			// $$('.photo_image').setStyle('opacity', 0.5);
			// $$('.photo_image').addEvents({
			
				// 'mouseover' : function(e) {
					// this.setStyle('opacity', 1);
				// },
			
				// 'mouseout' : function(e) {
					// this.setStyle('opacity', 0.7);
				// }
				
			// });
		// }			
	}	
	
	function setupCufon()
	{
		Cufon.replace('.verlag_book', { fontFamily: 'Verlag Book' });
	}	
	
	//================================================================================================
	// SCALLING BACKGROUND
	//================================================================================================		
	function $E(tag,el){return $(el||document).getElement(tag)}
	
	kina={
		doc:{x:0,y:0},
		fix:
			function()
			{				
				if(kina.bg.complete&&(db.offsetWidth!=kina.doc.x||db.offsetHeight!=kina.doc.y||kina.fix.src!=kina.bg.src))
				{
					var bg=kina.bg.getSize();
					kina.doc={x:db.offsetWidth,y:db.offsetHeight};
					kina.fix.src==kina.bg.src||$extend(kina.fix,{p:bg.x/bg.y,src:kina.bg.src});
					kina.bg.setStyles({width:(bg.y=kina.doc.x>(bg.x=Math.round(kina.doc.y*kina.fix.p)))?kina.doc.x:bg.x,height:bg.y?Math.round(kina.doc.x/kina.fix.p):kina.doc.y})			
				}								
			}
	}	
	
	function bgFull(container, interval)
	{
		if ($chk($(container)))
		{
			$extend
			(
				kina,{bg:$E('img',$E('#' + container,db=$(document.body))),timer:setInterval(kina.fix,interval)}
			);			
		}		
	}		
	
	//================================================================================================
	// START THIS WHEN PAGE DOM READY
	//================================================================================================		
	window.addEvents({
	
		'domready' : function(e) {
			setupActions();
			setupCufon();
			initHeight();
			initBackgrounds();
						
			if ($chk($('content_category')))
			{
				galleryImageIDs = $$('.img_thumb').get('id');
			}
						
		},
		
		'resize' : function() {
			initHeight();
			resizeImages();
		}
		
	});
	

//-->
