
var map = document.getElementById("map");
var popup = document.getElementById("popup");
var highlightedarea = "northamerica";

function init() {
    document.getElementById('container').style.display = "block";
    document.getElementById('noscript').style.display = "none";
    movenav();
}
function movenav() {
    var nav = document.getElementById("nav");
    var ref = document.getElementById("ref");
    if (ref.width > 760) {
        var left = ref.width - 290 + "px";
        nav.style.left = left;
    }
    if (ref.width > 990) {
        nav.style.left = "700px";
    } 
}

function overarea(area) {
    var area_hovered = area + "_selected";
    fade(area_hovered);
}

function outarea(area) {
    var area_hovered = area + "_selected";
    fade(area_hovered);
}

function showcountry(area) {
    resetpopup();
    resetmap();
    var selectedarea = document.getElementById(area + "_selected");
    selectedarea.style.display = "block";
    var div_area = document.getElementById('div_' + area);
    div_area.style.display = "block"

    map.src = "/sec_global/v3/images_g5/map_" + area + ".gif";
    fade('popup');
    
}

function selectcountry(country, area) {
    highlightedarea = area;
    closepopup();
    
    var location = document.getElementById("location");

    var printer = document.getElementById("printer");
    var pos = document.getElementById("pos");
    var electronic = document.getElementById("electronic");
    var factory = document.getElementById("factory");
    
    var link_printer = document.getElementById("link_printer");
    var link_pos = document.getElementById("link_pos");
    var link_electronic = document.getElementById("link_electronic");
    var link_factory = document.getElementById("link_factory");

    var h1_printer = document.getElementById("h1_printer");
    var h1_pos = document.getElementById("h1_pos");
    var h1_electronic = document.getElementById("h1_electronic");
    var h1_factory = document.getElementById("h1_factory");
    
    var cta_printer = document.getElementById("cta_printer");
    var cta_pos = document.getElementById("cta_pos");
    var cta_electronic = document.getElementById("cta_electronic");
    var cta_factory = document.getElementById("cta_factory");
    
    getdata(country);
    location.innerHTML = countryname;
    location.href = printer_link;
    
    if (link_printer.length != 0) {
        link_printer.href = printer_link;
        h1_printer.href = printer_link;
        cta_printer.href = printer_link;
        
        printer.style.display = "block";
    }
    else {
        printer.style.display = "none";
    }

    if (pos_link.length != 0) {
        link_pos.href = pos_link;
        h1_pos.href = pos_link;
        cta_pos.href = pos_link;

        pos.style.display = "block";
    }
    else {
        pos.style.display = "none";
    }

    if (electronic_link.length != 0) {
        link_electronic.href = electronic_link;
        h1_electronic.href = electronic_link;
        cta_electronic.href = electronic_link;

        electronic.style.display = "block";
    }
    else {
        electronic.style.display = "none";
    }

    if (factory_link.length != 0) {
        link_factory.href = factory_link;
        h1_factory.href = factory_link;
        cta_factory.href = factory_link;

        factory.style.display = "block";
    }
    else {
        factory.style.display = "none";
    }
}

function closepopup() {
    map.src = "/sec_global/v3/images_g5/map_" + highlightedarea + ".gif";
    fade('popup');
}

function resetpopup() {
    var northamerica = document.getElementById("div_northamerica");
    var latinamerica = document.getElementById("div_latinamerica");
    var europe = document.getElementById("div_europe");
    var asia = document.getElementById("div_asia");
    var oceania = document.getElementById("div_oceania");
    var africa_mideast = document.getElementById("div_africa_mideast");

    northamerica.style.display = "none";
    latinamerica.style.display = "none";
    europe.style.display = "none";
    asia.style.display = "none";
    oceania.style.display = "none";
    africa_mideast.style.display = "none";
}
function resetmap() {
    var northamerica = document.getElementById("northamerica_selected");
    var latinamerica = document.getElementById("latinamerica_selected");
    var europe = document.getElementById("europe_selected");
    var asia = document.getElementById("asia_selected");
    var oceania = document.getElementById("oceania_selected");
    var africa_mideast = document.getElementById("africa_mideast_selected");

    northamerica.style.display = "none";
    latinamerica.style.display = "none";
    europe.style.display = "none";
    asia.style.display = "none";
    oceania.style.display = "none";
    africa_mideast.style.display = "none";
}

