function popupTip(cell)
{
    //Use the tooltip text. It is necessary to format it correctly
    var content="<TABLE><TD id='PopupText'>"+ReplaceReturnCharacters(cell.title,'<br>')+"</TD></TABLE>";
    yyy=Yoffset;
    if(ns4) {skn.document.write(content);skn.document.close();skn.visibility="visible"}
    if(ns6) {document.getElementById(PopupArea).innerHTML=content;skn.display=''}
    if(ie4) {document.all(PopupArea.id).innerHTML=content;skn.display=''}
    cell.title='';
    cell.setAttribute ("OriginalClass",cell.className);
    cell.className=MouseOverClass;
}

function get_mouse(e)
{
    var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
    skn.left=x+Xoffset;
    var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
    skn.top=y+yyy;
}

function kill(cell)
{
    yyy=-1000;
    if(ns4){skn.visibility="hidden";}
    else if (ns6||ie4)
    skn.display="none"
    cell.className=cell.getAttribute("OriginalClass");
    if(ns4) cell.title = document.PopupText;
    if(ns6) cell.title = document.getElementById('PopupText').innerHTML;
    if(ie4) cell.title = PopupText.innerHTML;
}

function hideCheckBoxes()
{
    if(DHTMLSupported)
    {
        var numForms = document.forms.length;
        for (var i=0; i < numForms; i++)
        {
            var form = document.forms[i];
            var numElements = form.length;
            for (var i2=0; i2 < numElements; i2++)
            {
                var e = form.elements[i2];
                if ((e.type == 'checkbox') && (e.name.indexOf('chkUA') >= 0))
                {
                    e.style.display="none";
                }
            }
        }
    }
}

function availChange(cell,UnAvailType)
{
    if(DHTMLSupported)
    {
        var items = cell.getElementsByTagName("input");
        var checkBox;
        //Find the checkbox
        for(i=0;i<items.length;i++)
        {
            if(items[i].name.indexOf("cbCal")>=0)
            {
                checkBox = items[i];
                break;
            }
        }
        var resvID = checkBox.getAttribute("RID");
        var origAvail = checkBox.getAttribute("OrigAvail");
        if(checkBox.checked && (resvID == null || !(resvID > 0)))
        {
            //The day is unavailable and does not have an associated reservation, make it avail
            if(origAvail == null || origAvail.length == 0)
            {
                //Get the original values
                origAvail = 'true';
                checkBox.setAttribute("OrigAvail",origAvail);
            }
            checkBox.checked = false;
            checkBox.setAttribute("UAT","0");
            if(origAvail == 'true')
            {
                cell.style.textDecoration = 'none';
                cell.style.fontStyle = 'normal';
                cell.style.color = 'black';
            }
            else
            {
                //Restore the original value
                cell.style.textDecoration = '';
                cell.style.fontStyle = '';
                cell.style.color = '';
            }
        }
        else if(!checkBox.checked)
        {   
            //The day is available, make it unavail
            if(origAvail == null || origAvail.length == 0)
            {
                //Get the original values   
                origAvail = 'false';
                checkBox.setAttribute("OrigAvail",origAvail);
            }
            checkBox.checked = true;
            checkBox.setAttribute("UAT",UnAvailType);
            if(origAvail == 'false')
            {
                cell.style.textDecoration = 'line-through';
                cell.style.fontStyle = 'italic';
                cell.style.color = 'red';
            }
            else
            {
                //Restore the original value
                cell.style.textDecoration = '';
                cell.style.fontStyle = '';
                cell.style.color = '';
            }
        }
        else
        {
            //The day has an associated reservation
        }
    }
}

function monthClick(month,init)
{
    if(DHTMLSupported)
    {
        var cal = document.getElementById(month);
        var items = cal.getElementsByTagName("td");
        var setValue = cal.getAttribute('mode');
        if(setValue == null || setValue.length == 0)
            setValue = init;
        else
        {
            if(setValue == 'true')
                setValue = true;
            else if(setValue == 'false')
                setValue = false;
        }
        cal.setAttribute('mode',!setValue);
        //cal.setAttribute('mode',false);
        for (var i=0;i<items.length;i++)
        {
            var contents = items[i].getElementsByTagName("input");
            for (var i2=0;i2<contents.length;i2++)
            {
                if ((contents[i2].type == 'checkbox') && (contents[i2].name.indexOf('cbCal:'.concat(month.substr(month.length - 7))) >= 0))
                {
                    var origAvail = contents[i2].getAttribute("OrigAvail")
                    if(origAvail == null || origAvail.length == 0)
                    {
                        if(contents[i2].checked)
                            origAvail = 'true';
                        else
                            origAvail = 'false';
                        contents[i2].setAttribute("OrigAvail",origAvail);
                    }
                    contents[i2].checked = setValue;
                    if(setValue && origAvail == 'false')
                    {
                        items[i].style.textDecoration = 'line-through';
                        items[i].style.color = 'red';
                    }
                    else if(!setValue && origAvail == 'true')
                    {
                        items[i].style.textDecoration = 'none';
                        items[i].style.color = 'black';
                    }
                    else
                    {
                        items[i].style.textDecoration = '';
                        items[i].style.color = '';
                    }
                }
            }
        }
    }
}

    function DHTMLSupported()
    {
        if (document.getElementById || document.all || document.layers)
        {
            if(!document.getElementById) 
            {
                if (document.all)
                {
                    document.getElementById = function(id) 
                    {
                        return document.all[id];
                    }
                }
                else if (document.layers)
                {
                    document.getElementById = function(id) 
                    {
                        return document.layers[id];
                    }
                }
                else
                    return false;
            }
            else
                return true;
        }
        else
            return false;
    }
