var timer;
var timer2;
var timer3;
var value = 30;

function x() {}

function showList() {
    clearTimeout(timer);
    var div_country;

    div_country = document.getElementById("country_list");
    div_country.style.display = "block";
}

function hideList() {
    timer = setTimeout("doHide();", 100);
}

function doHide() {
    var div_country;

    div_country = document.getElementById("country_list");
    div_country.style.display = "none";
}

function changeBg(obj) {
    obj.style.color = "#DC1212";
    obj.style.borderColor = "#3F89C3";
    obj.style.fontWeight = "bold";
    showList();
}

function revertBg(obj) {
    obj.style.color = "#3F89C3";
    obj.style.borderColor = "#DC1212";
    obj.style.fontWeight = "normal";
    hideList();
}

function chgMarket(page, exch) {
    window.location = page + "?exch=" + exch;
}

function chgChart(id, path) {
    while (value > 0) {
        fadeout();
    }

    var chart_type;
    chart_type = path;

    setInterval("fadein()", 100);

    if (document.getElementById('minichart')) {
        document.getElementById('minichart').src = chart_type;

        for (i=1;i<7;i++) {
            if (i == id) {
                document.getElementById("chart"+i).style.backgroundColor = "#B0C1D9";
                document.getElementById("chart"+i).style.fontWeight = "bold";
                document.getElementById("chart"+i).style.color = "#000000";
            }
            else {
                document.getElementById("chart"+i).style.backgroundColor = "#FFFFFF";
                document.getElementById("chart"+i).style.fontWeight = "normal";
                document.getElementById("chart"+i).style.color = "#0000FF";
            }
        }
    }
}

function fadein()
{
    if (value<100)
        value += 2;

    if (window.sidebar) {
        if (document.getElementById("minichart")) {
            document.getElementById("minichart").style.MozOpacity = value / 100;
        }
    }
    else if (window.opera && window.getSelection) {
        if (document.getElementById("minichart")) {
            document.getElementById("minichart").style.opacity = value / 100;
        }
    }
    else if (document.all) {
        if (document.getElementById("minichart")) {
            document.getElementById("minichart").filters[0].opacity = value;
        }
    }
}

function fadeout()
{
    if (value>0)
        value -= 1;

    if (window.sidebar) {
        if (document.getElementById("minichart")) {
            document.getElementById("minichart").style.MozOpacity = value / 100;
        }
    }
    else if (window.opera && window.getSelection) {
        if (document.getElementById("minichart")) {
            document.getElementById("minichart").style.opacity = value / 100;
        }
    }
    else if (document.all) {
        if (document.getElementById("minichart")) {
            document.getElementById("minichart").filters[0].opacity = value;
        }
    }
}

// returns XMLHttp Object in an IE/Mozilla/Safari-friendly method
// with code modified from http://jibbering.com/2002/4/httprequest.html
function getXMLHttpObject() {
  var XMLobj = null;
  try {
    XMLobj = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      XMLobj = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      XMLobj = null;
    }
  }
  if (!XMLobj && typeof XMLHttpRequest != 'undefined') {
    XMLobj = new XMLHttpRequest();
  }
  return XMLobj;  
}

function showHideMenu(id) {
    if (document.getElementById("sub_mnu_" + id)) {
        var obj = document.getElementById("sub_mnu_" + id);
        if (obj.style.display == "block") {
            obj.style.display = "none";
        }
        else if (obj.style.display == "none") {
            obj.style.display = "block";
        }
    }
}

function bgRed(obj) {
    obj.style.backgroundColor = "#DD1212";
    obj.style.color = "#FFFFFF";
}

function bgWhite(obj) {
    obj.style.backgroundColor = "#FFFFFF";
    obj.style.color = "#3F89C3";
}

function openTellUs(page) {
    window.open('tellus.php?pg='+page, 'tellus', 'height=600,width=600,status=no,menubar=no,location=no,resizable=no,scrollbars=no,fullscreen=no');
}

function chkValue(obj) {
    var chk = document.getElementById("news");
    var chk_1 = document.getElementById("news_1");
    var chk_2 = document.getElementById("news_2");
    var chk_3 = document.getElementById("news_3");

    if (obj.id == chk.id) {
        if (chk.checked) {
            chk_1.checked = true;
            chk_2.checked = true;
            chk_3.checked = true;
        }
        else {
            chk_1.checked = false;
            chk_2.checked = false;
            chk_3.checked = false;
        }
    }
    else {
        if ((chk_1.checked == false) && (chk_2.checked == false) && (chk_3.checked == false)) {
            chk.checked = false;
        }
        else
            chk.checked = true;
    }
}

function showPost() {
    clearTimeout(timer2);
    var div_post;

    div_post = document.getElementById("divPost");
    div_post.style.display = "block";
}

function hidePost() {
    timer2 = setTimeout("doHide2();", 100);
}

function doHide2() {
    var div_post;

    div_post = document.getElementById("divPost");
    div_post.style.display = "none";
}

function changeBg1(obj) {
    obj.style.color = "#DC1212";
    obj.style.borderColor = "#3F89C3";
    obj.style.fontWeight = "bold";
    showPost();
}

function revertBg1(obj) {
    obj.style.color = "#3F89C3";
    obj.style.borderColor = "#DC1212";
    obj.style.fontWeight = "normal";
    hidePost();
}

function showRealTime() {
    clearTimeout(timer3);
    var obj = document.getElementById("rtDiv");
    obj.style.display = "block";
}

function hideRealTime() {
    timer3 = setTimeout("hideRT();", 1000);
}

function hideRT() {
    var obj = document.getElementById("rtDiv");
    obj.style.display = "none";
}