//fading animation
var TimeToFade = 250.0;
function fade(eid) {
    var element = document.getElementById(eid);
    if (element == null)
        return;
    if (element.FadeState == null) {
        if (element.style.opacity == null
            || element.style.opacity == ''
            || element.style.opacity == '1') {
            element.FadeState = -2;
        }
        else {
            element.FadeState = 2;
        }
    }
    if (element.FadeState == 1 || element.FadeState == -1) {
        element.FadeState = element.FadeState == 1 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    }
    else {
        element.FadeState = element.FadeState == 2 ? -1 : 1;
        element.FadeTimeLeft = TimeToFade;
        element.style.display = element.FadeState == 2 ? 'none' : 'block';
        setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
    }
}
function animateFade(lastTick, eid) {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;
    var element = document.getElementById(eid);
    if (element.FadeTimeLeft <= elapsedTicks) {
        element.style.display = element.FadeState == 1 ? 'block' : 'none';
        element.style.opacity = element.FadeState == 1 ? '1' : '0';
        element.style.filter = 'alpha(opacity = '
        + (element.FadeState == 1 ? '100' : '0') + ')';
        element.FadeState = element.FadeState == 1 ? 2 : -2;
        return;
    }

    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft / TimeToFade;
    if (element.FadeState == 1)
        newOpVal = 1 - newOpVal;
    newOpVal = newOpVal * 1;
    element.style.opacity = newOpVal;
    element.style.filter = 'alpha(opacity = ' + (newOpVal * 100) + ')';

    setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}

/*---------- DATA -------------*/
var countryname;
var printer_link;
var pos_link;
var electronic_link;
var factory_link;

