function favoris() {
    if ( navigator.appName != 'Microsoft Internet Explorer' ) {
        window.sidebar.addPanel("Robo Calls - WinningCalls.com","http://www.WinningCalls.com/","");
    } else {
        window.external.AddFavorite("http://www.WinningCalls.com/","Robo Calls - WinningCalls.com");
    }
}

function closestate() {
    var id = "statemap";

    var timer = 0;
    var millisec = 300;
    var speed = Math.round(millisec / 100);

    for(i=98; i>=0; i--) {
        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
        timer++;
    }
}

function pickstate(_abbr) {
    var id = "statemap";
    var xmlhttp;
    var url = "statelaw" + _abbr.substring(0,2).toUpperCase() + ".html";

    var timer = 0;
    var millisec = 700;
    var speed = Math.round(millisec / 100);

    try {
        xmlhttp=new XMLHttpRequest();
    } catch (e) {
        try {
            xmlhttp=new ActiveXObject("Microsoft.Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert("Your browser does not support XMLHTTP.  Please upgrade your browser or download the Mozilla Firefox browser.");
                return false;
            }
        }
    }

    for(i=0; i<98; i++) {
        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
        timer++;
    }

    // GET breaks here on IE during multiple clicks on same state
    xmlhttp.open("POST", url, true);
    xmlhttp.onreadystatechange = stateChange(xmlhttp, id);
    xmlhttp.send(null);

}

function pickstate2(_abbr) {
    var id = "statemap";
    var xmlhttp;
    var url = "statelaws/" + _abbr.substring(0,2).toUpperCase() + ".html";

    var timer = 0;
    var millisec = 700;
    var speed = Math.round(millisec / 100);

    try {
        xmlhttp=new XMLHttpRequest();
    } catch (e) {
        try {
            xmlhttp=new ActiveXObject("Microsoft.Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert("Your browser does not support XMLHTTP.  Please upgrade your browser or download the Mozilla Firefox browser.");
                return false;
            }
        }
    }

    for(i=0; i<98; i++) {
        setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
        timer++;
    }

    // GET breaks here on IE during multiple clicks on same state
    xmlhttp.open("POST", url, true);
    xmlhttp.onreadystatechange = stateChange(xmlhttp, id);
    xmlhttp.send(null);

}

function stateChange(xmlhttp, id) {
    return function() {
        if (xmlhttp.readyState==4) {
            var object = document.getElementById(id);
            var closetxt = '<div id="closeout"><a href="javascript:void(closestate());">[X]</a></div>';
            if (xmlhttp.status==404)
                object.innerHTML = closetxt + '<i>This state\'s laws are pending further review.</i>';
            else
                object.innerHTML = closetxt + xmlhttp.responseText + '<p><br><p>';
            xmlhttp = '';
        }
    }
}

function changeOpac(opacity, id) {
    var obj = document.getElementById(id);
    obj.style.opacity = (opacity / 100);
    obj.style.MozOpacity = (opacity / 100);
    obj.style.KhtmlOpacity = (opacity / 100);
    obj.style.filter = "alpha(opacity=" + opacity + ")"; 
    if(opacity > 0) {
        obj.style.visibility = "visible";
    } else {
        obj.style.visibility = "hidden";
        obj.innerHTML = "";
    }
}
