﻿function getCountry(src){
	
	var ctry = document.getElementById("country").value;
	var new_opt_element = document.createElement('option');
	
	if (ctry == ''){
		alert("Your must choose a country to continue");
		return;
	}
	
	if (ctry == 'benin' || ctry == 'bfaso' || ctry == 'car' || ctry == 'comoros' || ctry == 'congob' || ctry == 'cdivoire' || ctry == 'djibouti' || ctry == 'drc' || ctry == 'gabon' || ctry == 'gbissau' || ctry == 'guinea' || ctry == 'madagascar' || ctry == 'mali' || ctry == 'mauritania' || ctry == 'morocco' || ctry == 'niger' || ctry == 'senegal' || ctry == 'togo' || ctry == 'tunisia'){
		if (src == 0){
			window.location = 'fra/' + ctry + 'news.htm';
		}else if (src == 1){
			window.location = '../fra/' + ctry + 'news.htm';
		}else{
			window.location = '../../fra/' + ctry + 'news.htm';
		}
		return;
	}else if (ctry == 'botswana' || ctry == 'eritrea' || ctry == 'ethiopia' || ctry == 'gambia' || ctry == 'ghana' || ctry == 'kenya' || ctry == 'lesotho' || ctry == 'liberia' || ctry == 'libya' || ctry == 'malawi' || ctry == 'mauritius' || ctry == 'namibia' || ctry == 'nigeria' || ctry == 'rwanda' || ctry == 'seychelles' || ctry == 'sleone' || ctry == 'safrica' || ctry == 'sudan' || ctry == 'swaziland' || ctry == 'tanzania' || ctry == 'zambia' || ctry == 'zimbabwe' || ctry == 'uganda'){
		if (src == 0){
			window.location = 'eng/' + ctry + 'news.htm';
		}else if (src == 1){
			window.location = '../eng/' + ctry + 'news.htm';
		}else{
			window.location = '../../eng/' + ctry + 'news.htm';
		}
		return;
	}else if(ctry == 'cverde' || ctry == 'eguinea' || ctry == 'mozambique' || ctry == 'saotome'){
		if (src == 0){
			window.location = 'por/' + ctry + 'news.htm';
		}else if (src == 1){
			window.location = '../por/' + ctry + 'news.htm';
		}else{
			window.location = '../../por/' + ctry + 'news.htm';
		}
		return;
	}else if(ctry == 'egypt'){
		if (src == 0){
			window.location = 'ara/' + ctry + 'news.htm';
		}else if (src == 1){
			window.location = '../ara/' + ctry + 'news.htm';
		}else{
			window.location = '../../ara/' + ctry + 'news.htm';
		}
		return;
	}
	
	document.getElementById("lang_form").style.display = 'block';
	document.getElementById("country").disabled = 'disabled';
	document.getElementById("ctry_submit").disabled = 'disabled';

	new_opt_element = document.createElement('option')
	new_opt_element.text = '';
	new_opt_element.value = '';
	
	try{
		document.getElementById("language").add(new_opt_element,null); // standards compliant
	}
	catch(ex){
		document.getElementById("language").add(new_opt_element); // IE only
	}
	
	if (ctry == 'algeria'){
		new_opt_element = document.createElement('option')
		new_opt_element.text = 'العربية';
		new_opt_element.value = 'ara';
		
		try{
			document.getElementById("language").add(new_opt_element,null); // standards compliant
		}
		catch(ex){
			document.getElementById("language").add(new_opt_element); // IE only
		}
	}
	if (ctry == 'algeria' || ctry == 'angola' || ctry == 'burundi' || ctry == 'cameroon' || ctry == 'chad' || ctry == 'somalia' || ctry == 'tunisia' || ctry == 'uganda'){
		new_opt_element = document.createElement('option')
		new_opt_element.text = 'English';
		new_opt_element.value = 'eng';
		
		try{
			document.getElementById("language").add(new_opt_element,null); // standards compliant
		}
		catch(ex){
			document.getElementById("language").add(new_opt_element); // IE only
		}
	}
	if (ctry == 'algeria' || ctry == 'angola' || ctry == 'burundi' || ctry == 'cameroon' || ctry == 'chad'){
		new_opt_element = document.createElement('option')
		new_opt_element.text = 'Francais';
		new_opt_element.value = 'fra';
		
		try{
			document.getElementById("language").add(new_opt_element,null); // standards compliant
		}
		catch(ex){
			document.getElementById("language").add(new_opt_element); // IE only
		}
	}
	if (ctry == 'angola'){
		new_opt_element = document.createElement('option')
		new_opt_element.text = 'Portugais';
		new_opt_element.value = 'por';
		
		try{
			document.getElementById("language").add(new_opt_element,null); // standards compliant
		}
		catch(ex){
			document.getElementById("language").add(new_opt_element); // IE only
		}
	}
	if (ctry == 'somalia'){
		new_opt_element = document.createElement('option')
		new_opt_element.text = 'Somali';
		new_opt_element.value = 'som';
		
		try{
			document.getElementById("language").add(new_opt_element,null); // standards compliant
		}
		catch(ex){
			document.getElementById("language").add(new_opt_element); // IE only
		}
	}
}

function rechooseCtry(){
	var lang_select_element = document.getElementById("language");
	var LENGTH = lang_select_element.length;
	
	for(var i=0;i<LENGTH;i++){
		lang_select_element.remove(0);
	}
	
	document.getElementById("lang_form").style.display = 'none';
	document.getElementById("country").disabled = '';
	document.getElementById("ctry_submit").disabled = '';
	document.getElementById("country").value = '';
}

function getLanguage(src){
	var ctry = document.getElementById("country").value;
	var lang = document.getElementById("language").value;
	
	if (ctry == ''){
		alert("Your must choose a country to continue");
		return;
	}
	
	if (lang == ''){
		alert("Your must choose a language to continue");
		return;
	}

	if (src == 0){
		window.location = lang + '/' + ctry + 'news.htm';
	}else if (src == 1){
		window.location = '../' + lang + '/' + ctry + 'news.htm';
	}else{
		window.location = '../../' + lang + '/' + ctry + 'news.htm';
	}
}