﻿/*
 * Array "continent" enthÃ¤lt alle Kontinente
 * Jedem Kontinent ist ein weiteres Array mit den zugehÃ¶rigen LÃ¤ndernamen zugewiesen
 */
var continent = new Array();
continent["Africa"] = new Array(
    'South Africa');
continent["Asia"] = new Array(
    'China');
continent["Australia"] = new Array(
    'Australia');
continent["Europe"] = new Array(
    'Austria',
    'Belgium',
    'France',
    'Germany',
    'Italy',
    'Netherlands',
    'Poland',
    'Russia',
    'Spain',
    'Sweden',
    'Switzerland',
    'Turkey',
    'United Kingdom');
continent["North America"] = new Array(
    'Canada',
    'United States of America');
continent["Latin America"] = new Array(
    'Brazil',
    'Mexico');
/*
 * Das Array "pageNavigation" enthÃ¤lt alle Seitenlinks auf die verwiesen
 * wird. Als Key wird der in in "continent" abgelegte LÃ¤ndername verwendet.
 */
var pageNavigation = new Array();
pageNavigation["Australia"] = 'http://www.pferd.com/au-en/';
pageNavigation["Austria"] = 'http://www.pferd.com/at-de/';
pageNavigation["Belgium"] = 'http://www.pferd.com/be-nl/';
pageNavigation["Brazil"] = 'http://www.pferd.com/br-pt/';
pageNavigation["Canada"] = 'http://www.pferdusa.com/';
pageNavigation["China"] = 'http://www.pferd.com/cn-cn/';
pageNavigation["France"] = 'http://www.pferd.com/fr-fr/';
pageNavigation["Germany"] = 'http://www.pferd.com/de-de/';
pageNavigation["Italy"] = 'http://www.pferd.com/it-it/';
pageNavigation["Mexico"] = 'http://www.pferd-fandeli.com.mx/';
pageNavigation["Netherlands"] = 'http://www.pferd.com/nl-nl/';
pageNavigation["Latinoamerica"] = 'http://www.pferd.com/la-es/';
pageNavigation["Poland"] = 'http://www.pferd.com/pl-pl/';
pageNavigation["Russia"] = 'http://www.pferd.com/ru-ru/';
pageNavigation["Spain"] = 'http://www.pferd.com/es-es/';
pageNavigation["South Africa"] = 'http://www.pferd.com/za-en/';
pageNavigation["Sweden"] = 'http://www.pferd.com/se-se/';
pageNavigation["Switzerland"] = 'http://www.pferd.com/ch-de/';
pageNavigation["Turkey"] = 'http://www.pferd.com/tr-tr/';
pageNavigation["United Kingdom"] = 'http://www.pferd.com/uk-en/';
pageNavigation["United States of America"] = 'http://www.pferdusa.com/';
/*
 * Der Link in "internationalPage" wird verwendet wenn ein Land ausgewÃ¤hlt wurde das
 * keine Linkzuordnung in "pageNavigation" hat.
 */
internationalPage = 'http://www.pferd.com/int-en/';
internationalPageLA = 'http://www.pferd.com/la-es/';
/*
 * FÃ¼llt die "Country" SelectBox mit allen LÃ¤nderoptionen des gewÃ¤hlten Kontinents
 */
function getCountry(cont){
    if(cont == 'all'){
        getAllCountries();
        return;
    }
    var selectBox = document.getElementById("country");
    selectBox.innerHTML='';
    var countryOption = document.createElement("option");
    countryOption.appendChild(document.createTextNode("Country"));
    selectBox.appendChild(countryOption);
    for ( var i in continent[cont]){
        var option = document.createElement("option");
        option.appendChild(document.createTextNode(continent[cont][i]));
        option.value= pageNavigation[continent[cont][i]] != undefined ? pageNavigation[continent[cont][i]] : internationalPage;
        selectBox.appendChild(option);
    }
    if(cont == 'North America' || cont == 'Australia'){
        return;
    }
     option = document.createElement("option");
     option.appendChild(document.createTextNode("Other Countries"));
     if(cont == 'Latin America'){
        option.value= internationalPageLA;
       }else{
        option.value= internationalPage;
     }    
     selectBox.appendChild(option);
}
/*
 * BefÃ¼llung der "Country-SelectBox" mit allen mÃ¶glichen LÃ¤ndern.
 */
function getAllCountries(){
    var selectBox = document.getElementById("country");
    selectBox.innerHTML='';
    var countryOption = document.createElement("option");
    countryOption.appendChild(document.createTextNode("Country"));
    selectBox.appendChild(countryOption);
    var countryList = new Array();
    for ( var x in continent){
        for ( var y in continent[x]){
            countryList.push(continent[x][y])
        }
    }
    countryList.push("Latinoamerica");
    countryList.sort();
    for(var n in countryList){
        var option = document.createElement("option");
        option.appendChild(document.createTextNode(countryList[n]));
        option.value = countryList[n] != undefined ? pageNavigation[countryList[n]] : internationalPage;
        selectBox.appendChild(option);
    }
    option = document.createElement("option");
    option.appendChild(document.createTextNode("Other Countries"));
    option.value= internationalPage;
    selectBox.appendChild(option);
}
/*
 * - Initiale befÃ¼llung der LÃ¤nderbox
 * - Continentbox sichtbar machen, da ohne js ausgeblendet
 */
window.onload = function(){
    getAllCountries();
    var selBoxCont = document.getElementById("continent");
    selBoxCont.removeAttribute("style");
}
