<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	
	var galleryImagePos = 1;
	var maxGallery = 1;

	/*
	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 $E(tag,el){return $(el||document).getElement(tag);}
	*/

	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function showFeatured(url)
	{
		//var url = "featured_" + featuredID + ".php";

		var data = "sid=" + Math.random();

		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				$('featured_content').set('html', txt);

				if ($chk($('featured_image_container')))
				{
					makeScrollbar( $('main_image_1'), $('scroller_highlights_1'), $('home_scroller_handle_1'), true );
				}

				if ($chk($$('.featured')))
				{
					$$('.featured').addEvent('click', function(event){
						event.stop();
						showFeatured($(this).get('href'));
					});
				}
			},

			onFailure: function() {
				alert("Error connecting to server. Please refresh this page...");
			}

		}).send(data);
	}

	function showTheWork(url)
	{
		var data = "sid=" + Math.random();

		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				$('thework_content').set('html', txt);

				if ($chk($('thework_image_container')))
				{
					makeScrollbar( $('main_image_1'), $('scroller_highlights_1'), $('home_scroller_handle_1'), true );
				}

				//rollover feature for the work thumbs
				if ($chk($$('image_thumb')))
				{
					$$('.image_thumb').addEvents({
						'mouseout' : function(){
							$($(this).getElement('.on')).setStyle('display', 'none');
							$($(this).getElement('.off')).setStyle('display', 'block');
						},
						'mouseover' : function(){
							$($(this).getElement('.on')).setStyle('display', 'block');
							$($(this).getElement('.off')).setStyle('display', 'none');
						}
					});

					//reset maxGallery
					resetMaxGallery();

					//reset thumb to the actual position
					showThumbTheWork(galleryImagePos);
				}

				if ($chk($$('.portfolio')))
				{
					$$('.portfolio').addEvent('click', function(event){
						event.stop();
						showTheWork($(this).get('href'));
					});
				}
			},

			onFailure: function() {
				alert("Error connecting to server. Please refresh this page...");
			}

		}).send(data);
	}

	//================================================================================================
	// FORM FUNCTIONS
	//================================================================================================

	
	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================			
	function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
		var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y));

		if (steps > 0)
		{
			var slider = new Slider(scrollbar, handle, {	
				steps: steps,
				mode: (horizontal?'horizontal':'vertical'),
				onChange: function(step){
					// Scrolls the content element in x or y direction.
					var x = (horizontal?step:0);
					var y = (horizontal?0:step);
					content.scrollTo(x,y);
				}
			}).set(0);

			if( !(ignoreMouse) ){
				// Scroll the content element when the mousewheel is used within the
				// content or the scrollbar element.
				$$(content, scrollbar).addEvent('mousewheel', function(e){
					e = new Event(e).stop();
					var step = slider.step - e.wheel * 30;
					slider.set(step);
				});
			}

			if ($chk($$(".scrollPrev"))) 
			{
				$$(".scrollPrev").addEvent('mousedown', function(e) {
					//slider.set(slider.step - 30);
					featureIntervalPrev = scrollContentPrev.periodical(5, slider);
				});
			}

			if ($chk($$(".scrollNext"))) 
			{
				$$(".scrollNext").addEvent('mousedown', function(e) {
					//slider.set(slider.step + 30);
					featureIntervalNext = scrollContentNext.periodical(5, slider);
				});
			}

			if ($chk($$(".scrollPrev"))) 
			{
				$$(".scrollPrev").addEvent('mouseup', function(e) {
					featureIntervalPrev = $clear(featureIntervalPrev);
				});
			}

			if ($chk($$(".scrollNext"))) 
			{
				$$(".scrollNext").addEvent('mouseup', function(e) {
					featureIntervalNext = $clear(featureIntervalNext);
				});
			}

			// Stops the handle dragging process when the mouse leaves the document body.
			$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
		}
		else
		{
			var area_scroller = $(scrollbar).getParent('div');
			$(area_scroller).setStyle('display', 'none');
		}
	}

	function scrollContentNext()
	{
		this.set(this.step + 50);
	}

	function scrollContentPrev()
	{
		this.set(this.step - 50);
	}

	function toggleThumbTheWork(step, max)
	{
		if ((galleryImagePos == 1) && (galleryImagePos > 10))
		{
			galleryImagePos = max - 10;
		}

		if(step == 1)
		{
			galleryImagePos++;

			if(galleryImagePos > max)
			{
				galleryImagePos = max;
			}
		}
		else if(step == -1)
		{
			galleryImagePos--;

			if(galleryImagePos < 1)
			{
				galleryImagePos = 1;
			}
		}

		//maxGallery = max;
		showThumbTheWork(galleryImagePos);
	}

	function showThumbTheWork(imageID)
	{
		resetArrow();
		new Fx.Scroll($('thumbnail_content_1')).toElement('image' + imageID);
	}

	function resetArrow()
	{
		if (maxGallery <= 10)
		{
			if ($chk($('arrow_prev')))
				$('arrow_prev').setStyle('display', 'none');

			if ($chk($('arrow_next')))
				$('arrow_next').setStyle('display', 'none');
		}
		else
		{
			if (galleryImagePos > 1)
			{
				$('arrow_prev').setStyle('display', 'block');
			}
			else if (galleryImagePos <= 1)
			{
				$('arrow_prev').setStyle('display', 'none');
			}
	
			if (galleryImagePos <= (maxGallery-10))
			{
				$('arrow_next').setStyle('display', 'block');
			}
			else if (galleryImagePos > (maxGallery - 10))
			{
				$('arrow_next').setStyle('display', 'none');
			}
		}
	}

	function initBackgrounds()
	{
		var container = 'background';
		var path = 'images/site/';
		var images;
		
		if ($chk($(container)))
		{
			var bg = $(container).getChildren('div')[0];
			//var bg_id = bg[0].get('id');
			
			/* preloading */  			
			images = [ path + 'bg_fullscreen.jpg' ];
								
			//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, 100);
					
					$(container).removeClass('bg_hide');
					new Fx.Tween($(container)).start('opacity', 0, 1);
				}  
			});					
		}
	}

	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupActions()
	{
		BrowserDetect.init();

		if ($chk($('logo')))
		{
			$('logo').addEvents({
				'mouseout' : function() {
					$('logo_off').setStyle('display', 'block');
					$('logo_on').setStyle('display', 'none');
				},
				'mouseover' : function() {
					$('logo_off').setStyle('display', 'none');
					$('logo_on').setStyle('display', 'block');
				}
			});
		}

		if ($chk($$('.menu_image')))
		{
			$$('.menu_image').addEvents({
				'mouseout' : function() {
					$($(this).get("id") + "_on").setStyle("display", "none");
					$($(this).get("id") + "_on").setStyle("visibility", "hidden");
					$($(this).get("id") + "_off").setStyle("display", "block");
					$($(this).get("id") + "_off").setStyle("visibility", "visible");
				},
				'mouseover' : function() {
					$($(this).get("id") + "_on").setStyle("display", "block");
					$($(this).get("id") + "_on").setStyle("visibility", "visible");
					$($(this).get("id") + "_off").setStyle("display", "none");
					$($(this).get("id") + "_off").setStyle("visibility", "hidden");
				}
			});
		}

		if ($chk($('bluestripe')))
		{
			var IE6 = false;
			if (BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7)
			{
				IE6 = true;	
			}

			if (IE6)
			{
				$('bluestripe').addClass('bluestripe_ie6');
			}
			else
			{
				$('bluestripe').addClass('bluestripe_other');
			}
		}
	}

	function setupScrollbar()
	{
		//scrollbar on index page
		if ($chk($('main_image_container')))
		{
			makeScrollbar( $('main_image_1'), $('scroller_highlights_1'), $('home_scroller_handle_1'), true );
		}
	}

	function resetMaxGallery()
	{
		if ($chk($$('.image_thumb')))
		{
			var image_thumbs = $$('.image_thumb');
			maxGallery = image_thumbs.length;
		}
	}

	/*
	function setupFlashBG()
	{
		var version = deconcept.SWFObjectUtil.getPlayerVersion();
	
		if (document.getElementById && ((BrowserDetect.OS == "Windows" && version["major"] > 10) || (BrowserDetect.OS == "Mac" && version["major"] > 9)))
		{
			var so = new SWFObject("common/swf/background.swf", "fullscreen", "100%", "100%", "6", "#ffffff");
			so.addParam("scale", "noscale");
			so.addParam('salign', 'lt'); 
			so.addParam("wmode","opaque");
			so.addParam("FlashVars","bg=images/site/bg_fullscreen.png");
			so.write("flashcontent");
		}
		else
		{
			//$('flashcontent').set('html', 'Please upgrade your flash player to version 10 or higher.\nPlease download it at <a href="http://get.adobe.com/flashplayer/otherversions/" target="_blank">http://get.adobe.com/flashplayer/otherversions/</a>');

			alert("Please upgrade your flash player to version 10 or higher.\nPlease download it at http://get.adobe.com/flashplayer/otherversions/");
		}
	}
	*/

	//================================================================================================
	// 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();
			resetMaxGallery();
			//setupFlashBG();
			setupScrollbar();
			initBackgrounds();
		},
		
		'resize' : function() {

		}
		
	});
	

//-->