﻿/******************************************************************************************************
* MFC JS Library 
******************************************************************************************************/
var PageEnabled			    = 1;
var InternetExplorer		= ( navigator.appVersion.toLowerCase().indexOf( 'msie' ) > -1 );
var PageRunning             = 0;
var w	                    = window;
var s	                    = self;
var d	                    = document;
var b	                    = d.body;
var a	                    = d.all;
var f	                    = d.forms[0];

/*********************************************************************************************************
Name: initPage
Desc: JS Function to call on page load
Param: 
None
*********************************************************************************************************/
function PageInitialize(sMainFormName, sDefaultFocusElement, sLocalFunction)
{
    w	                    = window;
    s	                    = self;
    d	                    = document;
    b	                    = d.body;
    a	                    = d.all;
	InternetExplorer	    = ( navigator.appVersion.toLowerCase().indexOf( 'msie' ) > -1 );
	f			            = ( !sMainFormName )	? d.forms[0] : d.forms[ sMainFormName ];

    b.style.display = "block";
    DisablePage(false);

    if(sDefaultFocusElement)
    {   
        try
        {
            d.getElementById(sDefaultFocusElement).focus();
            //f.elements[sDefaultFocusElement].focus();
        }
        catch(e)
        {
        }
    }
    
    if(sLocalFunction)
    {
        eval( sLocalFunction );
    }
}

//****************************** Disable Page (PUBLIC)
function DisablePage(bDisable){
    DisableForm(bDisable);
    b.disabled = bDisable;
}

//****************************** Disable Page (PUBLIC)
function DisableForm(bDisable){
    var objElements = f.elements;
    
    for(var i=0;i<objElements.length;i++)
    {
        objElements[i].disabled = bDisable;
    }
}

//****************************** Processing Status (PUBLIC)
function processingStatus(bStart) {
    DisablePage(bStart);
    ProcessingMsg(bStart);
}

//****************************** Processing Msg (PUBLIC)
function ProcessingMsg(bMsgOn) {
    if(InternetExplorer)
    {
        if(bMsgOn)
        {
            document.getElementById("divProcessing").style.display = 'block';
            ProcessingCenter(divProcessing);
        }
        else
        {
            document.getElementById("divProcessing").style.display = 'none';
        }      
    }
}

//****************************** Processing Center (PRIVATE)
function ProcessingCenter(oElement)
{
    var iWidth = InternetExplorer ? d.documentElement.clientWidth : s.innerWidth;
    var iHeight = InternetExplorer ? d.documentElement.clientHeight : s.innerHeight;
    var iScroll = InternetExplorer ? d.documentElement.scrollTop : b.scrollTop;
 
    oElement.style.width = iWidth;
    oElement.style.height = iHeight+iScroll;
}
/******************************************************************************************************
Mouse on and off functions for images.
******************************************************************************************************/
function imgChange(overName, imgpath, ext)
{
	//Change img
	//eval("document.images('" + overName + "')").src = "../images/" + imgpath + "." + ext;
    eval("document.getElementById('" + overName + "')").src = "/images/" + imgpath + "." + ext;
}
function setText(TextNum)
{

    var HeaderText = new Array();

    HeaderText[0] = "";
    HeaderText[1] = "";
    HeaderText[2] = "";
    HeaderText[3] = "";
    HeaderText[4] = "";

    var TitleText = new Array();

    TitleText[0] = "";
    TitleText[1] = "";
    TitleText[2] = "";
    TitleText[3] = "";
    TitleText[4] = "";

    document.all.htext.innerHTML = HeaderText[TextNum];
    document.all.htitle.innerHTML = TitleText[TextNum];
}
/******************************************************************************************************
Add or subtracts from a date.
******************************************************************************************************/
function DateAdd(timeU,byMany,dateObj) {
	var millisecond=1;
	var second=millisecond*1000;
	var minute=second*60;
	var hour=minute*60;
	var day=hour*24;
	var year=day*365;

	var newDate;
	var dVal=dateObj.valueOf();
	switch(timeU) {
		case "ms": newDate=new Date(dVal+millisecond*byMany); break;
		case "s": newDate=new Date(dVal+second*byMany); break;
		case "mi": newDate=new Date(dVal+minute*byMany); break;
		case "h": newDate=new Date(dVal+hour*byMany); break;
		case "d": newDate=new Date(dVal+day*byMany); break;
		case "y": newDate=new Date(dVal+year*byMany); break;
	}
	return newDate;
}