﻿function loginUser()
{
    $('#LoginForm').hide();
    //alert($('#Username').val() + "\r\n" + $('#Password').val());
    
    loadContent("/Bowring/SecureArea/Authenticate.aspx?Username=" + encodeURIComponent($('#Username').val()) 
                + "&Password=" + encodeURIComponent($('#Password').val()));
    
    $('#EventCalendarContainer').hide();
    //$('#EventCalendarContainer').attr("width", "2px");
    $('#ContentBlock').attr("style", "width:" + (parseInt(GetWidth())-300) + "px;");
    
    /*
    $('#EventCalendarContainer').hide();
    //$('#EventCalendarContainer').attr("width", "2px");
    $('#ContentBlock').attr("style", "width:" + (parseInt(GetWidth())-300) + "px;");
    
    $('#ContentBlock').load("/Bowring/SecureArea/Authenticate.aspx?Username=" + encodeURIComponent($('#Username').val()) 
                + "&Password=" + encodeURIComponent($('#Password').val()));
                */
}

function logoutUser()
{
    $('#EventCalendarContainer').show();
    var curDate = new Date();
    getCalendar(curDate.getMonth(), curDate.getFullYear());
    //$('#EventCalendarContainer').attr("width", "2px");
    $('#ContentBlock').attr("style", "width:" + (parseInt(GetWidth())-525) + "px;");
    
    $('#LoginForm').show();
    $('#Password').val('');
    loadContent("/Bowring/SecureArea/Authenticate.aspx?Logout=Y");
    loadContent('/Bowring/Content/HomePage.htm');
}

function showHideSummary(obj)
{
    if(document.getElementById('SummaryLink').innerText == "View Previous Months Summary")
        document.getElementById('SummaryLink').innerText = "Hide Previous Months Summary";
    else
        document.getElementById('SummaryLink').innerText = "View Previous Months Summary";
    $("#Summary").toggle("slow");
}

function changePassword()
{
    $('#Content').html("<table width=500px><tr>" +
                    "<th align='left' class='gridheader'>Current Password</th> <th><input type=password id=oldPassword /></th> </tr>" +
                    "<tr><th align='left' class='gridheader'>New Password</th> <th><input type=password id=newPassword /></th> </tr>" +
                    "<tr><th align='left' class='gridheader'>Re-enter Password</th> <th><input type=password id=newPassword1 /></th> </tr>" +
                    "<tr><th colspan=2><input type=Button value='Change Password' onclick=updatePassword() /></th> </tr></table>");
}

function updatePassword()
{
    if($('#newPassword').val() == $('#newPassword1').val())
    {
        //alert("/Bowring/SecureArea/UpdatePassword.aspx?OldPassword=" + encodeURIComponent($('#oldPassword').val()) + "&NewPassword=" + encodeURIComponent($('#newPassword1').val()));
        loadContent("/Bowring/SecureArea/UpdatePassword.aspx?OldPassword=" + encodeURIComponent($('#oldPassword').val()) + "&NewPassword=" + encodeURIComponent($('#newPassword1').val()));
    }
    else
    {
        alert("The new password entered do not match. Please re-enter");
        $('#newPassword').val("");
        $('#newPassword1').val("");
    }
}