﻿// launches the backup database screen
function BackUpDatabase()
{
    var objWindow = window.open("BackupDatabase.aspx", "BackupDatabase", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=400px, height=200px, top=" + (document.body.clientHeight - 200) / 2 + ", left=" + (document.body.clientWidth - 400) / 2);
    objWindow.focus();
}

// prompts the user to confirm log out of the administration section
function ConfirmLogout()
{
    return confirm("Are sure you want to log out?");
}

// prompts the user to confirm deleteion of content in administration section
function ConfirmDeleteParagraph()
{
    return confirm("Are sure you want to delete this content?");
}

// shows the loading image on the attach image screen
function ShowLoading()
{
    document.getElementById('LoadingForm').className = "show";
    document.getElementById('AttachForm').className = "hide";
}

// shows the form on the attach image screen
function ShowAttachForm()
{
    document.getElementById('LoadingForm').className = "hide";
    document.getElementById('AttachForm').className = "show";
}

// populates a field in the parent form from the attachment popup with the saved filename
function PopulateParentUploadField(strImageFieldName, strFilePath, strTextFieldName, strFileName)
{
    opener.document.getElementById(strImageFieldName).src = strFilePath;
    opener.document.getElementById(strTextFieldName).value = strFileName;
}

// populates a field in the parent form from the attachment popup with the saved filename
function PopulateFlashSrc(strLabelFieldName, strFilePath, strTextFieldName, strFileName)
{
    var flashHtml = "<object width=\"800px\" height=\"800px\">";
        flashHtml = flashHtml + "<param name=\"movie\" value=\"" + strFileName + "\" />";
        flashHtml = flashHtml + "<embed src=\"../Temporary Images/" + strFileName + "\"></embed>";
        flashHtml = flashHtml + "</object>";

    opener.document.getElementById(strLabelFieldName).innerHTML = flashHtml;
    opener.document.getElementById(strTextFieldName).value = strFileName;
}

// calls the attach image popup
function AttachImage(strImageFieldId, strTextFieldId, boolCreateThumbnail)
{
    var objWindow = window.open("AttachImage.aspx?&CreateThumbnail=" + boolCreateThumbnail + "&ParentImageField=" + strImageFieldId + "&ParentTextField=" + strTextFieldId, "AttachImage", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=400px, height=200px, top=" + (document.body.clientHeight - 200) / 2 + ", left=" + (document.body.clientWidth - 400) / 2);
    objWindow.focus();
}

// calls the attach image popup
function AttachFlash(strLabelId, strTextFieldId)
{
    var objWindow = window.open("AttachImage.aspx?&Flash=Y&ParentImageField=" + strLabelId + "&ParentTextField=" + strTextFieldId, "AttachImage", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=400px, height=200px, top=" + (document.body.clientHeight - 200) / 2 + ", left=" + (document.body.clientWidth - 400) / 2);
    objWindow.focus();
}

// redirects to the specified page
function LaunchPage(strLocation)
{
    document.location = strLocation;
}

// prompts the user to confirm a cancel operation on the administration pages
function ConfirmCancel()
{
    return confirm("Are sure you want to cancel? Any unsubmitted changes will be lost");
}

// prompts the user to confirm a delete operation on the administration pages
function ConfirmDelete()
{
    return confirm("Are sure you want to delete this item?");
}

// calls the calender popup
function CallCalenderPopup(strControlId)
{
    var objWindow = window.open("../DatePicker.aspx?control=" + strControlId, "DatePicker", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=200px, height=150px, top=" + (document.body.clientHeight - 150) / 2 + ", left=" + (document.body.clientWidth - 200) / 2);
    objWindow.focus();
}

// calls the form calender popup
function CallFormCalenderPopup(strControlId)
{
    var objWindow = window.open("DatePicker.aspx?control=" + strControlId, "DatePicker", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=200px, height=150px, top=" + (document.body.clientHeight - 150) / 2 + ", left=" + (document.body.clientWidth - 200) / 2);
    objWindow.focus();
}

// closes the calender popup
function CloseCalenderPopup(strSelectedDate, strControl)
{
    opener.document.getElementById(strControl).value = strSelectedDate;
	window.close();
}

// opens the popup window from the main page link
function OpenMainWindow(strPageType)
{
    var objWindow = window.open("ShowPopup.aspx?Item=" + strPageType, "ShowPopup", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=700px, height=400px, top=" + (document.body.clientHeight - 400) / 2 + ", left=" + (document.body.clientWidth - 700) / 2);
    objWindow.focus();
}

// limits the amount of text in a text area
function LimitTextArea(strFieldName, intMaxLength)
{
    if (strFieldName.value.length > intMaxLength)
    {
        strFieldName.value = strFieldName.value.substring(0, intMaxLength);
        alert("The maximum permitted number of characters (" + intMaxLength + ") has been reached");
    }
}

// set the links in the parent
function SetLinks(strLinkTypeField, strLinkField, strLinkType, strLink)
{
    opener.document.getElementById(strLinkTypeField).value = strLinkType;
    opener.document.getElementById(strLinkField).value = strLink;
    
    window.close();
}

// call the attach link screen
function LaunchSelectLink(strLinkType, strLink)
{
    var objWindow = window.open("AttachLink.aspx?&LinkType=" + document.getElementById(strLinkType).value + "&LinkTypeField=" + strLinkType + "&Link=" + document.getElementById(strLink).value + "&LinkField=" + strLink, "AttachLink", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, fullscreen=no, width=700px, height=400px, top=" + (document.body.clientHeight - 400) / 2 + ", left=" + (document.body.clientWidth - 700) / 2);
    objWindow.focus();
    
    return false;
}




