/*
 * Fetches Map-loader download info from XML and generates language selector drop-down box
 */

$(document).ready(function() {
//Load the XML
	$.ajax( {
	  url: flashPath+'download_loader.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: 10000,
		error: function(){
   	},
		
		success: function(xml) {
		
			$(xml).find('item').each(function() {
        //fetch language version download info from each item except the one with id='general'
        if ($(this).attr('id') != 'general') {
  			  var langName = $(this).find('language_txt').text();
	  			var downloadURL = $(this).find('url').text();
				  $('<option value="'+downloadURL+'"></option>').html(langName).appendTo('#langselect');
        }
			});
      if(document.getElementById('langselect') != null) {
        document.getElementById('langselect').selectedIndex = 5; //default to English
      }
		}
	});
});
