sl_locales = {};
sl_locales["global"]="/";
sl_locales["de_de"]="/de_de/";

function processLocales() {
	var arrLocales = [], i, anItem, strCountry, strLanguage, sortCol, sortOrder, lengthLocales;
	_page.locales = sl_locales;
	// Build array
	if(_page.locales["others"]) delete _page.locales["others"];			// Delete current others var if exists, as it will be appended to the bottom
	i = 1;
	for(anItem in _page.locales){
		if(anItem != "global") {
			strCountry = _page.countries[anItem.substring(0,2)];
			strLanguage = _page.languages[anItem.substring(3,5)];
			arrLocales[i] = [];
			arrLocales[i][0] = anItem;									// Store locale code
			arrLocales[i][1] = strCountry;								// Store country
			arrLocales[i][2] = strLanguage; 							// Store language
			arrLocales[i][3] = _page.locales[anItem]; 					// Store link
			arrLocales[i][4] = strCountry+" / "+strLanguage; 			// Store combi country/language
			i++;
		}
	}
	if(i > 1) {
		arrLocales[0] = []; 	// Create first container for locale global.
		arrLocales[0][4] = "/"	// Enter empty value, inorder to make sure the element is on top of the list
		// Sort array
		function sortArray(a,b) {
			if (a[sortCol]<b[sortCol]) return (sortOrder=="asc"?-1:1);
			if (a[sortCol]>b[sortCol]) return (sortOrder=="asc"?1:-1);
			return 0;
		}
		sortCol=4;
		sortOrder="asc";
		arrLocales.sort(sortArray);
		// Insert global locale as first element
		arrLocales[0][0] = "global";
		arrLocales[0][1] = "Global";
		arrLocales[0][2] = "English";
		arrLocales[0][3] = _page.locales["global"];
		arrLocales[0][4] =  arrLocales[0][1]+" / "+arrLocales[0][2];
	}	
	return arrLocales;
}

