/** This is the JavaScript engine file handling some desgin function **/

/** GLOBAL VARIABLES **/
var act_map = "";
var pnl_opened = false;

/** This function gets the window size **/
function get_window_size() {
var size = Array(0, 0);
    size[0] = document.body.clientWidth;
    size[1] = document.body.clientHeight;
    
    if (size[0] == 0 || size[1] == 0) {
        size[0] = document.documentElement.clientWidth;
        size[1] = document.documentElement.clientHeight;
    }
    
    if (size[0] == 0 || size[1] == 0) {
        size[0] = window.innerWidth;
        size[1] = window.innerHeight;
    }
    
    return size;
}

/** This function gets the size of an object **/
function get_object_size(objectid) {
var object = document.getElementById(objectid);
var size = Array(0, 0);
    size[0] = object.clientWidth;
    size[1] = object.clientHeight;
    
    if (size[0] == 0 || size[1] == 0) {
        size[0] = object.clientWidth;
        size[1] = object.clientHeight;
    }
    
    if (size[0] == 0 || size[1] == 0) {
        size[0] = object.innerWidth;
        size[1] = object.innerHeight;
    }
    
    return size;
}

/** This function shows more details when mouseover a map area**/
function show_map_details(fullname, mapname, clsname, mleft, mtop, pleft, ptop, intval) {
    if (act_map !== "") {
        hide_map_details(act_map);
    }
        map_container = document.getElementById("map");
        map_image = document.getElementById("img" + mapname);
        win_size = get_window_size();
        ads_size = get_object_size("lastads");
        x_start = (win_size[0] - (win_size[0] - ads_size[0]) - 2);
        map_pnl = document.createElement("div");
        map_pnl.id = "pnl_" + mapname;
        map_pnl.style.border = "1px dotted lime";
        map_pnl.style.position = "absolute";
        map_image.style.top = 110 + mtop + "px";
        map_pnl.style.top = 110 + ptop + "px";
        map_image.style.left = x_start + mleft + "px";
        map_pnl.style.left = x_start + pleft + "px";
        map_pnl.style.backgroundColor = "blue";
        map_pnl.style.filter = "filter: alpha(opacity=80)";
		map_pnl.style.opacity = ".80";
        map_pnl.onmouseout = function() { hide_map_details(mapname) }
        map_pnl.onclick = function() { window.location = "http://" + mapname + ".europroscript.com"; }
        map_pnl.innerHTML = "<table><tr><td rowspan='2'><img src='engine/resources/static/images/flags/" + mapname +".png' border='0'/></td>" 
                          + "<td align='left'><font face='Arial' size='2' color='white'>" + fullname + "</font></td></tr>" 
                          + "<tr><td align='left'>" 
                          + "<font face='Arial' size='1' color='yellow'><b>" + intval + " " + clsname + "</b></font></td></tr></table>";
        map_image.style.visibility = "visible";                  
        map_container.appendChild(map_pnl);
        act_map = mapname;
}

/** This function hide details when mousout a map area **/
function hide_map_details(mapname) {
    map_container = document.getElementById("map");
    document.getElementById("img" + mapname).style.visibility = "hidden";
    map_container.removeChild(document.getElementById("pnl_" + mapname));
    act_map = "";
}

