var userLang;

if (!(document.cookie)) {
	// If the language isn't set, then set it to English as default
	userLang = "english";
} else {
	// If the language is set, then use the cookie
	// But also get rid of "lang="
	userLang = document.cookie.substring(5,document.cookie.length);
	if (userLang.indexOf(';') != -1) {
		// Make a note of where the semicolon is in the string
		var x = userLang.indexOf(';');
		// ... and chop everything from the start of the string to just before the semicolon
		userLang = userLang.substring(0,x);
	}
}

// *****************************************************************
// *              Code that prepares language tab images           *
// *****************************************************************
function chooseImage(imageName) {
	if (userLang == imageName) {
		// Make the image grey (i.e _active suffix)
		document.write('<a href="#" onClick="setUserLang\(\''+ imageName + '\'\); return false;" onMouseOver="swapImage\(\''+ imageName + '\'\);" onMouseOut="restoreImage\(\''+ imageName + '\'\);"><img name="'+ imageName + '" src="./images/'+ imageName + '_active.gif" border="0" alt="' + imageName + '" /></a>');
	} else {
		// Make the image whatever it is (i.e. no suffix)
		document.write('<a href="#" onClick="setUserLang\(\''+ imageName + '\'\); return false;" onMouseOver="swapImage\(\''+ imageName + '\'\);" onMouseOut="restoreImage\(\''+ imageName + '\'\);"><img name="'+ imageName + '" src="./images/'+ imageName + '.gif" border="0" alt="' + imageName + '" /></a>');
	}
}
// *****************************************************************
// *                       Rollover Engine                         *
// *****************************************************************

// Preload the images

preloadEnglish = new Image;
preloadBosnian = new Image;
preloadIndonesian = new Image;

preloadEnglish.src = "./images/english_on.gif";
preloadBosnian.src = "./images/bosnian_on.gif";
preloadIndonesian.src = "./images/indonesian_on.gif";

function swapImage(imageName) {
	if (userLang != imageName) {
		document[imageName].src = "./images/" + imageName + "_on" + ".gif";
	}
}
function restoreImage(imageName) {
	if (userLang != imageName) {
		document[imageName].src = "./images/" + imageName + ".gif";
	}
}

// *****************************************************************
// *                   Text for top navigation                     *
// *****************************************************************
var englishTopNav = new Array('<a href="./index.htm" id="current">Home</a>', '<a href="./about/index.htm" class="topNav">About the project</a>', '<a href="./join/index.htm" class="topNav">How to take part</a>', '<a href="./resources/index.htm" class="topNav">Resources</a>', '<a href="./contact/index.htm" class="topNav">Contact</a>');
var bosnianTopNav = new Array('<a href="./index.htm" id="current">Početak</a>', '<a href="./about/index.htm" class="topNav">O projektu</a>', '<a href="./join/index.htm" class="topNav">Kako sud-<br />jelovati</a>', '<a href="./resources/index.htm" class="topNav">Resurs</a>', '<a href="./contact/index.htm" class="topNav">Kontakt</a>');
var indonesianTopNav = new Array('<a href="./index.htm" id="current">Halaman Depan</a>', '<a href="./about/index.htm" class="topNav">Tentang Proyek</a>', '<a href="./join/index.htm" class="topNav">How to take part</a>', '<a href="./resources/index.htm" class="topNav">Sumber Informasi</a>', '<a href="./contact/index.htm" class="topNav">Kontak</a>');

// *****************************************************************
// *                   Text for side navigation                    *
// *****************************************************************
var englishSideNav = '<p id="sCurrent"><br /><a href="./">Mission Statement</a></p>';
var bosnianSideNav = '<p id="sCurrent"><br /><a href="./">Misionarsaki stav</a></p>';
var indonesianSideNav = '<p id="sCurrent"><br /><a href="./">Indonesian navigation</a></p>';

