jQuery(function($){ //when DOM is ready 
 
  $.translate(function(){  //when the Google Language API is loaded 

    function translateTo( destLang ){ 
  		var tlc = $.translate().toLanguageCode // create a shorthand
		if( tlc( destLang ) == "en" && tlc($.cookie("destLang")) == "en") // hide loading icon when surfing in English
		return;
		$('body').translate( 'english', destLang, {   //translate from english to the selected language 
			 not: '.notranslate',  //by default the generated element has this id  
			 fromOriginal:true   //always translate from english (even after the page has been translated) 
	   }); 
    } 

  $('#translatePage') // added to include the flag thing
      .find('span')
      .click(function(){
         var lang = $(this).attr('id');
         translateTo( lang );
         $.cookie('destLang', lang );
         return false;
			
      }) 

    var destLang = $.cookie('destLang'); //get previously translated language  
     
    if( destLang )  //if it was set then 
        translateTo( destLang ); 
 
  }); //end of Google Language API loaded 
   
}) //end of DOM ready