/** This function shows the languages panel **/
function show_langs_panel() {
    pnl_container = document.getElementById("map");
    if (pnl_opened == false) {
        langs_panel = document.createElement("div");
        langs_panel.id = "langs_panel";
        win_size = get_window_size();
        x_start = win_size[0] - 310;
        langs_panel.style.border = "none";
        langs_panel.style.position = "absolute";
        langs_panel.style.top = "70px";
        langs_panel.style.left = x_start + "px";
        langs_panel.style.width = "300px";
        langs_panel.style.filter = "filter: alpha(opacity=80)";
        langs_panel.style.opacity = ".80";
        langs_panel.innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">" 
                            + "<tr><td height=\"12px\" style=\"background-repeat: no-repeat; background-image:url('engine/resources/static/images/lngpnltop.gif')\"></tr>" 
                            + "<tr><td height=\"12px\" style=\"background-repeat: repeat-y; background-image:url('engine/resources/static/images/lngpnlmid.gif')\">" 
                            + "<table align=\"center\" width=\"98%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">" 
                            + "<tr>" 
                            + "<td align=\"center\"><a href=\"http://ad.europroscript.com\" title=\"Andorra\"><img src=\"engine/resources/static/images/flags/ad.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://al.europroscript.com\" title=\"Shqiperia\"><img src=\"engine/resources/static/images/flags/al.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://at.europroscript.com\" title=\"&Ouml;sterreich\"><img src=\"engine/resources/static/images/flags/at.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ba.europroscript.com\" title=\"Bosna i Hercegovina\"><img src=\"engine/resources/static/images/flags/ba.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://be.europroscript.com\" title=\"Belgi&euml;\"><img src=\"engine/resources/static/images/flags/be.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://bg.europroscript.com\" title=\"&#1041;&#1098;&#1083;&#1075;ap&#1080;&#1103;\"><img src=\"engine/resources/static/images/flags/bg.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://by.europroscript.com\" title=\"&#1041;e&#1083;apyc&#1100;\"><img src=\"engine/resources/static/images/flags/by.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ch.europroscript.com\" title=\"Die Schweiz\"><img src=\"engine/resources/static/images/flags/ch.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://cy.europroscript.com\" title=\"K&#973;&#960;&#961;o&#962;\"><img src=\"engine/resources/static/images/flags/cy.gif\" border=\"0\"/></a></td>" 
                            + "</tr>" 
                            + "<tr><td height=\"5px\"></td></tr>"
                            + "<tr>" 
                            + "<td align=\"center\"><a href=\"http://cz.europroscript.com\" title=\"&#268;esko\"><img src=\"engine/resources/static/images/flags/cz.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://de.europroscript.com\" title=\"Deutschland\"><img src=\"engine/resources/static/images/flags/de.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://dk.europroscript.com\" title=\"Danmark\"><img src=\"engine/resources/static/images/flags/dk.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ee.europroscript.com\" title=\"Eesti\"><img src=\"engine/resources/static/images/flags/ee.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://es.europroscript.com\" title=\"Espa&ntilde;a\"><img src=\"engine/resources/static/images/flags/es.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://fi.europroscript.com\" title=\"Suomi\"><img src=\"engine/resources/static/images/flags/fi.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://fr.europroscript.com\" title=\"France\"><img src=\"engine/resources/static/images/flags/fr.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://gr.europroscript.com\" title=\"E&#955;&#955;&#940;&#948;&#945;\"><img src=\"engine/resources/static/images/flags/gr.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://hr.europroscript.com\" title=\"Hrvatska\"><img src=\"engine/resources/static/images/flags/hr.gif\" border=\"0\"/></a></td>" 
                            + "</tr>" 
                            + "<tr><td height=\"5px\"></td></tr>"
                            + "<tr>" 
                            + "<td align=\"center\"><a href=\"http://hu.europroscript.com\" title=\"Magyarorsz&aacute;g\"><img src=\"engine/resources/static/images/flags/hu.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ie.europroscript.com\" title=\"&Eacute;ire\"><img src=\"engine/resources/static/images/flags/ie.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://is.europroscript.com\" title=\"&Iacute;sland\"><img src=\"engine/resources/static/images/flags/is.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://it.europroscript.com\" title=\"Italia\"><img src=\"engine/resources/static/images/flags/it.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://li.europroscript.com\" title=\"Liechtenstein\"><img src=\"engine/resources/static/images/flags/li.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://lt.europroscript.com\" title=\"Lietuva\"><img src=\"engine/resources/static/images/flags/lt.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://lu.europroscript.com\" title=\"L&euml;tzebuerg\"><img src=\"engine/resources/static/images/flags/lu.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://lv.europroscript.com\" title=\"Latvija\"><img src=\"engine/resources/static/images/flags/lv.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://mc.europroscript.com\" title=\"Monaco\"><img src=\"engine/resources/static/images/flags/mc.gif\" border=\"0\"/></a></td>" 
                            + "</tr>" 
                            + "<tr><td height=\"5px\"></td></tr>"
                            + "<tr>" 
                            + "<td align=\"center\"><a href=\"http://md.europroscript.com\" title=\"Moldova\"><img src=\"engine/resources/static/images/flags/md.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://me.europroscript.com\" title=\"&#1062;p&#1085;a &#1043;opa\"><img src=\"engine/resources/static/images/flags/me.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://mk.europroscript.com\" title=\"Ma&#1082;e&#1076;o&#1085;&#1080;ja\"><img src=\"engine/resources/static/images/flags/mk.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://mt.europroscript.com\" title=\"Malta\"><img src=\"engine/resources/static/images/flags/mt.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://nl.europroscript.com\" title=\"Nederland\"><img src=\"engine/resources/static/images/flags/nl.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://no.europroscript.com\" title=\"Noreg\"><img src=\"engine/resources/static/images/flags/no.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://pl.europroscript.com\" title=\"Polska\"><img src=\"engine/resources/static/images/flags/pl.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://pr.europroscript.com\" title=\"Portugal\"><img src=\"engine/resources/static/images/flags/pr.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ro.europroscript.com\" title=\"Rom&#226;nia\"><img src=\"engine/resources/static/images/flags/ro.gif\" border=\"0\"/></a></td>" 
                            + "</tr>" 
                            + "<tr><td height=\"5px\"></td></tr>"
                            + "<tr>" 
                            + "<td align=\"center\"><a href=\"http://rs.europroscript.com\" title=\"Cp&#1073;&#1080;ja\"><img src=\"engine/resources/static/images/flags/rs.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ru.europroscript.com\" title=\"Pocc&#1080;&#1103;\"><img src=\"engine/resources/static/images/flags/ru.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://se.europroscript.com\" title=\"Sverige\"><img src=\"engine/resources/static/images/flags/se.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://si.europroscript.com\" title=\"Slovenija\"><img src=\"engine/resources/static/images/flags/si.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://sk.europroscript.com\" title=\"Slovensko\"><img src=\"engine/resources/static/images/flags/sk.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://sm.europroscript.com\" title=\"San Marino\"><img src=\"engine/resources/static/images/flags/sm.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://tr.europroscript.com\" title=\"T&uuml;rkiye\"><img src=\"engine/resources/static/images/flags/tr.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://ua.europroscript.com\" title=\"&#1059;&#1082;pa&#1111;&#1085;a\"><img src=\"engine/resources/static/images/flags/ua.gif\" border=\"0\"/></a></td>" 
                            + "<td align=\"center\"><a href=\"http://uk.europroscript.com\" title=\"United Kingdom\"><img src=\"engine/resources/static/images/flags/uk.gif\" border=\"0\"/></a></td>" 
                            + "</tr>" 
                            + "</table>" 
                            + "</td></tr>"
                            + "<tr><td height=\"12px\" style=\"background-repeat: no-repeat; background-image:url('engine/resources/static/images/lngpnlbot.gif')\"></tr>" 
                            + "</table>";
        pnl_container.appendChild(langs_panel);
        pnl_opened = true;
    } else {
        pnl_container.removeChild(document.getElementById("langs_panel"));
        pnl_opened = false;
    }
}

/** This function shows a date and hour wherever you want **/
function show_complete_date(display_id) {
    var currentTime = new Date ();
    var currentHours = currentTime.getHours ();
    var currentMinutes = currentTime.getMinutes ();
    var currentSeconds = currentTime.getSeconds ();

    var currentYear = currentTime.getYear();
    if (currentYear < 1000) {
            currentYear+=1900;
    }
    var currentDay = currentTime.getDate();
    var currentMonth = currentTime.getMonth();

    var montharray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

    var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;

    document.getElementById(display_id).innerHTML = currentDay + " " + months[currentMonth] + " " + currentYear + ", " + currentTimeString;
}