// *****************************************************************
// *                    Text for Column 1                          *
// *****************************************************************
var englishTextColumn1 = '<h1>Mission Statement</h1>   <img src="images/everyone_has_rights.gif" width="202" height="160" alt="" border="0">  <p>Everyone has rights. Governments everywhere agree that people have rights, and governments agree to educate their people about human rights. Governments tend to work slowly, however. </p>   <p><b>Project Human Rights Education</b> helps spread the process of educating about human rights. The <b>Project</b> works directly at grassroots with Non-Governmental Organizations (NGOs). NGOs everywhere are an untapped resource for reaching people at the grassroots and helping them learn their rights.</p>    ';

var bosnianTextColumn1 = '<h1>Misionarsaki stav</h1><img src="images/everyone_has_rights_bos.gif" width="202" height="160" alt="" border="0"> <p>Svako ima prava. Vlade se svugdje slazu da ljudi imaju prava, i vlade se slazu da edukuju njihov narod o ljudskim pravima. Medjutim, Vlade nastoje da rade polako.</p>   <p><b>Projekat edukacije o Ljudskim Pravima</b> pomaze ubrzati proces edukacije o ljudskim pravima. Projekat saradjuje direktno sa novonastalim Nevladinim Organizacijama (NGO). NGO su posvuda postavile izvore kako bi stupili u vezu sa pocetnim grupama i pomogli im da uce o njihovim pravima. </p>';

var indonesianTextColumn1 = '<h1>iMission Statement</h1><p>Plug in content.</p>';

// *****************************************************************
// *                    Text for Column 2                          *
// *****************************************************************
var englishTextColumn2 = '<p>The <b>Project</b>, in collaboration with grassroots NGOs in different countries, helps disseminate human rights information to the public. People in different countries are becoming educated about their rights through this <b>Project</b>.</p>  <p>There is a one-page flyer that NGOs can download and distribute. <a href="./resources/">See the links section for more information</a>.</p>';

var bosnianTextColumn2 = '<p><b>Projekat</b>, u saradnji sa novonastalim NGO u razlicitim drzavama, pomaze izloziti informacije o ljudskim pravima javnosti. Ljudi u razlicitim zemljama postaju informisani o njihovim pravima kroz ovaj Projekat.Postoji jedna stranica kratkog pregleda sta NGO nudi i distribuira. <a href="contact/index.htm">Pogledaj dio veze za jos informacija</a>.</p>';

var indonesianTextColumn2 = '';

// *****************************************************************
// *            Text for Column 3 (thin col on right)              *
// *****************************************************************
var englishTextColumn3 = '<a href="http://www.fundforpeace.org/" class="col3">The Fund for Peace website</a><br /><br /><a href="./text_only.htm" class="col3">Text-only version (all other languages)</a><br /><br /><a href="./resources/flyer.htm" class="col3">Download the HRE flyer</a>';

function setUserLang(lang) {
	// Step 1: change the cookie, adding "lang=" before the text, and ";path=/" after it
	document.cookie = 'lang=' + lang + ';' + 'path=/;';
	// Step 2: Reload the page
	location.reload();
}

function firstColumn() {
	if (userLang == "bosnian") {
		return bosnianTextColumn1;
	} else if (userLang == "indonesian") {
		return indonesianTextColumn1;
	} else {
		return englishTextColumn1;
	}
}

function secondColumn() {
	if (userLang == "bosnian") {
		return bosnianTextColumn2;
	} else if (userLang == "indonesian") {
		return indonesianTextColumn2;
	} else {
		return englishTextColumn2;
	}
}

function sideNav() {
	if (userLang == "bosnian") {
		return bosnianSideNav;
	} else if (userLang == "indonesian") {
		return indonesianSideNav;
	} else {
		return englishSideNav;
	}
}

function writeTopNav(index) {
	if (userLang == 'bosnian') {
		return bosnianTopNav[index];
	} else if (userLang == 'indonesian') {
		return indonesianTopNav[index];
	} else {
		return englishTopNav[index];
	}
}

