﻿window.document.onclick = check;
window.document.onmousedown = mdown;
window.document.onmouseup = mup;
window.document.onmouseover = mover;
window.document.onmouseout = mout;
function check(e) {
    var target = (e && e.target) || (event && event.srcElement);

    if (document.getElementById("loginDialog_c") != null) {
        if (target.id != "nguest" && checkParent(target) && (document.getElementById("loginDialog_c").style.visibility == "visible")) {

            document.getElementById("nguest").setAttribute("class", "closesignin");
            document.getElementById("loginDialog_c").style.visibility = 'hidden';
            var hb = document.getElementById("nguest");
            var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/tipsy-south.gif' + ')';
            hb.style.background = URL;
            hb.style.backgroundRepeat = "no-repeat";
            hb.style.backgroundPosition = "100% 50%";
           
        }

    }

    if (target.id == "containerclose") {
        document.getElementById("reportPanel_c").style.visibility = "hidden";
        var hb = document.getElementById("help_button");
        var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/tipsy-south.gif' + ')';
        hb.style.background = URL;
        hb.style.backgroundRepeat = "no-repeat";
        hb.style.backgroundPosition = "center right";
        hb.style.fontWeight = "600";
    }
 
        
}

function checkParent(t) {
    while (t.parentNode) {
       // alert(t.id);
        if (t == document.getElementById('loginDialog_c')) {
            return false;
        }
        t = t.parentNode
    }
    return true;
}


function mdown(e) {
    
    
    var target = (e && e.target) || (event && event.srcElement);
    if (target.id == "searchbutton") {

        //document.getElementById("searchbutton").className = "sbutton";
        var sb = document.getElementById("searchbutton");
        if (iFactor.common.config.themeInfo.compassColor == "#EEC941") {
            
            sb.style.background = "url(images/search_yellow_md.jpg)";
        }
        else {
            if (iFactor.common.config.themeInfo.compassColor == "green") {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_green_md.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
            else if (iFactor.common.config.themeInfo.compassColor == "#ac1a1b") {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_red_md.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
            else if (iFactor.common.config.themeInfo.compassColor == "#235087") {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_blue_md.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL
            }
            else {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_yellow_md.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
        }
        
    }
}


function mup(e) {
    var target = (e && e.target) || (event && event.srcElement);
    if (target.id == "searchbutton") {
        var sb = document.getElementById("searchbutton");
        if (iFactor.common.config.themeInfo.compassColor == "#EEC941") {
            var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_yellow.jpg' + ')';
            document.getElementById("searchbutton").style.background = URL;
        }
        else {
            if (iFactor.common.config.themeInfo.compassColor == "green") {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_green.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
            else if (iFactor.common.config.themeInfo.compassColor == "#ac1a1b") {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_red.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
            else if (iFactor.common.config.themeInfo.compassColor == "#235087") {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_blue.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
            else {
                var URL = 'url(' + iFactor.common.config.IFactorStreetlightoutagesURL + 'images/search_yellow.jpg' + ')';
                document.getElementById("searchbutton").style.background = URL;
            }
            
        }
        
    }
}


function mover(e) {
    var target = (e && e.target) || (event && event.srcElement);
    if (target.id == "mpheader" || target.id == "help_button" || target.id == "ask_us" || target.id == "help_ask_reports"
    || target.id == "MSVE_navAction_topBackground" || target.id == "statusLn" || target.id == "nav_action_toggle" || target.id == "action_toggle") 
    {
        var bg = document.getElementById("MSVE_navAction_leftBackground");
        bg.style.opacity = 0.9;

        var bg = document.getElementById("MSVE_navAction_topBackground");
        bg.style.opacity = 0.9;

        var bg = document.getElementById("MSVE_navAction_compassBackground");
        bg.style.opacity = 0.9;

        var is_ie4up = (document.all) ? true : false;

        if (is_ie4up) {
            var bg = document.getElementById("MSVE_navAction_leftBackground");

            bg.style.filter = 'alpha(opacity=90)';
            var bg = document.getElementById("MSVE_navAction_topBackground");

            bg.style.filter = 'alpha(opacity=90)';
            var bg = document.getElementById("MSVE_navAction_compassBackground");

            bg.style.filter = 'alpha(opacity=90)';
        }

    }

    if (target.id == "searchopacity" || target.id == "address_value" || target.id=="searchbutton") {
        var op = document.getElementById("searchopacity");
        op.style.opacity = 1.0;

        var is_ie4up = (document.all) ? true : false;
        if (is_ie4up) {
            var op = document.getElementById("searchopacity");
            op.style.filter = 'alpha(opacity=100)';
            
        }
        
    }
    
}

function mout(e) {
    var target = (e && e.target) || (event && event.srcElement);
    if (target.id == "mpheader" || target.id == "help_ask_reports") {
        //alert('check');
        var bg = document.getElementById("MSVE_navAction_leftBackground");
        bg.style.opacity = 0.7;
        var bg = document.getElementById("MSVE_navAction_topBackground");
        bg.style.opacity = 0.7;
        var bg = document.getElementById("MSVE_navAction_compassBackground");
        bg.style.opacity = 0.7;

        var is_ie4up = (document.all) ? true : false;

        if (is_ie4up) {
            var bg = document.getElementById("MSVE_navAction_leftBackground");
            bg.style.filter = 'alpha(opacity=70)';
            var bg = document.getElementById("MSVE_navAction_topBackground");
            bg.style.filter = 'alpha(opacity=70)';
            var bg = document.getElementById("MSVE_navAction_compassBackground");
            bg.style.filter = 'alpha(opacity=70)';
        }
    }


    if (target.id == "searchopacity" || target.id == "address_value" || target.id == "searchbutton") {
        var op = document.getElementById("searchopacity");
        op.style.opacity = 0.4;

        var is_ie4up = (document.all) ? true : false;
        if (is_ie4up) {
            var op = document.getElementById("searchopacity");
            op.style.filter = 'alpha(opacity=40)';

        }

    }
}