function getdata(id) {
//    countryname = "";
//    printer_link = "";
//    pos_link = "";
//    electronic_link = "";
//    factory_link = "";
    
    switch (id) {
        /*------------ North America -----------*/
        case "usa":
            countryname = "USA";
            printer_link = "http://www.epson.com/cgi-bin/Store/jsp/index.do";
            pos_link = "http://pos.epson.com/posindex";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "canada":
            countryname = "Canada";
            printer_link = "http://www.epson.ca/cgi-bin/ceStore/index.jsp"
            pos_link = "http://pos.epson.com/posindex";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "mexico":
            countryname = "Mexico";
            printer_link = "http://www.epson.com.mx";
            pos_link = "http://www.epson.com.mx";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "puertorico":
            countryname = "Puerto Rico"
            printer_link = "http://www.epson.com/cgi-bin/Store/jsp/index.do?BV_UseBVCookie=yes";
            pos_link = "http://pos.epson.com/posindex";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;
        /*-------- End of North America --------*/

        /*----------- Latin America ------------*/ 
        //note: Mexico and Puerto Rico are details in the North America section
        case "argentina":
            countryname = "Argentina";
            printer_link = "http://www.epson.com.ar";
            pos_link = "http://www.epson.com.ar";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "bolivia":
            countryname = "Bolivia";
            printer_link = "http://www.epson.com.bo";
            pos_link = "http://www.epson.com.bo";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "brazil":
            countryname = "Brazil";
            printer_link = "http://www.epson.com.br";
            pos_link = "http://www.epson.com.br";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "chile":
            countryname = "Chile";
            printer_link = "http://www.epson.cl";
            pos_link = "http://www.epson.cl";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "columbia":
            countryname = "Columbia";
            printer_link = "http://www.epson.com.co";
            pos_link = "http://www.epson.com.co";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "costarica":
            countryname = "Costa Rica";
            printer_link = "http://www.epson.co.cr";
            pos_link = "http://www.epson.co.cr";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "ecuador":
            countryname = "Ecuador";
            printer_link = "http://www.epson.com.ec";
            pos_link = "http://www.epson.com.ec";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "nigaragua":
            countryname = "Nigaragua";
            printer_link = "http://www.latin.epson.com/asp/home.asp?pais=LA";
            pos_link = "http://www.latin.epson.com/asp/home.asp?pais=LA";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "panama":
            countryname = "Panama";
            printer_link = "http://www.epson.com.pa";
            pos_link = "http://www.epson.com.pa";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "paraguay":
            countryname = "Paraguay";
            printer_link = "http://www.epson.com.py";
            pos_link = "http://www.epson.com.py";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "peru":
            countryname = "Peru";
            printer_link = "http://www.epson.com.pe";
            pos_link = "http://www.epson.com.pe";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "uruguay":
            countryname = "Uruguay";
            printer_link = "http://www.epson.com.uy";
            pos_link = "http://www.epson.com.uy";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "venezuela":
            countryname = "Venezuela";
            printer_link = "http://www.epson.com.ve";
            pos_link = "http://www.epson.com.ve";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "otherlatincountries":
            countryname = "Other Latin American Countries";
            printer_link = "http://www.latin.epson.com/asp/home.asp?pais=LA";
            pos_link = "http://www.latin.epson.com/asp/home.asp?pais=LA";
            electronic_link = "http://www.eea.epson.com/portal/page/portal/home/";
            factory_link = "http://www.robots.epson.com/";
            break;
        /*------- End of Latin America ---------*/ 
        
        /*--------------- Europe ---------------*/
        case "austria":
            countryname = "Austria";
            printer_link = "http://www.epson.at/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "belgium":
            countryname = "Belgium";
            printer_link = "http://www.epson.be/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "czechrepublic":
            countryname = "Czech Republic";
            printer_link = "http://www.epson.cz/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;
        case "denmark":
            countryname = "Denmark";
            printer_link = "http://www.epson.dk/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "finland":
            countryname = "Finland";
            printer_link = "http://www.epson.fi/";
            pos_link = "";
            electronic_link = "";
            factory_link = "";
            break;

        case "france":
            countryname = "France";
            printer_link = "http://www.epson.fr/";
            pos_link = "http://www.epson.fr/content/FR/fr_FR/solutions/EFS_solution_PDV_listing_FR.ilocal.htm";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "germany":
            countryname = "Germany";
            printer_link = "http://www.epson.de/";
            pos_link = "http://content.epson.de/rsd/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;
            
        case "ireland":
            countryname = "Ireland";
            printer_link = "http://www.epson.ie/";
            pos_link = "";
            electronic_link = "";
            factory_link = "";
            break;

        case "italy":
            countryname = "Italy";
            printer_link = "http://www.epson.it/";
            pos_link = "http://content.epson.it/prodotti/index.htm";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "netherlands":
            countryname = "Netherlands";
            printer_link = "http://www.epson.nl/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "norway":
            countryname = "Norway";
            printer_link = "http://www.epson.no/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;
            
        case "portugal":
            countryname = "Portugal";
            printer_link = "http://www.epson.pt/";
            pos_link = "http://sd.epson.pt/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "poland":
            countryname = "Poland";
            printer_link = "http://www.epson.pl/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "russia":
            countryname = "Russia";
            printer_link = "http://www.epson.ru/";
            pos_link = "http://www.epson.ru/products/trade/default.asp";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "spain":
            countryname = "Spain";
            printer_link = "http://www.epson.es/";
            pos_link = "http://sd.epson.es/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "sweden":
            countryname = "Sweden";
            printer_link = "http://www.epson.se/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "switzerland":
            countryname = "Switzerland";
            printer_link = "http://www.epson.ch/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "";
            factory_link = "";
            break;

        case "turkey":
            countryname = "Turkey";
            printer_link = "http://www.epson.com.tr/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "";
            factory_link = "";
            break;

        case "unitedkingdom":
            countryname = "United Kingdom";
            printer_link = "http://www.epson.co.uk/";
            pos_link = "http://www.pos.epson.co.uk/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;

        case "othereuropeancountries":
            countryname = "Other European Countries";
            printer_link = "http://www.epson-europe.com/";
            pos_link = "http://www.pos.epson-europe.com/";
            electronic_link = "http://www.epson-electronics.de/cgi-bin/panamafe/panama/demand/home.do";
            factory_link = "http://content.epson.de/robots/";
            break;
        /*----------- End of Europe ------------*/  
            
        /*--------------- Asia -----------------*/
        case "china":
            countryname = "China";
            printer_link = "http://www.epson.com.cn/";
            pos_link = "http://www.epson.com.cn/";
            electronic_link = "http://www.epson.com.cn/ed/index.asp";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "hongkong":
            countryname = "Hong Kong";
            printer_link = "http://www.epson.com.hk/en/home.html";
            pos_link = "http://www.epson.com.hk/en/pos/home.html";
            electronic_link = "http://www.epson.com.hk/ED/docs/";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "india":
            countryname = "India";
            printer_link = "http://www.epson.co.in/";
            pos_link = "http://www.epson.co.in/";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "indonesia":
            countryname = "Indonesia";
            printer_link = "http://www.epson.co.id/";
            pos_link = "http://www.epson.co.id/products/pos/pos_list.shtml";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "japan":
            countryname = "Japan";
            printer_link = "http://www.epson.jp/";
            pos_link = "http://www.epson.jp/";
            electronic_link = "http://www.epson.jp/device/";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "korea":
            countryname = "Korea";
            printer_link = "http://www.epson.co.kr/";
            pos_link = "http://pos.epson.co.kr/";
            electronic_link = "http://www.epson-device.co.kr/main/main.asp";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;
            
        case "malaysia":
            countryname = "Malaysia";
            printer_link = "http://www.epson.com.my/";
            pos_link = "http://www.epson.com.my/";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "philippines":
            countryname = "Philippines";
            printer_link = "http://www.epson.com.ph";
            pos_link = "http://www.epson.com.ph";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "singapore":
            countryname = "Singapore";
            printer_link = "http://www.epson.com.sg/";
            pos_link = "http://www.epson.com.sg/";
            electronic_link = "http://www.epson.com.sg/html/electronic_devices.html";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "taiwan":
            countryname = "Taiwan";
            printer_link = "http://w3.epson.com.tw/epson/index.asp";
            pos_link = "http://w3.epson.com.tw/epson/index.asp";
            electronic_link = "http://w3.epson.com.tw/electronics";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "thailand":
            countryname = "Thailand";
            printer_link = "http://www.epson.co.th/";
            pos_link = "http://www.epson.co.th/";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.jp/fa/e/index.htm";
            break;

        case "otherasiancountries":
            countryname = "Other Asian Countries";
            printer_link = "http://www.epson.co.jp/e/asia/index.htm";
            pos_link = "";
            electronic_link = "";
            factory_link = "";
            break;
        /*------------- End of Asia ------------*/

        /*--------------- Oceania --------------*/           
        case "australia":
            countryname = "Australia";
            printer_link = "http://www.epson.com.au/";
            pos_link = "http://www.epson.com.au/";
            electronic_link = "http://www.epson.com.sg/html/electronic_devices.html";
            factory_link = "http://www.robots.epson.com/";
            break;

        case "newzealand":
            countryname = "New Zealand";
            printer_link = "http://www.epson.co.nz/";
            pos_link = "http://www.epson.co.nz/";
            electronic_link = "http://www.epson.com.sg/html/electronic_devices.html";
            factory_link = "http://www.robots.epson.com/";
            break;
        /*----------- End of Oceania -----------*/

        /*--------- Africa - Mid East ----------*/   
        case "israel":
            countryname = "Israel";
            printer_link = "http://www.epson.co.il/";
            pos_link = "http://www.epson.co.uk/welcome/welcome_africa.htm";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.co.uk/welcome/welcome_africa.htm";
            break;

        case "southafrica":
            countryname = "South Africa";
            printer_link = "http://www.epson.co.za/";
            pos_link = "http://www.epson.co.za/";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://www.epson.co.za/";
            break;

        case "otherafricancountries":
            countryname = "Other African Countries";
            printer_link = "http://content.epson-europe.com/africa/";
            pos_link = "http://content.epson-europe.com/africa/";
            electronic_link = "http://www.epson.jp/device/e/index.htm";
            factory_link = "http://content.epson-europe.com/africa/";
            break;
        /*------ End of Africa - Mid East ------*/   
        
        default: break;
    }
}

