var _dictionary = null;

function setupDictionaries () {
    try {
        var objects = null;
        var start = null;
        var legend = null;
        var info = null;
        var misc = null;
        var icons = null;
        var favorite = null;
        var printPage = null;
        var menu = null;
                                       
        try {
            objects = setupDictionaryForObjectSelection ();
            start = setupDictionaryForMapStart ();
            legend = setupDictionaryForLegend ();
            info = setupDictionaryForInfo ();
            misc = setupDictionaryForMisc ();
            icons = setupDictionaryForIcons ();
            favorite = setupDictionaryForFavorite ();
            printPage = setupDictionaryForPrintPage ();
            menu = setupDictionaryForMenu ();
            
        } catch (e) {}
        
        try {
            _dictionary = new Dictionary (
                {
                    "objectSelection" : objects,
                    "mapStart" : start,
                    "legend" : legend,
                    "info" : info,
                    "misc" : misc,
                    "icons" : icons,
                    "favorite" : favorite,
                    "printPage" : printPage,
                    "menu" : menu
                }
             )
        } catch (e) {}
    } catch (e) {}
}
function setupDictionaryForIcons () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("objInfo", "Information om objekt", "Information about object"));         
        dictionary.push (new DictionaryItem ("zoom", "Zooma in i kartan", "Zoom into map"));         
        dictionary.push (new DictionaryItem ("pan", "Flytta kartan", "Move map"));         
        dictionary.push (new DictionaryItem ("backToRegions", "Återgå till val av region", "Return to ‘select region’"));         
        dictionary.push (new DictionaryItem ("panUp", "Panorera upp", "Pan up"));         
        dictionary.push (new DictionaryItem ("panDown", "Panorera ner", "Pan down"));         
        dictionary.push (new DictionaryItem ("panLeft", "Panorera vänster", "Pan left"));         
        dictionary.push (new DictionaryItem ("panRight", "Panorera höger", "Pan right"));         
        dictionary.push (new DictionaryItem ("zoomIn", "Zooma in", "Zoom in"));         
        dictionary.push (new DictionaryItem ("zoomOut", "Zooma out", "Zoom out"));
        dictionary.push (new DictionaryItem ("selZoomLevel", "Vald zoomnivå", "Selected zoom level"));      
        dictionary.push (new DictionaryItem ("printPage", "Utskriftsvänlig sida", "Print-friendly page"));       
        dictionary.push (new DictionaryItem ("saveArea", "Spara valt område som favorit", "Save selected area as favorite"));         
        dictionary.push (new DictionaryItem ("help", "Hjälp om sidan", "Help"));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForMenu () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("start", "Startsida", "Home"));         
        dictionary.push (new DictionaryItem ("advMap", "Avancerad karta", "Advanced map"));         
        dictionary.push (new DictionaryItem ("search", "Sök", "Search"));         
        dictionary.push (new DictionaryItem ("simpleMap", "Enkel karta", "Simple map"));         
        dictionary.push (new DictionaryItem ("txtRep", "Textrapporter", "Text reports"));         
        dictionary.push (new DictionaryItem ("pt", "Kollektivtrafik", "Public transportation"));         
        dictionary.push (new DictionaryItem ("slippery", "Halkprognos", "Icy road forecast"));         
        dictionary.push (new DictionaryItem ("selInfo", "Välj information", "Select information"));         
        dictionary.push (new DictionaryItem ("fav", "Favoriter", "Favorites"));         
        dictionary.push (new DictionaryItem ("legend", "Teckenförklaring", "Legend"));         
        dictionary.push (new DictionaryItem ("info", "Information", "Information"));         
        dictionary.push (new DictionaryItem ("etm", "Akuta trafikmeddelanden", "Acute traffic situations"));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForPrintPage () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("mapCreated", "Kartan skapad", "Map generated"));         
        dictionary.push (new DictionaryItem ("legend", "Teckenförklaring", "Legend"));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForFavorite () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem (
            "infoText", 
            "Du har valt att spara ett inzoomat område i kartan som favorit", 
            "You have selected a zoom area of the map as a favorite "));         
        dictionary.push (new DictionaryItem ("favoriteName", "Ange ett beskrivande namn", "Provide a descriptive name"));         
        dictionary.push (new DictionaryItem ("headerLabel", "Spara favorit", "Save favorite"));         
        dictionary.push (new DictionaryItem ("btnSave", "Spara favorit", "Save favorite"));         
        dictionary.push (new DictionaryItem ("cancel", "Avbryt", "Cancel"));         

        dictionary.push (new DictionaryItem ("delFav", "Ta bort markerade favoriter", "Delete marked favorites"));         
        dictionary.push (new DictionaryItem ("noFav", "Inga favoriter finns", "There are no favorites"));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForMisc () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("retInfo", "Hämtar information", "Getting information"));         
        dictionary.push (new DictionaryItem (
            "lblSaveFav", 
            "Denna #label# har nu sparats i din favoritlista. För att se dina favoriter, klicka på länken <b>\"Visa Favoriter\"</b> i menyvalet <b>\"Sök\"</b>.", 
            "This #label# has been saved in your list of favorites. To view your favorites, click on the link <b>\"View Favorites\"</b> in the menu <b>\"Search\"</b>."
        ));         
        dictionary.push (new DictionaryItem ("back", "Tillbaka", "Go back"));         
        dictionary.push (new DictionaryItem ("saveFav", "Spara som favorit", "Save as favorite"));         
        dictionary.push (new DictionaryItem ("err", "FEL", "ERROR"));         
        dictionary.push (new DictionaryItem ("yes", "Ja", "Yes"));         
        dictionary.push (new DictionaryItem ("clickImg", "Klicka i bilden för en större bild", "Click on the image to enlarge"));         
        dictionary.push (new DictionaryItem ("clickHere", "Klicka här", "Click here"));         
        dictionary.push (new DictionaryItem ("errTry", "Fel uppstod. Försök igen.", "Error. Try again."));         
        dictionary.push (new DictionaryItem ("readMore", "Läs mer", "Read more"));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForInfo () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("source", "Källa", "Source"));         
        dictionary.push (new DictionaryItem ("desc", "Beskrivning", "Description"));         
        dictionary.push (new DictionaryItem ("tempRest", "Tillfälliga begränsningar", "Temporary limitations"));         
        dictionary.push (new DictionaryItem ("msg", "Meddelande", "Message"));         
        dictionary.push (new DictionaryItem ("loc", "Plats", "Location"));         
        dictionary.push (new DictionaryItem ("effect", "Påverkan", "Effect"));         
        dictionary.push (new DictionaryItem ("startTime", "Starttid", "Start time"));         
        dictionary.push (new DictionaryItem ("stopTime", "Stopptid", "End time"));         
        dictionary.push (new DictionaryItem ("roadNo", "Vägnr", "Road no"));         
        dictionary.push (new DictionaryItem ("rc", "Väglag", "Road conditions"));         
        dictionary.push (new DictionaryItem ("warn", "Varning", "Warning"));         
        dictionary.push (new DictionaryItem ("rcUpdated", "Väglaget uppdaterat", "Road conditions updated"));         
        dictionary.push (new DictionaryItem ("locDesc", "Lägesbeskrivning", "Description of location"));         
        dictionary.push (new DictionaryItem ("distFromLoc", "Avstånd från ort", "Distance from district"));         
        dictionary.push (new DictionaryItem ("open", "Öppet", "Open"));         
        dictionary.push (new DictionaryItem ("tourInfo", "Turistinformation", "Tourist Information"));         
        dictionary.push (new DictionaryItem ("raFurn", "Rastplatsmöbler", "Roadside rest area accommodations"));         
        dictionary.push (new DictionaryItem ("waste", "Sophantering", "Garbage collection"));         
        dictionary.push (new DictionaryItem ("lava", "Latrintömning", "Collection of night soil"));         
        dictionary.push (new DictionaryItem ("wcDis", "HandikappToalett", "Restroom for disabled persons"));         
        dictionary.push (new DictionaryItem ("wc", "Toalett", "Toilet"));         
        dictionary.push (new DictionaryItem ("servName", "Serveringsnamn", "Name of food service"));         
        dictionary.push (new DictionaryItem ("servType", "Typ av servering", "Type of food service"));         
        dictionary.push (new DictionaryItem ("servHours", "Serveringens öppettider", "Food service opening hours"));         
        dictionary.push (new DictionaryItem ("servPhone", "Serveringens telefon", "Food service telephone"));         
        dictionary.push (new DictionaryItem ("psName", "Bensinstationsnamn", "Name of gas station"));         
        dictionary.push (new DictionaryItem ("psHours", "Bensinstationens öppettider", "Gas station opening hours"));         
        dictionary.push (new DictionaryItem ("psPhone", "Bensinstationens telefon", "Gas station telephone"));         
        dictionary.push (new DictionaryItem ("psType", "Bensinstationens typ", "Type of gas station"));         
        dictionary.push (new DictionaryItem ("otherInfo", "Övrig information", "other information"));         
        dictionary.push (new DictionaryItem ("phoneType", "Typ av telefon", "Type of telephone"));         
        dictionary.push (new DictionaryItem ("store", "Butik", "Shop"));         
        dictionary.push (new DictionaryItem ("wShop", "Verkstad", "Garage"));         
        dictionary.push (new DictionaryItem ("roadW", "Vägväder", "Road weather conditions"));         
        dictionary.push (new DictionaryItem ("station", "Station", "Station"));         
        dictionary.push (new DictionaryItem ("sched", "Tidtabell", "Timetable"));         
        dictionary.push (new DictionaryItem ("cardsCoins", "Kort och mynt", "Credit cards and coins"));         
        dictionary.push (new DictionaryItem ("card", "Kort", "Card"));         
        dictionary.push (new DictionaryItem ("coin", "Mynt", "Coin"));         
        dictionary.push (new DictionaryItem ("autMan", "Automat och manuell", "Automatic and manual"));         
        dictionary.push (new DictionaryItem ("aut", "Automat", "Automatic"));         
        dictionary.push (new DictionaryItem ("man", "Manuell", "manual"));         
        dictionary.push (new DictionaryItem ("measTime", "Mätningstid ", "Measuretime"));         
        dictionary.push (new DictionaryItem ("avWind", "Medelvind ", "Averagewind"));         
        dictionary.push (new DictionaryItem ("dir", "Riktning ", "Direction"));         
        dictionary.push (new DictionaryItem ("air", "Luft", "Air"));         
        dictionary.push (new DictionaryItem ("roadSur", "Vägyta ", "Road surface"));         
        dictionary.push (new DictionaryItem ("roadWStat", "vägväderstation", "Road weather station"));         
        dictionary.push (new DictionaryItem ("ra", "rastplats", "Rest area"));         
        dictionary.push (new DictionaryItem ("cam", "kamera", "camera"));         
        dictionary.push (new DictionaryItem ("maxWind", "Maxvind", "Max wind"));         
        dictionary.push (new DictionaryItem ("wind", "Vind", "Wind"));         
        dictionary.push (new DictionaryItem ("precip", "Nederbörd", "Precipitation"));         
        dictionary.push (new DictionaryItem ("temp", "Temperatur", "Temperature"));         
        dictionary.push (new DictionaryItem ("tempAir", "Lufttemperatur", "Air temperature"));         
        dictionary.push (new DictionaryItem ("tempRoad", "Vägtemperatur", "Road temperature"));         
        dictionary.push (new DictionaryItem ("cafe", "Café", "Café"));         
        dictionary.push (new DictionaryItem ("rest", "Restaurant", "Restaurant"));         
        dictionary.push (new DictionaryItem ("fastfood", "Snabbmat", "Fastfood"));         
        dictionary.push (new DictionaryItem ("kiosk", "Kiosk", "Kiosk"));         

        dictionary.push (new DictionaryItem ("noData", "Ingen information hittades.", "No information was found."));         
        dictionary.push (new DictionaryItem ("error", "Fel uppstod", "Error"));         
        dictionary.push (new DictionaryItem ("missingInfo", "Uppgift saknas", "Data missing"));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForLegend () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("", "Zooma in ett område så får du se all information om trafikläget i just det området.", "Zoom into an area to view all information on traffic conditions in that area."));         
        dictionary.push (new DictionaryItem ("acc", "Olycka", "Accident"));         
        dictionary.push (new DictionaryItem ("ferryDist", "Färja med trafikstörning", "Ferryboat with traffic disruption"));         
        dictionary.push (new DictionaryItem ("queMsg", "Kömeddelande", "Traffic congestion"));         
        dictionary.push (new DictionaryItem ("roadClosed", "Avstängd väg", "Road closed"));         
        dictionary.push (new DictionaryItem ("bridgeOpen", "Broöppning", "Opening of bridge"));         
        dictionary.push (new DictionaryItem ("tm", "Trafikmeddelande", "Traffic information"));         
        dictionary.push (new DictionaryItem ("planRoadClosed", "Planerad avstängd väg", "Planned road close"));         
        dictionary.push (new DictionaryItem ("planTM", "Planerad trafikmeddelande", "Planned traffic information"));         
        dictionary.push (new DictionaryItem ("actRW", "Aktivt vägarbete", "Roadwork in progress"));         
        dictionary.push (new DictionaryItem ("rwRoadClosed", "Vägarbete, väg avstängd", "Road construction, road closed"));         
        dictionary.push (new DictionaryItem ("planRW", "Planerat vägarbete", "Planned road construction"));         
        dictionary.push (new DictionaryItem ("ra", "Rastplats", "Rest area"));         
        dictionary.push (new DictionaryItem ("scheduleOK", "Går enligt tidtabell", "On time"));         
        dictionary.push (new DictionaryItem ("ferryDist", "Färja med trafikstörning", "Ferryboat with traffic disruption"));         
        dictionary.push (new DictionaryItem ("ferryPlanDist", "Färja med planerad störning/åtgärd", "Ferryboat with planned traffic disruption"));         
        dictionary.push (new DictionaryItem ("redFD", "Nedsatt bärighet", "Low bearing capacity"));         
        dictionary.push (new DictionaryItem ("windN", "Nordlig vind", "Northerly wind"));         
        dictionary.push (new DictionaryItem ("windNE", "Nordostlig vind", "Northeasterly wind"));         
        dictionary.push (new DictionaryItem ("windNW", "Nordvästlig vind", "Northwesterly wind"));         
        dictionary.push (new DictionaryItem ("windE", "Ostlig vind", "Easterly wind"));         
        dictionary.push (new DictionaryItem ("windS", "Sydlig vind", "Southerly wind"));         
        dictionary.push (new DictionaryItem ("windSE", "Sydostlig vind", "Southeasterly wind"));         
        dictionary.push (new DictionaryItem ("windSW", "Sydvästlig vind", "Southwesterly wind"));         
        dictionary.push (new DictionaryItem ("windW", "Västlig vind", "Westerly wind"));         
        dictionary.push (new DictionaryItem ("noWind", "Ingen vind", "No wind"));         
        dictionary.push (new DictionaryItem ("noRead", "Inget mätvärde", "No measurement data"));         
        dictionary.push (new DictionaryItem ("inactiveStation", "Stationen ej i drift", "Station not in operation"));         
        dictionary.push (new DictionaryItem ("snow", "Snö", "Snow"));         
        dictionary.push (new DictionaryItem ("snowRain", "Snöblandat regn", "Sleet"));         
        dictionary.push (new DictionaryItem ("coldRain", "Underkylt regn", "Supercooled rain"));         
        dictionary.push (new DictionaryItem ("rain", "Regn", "Rain"));         
        dictionary.push (new DictionaryItem ("noPrecip", "Ingen nederbörd", "No precipitation"));         
        dictionary.push (new DictionaryItem ("none", "Ingen uppgift", "No data"));         
        dictionary.push (new DictionaryItem ("tempAirRoad", "Temperatur luft/vägyta", "Air /Road temperature"));         
        dictionary.push (new DictionaryItem ("atk", "Hastighetskamera", "Traffic enforcement camera"));         
        dictionary.push (new DictionaryItem ("rcCam", "Väglagskamera", "Road condition camera"));         
        dictionary.push (new DictionaryItem ("trCam", "Trafikkamera", "Traffic camera"));         
        dictionary.push (new DictionaryItem ("trCamService", "Trafikkamera ur drift", "Camera not functioning"));         
        
        dictionary.push (new DictionaryItem ("rcNoInfo", "Sträckan saknar information", "No information on this stretch"));         
        dictionary.push (new DictionaryItem ("rcNoProb", "Inga problem inrapporterade", "No problems reported"));         
        dictionary.push (new DictionaryItem ("rcRisk", "Risk för besvärligt väglag", "Risk for difficult road conditions"));         
        dictionary.push (new DictionaryItem ("rcDiff", "Besvärligt väglag", "Difficult road conditions"));         
        dictionary.push (new DictionaryItem ("rcSnowIce", "Snö och isvägbana", "Snow and icy road conditions"));         
        
        dictionary.push (new DictionaryItem ("info1", 
            "Zooma in ett område så får du se all information om trafikläget i just det området.", 
            "Zoom into an area to view all information on traffic conditions in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("info2", 
            "Zooma in ett område så får du se alla vägarbeten i just det området.", 
            "Zoom into an area to view all roadwork in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("info3", 
            "Zooma in ett område så får du se alla rastplatser i just det området.", 
            "Zoom into an area to view all the roadside rest areas in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("info4", 
            "Zooma in ett område så får du se alla färjor i just det området.", 
            "Zoom into an area to view all the ferryboats in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("info5", 
            "Zooma in ett område så får du se alla vägar med nedsatt bärighet i just det området.", 
            "Zoom into an area to view all roads with a low bearing capacity in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("info7", 
            "Zooma in ett område så får du se alla hastighetskameror i just det området.", 
            "Zoom into an area to view all the traffic enforcement cameras in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("infoVVIS", 
            "Zooma in ett område så får du se alla väderstationer i just det området.", 
            "Zoom into an area to view all the weather stations in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("info12", 
            "Zooma in ett område så får du se alla avstängda vägar i just det området.", 
            "Zoom into an area to view all road closures in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("infoCam", 
            "Zooma in ett område så får du se alla kameror i just det området.", 
            "Zoom into an area to view all the cameras in that particular area."
        ));         
        dictionary.push (new DictionaryItem ("infoCam2", 
            "Då utbyggnad av kameraskåp pågår, kan antalet i verkligheten vara ett annat.", 
            "Due to ongoing construction of camera cabinets, the true number of cameras may differ from the indicated figure."
        ));         
 
        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForMapStart () {
    try {
        var dictionary = new Array ();

        dictionary.push (new DictionaryItem ("header", "Välj någon av kartans tre områden", "Choose one of the three areas on the map."));         
        dictionary.push (new DictionaryItem (
            "info1", 
            "Läget på vägarna har fått ett nytt utseende och kartan har blivit större. Det finns även en zoom-funktion vid sidan av kartan.", 
            "“Road Conditions” has a new appearance and a larger map. There is also a zoom function beside the map."
        ));         
        dictionary.push (new DictionaryItem (
            "info2", 
            "Kartan är optimerad för skärmupplösningen 1024x768 och testad för följande webbläsare:", 
            "The map is optimized for a screen resolution of 1024 x 768 and has been compatibility tested for use with the following web browsers:"
        ));         

        return dictionary;
    } catch (e) {return null;}
}
function setupDictionaryForObjectSelection () {
    try {
        var dictionary = new Array ();

        // Trafikinformation
        dictionary.push (new DictionaryItem ("headerTrafficInfo", "Trafikinformation", "Traffic information"));         
        dictionary.push (new DictionaryItem ("trafCond", "Trafikläget", "Traffic conditions"));         
        dictionary.push (new DictionaryItem ("rw", "Vägarbete", "Road construction work"));         
        dictionary.push (new DictionaryItem ("ra", "Rastplats", "Rest area"));         
        dictionary.push (new DictionaryItem ("ferry", "Färjor", "Ferry-boats"));         
        dictionary.push (new DictionaryItem ("fd", "Tjälskador", "Frost-damaged surface"));     
        dictionary.push (new DictionaryItem ("restriction", "Restriktioner", "Restrictions"));         
        
        // Vägväder
        dictionary.push (new DictionaryItem ("headerWeather", "Vägväder", "Road weather"));         
        dictionary.push (new DictionaryItem ("averWind", "Medelvind", "Average wind"));         
        dictionary.push (new DictionaryItem ("maxWind", "Maxvind", "Max wind"));         
        dictionary.push (new DictionaryItem ("precip", "Nederbörd", "Precipitation"));         
        dictionary.push (new DictionaryItem ("temp", "Temperatur", "Temperature"));         

        // Kameror
        dictionary.push (new DictionaryItem ("headerCameras", "Kameror", "Cameras"));         
        dictionary.push (new DictionaryItem ("atk", "Hastighets-<br />kamera", "Traffic enforce-<br />ment camera"));         
        dictionary.push (new DictionaryItem ("rcCam", "Väglagskamera", "Road condition camera"));         
        dictionary.push (new DictionaryItem ("trCam", "Trafikkamera", "Traffic camera"));         
        
        return dictionary;
    } catch (e) {return null;}
}

// Common functions
function getLanguageString (languageStringId, altTxt) {
    try {
        var txt = "";
        
        try {
            txt = _dictionary.findString (languageStringId);
        } catch (e) {txt="";}
        
        if (txt=="")       
            return altTxt
        else
            return txt;	            
    } catch (e) {return altTxt;}
}
function replaceElementText (id, value) {
     try {
            if (value==null) return;
            if (value=="") return;
            
            $(id).innerHTML = value;
     } catch (e) {}
}
function replaceImageAltText (id, value) {
     try {
            if (value==null) return;
            if (value=="") return;
            
            $(id).alt = value;
     } catch (e) {}
}
function replaceButtonText (id, value) {
     try {
            if (value==null) return;
            if (value=="") return;
            
            $(id).value = value;
     } catch (e) {}
}
function replaceImageAltTextExt (title, value) {
     try {
            if (value==null) return;
            if (value=="") return;
            
            var imgs = document.getElementsByTagName ("img");
            
            for (var i=0; i<imgs.length; i++) {
                if (imgs[i].title.toLowerCase () == title.toLowerCase ()) {
                    imgs[i].alt = value;
                    imgs[i].title = value;
                    return;
                }
            }
            $(id).alt = value;
     } catch (e) {}
}