// GAC DROP DOWN - Initialization script
function addOption(selectbox, text, value)
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}
function update(value)
{
	$('.gac li').remove();
	if(value != "" || value != null)
	{
		$.ajax({
		type: "GET",
		url: "/common/xml/gac.xml?"+new Date().getTime(),
		dataType: "xml",
		complete: function(data) {			
			var json = $.xmlToJSON(data.responseXML);	
			var nodePos = json.countries[0].country.indexOf("name", value);
			if(nodePos != -1)
			{
				json.countries[0].country[nodePos].bank.SortByValue();
				for(var i = 0; i < json.countries[0].country[nodePos].bank.length; i++) {
					var onClick = "javascript: pageTracker._trackEvent('Links', 'GAC', '/En/"+json.countries[0].country[nodePos].name+"/"+json.countries[0].country[nodePos].bank[i].Text+"');";
					$(".fullContent ul").append('<li><a href="'+decodeURIComponent(json.countries[0].country[nodePos].bank[i].url)+'" target="_blank" onclick="'+onClick+'">'+json.countries[0].country[nodePos].bank[i].Text+'</a></li>');
				}
			}
		}
		});
	}
}
$(document).ready(function() {
	$("body select").msDropDown();
		$.ajax({
			type: "GET",
			url: "/common/xml/gac.xml?"+new Date().getTime(),
			dataType: "xml",
			complete: function(data) {
				var json = $.xmlToJSON(data.responseXML);
				json.countries[0].country.SortByAttribute("name");
				for(var i = 0; i < json.countries[0].country.length; i++) {
					addOption(document.getElementById("country"), json.countries[0].country[i].name, json.countries[0].country[i].name);
			}
			document.getElementById("country").refresh();
		}
	});
});
