
jQuery(function($){		
		//$('body').css('height','900px');
		
		$.translate(function(){  //when the Google Language API is loaded
		//$('#loading').fadeIn(1000);
		   function translateTo(destLang){ //this can be declared in the global scope too if you need it somewhere else
		   
		   $(".jq-translate-ui").children('option:eq(13)').attr('selected','selected');
		   
		   for(var i=0; i<$(".jq-translate-ui").children('option').size(); i++)
				   {
						var setOn = $(".jq-translate-ui").children('option:eq('+i+')').text();
					
					   if(setOn == destLang)
					   {
							$(".jq-translate-ui").children('option').removeAttr('selected');
							$(".jq-translate-ui").children('option:eq('+i+')').attr('selected','selected');	
					   }
				   }
			   
		   
		       $('body').translate( 'english', destLang, {   //translate from english to the selected language
		         not: '.jq-translate-ui',  //by default the generated element has this className
		         fromOriginal:true   //always translate from english (even after the page has been translated)
				 
		       });
			   
			     }
			  // $(".jq-translate-ui").children('option:eq(13)').attr('selected','selected');
			      
		   
		   $.translate().ui('select','option')
		   	.val('English')
		     .appendTo('#ddlLang')    //insert the element to the page
			
		     .change(function(){   //when selecting another language
			$('#loading').fadeIn(10);
		       translateTo($(this).val());
		       $.cookie('destLang', $(this).val() );
		       // set a cookie to remember the selected language
			$('#loading').fadeOut(100);
		       return false; //prevent default browser action
	    	}
			
			
	    )
	    
		
		var destLang = $.cookie('destLang'); //get previously translated language
	    
 		if(destLang)  //if it was set then
		
	       translateTo(destLang);
		     $('#loading').fadeOut(100);
		   
		}); //end of Google Language API loaded
		
	});




