


// JavaScript Document
$(document).ready(function() {
	

	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 100, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 10, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 10, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);




$(".slidetabs").tabs(".images > div", {
 
	// enable "cross-fading" effect
	effect: 'fade',
	fadeOutSpeed: "slow",
 
	// start from the beginning after the last tab
	rotate: true
 
// use the slideshow plugin. It accepts its own configuration
}).slideshow();
$(".slidetabs").data("slideshow").play();

});











  $(document).ready(function() {
        $('.viewport').mouseenter(function(e) {
            $(this).children('a').children('img').animate({ height: 'auto', left: '0', top: '0', width: 'auto'}, 160);
            $(this).children('a').children('span').fadeIn(200);
        }).mouseleave(function(e) {
            $(this).children('a').children('img').animate({ height: 'auto', left: '0', top: '0', width: 'auto'}, 100);
            $(this).children('a').children('span').fadeOut(200);
        });
    });





	jQuery(function($) {

		var slide = false;

		var height = $('#footer_content').height();

		$('#footer_button').click(function() {

			var docHeight = $(document).height();

			var windowHeight = $(window).height();

			var scrollPos = docHeight - windowHeight + height;

			$('#footer_content').animate({ height: "toggle"}, 1000);

			if(slide == false) {

				if($.browser.opera) {

					$('html').animate({scrollTop: scrollPos+'px'}, 1000);

				} else {

					$('html, body').animate({scrollTop: scrollPos+'px'}, 1000);

				}

				slide = true;

			} else {

				slide = false;

			}

		});

	});
	
	
	$(document).ready(function () {
	
	$('#toggle-view li').click(function () {

		var text = $(this).children('p');

		if (text.is(':hidden')) {
			text.slideDown('200');
			$(this).children('span').html('-');		
		} else {
			text.slideUp('200');
			$(this).children('span').html('+');		
		}
		
	});

});



	
 



	
	
	
	
	
