<?php
	/*
	The file /includes/google_translate_langs.php needs to be placed where the languages selections are available to the user (e.g. in the main menu).
	Update this file to display the required languages.
	*/
 if (GOOGLE_TRANSLATE_ENABLED)
 {
?>
<!-- Code provided by Google -->
<div id="google_translate_element">
</div>
<script>
  function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false}, 'google_translate_element');
  }
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<!-- Flag click handler -->
<script>
    $('.translation-links a').click(function()
	{
		var lang = $(this).data('lang');
		var $frame = $('.goog-te-menu-frame:first');
		if (!$frame.size()) 
		{
			alert("Error: Could not find Google translate frame.");
			return false;
		}
		var obj = $frame.contents().find('.goog-te-menu2-item span.text:contains('+lang+')').get(0);
		if (obj !== undefined) obj.click();
		return false;
    });
</script>
<?php
 }
?>