jQuery(function($){ //when DOM is ready 
 $.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 
   	//alert(destLang);
       $('body').translate( 'english', destLang, {   //translate from english to the selected language 
         not: 'select, pre, #testnav',  //by default the generated element has this className 
         fromOriginal:true,   //always translate from english (even after the page has been translated)
		 start:     function(){   $('#throbber').show()   },
         complete:  function(){ 
		 $('#throbber').hide();
		 //set the text to be smaller
		 var buttonother = document.getElementById('navigation');
		 buttonother.className = "smallernav"; 
		 //change the text image on the left
		 //coming soon.
		 },
         error:     function(){   $('#throbber').hide()   }	
       });	
	   
   } 
 $('#testnav')
      .find('a')
      .click(function(){
         var lang = $(this).attr('id');
         //translateTo( lang );         
        $.cookie('destLang', lang );  
        // set a cookie to remember the selected language 
        // see: http://plugins.jquery.com/project/Cookie 
         //return false;
		 window.location.reload();
      }) 
	
	
	//automattically set cookiet  
   var destLang = $.cookie('destLang'); //get previously translated language 
   $.cookie('destLang', destLang );
	
   if( destLang )  //if it was set then 
   		if(destLang != "English"){ 
			translateTo( destLang );
			//set styles for the navigation
			var buttonother = document.getElementById('navigation');
			buttonother.className = "smallernav";
			//alter the menu
			if(destLang == "Spanish"){			
				var homeother = document.getElementById('leftside');
				homeother.className = "homespa";
			}else{
				var homeother = document.getElementById('leftside');
				homeother.className = "homefre";
			}
			
		}else{
			var buttonother = document.getElementById('navigation');
			buttonother.className = "";
			//change the mission back
			var missionother = document.getElementById('logomission');
			missionother.className = "";
						
		}
 
 }); //end of Google Language API loaded 
 
}) //end of DOM ready