		
/*--------------------------------------------------------------------------------
--------------------------------------------------------------------------------*

	document.observe('dom:loaded', function() {
		
		// Force the sub navigation of the selected page to be displayed
		var selected_li = $('nav').select('li.selected')[0];
		if (selected_li)
		{
			var ul = selected_li.down('ul');
			ul.show();
		}
		
		// Hide the sub navigation of the selected page when mousing over other elements
		// so that they don't overlap
		$('nav').childElements().each(function(li){
			if (selected_li){
				li.observe('mouseover', function(){ selected_li.removeClassName('selected'); });
				li.observe('mouseout', function(){ selected_li.addClassName('selected'); });
			}
		});
		
	});
	
	
		
/*--------------------------------------------------------------------------------
	Navigation functionality
--------------------------------------------------------------------------------*/

	document.observe('dom:loaded', function() {
	
		$('nav').observe('mouseover', function(){
			
			if (!$('overlay'))
			{
				$('nav').addClassName('js');
				
				// Overlay dimensions
				var obj = getPageSize();
				var width = obj[0];
				var height = obj[1];
				
				// Create overlay		
				var div = new Element('div', {'id': 'overlay'});
				div.hide();
				div.setStyle({
					'position': 'absolute',
					'width': width + 'px',
					'height': height + 'px',
					'zIndex': 10
				});
				div.observe('mouseover', function(){
					div.remove();
				});
				
				$$('body')[0].insert(div);
				
				Effect.Appear(div, { 
					duration: 0.3,
					to: 0.6,
					afterFinish: function(){
						$('nav').removeClassName('js');
					}
				});
			}
			
		});
	});
	
	
		
/*--------------------------------------------------------------------------------
	Email button functionality
--------------------------------------------------------------------------------*/

	document.observe('dom:loaded', function() {
	
		var btn = $('email_us_button');
		if (btn){
			btn.observe('click', function(event){
				event.stop();
				
				// Overlay dimensions
				var obj = getPageSize();
				var width = obj[0];
				var height = obj[1];
				
				// Create overlay		
				var div = new Element('div', {'id': 'overlay'});
				div.hide();
				div.setStyle({
					width: width + 'px',
					height: height + 'px',
					zIndex: 20
				});
				div.observe('click', function(){
					$('contact_us_form').hide();
					this.remove();
				});
				$('contact_us_form').observe('click', function(){
					$('contact_us_form').hide();
					div.remove();
				});
				$('contact_us_form').down().observe('click', function(event){
					event.cancelBubble = true;
					if (event.stopPropagation) event.stopPropagation();
				});
				$$('body')[0].insert(div);
				
				// Close link
				$('contact_us_form').down('a').observe('click', function(){
					$('contact_us_form').hide();
					div.remove();
				});
				Effect.Appear(div, { 
					duration: 0.3,
				//	delay: 0.1,
					to: 0.6,
					afterFinish: function(){
						$('contact_us_form').show();
					}
				});
				
				
				
			});
		}
	
	});
	
	
		
/*--------------------------------------------------------------------------------
	Carousel animation
--------------------------------------------------------------------------------*/

	document.observe('dom:loaded', function() {
	
		var div = $('carousel');
		
		if (div) {
			
			var div1 = div.down('div.left');
			div1.observe('mouseover', function(){ speed = -3; });
			div1.observe('mouseout', function(){ speed = 2; });
			
			var div2 = div.down('div.right');
			div2.observe('mouseover', function(){ speed = 3; });
			div2.observe('mouseout', function(){ speed = 2; });
			
			var table_obj = div.down('table');
			table_obj.observe('mouseover', function(){ speed = 0; });
			table_obj.observe('mouseout', function(){ speed = 2; });
			
			
			var speed = 2;
			var i = 0;
			var bob = setInterval(function(){
				
				// Move the table_obj 1 pixel to the left
				var l = parseInt(table_obj.getStyle('left'));
				if (isNaN(l)) l = 0;
				var l = l - speed;
				table_obj.setStyle({'left': l + 'px'});
				
				var left = table_obj.positionedOffset()[0];
				
				
				// Going right
				if (speed < 0) {
					
					var td = table_obj.down('tr').childElements().last();
					var width = td.getWidth();

					if (left >= 0){
						table_obj.down('tr').insert({top: td.remove()});
						table_obj.setStyle({'left': (0 - width) + 'px'});
					}
				
				
				// Going left
				} else {
					
					var td = table_obj.down('tr').childElements().first();
					var width = td.getWidth();
					
					if (width + left <= 0){
						table_obj.down('tr').insert(td.remove());
						table_obj.setStyle({'left': 0});
					}
				}
				
				
			//	i++; if (i > 3){ clearInterval(bob); }
				
			}, 10);
		}
		
	});

	
	
		
/*--------------------------------------------------------------------------------
	Sets the content div's height to be the height of the viewport minus the 
	header and footer margins
--------------------------------------------------------------------------------*/

	document.observe('dom:loaded', function() {
	
		var height = document.viewport.getHeight();
		height = height - 284;
		$('content').setStyle({
			'height': height + 'px',
			'overflow': 'auto'
		});
		
		$$('body')[0].setStyle({'overflow': 'hidden'});
	
	});
	
	
		
/*--------------------------------------------------------------------------------
--------------------------------------------------------------------------------*/

    function getPageSize(){
	        
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		
		return [pageWidth,pageHeight,xScroll,yScroll];
	}
	
	
		
/*--------------------------------------------------------------------------------
--------------------------------------------------------------------------------*/



