/* calendar functions */

var PREFIX = "cal";
var BGCOLOR_DEFAULT = new Array(new Array("event", "#DEE7EC"), new Array("noevent", "#F7F9FA"), new Array("outOfMonth", "#FFFFFF"));
var BGCOLOR_HIGHLIGHTED = "#FFE7C4";
var MAX_ID = 0;



/**
 * Functions called from pt. Calls highlightEventRange() and showCalPopup() or clearEventRange() and hideCalPopup().
 */
function mouseOverEvent(start, end, eventID) {
    highlightEventRange(start, end);
    showCalPopup(eventID);
}
function mouseOutEvent(start, end, eventID) {
    clearEventRange(start, end);
    hideCalPopup(eventID);
}



/**
 * Functions used for highlighting the time-range of an event in the current (month, week, week2, day) calendarview.
 */
function setMax(maxID) {
    MAX_ID = maxID;
}
function highlightEventRange(start, end) {
    for(i = start; i <= end; i++) {
        if ((MAX_ID > 0) && (i > MAX_ID)) {
            i = end;
        }
        else {
            getElem("id", PREFIX + i, null).style.backgroundColor = BGCOLOR_HIGHLIGHTED;
        }
    }
}
function clearEventRange(start, end) {
    for(i = start; i <= end; i++) {
        if ((MAX_ID > 0) && (i > MAX_ID)) {
            i = end;
        }
        else {
            elem = getElem("id", PREFIX + i, null);
            elemClass = getAttr("id", PREFIX + i, null, "class");
            bgcolor = "";
            for(j = 0; j < BGCOLOR_DEFAULT.lenght; j++) {
                if (BGCOLOR_DEFAULT[j][0] == elemClass) {
                    bgcolor = BGCOLOR_DEFAULT[j][1];
                    j = BGCOLOR_DEFAULT.length;
                }
            }
            getElem("id", PREFIX + i, null).style.backgroundColor = bgcolor;
        }
    }
}

/**
 * function used to show/hide popup "window" (div-tag)
 */
function showCalPopup(tagID) {
    getElem("id", tagID, null).style.visibility = "visible";
}
function hideCalPopup(tagID) {
    getElem("id", tagID, null).style.visibility = "hidden";
}