//functions to be executed on page load
$(function(){
						   
	//Open all links with rel="external" in new window
	$('a[rel="external"]').click( function() {
			window.open( $(this).attr('href') );
			return false;
    });
	
	//Remove border from last list item
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
   		$('#sub_floor_2 li:last,#sub_floor_5 li:last').css('border','none');
	} else {
		$('#sub_floor_2 li:last,#sub_floor_5 li:last').css('background','none');
	}
	
	
	
	
});

//functions to be executed inline

var mylib =
{
	tabs :
	{
		init : function()
		{
			$('#tab2-content').css('display', 'none');
			$('#tab3-content').css('display', 'none');
			
			var tabsHeight = $("#tabs").height();
			$("#tabs").height(tabsHeight);
			
			// bind test anchors
			$('.tab1').click(function() {
				var myClass = $(this).attr("class");
		
				$('#tab2-content').css('display', 'none');
				$('#tab3-content').css('display', 'none');
				$('#tab1-content').fadeIn();
				// Adjust outer wrapper to fit new list snuggly
				var newHeight = $("#"+myClass+"-content").height();
				$("#tabs").animate({
					height: newHeight
				});
				return false;
			});
			
			$('.tab2').click(function() {
				var myClass = $(this).attr("class");
				
				$('#tab1-content').css('display', 'none');
				$('#tab3-content').css('display', 'none');
				$('#tab2-content').fadeIn();
				// Adjust outer wrapper to fit new list snuggly
				var newHeight = $("#"+myClass+"-content").height();
				$("#tabs").animate({
					height: newHeight
				});
				return false;
			});
			
			$('.tab3').click(function() {
				var myClass = $(this).attr("class");
				
				$('#tab1-content').css('display', 'none');
				$('#tab2-content').css('display', 'none');
				$('#tab3-content').fadeIn();
				// Adjust outer wrapper to fit new list snuggly
				var newHeight = $("#"+myClass+"-content").height();
				$("#tabs").animate({
					height: newHeight
				});
				return false;
			});
		}
	},
	slideshow :
	{
		init : function()
		{
			$('#carousel').jcarousel();
		}
	},
	gallery :
	{
		init : function()
		{
			$(".people a").fancybox();
		}
	},
	carouselLightbox :
	{
		init : function()
		{
			$(".jcarousel-skin-tango a").fancybox();
		}
	},
	vehicleLightbox :
	{
		init : function()
		{
			$("#tabs a").fancybox();
		}
	},	
	translate :
	{
		init : function()
		{
			$.translate(function(){  //when the Google Language API is loaded
		  
				function translateTo( destLang ){ //this can be declared in the global scope too if you need it somewhere else
					$('body').translate( 'english', destLang, {   //translate from english to the selected language
					  not: '#lang',  //by default the generated element has this className
					  fromOriginal:true   //always translate from english (even after the page has been translated)
					});
				}
				
				//Get all languages
				//var lang = $.translate.getLanguages( true );
				//console.log( lang );
			
				//you can generate other controls as well, not just a dropdown:
				$.translate.ui('ul').find('li').css('cursor','pointer');
			
				$('.jq-translate-ui li').click(function(){   //when selecting another language
					//alert($(this).text());
					translateTo( $(this).text() );
					$.cookie('destLang', $(this).text() );
					var langTxt = $(this).text();
					$('#lang > li span').removeClass().addClass(langTxt);
					// set a cookie to remember the selected language
					// see: http://plugins.jquery.com/project/Cookie
					location.reload();
					return false; //prevent default browser action
				})
				
				
				var destLang = $.cookie('destLang'); //get previously translated language
				
				if( destLang ) {
					//if it was set then
					translateTo( destLang );
					$('#lang > li span').removeClass().addClass(destLang);
				} else {
					$('#lang > li span').removeClass().addClass('English');
				}
		
		    }); //end of Google Language API loaded
			
			$('#lang > li').hover(  
			function () { 
				$(this).addClass('remove');
				$('ul', this).slideDown(100);  
			},   
			function () { 
				$('ul', this).slideUp(100,function(){$('#lang li').removeClass('remove');});         
			});  
		
		}
	}
}
