// JavaScript Document

// Glossary Hint Functionality
function FindAbsolutePosition(obj) {
    var posObj = { left: 0, top: 0 };
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    posObj.left = curleft;
    posObj.top = curtop;
    return posObj;
}

function showHideHelp(whoItIs, whichWay, quesNumb) {
    if (whichWay == "show")
        document.getElementById(whoItIs).style.display = "block";
    else
        document.getElementById(whoItIs).style.display = "none";
}

function showHideAltText(whoItIs, whichWay) {
    if (whichWay == "show") {
        hideAllAlt();
        document.getElementById(whoItIs).style.display = "block";
    }
    else
        document.getElementById(whoItIs).style.display = "none";
}
function hideAllAlt() {
    altLayers = ("homeMess,rLibMess,rMainPage,adminMess,gloss").split(",");
    for (x = 0; x < altLayers.length; x++) {
        if (document.getElementById(altLayers[x]))
            document.getElementById(altLayers[x]).style.display = "none";
    }
}

function showHint() {
    var params = showHint.arguments;
    var element = params[0];
    var term_str = params[1];

    //alert(term_str);
    var xOffset = 160;
    var yOffset = 0;
    if (params.length > 2) xOffset = params[2];
    if (params.length == 4) yOffset = params[3];

    var posObj = FindAbsolutePosition(element);
    var leftPos = posObj.left + xOffset;
    var topPos = posObj.top + yOffset;

    var textArray = new Array();

    textArray[0] = new Array();
    textArray[0][0] = "1.1";
    textArray[0][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Online courses for teachers' professional learning are available as soon as you register. To register and get a username and password, click the \"Register for Full Access\" link to the right.";

    textArray[1] = new Array();
    textArray[1][0] = "1.2";
    textArray[1][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Links to web-based essential information for teachers are available as soon as you register. To register and get a username and password, click the \"Register for Full Access\" link to the right.";

    textArray[2] = new Array();
    textArray[2][0] = "1.3";
    textArray[2][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Tools to aid your growth and in  planning and delivering lessons are available as soon as you register. To register and get a username and password, click the \"Register for Full Access\" link to the right.";

    textArray[3] = new Array();
    textArray[3][0] = "1.4";
    textArray[3][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Access to best practices and helpful hints from colleagues and mentors are available as soon as you register. To register and get a username and password, click the \"Register for Full Access\" link to the right.";

    var nDef = "";

    for (var i = 0; i < 4; i++) {
        if (textArray[i][0] == term_str) {
            nDef = textArray[i][1];
        }
    }

    var oldContainer = document.getElementById("hintContainer");

    if (!oldContainer) {

        var hintCode = "";
        hintCode += "<span id='hintContainer' style='z-index: 15; color:#000; position:absolute; left:" + leftPos + "px; top:" + topPos + "px;'>";
        hintCode += "<span style='width:291px; background:#F1F0F1; position:relative;'>";
        hintCode += "<span style='width:291px; background:#DBDADB; position:relative; left:-1px;top:-1px;'>";
        hintCode += "<span style='width:291px; background:#B8B6B8; position:relative; left:-1px;top:-1px;'>";
        hintCode += "<span style='width:270px; background:#fff; text-decoration:none; border:1px solid #00B173; border-top:5px solid #00B173; position:relative;padding:10px;padding-top:4px;'>";
        hintCode += nDef;
        hintCode += "</span></span></span></span></span>";

        var spanId = "";
        
        if (term_str.indexOf(' ') != -1) {
            for (var i = 0; i < term_str.length; i++) {
                if (term_str.charAt(i) == ' ') spanId += '_';
                else spanId += term_str.charAt(i);
            }
        }
        else spanId = term_str;

        var areaCont = document.getElementById(spanId);
        if (areaCont) areaCont.innerHTML = hintCode;
    }

}

function showHint2() {
    var params = showHint2.arguments;
    var element = params[0];
    var term_str = params[1];

    //alert(term_str);
    var xOffset = 160;
    var yOffset = 0;
    if (params.length > 2) xOffset = params[2];
    if (params.length == 4) yOffset = params[3];

    var posObj = FindAbsolutePosition(element);
    var leftPos = posObj.left + xOffset;
    var topPos = posObj.top + yOffset;

    var textArray = new Array();

    textArray[0] = new Array();
    textArray[0][0] = "1.1";
    textArray[0][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Online courses for teachers' professional learning are available as soon as you register. To register and get a username and password, click \"Home\" above, and then click the \"Register for Full Access\" link.";

    textArray[1] = new Array();
    textArray[1][0] = "1.2";
    textArray[1][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Links to web-based essential information for teachers are available as soon as you register. To register and get a username and password, click \"Home\" above, and then click the \"Register for Full Access\" link.";

    textArray[2] = new Array();
    textArray[2][0] = "1.3";
    textArray[2][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Tools to aid your growth and in  planning and delivering lessons are available as soon as you register. To register and get a username and password, click \"Home\" above, and then click the \"Register for Full Access\" link.";

    textArray[3] = new Array();
    textArray[3][0] = "1.4";
    textArray[3][1] = "&nbsp;&nbsp;&nbsp;&nbsp;Access to best practices and helpful hints from colleagues and mentors are available as soon as you register. To register and get a username and password, click \"Home\" above, and then click the \"Register for Full Access\" link.";

    var nDef = "";

    for (var i = 0; i < 4; i++) {
        if (textArray[i][0] == term_str) {
            nDef = textArray[i][1];
        }
    }

    var oldContainer = document.getElementById("hintContainer");

    if (!oldContainer) {

        var hintCode = "";
        hintCode += "<span id='hintContainer' style='z-index: 15; color:#000; position:absolute; left:" + leftPos + "px; top:" + topPos + "px;'>";
        hintCode += "<span style='width:291px; background:#F1F0F1; position:relative;'>";
        hintCode += "<span style='width:291px; background:#DBDADB; position:relative; left:-1px;top:-1px;'>";
        hintCode += "<span style='width:291px; background:#B8B6B8; position:relative; left:-1px;top:-1px;'>";
        hintCode += "<span style='width:270px; background:#fff; text-decoration:none; border:1px solid #00B173; border-top:5px solid #00B173; position:relative;padding:10px;padding-top:4px;'>";
        hintCode += nDef;
        hintCode += "</span></span></span></span></span>";

        var spanId = "";
        
        if (term_str.indexOf(' ') != -1) {
            for (var i = 0; i < term_str.length; i++) {
                if (term_str.charAt(i) == ' ') spanId += '_';
                else spanId += term_str.charAt(i);
            }
        }
        else spanId = term_str;

        var areaCont = document.getElementById(spanId);
        if (areaCont) areaCont.innerHTML = hintCode;
    }

}

function hideHint(term_str) {

    var areaCont = document.getElementById(term_str);
    areaCont.innerHTML = "";

}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

// JScript for RadWindow
var oWnd

function openMapIt(_name) {
    //alert(_name);
    GetRadWindowManager().CloseAll();

    oWnd = radopen(_name, null);
    return oWnd
}

function closeTheWindow() {
    GetRadWindowManager().CloseAll();
}

function GetRadWindow() {

    var oWindow = null;

    if (window.radWindow) oWindow = window.radWindow;

    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;

    return oWindow;

}

function select_deselectAll(checkState) {
    var frm = document.forms[0];
    // Loop through all elements
    for (i = 0; i < frm.length; i++) {
        if (frm.elements[i].type == "checkbox")
            frm.elements[i].checked = checkState;
    }
}

function OnClientShow(oWnd) {
    var iframe = oWnd.GetContentFrame();
    iframe.allowTransparency = true;
}


function closeWin() {
    GetRadWindow().BrowserWindow.closeTheWindow();
}
