﻿function DisplayYesNo(question, title, func, height, width) {

    var html = "<div class='commonYesNo'><table><tr><td>" + question + "</td></tr><br /><tr><td><input id='commonJSYes' type='button' " +
        "style='width:60px' onclick='parent.Shadowbox.close(); " + func + "(true);' value='Yes' /><input id='commonJSNo' type='button' " +
        "style='width:60px' onclick='parent.Shadowbox.close(); " + func + "(false);' value='No' /></td></tr></table></div>";

    Shadowbox.open({
        content: html,
        player: "html",
        title: title,
        height: height,
        width: width
    });
}


var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e) { cX = e.pageX; cY = e.pageY; }
function UpdateCursorPositionDocAll(e) { cX = event.clientX; cY = event.clientY; }

if (document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d) {
    if (self.pageYOffset) {
        rX = self.pageXOffset;
        rY = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop) {
        rX = document.documentElement.scrollLeft;
        rY = document.documentElement.scrollTop;
    }
    else if (document.body) {
        rX = document.body.scrollLeft;
        rY = document.body.scrollTop;
    }
    if (document.all) {
        cX += rX;
        cY += rY;
    }
    d.style.left = (cX - 10) + "px";
    d.style.top = (cY - 10) + "px";
}
function HideText(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}
function ShowText(d) {
    if (d.length < 1) { return; }
    var dd = document.getElementById(d);
    if (dd != null) {
        AssignPosition(dd);
        dd.style.display = "block";   
    }
}


function RESTGet(url, successFunction, failedFunction) {
    var rtn;
    try {
        xhr = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xhr = false;
        }
    }

    if (!xhr && typeof XMLHttpRequest != 'undefined') {
        xhr = new XMLHttpRequest();
    }

    xhr.open("GET", url);

    xhr.onreadystatechange = function() {
        if (xhr.readyState != 4) { return; }
        else {
            if (xhr.status == 200)
            { successFunction(eval('(' + xhr.responseText + ')')); }
            else { failedFunction(xhr.statusText); } 
        }
    }

    xhr.send(null);
}

function RESTGetNoReturn(url) {
    var rtn;
    try {
        xhr = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xhr = false;
        }
    }

    if (!xhr && typeof XMLHttpRequest != 'undefined') {
        xhr = new XMLHttpRequest();
    }

    xhr.open("GET", url);
    xhr.send(null);
}
