﻿function toggle(cell, fieldtextbox) {
    switch (cell.style.backgroundColor) {
        case 'limegreen': { fieldtextbox.value = "2"; fieldtextbox.style.backgroundColor = 'Yellow'; fieldtextbox.style.color = 'Yellow'; cell.style.backgroundColor = 'Yellow'; break; }
        case 'yellow': { fieldtextbox.value = "0"; fieldtextbox.style.backgroundColor = 'Red'; fieldtextbox.style.color = 'Red'; cell.style.backgroundColor = 'Red'; break; }
        case 'red': { fieldtextbox.value = "1"; fieldtextbox.style.backgroundColor = 'LimeGreen'; fieldtextbox.style.color = 'LimeGreen'; cell.style.backgroundColor = 'LimeGreen'; break; }
    }
}
function showhide(divId, btn) {
    var srcElement = document.getElementById(divId);
    if (srcElement != null) {
        if (srcElement.style.display == "block") {
            srcElement.style.display = 'none';
            srcElement.style.visibility = 'hidden';
            btn.innerHTML = Labels.Show;
        }
        else {
            srcElement.style.display = 'block';
            srcElement.style.visibility = 'visible';
            btn.innerHTML = Labels.Hide;
        }
    }
}

function gvonMouseOver(obj) {
    obj.style.background = 'green'; obj.style.color = 'white'; 
}
function gvonMouseOut(obj, color) {
    obj.style.background = color; obj.style.color = 'black'; 
}
Labels = {
    "Show": "Show Course Description",
    "Hide": "Hide Course Description"
};
function itemSelected(ev) {
    var index = $find("AutoCompleteEx")._selectIndex;
    var dd = $find("AutoCompleteEx").get_completionList().childNodes[index]._value;
    $find("AutoCompleteEx").get_element().value = dd.substring(0, dd.search(" "));

}
function dd() {
    var comletionList = $find("AutoCompleteEx").get_completionList();
    for (i = 0; i < comletionList.childNodes.length; i++) {

        var _value = comletionList.childNodes[i]._value;
        comletionList.childNodes[i]._value = _value.substring(_value.lastIndexOf('|') + 1); // parse id to _value

        _value = _value.substring(0, _value.lastIndexOf('|'));
        comletionList.childNodes[i].innerHTML = _value.replace('|', '<br/>');
    }

}
