/*-------------------------------------------------------------------------------------------------
 <project>
 SunGardHE.AWC
 </project>
 <file>
 AWCFunction.js
 </file>
 <company>
 Advancement Solutions, SunGard Higher Education
 http://www.sungardhe.com
 </company>
 <copyright>
  
 Copyright (c) 2003-2007 
 All Rights Reserved.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 DEALINGS IN THE SOFTWARE.
</copyright>
<summary>
 This js file handles the functions for controls throughout AWC on the web forms.
</summary>
<history>   
 Developer	Date		Version	Change
 --------------------------------------------------------------------------------------------------
 Sweatt     06/20/2005  1.0     Initial Creation
 Sweatt     05/11/2007  4.0     Added Calendar control over from AWA functions
 Sweatt     10/22/2007  4.1     Added AJAX Calls and new Alert function
 --------------------------------------------------------------------------------------------------
</history>   
--------------------------------------------------------------------------------------------------*/
// 05/11/2007
document.onclick = documentOnClick;
var _browser = new BrowserDetect();
function documentOnClick() {
    // insure any Calendar Popup controls are hidden when the user scrolls "theBody" element.
    hideCalendarPopup();
}//END documentOnClick

// 7/12/2007 Hamel - new function from AWA, called by checkboxes
function checkbox_onclick() {
    Submitted   = 0;
    bModified   = true;
}//END checkbox_onclick

function calendarPopup(dateboxId) {
    var datebox     = document.getElementById(dateboxId);
    if (!datebox.readOnly) {
        var iframe  = iFrameCreateWithoutDisplay("date_popup", "CalendarPopup.aspx?dateboxid=" + dateboxId + "&value=" + encodeURI(datebox.value));
        var newX    = getAbsoluteLeft(datebox, 0, false) - 75;
        // Removed the previous inclusion of theBody.offsetTop and theBody.scrollTop values from the
        // calculation here since they have now been integrated into the getAbsoluteTop function.
        var newY    = getAbsoluteTop(datebox, 0, false) + datebox.offsetHeight + 5;
      
        // determine if in a popupIFrame as we will need to take into consideration 
        // the iFrame height, instead of the document.body.clientHeight. If not use the document.body.clientHeight
        // as before.
        var itemForMeasure;
//        var value   = window.frameElement.getAttribute("popupIFrame");
//        if (value == "true") { // in popup
//            itemForMeasure = window.frameElement;
//        }
//        else {
            itemForMeasure = document.body;
//        }
        // adjust if it falls off the bottom
        if (newY + 190 > itemForMeasure.clientHeight) 
            // 7/7/2006 Williams - adjusted calculation to include datebox height & margin, and also the 
            // height of the calendar popup instead of the previously hardcoded value.
            newY = itemForMeasure.clientHeight - datebox.offsetHeight - 190 - 6;
        
        moveObject(iframe.id, newX, newY);
        iframe.style.width  = "235px";
        iframe.style.height = "200px";
        iFrameShow(iframe);
    }
}//END calendarPopup

/*----------------------------------------------------------------------------------------------------
 This function will located the current Calendar Popup iFrame, if it exists, and will hide it. 
----------------------------------------------------------------------------------------------------*/
function hideCalendarPopup() {
    var calendarPopup = document.getElementById("date_popup");
    if (calendarPopup != null)
        iFrameClose(calendarPopup);
} // END hideCalendarPopup

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if (document.getElementById && document.getElementById(objectId))
        // W3C DOM
        return document.getElementById(objectId).style;
    else if (document.all && document.all(objectId)) 
        // MSIE 4 DOM
        return document.all(objectId).style;
    else if (document.layers && document.layers[objectId])
        // NN 4 DOM.. note: this won't find nested layers
        return document.layers[objectId];
    else
        return false;
}//END getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if (styleObject) {
        styleObject.visibility = newVisibility;
        return true;
    } else
        return false;
    
}//END changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
        styleObject.left    = newXCoordinate + "px";
        styleObject.top     = newYCoordinate + "px";
        return true;
    } else
        return false;
}//END moveObject
// inScrollableRegion to fix Netscape positioning bug
function getAbsoluteTop(obj, level, inScrollableRegion) {
    // Readjusted calculations to be consistent with measurement differences that are necessary for XHTML.
    if (obj.offsetParent != null && 
        level < 25 && 
        obj.id != 'theBody') 
        return obj.offsetTop + getAbsoluteTop(obj.offsetParent, level+1, inScrollableRegion);
    else if (navigator.appName.indexOf("Microsoft") != -1)
        return obj.offsetTop + (-1 * document.getElementById("theBody").scrollTop);
    else if (inScrollableRegion) 
        return -1 * document.getElementById("theBody").scrollTop;
    else 
        return 0;
}//END  getAbsoluteTop

function getAbsoluteLeft(obj, level) {
    // Readjusted calculations to be consistent with measurement differences that are necessary for XHTML.
    if (obj.offsetParent != null && 
        level < 25)
        return obj.offsetLeft + getAbsoluteLeft(obj.offsetParent,level + 1);
    else 
        return obj.offsetLeft;
}//END getAbsoluteLeft

function OnChangeCallback(id) {
    var control = document.getElementById(id);
    if (control != null) {
        var onchange = control.getAttribute("onchangecallback")
        if (onchange != null && 
            onchange.length > 0) {
            tempOnchange = new Function(onchange);
            tempOnchange();
        }
    }
}//END OnChangeCallback
//05/11/2007 END

var source = '';
function NavigateTo(page) {
    document.location.href = page;
}//END NavigateTo

var _bookMarkUrl     = 'http://';
var _bookMarkTitle   = '';
function addbookmark()	{
    if (document.all)
        window.external.AddFavorite(_bookMarkUrl, _bookMarkTitle);
}//END addbookmark

function clearFormValues() {
    // Creat a form object variable
    var frm = document.frmMain;
    for (var index = 0; index < frm.elements.length; index++) {
        // Select Control
        if (frm.elements[index].type == 'select') 
            frm.elements[index].selectedIndex = 0;
        // Select-one Control
        if (frm.elements[index].type == 'select-one') 
            frm.elements[index].selectedIndex = 0;
        // Input Text Control
        if (frm.elements[index].type == 'text') 
            frm.elements[index].value = '';
        // Input Textarea Control
        if (frm.elements[index].type == 'textarea')
            frm.elements[index].value = '';
        // Input hidden control
        //if (frm.elements[index].type == 'hidden') 
        //	frm.elements[index].value = '';
        // Input checkbox control
        if (frm.elements[index].type == 'checkbox') {
            if (frm.elements[index].checked == true)
                frm.elements[index].checked = false;
        }
        // Input file control
        if (frm.elements[index].type == 'file') 
            frm.elements[index].value = '';
    }
}//END clearFormValues



/*----------------------------------------------------------------------------------------------------
How to write text on multiple lines in an alert box?
We can't use the <br /> tag here, as we did in write(), because
alert() is a method of the window object that cannot interpret HTML
tags. Instead we use the new line escape character
An escape character consists of a backslash ()
symbol and an alphabet. When preceeded by the backslash, these alphabet
assume a special function. Here are some commonly used escapes
characters:

- \n : Inserts a new line and causes the text following it to be placed on that line.
- \t : Inserts a tab
- \r : Carriage return
- \b : Backspace
- \f : Form feed
- \' : Single quote
- \" : Double quote
- \\ : Backslash
----------------------------------------------------------------------------------------------------*/
var _FileError;
var _HasFile;
function ValidateFileExtension(id) {
    var control     = document.getElementById(id);
    var fileName    = control.value;
    
    if (fileName != null) {
        fileName = fileName.toLowerCase();
        
        if (fileName.indexOf(".") != -1) {
            var msg = '';
            switch(fileName.substr(fileName.lastIndexOf(".") + 1)) {
                case 'doc':
                case 'rtf':
                case 'txt':
                case 'pdf':
                case 'html':
                case 'htm':
                    document.getElementById('hidAttach').value = 'Y';
                    break
                default:
                    msg =   'Incorrect file type. \n' +
                            'Please select one of the following file types:\n' + 
                            '\t- Microsoft Word (doc)\n' +
                            '\t- Rich Text Format (rtf)\n' +
                            '\t- Text File (txt)\n' +
                            '\t- Adobe Acrobat (pdf)\n' +
                            '\t- HTML (htm or html)\n';
            }
            if (msg != '') {
                alert(msg); 
                // Set Focus to the File Control
                control.focus();
                // highlight text to the File Control
                control.select();	
                return false;
            } else { 
                if (!RunCommand('CMD:SAVE',1)) 
                    return false;
                return true;
            }
            //alert(box.value.substr(box.value.lastIndexOf(".")+1));
        } else {
            if (!RunCommand('CMD:SAVE',1)) 
                return false;
            return true;
        }
    } else {
        if (!RunCommand('CMD:SAVE',1)) 
            return false;
        return true;
    }
}//END ValidateFileExtension

function LoadAttachmentVars() {
    _FileError   = document.getElementById('lblFileError');
    _HasFile     = document.getElementById('hidAttach');
    try {
        if (_HasFile.value == 'Y') 
            _FileError.style["display"] = "";
        else 
            _FileError.style["display"] = "none";
    }catch(ex) {
        _FileError.style["display"] = "none";
    }
}//END LoadAttachmentVars

/*----------------------------------------------------------------------------------------------------
 Detects the type of browser the client is runnning
----------------------------------------------------------------------------------------------------*/
function BrowserDetect() {
   var ua = window.navigator.userAgent.toLowerCase(); 
   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);
   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ((this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   // 10/12/2007 Sweatt - Added FireFox
   this.isFireFox     = (ua.indexOf('firefox') != -1);   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   // rendering engine versions
   this.geckoVersion        = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla   = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion  = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   // correct version number
   if (this.isGecko && !this.isMozilla) 
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   else if (this.isMozilla) 
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   else if (this.isIE && this.versionMinor >= 4) 
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   else if (this.isKonqueror) 
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   else if (this.isSafari) 
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   else if (this.isOmniweb) 
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   else if (this.isOpera) 
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   else if (this.isIcab) 
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   
   this.versionMajor = parseInt(this.versionMinor); 
   // dom support
   this.isDOM1 = (window.document.getElementById);
   this.isDOM2Event = (window.document.addEventListener && window.document.removeEventListener);
   // css compatibility mode
   this.mode = window.document.compatMode ? window.document.compatMode : 'BackCompat';
   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   // specific browser shortcuts
   this.isNS4x  = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x  = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x  = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x  = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x  = (this.isIE && this.versionMajor == 5);
   this.isIE55  = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x  = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}//END BrowserDetect


/*----------------------------------------------------------------------------------------------------
 Custom Tooltip
 Image w/ Description Tooltip
 Step 1: Insert the below script into the <head> section of your page
 Step 2: Set up your links to contain the necessary onMouseover 
				and out attributes. Use the following code as an example, 
				where 0 and 1 refer to the image _toolTip's index number in the 
				script above that you wish to invoke :(Ex.)
 Step 3: Finally, add the below HTML code to the very end of your document, 
				directly above the </BODY> tag:

 Ex.
 <iframe id="fraDesginations" src="" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe>
 <div id="tipDiv" style="position:absolute; display:none; z-index:100"></div>
 <img id="img" src="images/info_16.gif" 
	onmouseover="doTooltip(event,0,'','tipDiv','fraDesginations','img','bottom')" 
	onmouseout="hideTip('tipDiv','fraDesginations','img','')"/>
-----------------------------------------------------------------------------------------------------*/
// IMPORTANT: Put script after _toolTip div or put _toolTip div just before or in a js file</BODY>. 
var dom     = (document.getElementById) ? true : false;
var ns5     = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5     = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4     = (document.layers && !dom) ? true : false;
var ie4     = (document.all && !dom) ? true : false;
var nodyn   = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
// resize fix for ns4
var origWidth;
var origHeight;
if (ns4) {
    origWidth       = window.innerWidth; origHeight = window.innerHeight;
    window.onresize = function() { 
        if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); 
    }
}

// avoid error of passing event object in older browsers
if (nodyn) 
    event = "nope" 

//*********************  CUSTOMIZATION AREA  *********************//
// settings for _toolTip 
// Do you want tip to move when mouse moves over link?
var _TipFollowMouse  = true;	
// Be sure to set _TipWidth wide enough for widest image
var _TipWidth        = 240;
var _TipOffX         = 20;	// how far from mouse to show tip
var _TipOffY         = 12; 
var _TipFontFamily   = "Verdana, arial, helvetica, sans-serif";
var _TipFontSize     = "8pt";
// set default text color and background color for _toolTip here
// individual tooltips can have their own (set in _messages arrays)
// but don't have to
var _TipFontColor    = "#000000";
var _TipBgColor      = "#DDECFF"; 
var _TipBorderColor  = "#61748B";
var _TipBorderWidth  = 2;
var _TipBorderStyle  = "ridge";
var _TipPadding      = 4;
var _iframeTipHeight = 90;
// _toolTip content goes here (image, optional bgColor, optional textcolor)
var _messages = new Array();
    // multi-dimensional arrays containing: 
    // image and text for _toolTip
    // optional: bgColor and color to be sent to _toolTip#DDECFF
    _messages[0] = new Array('','#FFFFFF');
    _messages[1] = new Array('images/info_16.gif','#FFFFFF');
    _messages[2] = new Array('images/info_16.gif','black','white');

//*********************  END OF CUSTOMIZATION AREA  *********************//
// preload images that are to appear in _toolTip
// from arrays above
if (document.images) {
    var theImgs = new Array();
    for (var index = 0; index < _messages.length; index++) {
        theImgs[index]      = new Image();
        theImgs[index].src  = _messages[index][0];
    }
}
// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// _startStr goes before image, _midStr goes between image and text
var _startStr    = '<table width="' + _TipWidth + '"><tr><td align="left" style="width:100%">';
var _imgStr;
var _imgStartStr     = '<img src="';
var _imgEndStr     = '" border="0" />';
// 12/06/2007 Sweatt - set the tooltip's message alignment align="Left" on td tag
var _midStr      = '</td></tr><tr><td valign="top" align="Left">';
var _endStr      = '</td></tr></table>';
var _toolTip;
var _tipCSS;
var _iframeTip;
var _iframeTipCSS;
var _imgTip;
var _imgTipCSS; // Global variables for _toolTip.
var _Tip1;
var _Tip2;             // for setTimeouts
var _TipOn = false;      // check if over _toolTip link
/*----------------------------------------------------------------------------------------------------
  doTooltip function																			
    Global variables for _toolTip. 												
    Set styles for all but ns4. 													
    Assembles content for _toolTip and writes 						
    it to tipDiv																				
-----------------------------------------------------------------------------------------------------*/
function doTooltip(evt, num, msg, pos, tipDivControl, iFrameControl, imgControl) {
    if (nodyn) 
        return;
        
    _toolTip    = document.getElementById(tipDivControl);
    _iframeTip  = document.getElementById(iFrameControl);
    _imgTip     = document.getElementById(imgControl);
    
    if (!_toolTip) 
        return;
        
    _tipCSS         = _toolTip.style;
    _iframeTipCSS   = _iframeTip.style;
    _imgTipCSS      = _imgTip.style;
    // Assign styles to the div and iframe controls
    if (ie4 || ie5 || ns5) {	// ns4 would lose all this on rewrites
        _tipCSS.width            = _TipWidth + "px";
        _tipCSS.fontFamily       = _TipFontFamily;
        _tipCSS.fontSize         = _TipFontSize;
        _tipCSS.color            = _TipFontColor;
        _tipCSS.backgroundColor  = _TipBgColor;
        _tipCSS.borderColor      = _TipBorderColor;
        _tipCSS.borderWidth      = _TipBorderWidth + "px";
        _tipCSS.padding          = _TipPadding + "px";
        _tipCSS.borderStyle      = _TipBorderStyle;
    }
    if (_messages[num][0] != '')
        _imgStr = _imgStartStr + _messages[num][0] + _imgEndStr;
    else
        _imgStr = ' ';
    
    if (_Tip1) 
        clearTimeout(_Tip1);	
    if (_Tip2)	
        clearTimeout(_Tip2);
        
    _TipOn = true;
    // set colors if included in _messages array
    var curBgColor;
    if (_messages[num][1])
        curBgColor = _messages[num][1];
    else
        curBgColor = _TipBgColor;
    
    var curFontColor;
    if (_messages[num][2])
        curFontColor = _messages[num][2];
    else
        curFontColor = _TipFontColor;
    
    // 12/06/2007 Sweatt - set the tooltip's message alignment align="Left" on td tag
    if (ns4) {
        var tip =     '<table bgcolor="' + _TipBorderColor 
                    + '" width="' + _TipWidth 
                    + '" cellspacing="0" cellpadding="' + _TipBorderWidth 
                    + '" border="0"><tr><td><table bgcolor="' + curBgColor 
                    + '" width="100%" cellspacing="0" cellpadding="' + _TipPadding 
                    + '" border="0"><tr><td align="Left">' + _startStr 
                    + _imgStr
                    + _midStr 
                    + '<span style="font-family:' + _TipFontFamily 
                    + '; font-size:' + _TipFontSize 
                    + '; color:' + curFontColor 
                    + ';">' + msg 
                    + '</span>' + _endStr 
                    + '</td></tr></table></td></tr></table>';
        _toolTip.write(tip);
        _toolTip.close();
    } else if (ie4||ie5||ns5) {
        var tip = _startStr + _imgStr + _midStr 
                + '<span style="font-family:' + _TipFontFamily 
                + '; font-size:' + _TipFontSize 
                + '; color:' + curFontColor 
                + ';">' + msg 
                + '</span>' + _endStr;
        _tipCSS.backgroundColor  = curBgColor;
        _toolTip.innerHTML       = tip;
    }
    
    if (!_TipFollowMouse)
        positionTip(evt);
    else
        _Tip1 = setTimeout("_tipCSS.display=''",100);
    
    var offsetTop   = 0;
    var offsetLeft  = 0;
    var node        = _imgTip;
    while(node.tagName.toUpperCase() != 'BODY') { 
        offsetLeft  += node.offsetLeft; 
        offsetTop   += node.offsetTop; 
        node        =  node.offsetParent; 
    }
    _iframeTipCSS.display   = "block";
    var position            = _imgTip;
    // position the div and iframe 
    switch (pos) {
        case "left": 
            _tipCSS.top         = offsetTop;
            _tipCSS.left        = (offsetLeft - position.offsetWidth);
            _iframeTipCSS.top   = offsetTop;
            _iframeTipCSS.left  = (offsetLeft - position.offsetWidth);
            break;
        case "right": 
            _tipCSS.top         = offsetTop;
            _tipCSS.left        = (offsetLeft + position.offsetWidth);
            _iframeTipCSS.top   = offsetTop;
            _iframeTipCSS.left  = (offsetLeft + position.offsetWidth);
            break;
        case "bottom": 
            _tipCSS.top         = (offsetTop + position.offsetHeight);
            _tipCSS.left        = offsetLeft;
            _iframeTipCSS.top   = (offsetTop + position.offsetHeight);
            _iframeTipCSS.left  = offsetLeft;
            break;
        case "top": 
            _tipCSS.top         = (offsetTop - position.offsetHeight);
            _tipCSS.left        = offsetLeft; 
            _iframeTipCSS.top   = (offsetTop - position.offsetHeight);
            _iframeTipCSS.left  = offsetLeft;
            break;
    }
    _iframeTipCSS.zIndex        = _tipCSS.zIndex - 1;
    _tipCSS.display             = "";
    _iframeTipCSS.visibility    = "hidden";
    _tipCSS.visibility          = "hidden";
    //alert(_toolTip.offsetWidth + '-' +_toolTip.offsetHeight);
    _iframeTipCSS.width         = _toolTip.clientWidth;
    _iframeTipCSS.height        = _toolTip.clientHeight;
    _iframeTipCSS.visibility    = "visible";
    _tipCSS.visibility          = "visible";
}//END doTooltip

/*----------------------------------------------------------------------------------------------------
 trackMouse function
    tracks the mouse events and positioning
-----------------------------------------------------------------------------------------------------*/
var _mouseX;
var _mouseY;
function trackMouse(evt) {
    _mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
    _mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
    if (_TipOn)
        positionTip(evt);
}//END trackMouse

/*----------------------------------------------------------------------------------------------------
 positionTip function																		
    If _TipFollowMouse set false, so trackMouse function		
    not being used, get position of mouseover event.			
    Calculations use mouseover event position, 						
    offset amounts and _toolTip width to position					
    _toolTip within window.																
-----------------------------------------------------------------------------------------------------*/
function positionTip(evt) {
    if (!_TipFollowMouse) {
        _mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
        _mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
    }
    // _toolTip width and height
    var tpWd = (ns4)? _toolTip.width: (ie4||ie5)? _toolTip.clientWidth: _toolTip.offsetWidth;
    var tpHt = (ns4)? _toolTip.height: (ie4||ie5)? _toolTip.clientHeight: _toolTip.offsetHeight;
    // document area in view (subtract scrollbar width for ns)
    var winWd = (ns4||ns5)? window.innerWidth - 20 + window.pageXOffset: document.body.clientWidth + document.body.scrollLeft;
    var winHt = (ns4||ns5)? window.innerHeight - 20 + window.pageYOffset: document.body.clientHeight + document.body.scrollTop;
    // check mouse position against tip and window dimensions
    // and position the _toolTip 
    if ((_mouseX + _TipOffX + tpWd) > winWd) 
        _tipCSS.left = ((ns4)? _mouseX - (tpWd + _TipOffX): _mouseX - (tpWd + _TipOffX)) + "px";
    else
        _tipCSS.left = ((ns4)? _mouseX + _TipOffX: _mouseX + _TipOffX) + "px";
    
    if ((_mouseY + _TipOffY + tpHt) > winHt)
        _tipCSS.top  = (((ns4)? winHt - (tpHt + _TipOffY): winHt - (tpHt + _TipOffY)) + 0) + "px";
    else
        _tipCSS.top  = (((ns4)? _mouseY + _TipOffY: _mouseY + _TipOffY) + 0) + "px";
    
    if (!_TipFollowMouse)
        _Tip1          = setTimeout("_tipCSS.display=''", 100);
}
/*----------------------------------------------------------------------------------------------------
 hideTip function																			
    makes the _toolTip hidden
-----------------------------------------------------------------------------------------------------*/
function hideTip() {
    if (!_toolTip) 
        return;
    
    _Tip2                   = setTimeout("_tipCSS.display='none'",100);
    _TipOn                  = false;
    // display none (hide) div and iframe
    _tipCSS.display         = "none";
    _iframeTipCSS.display   = "none";
}
/*----------------------------------------------------------------------------------------------------
 Custom Tooltip End
-----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
    Dom Image Rollover
    Description: This script makes it easy to add rollover/ mousedown 
    effects to any image on the page, including image submit buttons. Automatically 
    preloads images as well. Script works in all DOM capable browsers- IE5+, NS6+, 
    Opera7+.
    HTML Ex.
    Rollover only on image.                     <img src="original.jpg" srcover="over.jpg">
    Rollover and Mousedown.                     <img src="original.jpg" srcover="over.jpg" srcdown="down.jpg">
    Rollover and Mousedown on submit button.    <input type="image" name="submitimg" src="original.jpg" srcover="over.jpg" srcdown="down.jpg" border="0">
-----------------------------------------------------------------------------------------------------*/
function imageholderclass() {
    this.over   = new Array();
    this.down   = new Array();
    this.src    = new Array();
    this.store  = store;
    
    function store(src, down, over) {
        var index              = this.src.length;
        this.src[index]        = new Image(); 
        this.src[index].src    = src;
        this.over[index]       = new Image(); 
        this.over[index].src   = over;
        this.down[index]       = new Image(); 
        this.down[index].src   = down;
    }//END store
}//END imageholderclass

var ih          = new imageholderclass();
var mouseisdown = 0;

function preloader(ctl){
    for(var index = 0; index < ctl.length; index++) {
        if(ctl[index].getAttribute('srcover') ||
           ctl[index].getAttribute('srcdown')) {
            
            storeimages(ctl[index]);
            var checker = '';
            checker     = (ctl[index].getAttribute('srcover'))?checker+'A':checker+'';
            checker     = (ctl[index].getAttribute('srcdown'))?checker+'B':checker+'';
            
            switch(checker){
                case 'A' : 
                    mouseover(ctl[index]);
                    mouseout(ctl[index]); 
                    break;
                case 'B' : 
                    mousedown(ctl[index]); 
                    mouseup2(ctl[index]); 
                    break;
                case 'AB' : 
                    mouseover(ctl[index]);
                    mouseout(ctl[index]); 
                    mousedown(ctl[index]); 
                    mouseup(ctl[index]); 
                    break;
                default : return;
            }
            if(ctl[index].src)
                ctl[index].setAttribute("oldsrc", ctl[index].src);
        }
    }
}//END preloader
function mouseup(ctl) {
    var newmouseup;
    if(ctl.onmouseup) {
        ctl.oldmouseup  = ctl.onmouseup;
        newmouseup      = function() {
            mouseisdown = 0;
            this.src    = this.getAttribute("srcover");
            this.oldmouseup();
        }
    } else {
        newmouseup = function() {
            mouseisdown = 0;
            this.src = this.getAttribute("srcover");
        }
    }
    ctl.onmouseup = newmouseup;
}//END mouseup

function mouseup2(ctl) {
    var newmouseup;
    if(ctl.onmouseup) {
        ctl.oldmouseup  = ctl.onmouseup;
        newmouseup      = function() {
            mouseisdown = 0;
            this.src    = this.getAttribute("oldsrc");
            this.oldmouseup();
        }
    } else {
        newmouseup = function() {
            mouseisdown = 0;
            this.src    = this.getAttribute("oldsrc");
        }
    }
    ctl.onmouseup = newmouseup;
}//END mouseup2

function mousedown(ctl) {
    var newmousedown;
    if(ctl.onmousedown) {
        ctl.oldmousedown    = ctl.onmousedown;
        newmousedown        = function(){
            if(mouseisdown == 0) {
                this.src = this.getAttribute("srcdown");
                this.oldmousedown();
            }
        }
    } else {
        newmousedown = function() {
            if(mouseisdown == 0) {
                this.src = this.getAttribute("srcdown");
            }
        }
    }
    ctl.onmousedown = newmousedown;
}//END mousedown

function mouseover(ctl){
    var newmouseover;
    if(ctl.onmouseover) {
        ctl.oldmouseover    = ctl.onmouseover;
        newmouseover        = function() {
            this.src = this.getAttribute("srcover");
            this.oldmouseover();
        }
    } else {
        newmouseover = function() {
            this.src = this.getAttribute("srcover");
        }
    }
    ctl.onmouseover = newmouseover;
}//END mouseover

function mouseout(ctl) {
    var newmouseout;
    if(ctl.onmouseout) {
        ctl.oldmouseout = ctl.onmouseout;
        newmouseout     = function() {
            this.src = this.getAttribute("oldsrc");
            this.oldmouseout();
        }
    } else {
        newmouseout = function() {
            this.src = this.getAttribute("oldsrc");
        }
    }
    ctl.onmouseout = newmouseout;
}//END mouseout

function storeimages(ctl){
    var src  = (ctl.getAttribute('src'))?ctl.getAttribute('src'):'';
    var down  = (ctl.getAttribute('srcdown'))?ctl.getAttribute('srcdown'):'';
    var over  = (ctl.getAttribute('srcover'))?ctl.getAttribute('srcover'):'';
    ih.store(src, down, over);
}//END storeimages

function preloadimgsrc(){
    if(!document.getElementById) return;
    var it  = document.getElementsByTagName('IMG');
    var it2 = document.getElementsByTagName('INPUT');
    preloader(it);
    preloader(it2);
}//END preloadimgsrc

if(window.addEventListener)
    window.addEventListener("load", preloadimgsrc, false);
else {
    if(window.attachEvent)
        window.attachEvent("onload", preloadimgsrc);
    else {
        if(document.getElementById)
            window.onload = preloadimgsrc;
    }
}
/*----------------------------------------------------------------------------------------------------
 Dom Image Rollover End
-----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 Function to detect the Browser type. Use _browser instead detectBrowser is "Obsolete"
-----------------------------------------------------------------------------------------------------*/
var theform;
var isIE;
var isNS;
function detectBrowser(){
    if (window.navigator.appName.toLowerCase().indexOf('netscape') > -1)
        theform = document.forms['frmMain'];
    else
        theform = document.frmMain;
    //browser detection
    var userAgent = navigator.userAgent.toLowerCase();
    isIE             = userAgent.indexOf('msie') > -1;
    isNS             = userAgent.indexOf('netscape') > -1;
}//END detectBrowser

/*----------------------------------------------------------------------------------------------------
	Numeric Textbox
	Description: Numeric box using javascript. Automatically 
		This text box can be used explictly to accept Amount Values.
  	preloads images as well. Script works in all DOM capable browsers- IE5+, NS6+, 
  	Opera7+.
  	HTML Ex.
  	<input type="text" name="txtAmount" 
  		onChange="javascript:FormatAmtControl(this)"  
  		onKeyPress="return HandleAmountFiltering(this);" 
  		maxlength="10">

 This function will fire when the control leaves the Text Box.
 The function is responsible for formating the numbers to amount type.
-----------------------------------------------------------------------------------------------------*/
function FormatAmtControl(ctl) {
    var periodPos;
    var temp;
    var tempVals;
    var ctlVal             = ctl.value;
    var decimalAfterPeriod = 2
    var maxLen             = ctl.maxLength;
    
    if (isNaN(ctlVal))
        // clear the control as this is not a num
        ctl.value   = "";
    else {
        ctlVal      = ctl.value;
        periodPos   = ctlVal.indexOf(".");
        if (periodPos < 0) {
            if (ctl.value.length > (maxLen - 3)) {
                temp   = ctl.value
                tempVal = temp.substr(0,(maxLen - 3)) + ".00";
            } else
                tempVal = ctlVal + ".00"
        } else {
            if ((ctlVal.length - periodPos -1) == 1)
                tempVal = ctlVal + "0"
            if ((ctlVal.length - periodPos -1) == 0)
                tempVal = ctlVal + "00"
            if ((ctlVal.length - periodPos -1) == 2)
                tempVal = ctlVal;
            if ((ctlVal.length - periodPos -1) > 2)
                tempVal = ctlVal.substring(0, periodPos + 3);
        }
        ctl.value = tempVal;
    }
}

/*----------------------------------------------------------------------------------------------------
 This function is responsible for filtering the keys pressed and the maintain the amount format of the 
 value in the Text box
-----------------------------------------------------------------------------------------------------*/
function HandleAmountFiltering(ctl) {
    var keyCode;
    var objInput;
    var reValidChars = /[0-9.]/;
    var e       = window.event || arguments.callee.caller.arguments[0];
    var maxLen  = ctl.maxLength;
    var value   = ctl.value;
    detectBrowser();
    
    if (isIE) {
        keyCode = e.keyCode;
        objInput = e.srcElement;
    } else {
        keyCode = e.which;
        objInput = e.target;
    }
    var key = String.fromCharCode(keyCode);
    if (reValidChars.test(key)) {
        if(keyCode == 46) {
            if(objInput.value.indexOf('.') != -1)
                if (isIE)
                    e.keyCode = 0;
                else {
                    if(e.which != 0 && 
                       e.which != 8)
                        return false;
                }
        } else {
            if(objInput.value.indexOf('.')==-1) {
                if (objInput.value.length >= (maxLen - 3)) {
                    if (isIE)
                        e.keyCode= 0;
                    else {
                        if(e.which != 0 && 
                           e.which != 8)
                            return false;
                    }
                }
            }
            if ((objInput.value.length == (maxLen - 3)) && 
                (objInput.value.indexOf('.') == -1))
                objInput.value = objInput.value +'.';
        }
    } else {
        if (isIE)
            e.keyCode = 0;
        else {
            if(e.which != 0 && 
               e.which != 8)
                return false;
        }
    }
}
/*----------------------------------------------------------------------------------------------------
 This function is responsible for filtering the keys pressed and the maintain the amount format of the 
 value in the Text box END
-----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 05/17/2007 Sweatt - Copied over from AWAFuntions.js
 This routine will determine if the Collapse or Expand action has been invoked,
 and will render all "child" container elements appropriately
----------------------------------------------------------------------------------------------------*/
function performWebFormHeaderDisplayAction(sender) {
    try {
        var elementName     = "xformheader" + sender.getAttribute("formId");
        var rootDiv         = document.getElementById(elementName);
        var menuTitle       = sender.getAttribute("title");
        if (menuTitle.toLowerCase() == "maximize"){
            var siblingControl  = rootDiv.nextSibling;
            var siblingId       = siblingControl.id;
            if (siblingControl != null && siblingId.indexOf("xformheader") == -1) {
                sender.src      = "./images/collapseHeader.gif";
                sender.title    = "Minimize";
                while (siblingControl != null && (siblingId == null | siblingId == "" | siblingId.indexOf("xformheader") == -1)){
                    try {
                        if(siblingControl.tagName.toUpperCase() != "SPAN")
                            siblingControl.style.display = "";
                    } catch(e) {
                        e.cancelBubble = true;
                    }
                    siblingControl = siblingControl.nextSibling;
                    if (siblingControl != null) {
                        // Added if condition by RS[SOS] 04/11/2007. to fix TT-7453
                        if(typeof siblingControl.id != "undefined")
                            siblingId = siblingControl.id;
                    }
                }
            }
        }else{
            var siblingControl  = rootDiv.nextSibling;
            var siblingId       = siblingControl.id;
            if (siblingControl != null && 
               siblingId.indexOf("xformheader") == -1) {
                while (siblingControl != null && (siblingId == null || siblingId == "" || siblingId.indexOf("xformheader") == -1)) {
                    try {
                        siblingControl.style.display    = "none";
                    } catch(e) {
                        e.cancelBubble                  = true;
                    }
                    siblingControl  = siblingControl.nextSibling;
                    if (siblingControl != null)
                        siblingId   = siblingControl.id;
                }
                sender.src      = "./images/expandHeader.gif";
                sender.title    = "Maximize";
            }
        }
    } catch(exp){}
}
/*----------------------------------------------------------------------------------------------------
 05/17/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 06/19/2007 Sweatt    - copied over from AWA 9.1, paging controls calls it.
 12/01/2004 MGW       - This routine will scan all table row elements searching for "selected" rows.
                        It will capture the scroll positions and element id's of these rows parent "DIVS"
                        and the "theBody" element which acts as the "content window" in the action frame.
 04/24/2006 Hamel     - Added IgnoreScrollPosition to the tables holding the DataEntrySelect controls
     		            For performance improvements, ignore those tables when calculating this
----------------------------------------------------------------------------------------------------*/
function captureScrollPositions() {
    var tables			= document.getElementsByTagName("table");
    for (var tableIndex = 0; tableIndex < tables.length; tableIndex++) {  
	    if (tables[tableIndex].getAttribute("IgnoreScrollPosition") == null) {
		    var rows    = tables[tableIndex].rows; // document.getElementsByTagName("tr");
		    var value;
		    for (var counter = 0; counter < rows.length; counter++){
		        // 8/29/2006 Hamel - case for the CSS class changed to lowercase
			    if (rows[counter].className.toLowerCase().indexOf("masterrowselected") != -1) {
				    // 9/27/2005 MGW(BSR) - Investigate for special situations now to appropriately
				    //                      display selected rows in grids based on the initiating action. In
				    //                      these instances we now replace the scroll position value with a
				    //                      particular flag which the positionSelectedGridRows() function will use
				    //                      when the page is loaded after postback.
				    // 10/7/2005 MGW(BSR) - Added consideration for the delete operation.
				    var targetControlId = rows[counter].parentNode.parentNode.parentNode.id;
				    if (document.forms[0].hidCommand.value.toLowerCase().indexOf('faddnew') >= 0)
					    value += targetControlId + ":new;";
				    else if (document.forms[0].hidCommand.value.toLowerCase().indexOf('update') >= 0)
					    value += targetControlId + ":update;";
				    else if (document.forms[0].hidCommand.value.toLowerCase().indexOf('delete') >= 0)
					    value += targetControlId + ":delete;";
				    else if (document.forms[0].hidCommand.value.toLowerCase().indexOf('sortcolumn') >=0)
					    value += targetControlId + ":sort;";
				    else {
					    if (rows[counter].parentNode.parentNode.parentNode.scrollTop > 0)
					        value += targetControlId + ":" + rows[counter].parentNode.parentNode.parentNode.scrollTop + ";";
				    }
			    }
		    }
		    if(document.getElementById("theBody").scrollTop > 0)
			    scrollPosControl.value += "theBody:" + document.getElementById("theBody").scrollTop + ";";
	    }
    }
}

function GetFullyQualifiedPath() {
    return document.URL.substring(0, document.URL.lastIndexOf("/") + 1);
}
/*----------------------------------------------------------------------------------------------------
 06/19/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 09/29/2007 Sweatt - added character counter functionality for the textarea textCounter, SetCounter
----------------------------------------------------------------------------------------------------*/
function textCounter(field, maxlimit) {
    if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter
    else
        document.getElementById('Counter').innerHTML = (maxlimit - field.value.length) + '<span> characters left</span>';
}
function SetCounter() {
    var form = null;
    var characters  = 2000;
    if (_browser.isFireFox || 
        _browser.isMozilla || 
        _browser.isNS7up)
        form = document.forms['frmMain'];
    else if (_browser.isIE5up) 
        form = document.frmMain;
    else 
        alert('null Browser' + window.navigator.userAgent.toLowerCase());
        
    for(var index = 0; index < form.length; index++) {
        e = form.elements[index];
        if (e.type == 'textarea') {
            characters = (characters - e.value.length);
            break;
        }
    }
    document.getElementById('Counter').innerHTML = characters + ' <span> characters left</span>';
}
/*----------------------------------------------------------------------------------------------------
 09/29/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 10/25/2007 Sweatt - implement Get QueryString variable
----------------------------------------------------------------------------------------------------*/
function PageQuery(query) {
    if(query.length > 1)
        this.query = query.substring(1, query.length);
    else 
        this.query = null;
    
    this.keyValuePairs = new Array();
    if(query)
        for(var index = 0; index < this.query.split("&").length; index++)
            this.keyValuePairs[index] = this.query.split("&")[index];
    
    this.getKeyValuePairs = function() { 
        return this.keyValuePairs; 
    }//END getKeyValuePairs    
    this.getValue = function(value) {
        for(var index = 0; index < this.keyValuePairs.length; index++) {
            if(this.keyValuePairs[index].split("=")[0] == value)
                return this.keyValuePairs[index].split("=")[1];
        }
        return false;
    }//END getValue
    this.getParameters = function() {
        var params = new Array(this.getLength());
        for(var index = 0; index < this.keyValuePairs.length; index++)
            params[index] = this.keyValuePairs[index].split("=")[0];
        
        return params;
    }//END getParameters
    this.getLength = function() {
        return this.keyValuePairs.length; 
    }//END getLength
}
function queryString(key) {
    var page = new PageQuery(window.location.search); 
    return unescape(page.getValue(key)); 
}
/*----------------------------------------------------------------------------------------------------
 10/25/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 New Custom AlertModal
 Script execution is NOT suspended like a normal alert / confirm box would be, so be warned
 There is an iframe hack for IE6 to fix the zindex but with "select" elements.
 "select" elements are disabled in IE6 when an alert box is showing
 Tested in Firefox 1.5 + , Firefox 2.0 + , Alert.isIE6, IE7, Opera 9 + , Safari for Windows

<history>   
 Developer	Date		Change
 --------------------------------------------------------------------------------------------------
 Sweatt     10/22/2007  Initial Creation new custom alert function
 --------------------------------------------------------------------------------------------------
</history> 
----------------------------------------------------------------------------------------------------*/
function Alert(options) {
    var alertModal         = this;
    alertModal.version     = '1.1.0.0';
    var isIE6 = false;
    if (!window.XMLHttpRequest)
        isIE6 = true; // simple test to check for isIE6 or older browser or an older browser.

    var alarmWindow;
    var alarmBox;
    var alarmTitle;
    var alarmContent;
    var buttonContainer;
    var alarmButton;
    var mouseX;
    var mouseY;
    var parentElement;
    var alertY;
    var alertX;
    if(isIE6)
        var alarmFrame;

    var page = {
        viewportWidth : function() {
            return self.innerWidth  || (document.documentElement.clientWidth || document.body.clientWidth);
        },
        viewportHeight : function() {
            return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
        },
        viewportSize : function() {
            return {
                width : this.viewportWidth(), height : this.viewportHeight()
            };
        }
    };
    // Methods
    alertModal.Position    = objectPosition;
    alertModal.Dialog      = function(title, text, button, buttonEvent) {
        if(document.getElementById('modalWindow'))
            return

        createWindow('dialog', title, text, button, buttonEvent);
        objectPosition();
        if(isIE6)
            changeSelect(true);

        alarmButton.focus();
    }
    alertModal.Confirm     = function(title, text, button, buttonEvent, button2, button2Event) {
        if(document.getElementById('modalWindow'))
            return

        createWindow('confirm', title, text, button, buttonEvent, button2, button2Event);
        objectPosition();
        if(isIE6)
            changeSelect(true);

        confirmButton.focus();
    }
    // Functions
    function objectPosition() {
        var pageY                   = window.pageYOffset || document.documentElement.scrollTop;
        var pageX                   = window.pageXOffset || document.documentElement.scrollLeft;
        alarmBox.style.left         = (page.viewportWidth()  - alarmBox.offsetWidth)  / 2 + pageX + "px";
        alarmBox.style.top          = (page.viewportHeight() - alarmBox.offsetHeight) / 2 + pageY + "px";
        if(isIE6) {
            alarmFrame.style.left       = (page.viewportWidth()  - alarmBox.offsetWidth)  / 2 + pageX + "px";
            alarmFrame.style.top        = (page.viewportHeight() - alarmBox.offsetHeight) / 2 + pageY + "px";
            alarmFrame.style.height     = alarmBox.offsetHeight + "px";
            alarmFrame.style.visibility = 'visible';
        }
        alarmBox.style.visibility   = 'visible';
    }
    function changeSelect(bool) {
        var selectBoxes = document.getElementsByTagName('select');
        for(var i = 0; i < selectBoxes.length; i ++)
            selectBoxes[i].disabled = bool;
    }
    function alarmOnClickOk(event, onClickOk) {
        if(isIE6)
            changeSelect(false);

        document.body.removeChild(alarmWindow);
        window.onscroll     = null;
        window.onresize     = null;
        alarmWindow         = null;
        alarmBox            = null;
        alarmTitle          = null
        alarmContent        = null
        alarmButton         = null;
        buttonContainer     = null;
        if(onClickOk != '')
            eval(onClickOk);
    }
    function alarmOnClickCancel(event, onClickCancel) {
        if(isIE6)
            changeSelect(false);

        document.body.removeChild(alarmWindow);
        window.onscroll     = null;
        window.onresize     = null;
        alarmWindow         = null;
        alarmBox            = null;
        alarmTitle          = null
        alarmContent        = null
        alarmButton         = null;
        buttonContainer     = null;
        if(onClickCancel != '')
            eval(onClickCancel);
    }
    function mouseDown(e) {
        e       = (e == null) ? window.event : e;
        target  = (e.target) ? e.target : e.srcElement;
        if(target.id == 'title') {
            mouseX                  = e.clientX;
            mouseY                  = e.clientY;
            parentElement           = target.parentNode;
            alertX                  = parentElement.style.left;
            alertY                  = parentElement.style.top;
            document.onmousemove    = mouseMove;
            document.onmouseup      = mouseUp;
            document.onselectstart  = function () {
                return false
            };
            return false;
        }
    }
    function mouseMove(e) {
        e                           = (e == null) ? window.event : e;
        newX                        = parseInt(alertX.split('px')[0]);
        newY                        = parseInt(alertY.split('px')[0]);
        parentElement.style.left    = (newX + e.clientX - mouseX) + 'px';
        parentElement.style.top     = (newY + e.clientY - mouseY) + 'px';
        if(isIE6) {
            alarmFrame.style.left   = (newX + e.clientX - mouseX) + 'px';
            alarmFrame.style.top    = (newY + e.clientY - mouseY) + 'px';
        }
    }
    function mouseUp(e) {
        e                       = (e == null) ? window.event : e;
        document.onmousemove    = null;
        document.onselectstart  = null;
    }
    function createWindow(alertType, title, text, button, buttonEvent, button2, button2Event) {
        alarmWindow                         = document.body.appendChild(document.createElement("div"));
        alarmBox                            = alarmWindow.appendChild(document.createElement('div'));
        alarmTitle                          = alarmBox.appendChild(document.createElement('div'));
        alarmContent                        = alarmBox.appendChild(document.createElement('div'));
        buttonContainer                     = alarmBox.appendChild(document.createElement('div'));
        // Set up our modal Window
        alarmWindow.id                      = 'modalWindow';
        alarmWindow.style.height            = document.documentElement.scrollHeight + 'px';
        alarmWindow.style.backgroundColor   = 'transparent';
        alarmWindow.style.position          = 'absolute';
        alarmWindow.style.width             = '100%';
        alarmWindow.style.top               = '0px';
        alarmWindow.style.left              = '0px';
        alarmWindow.style.zIndex            = '10000';
        // IE hack.  Overlap  z - index doo - dads
        // This is a one pixel transparent png.
        alarmWindow.style.backgroundImage   = 'url(images/blank.png)';
        alarmBox.style.visibility           = 'hidden';
        alarmBox.style.position             = 'absolute';
        alarmBox.style.width                = options.width + 'px';
        alarmBox.style.border               = options.border + 'px';
        alarmBox.style.borderStyle          = options.borderStyle;
        alarmBox.style.borderColor          = options.borderColor;
        alarmBox.style.textAlign            = 'center';
        alarmBox.style.zIndex               = 101;
        alarmBox.style.background           = options.contentColor;
        // Create an iframe
        if(isIE6) {
            alarmFrame                  = alarmWindow.appendChild(document.createElement('iframe'));
            alarmFrame.src              = "javascript:void(0);";
            alarmFrame.style.visibility = 'hidden';
            alarmFrame.style.position   = 'absolute';
            alarmFrame.style.width      = options.width + 'px';
            alarmFrame.style.zIndex     = 100;
            alarmFrame.frameBorder      = '0';
        }
        // Create the title window
        alarmTitle                      = alarmBox.appendChild(document.createElement('div'));
        alarmTitle.id                   = 'title';
        alarmTitle.innerHTML            = title;
        alarmTitle.style.cursor         = 'default';
        alarmTitle.style.background     = options.titleColor;
        alarmTitle.style.color          = options.titleFontColor;
        alarmTitle.style.fontWeight     = options.titleWeight;
        alarmTitle.style.padding        = '1px';
        alarmTitle.style.borderTop      = '0px';
        alarmTitle.style.borderBottom   = '1px';
        alarmTitle.style.borderColor    = options.titleBorderColor;
        alarmTitle.style.borderLeft     = '0px';
        alarmTitle.style.borderRight    = '0px';
        alarmTitle.style.borderStyle    = 'solid';
        alarmTitle.style.marginTop      = '0px';
        alarmTitle.style.marginBottom   = '0px';
        if(window.addEventListener) {
            alarmTitle.addEventListener('mousedown', function(e) {
                mouseDown(e)
            }, false);
        } else
            alarmTitle.onmousedown = mouseDown;

        // Create the content window
        alarmContent                    = alarmBox.appendChild(document.createElement('div'));
        alarmContent.style.padding      = '5px';
        alarmContent.style.background   = options.contentColor;
        alarmContent.style.color        = options.contentFontColor;
        alarmContent.innerHTML          = text;
        alarmContent.style.marginBottom = '0px';
        alarmContent.style.marginTop    = '0px';
        alarmContent.style.textAlign    = 'left';
        // Create a button container
        buttonContainer                     = alarmBox.appendChild(document.createElement('div'));
        buttonContainer.style.background    = options.contentColor;
        buttonContainer.style.marginBottom  = '0px';
        buttonContainer.style.marginTop     = '0px';
        buttonContainer.style.padding       = '5px';
        buttonContainer.style.clear         = 'both';
        // Create our button
        alarmButton                         = document.createElement('input');
        alarmButton.type                    = 'button';
        alarmButton.style.border            = '1px solid';
        alarmButton.style.cursor            = 'pointer';
        alarmButton.value                   = button;
        alarmButton.onclick                 = function(event) {
            alarmOnClickOk(event, buttonEvent);
        }
        alarmButton.style.paddingLeft       = '5px';
        alarmButton.style.paddingRight      = '5px';
        buttonContainer.appendChild(alarmButton);
        // Create a second button for confirm type
        if(alertType == 'confirm') {
            confirmButton                   = document.createElement('input');
            confirmButton.type              = 'button';
            confirmButton.style.border      = '1px solid';
            confirmButton.style.cursor      = 'pointer';            // Works in firefox
            confirmButton.value             = button2;
            confirmButton.onclick           = function(event) {
                alarmOnClickCancel(event, button2Event);
            }
            confirmButton.style.paddingLeft     = '5px';
            confirmButton.style.paddingRight    = '5px';
            confirmButton.style.marginLeft      = '15px';
            buttonContainer.appendChild(confirmButton);
            if(alarmButton.offsetWidth > confirmButton.offsetWidth)
                confirmButton.style.width   = alarmButton.offsetWidth   + 'px';
            else
                alarmButton.style.width     = confirmButton.offsetWidth + 'px';
        }
        window.onscroll                     = function(){
            alertModal.Position()
        };
        window.onresize                     = function(){
            alertModal.Position()
        };
    }
}

var _ajax = new WEB.AJAX();
var _options = {
	border          : 1,
	borderStyle     : 'solid',
	borderColor     : '#000000',
	width           : 300,
	titleColor      : '#61748b',
	titleFontColor  : '#FFFFFF',
	titleWeight     : 700,
	titleBorderColor: '#000000',
	contentColor    : '#D8D8D8',
	contentFontColor: '#000000'
}
/*----------------------------------------------------------------------------------------------------
 10/22/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 10/26/2007 Sweatt - Make a Gift / Make A Pledge / Multiple Gift giving forms
                     Clears the contents of the combo box and adds the new filtered contents 
                     Changed ClearAndSetListItems to Populate
----------------------------------------------------------------------------------------------------*/
function Populate(method, xml) {
    try {
	    var arrItems        = new Array();
        var arrItemValues   = new Array();
        var control         = null;
        var indexItem       = 1;
        var indexValue      = 0;
        var qCat            = queryString('catg');
        var qSubCat         = queryString('subg');
        var qAlloc          = queryString('alloc');
        var hasCat          = (qCat     == null || qCat     == 'false')? false:true;
        var hasSubCat       = (qSubCat  == null || qSubCat  == 'false')? false:true;
        var hasAlloc        = (qAlloc   == null || qAlloc   == 'false')? false:true;
        var selectSubCat    = false;
        // 11/16/2007 Sweatt - added
        var vAlloc          = null;
        if (typeof allocFromMakeAGift != 'undefined') 
            vAlloc          = allocFromMakeAGift;
            
        var hasAllocDefault = (vAlloc != null)?true:false;
        var selectAlloc     = false;
	    switch (method) {
	        case 1:     // Sub Category Control
	            control     = document.getElementById("SubCat");
	            if (hasSubCat)
	                selectSubCat = true;
	            if (hasAlloc)
	                selectAlloc = true;
	            break;
            case 2:     // Allocation Control
                control     = document.getElementById("Allocation");
                indexItem   = 2;    // DISPLAY_NAME
                indexValue  = 0;    // ALLOCATION_CODE
                if (hasAllocDefault)
                    selectAlloc = true;
	            if (hasAlloc)
	                selectAlloc = true;
                break;
            case 3:     // Allocation Control based on System 140 set to 1, category onchange without subcategory
                control     = document.getElementById("Allocation");
                indexItem   = 2;    // DISPLAY_NAME
                indexValue  = 0;    // ALLOCATION_CODE
                if (hasAlloc)
                    selectAlloc = true;
                if (hasAllocDefault)
                    selectAlloc = true;
                break;
            case 4:     // Allocation Clear
                control         = document.getElementById("Allocation");
                indexItem       = 2;    // DISPLAY_NAME
                indexValue      = 0;    // ALLOCATION_CODE
                hasAlloc        = false;
                hasAllocDefault = false
                break;
	    }	
	    // Clears the combo box contents.
        for (var index = control.options.length; index >= 0; index--) 
            control.options[index] = null;
            
        for (var index = 0; index < xml.childNodes.length; index++) {
            arrItems[index]         = xml.childNodes(index).childNodes(indexItem).childNodes(0).text; 
            arrItemValues[index]    = xml.childNodes(index).childNodes(indexValue).childNodes(0).text;
        }
        // Add blank value
        var option      = document.createElement("OPTION");
        option.text     = '';
        option.value    = '';
        control.options.add(option);
        for (var index = 0; index < arrItems.length; index++) {
            option          = document.createElement("OPTION");
            option.text     = arrItems[index];
            option.value    = arrItemValues[index];
            control.options.add(option);
        }
        
        if (selectSubCat) {
            var options         = control.options;
            for(var index = 0; index < options.length; index++) {
                if(options[index].value == qSubCat) {
                    options[index].selected = "selected";
                }
            }
        }
        if (selectAlloc) {
            var options         = control.options;
            var allocFound      = false;
            for(var index = 0; index < options.length; index++) {
                if(options[index].value == ((hasAllocDefault)?vAlloc:((hasAlloc)?qAlloc:''))) {
                    options[index].selected = "selected";
                    allocFound = true;
                }
            }
            // Set the hidden fields with the Allocation Value and Text properties for the .Net code to get selected options
            if (allocFound)
                SetAllocationHidden(control);
        }
        
        // Testing Success
        //displayError('Make A Gift','Successful Ajax callback', null, 2); 
    } catch (ex) {
        displayError('Make A Gift','unsuccessful Ajax callback', ex, 1);
        return;
    }
    switch (method) {
        case 1:     
            // Need to fill the allocation dropdown with the categories of Category 
            _ajax.callWebPage("AjaxServer.aspx?method=2", 
                              Populate, 
                              "POST", 
                              control.id + "=" + document.getElementById('Cat').value + "|" + control.value, 
                              2); 
            break;
    }
}
function SetAllocationHidden(control) {
    var hidAlloc        = document.getElementById('hidSelectedAllocationCode');
    var hidAllocText    = document.getElementById('hidSelectedAllocationText');
    var allocText       = control.options[control.selectedIndex].text;
    var allocValue      = control.options[control.selectedIndex].value;
    if (hidAlloc != null) {
        hidAlloc.value = allocValue;
        if (hidAllocText != null)
            hidAllocText.value = allocText;
    }
    
    // 12/01/2007 SN[SOS] - Added to fix 2502
    var Allocation165 = document.getElementById('hiddenAllocation165');    
    var Allocation165 = document.getElementById('hiddenAllocation165');        
    var printOpt =  document.frmMain.rptType;       
    var giftTypeSelected = GetSelectedGiftTypeOption();
    
    if(Allocation165 != null)
    {
        if(Allocation165.value == allocValue || giftTypeSelected == "1")
        {
            if(printOpt != null)
            {
                printOpt[0].disabled = true;
                printOpt[0].checked = false;
                printOpt[1].checked = true;
            }
        }
        else
        {
            if(printOpt != null)
            {
                printOpt[0].disabled = false;
                printOpt[0].checked = true;
                printOpt[1].disabled = false;
            }        
        
        }
    }
}
/*----------------------------------------------------------------------------------------------------
  11/19/2007 Sweatt - SetSelectedAllocation handles the setting of the Allocation dropdrown when 
                      navigating back to the page on previous or an error gift/pledge
----------------------------------------------------------------------------------------------------*/
function SetSelectedAllocation() {
    if (typeof allocationInitValue == 'undefined')
        return;
    if (allocationInitValue != null) {
        var alloc   = document.getElementById('Allocation');
        if (alloc != null) {
            var options = alloc.options;
	        for(var index = 0; index < options.length; index++) {
                if(options[index].value == allocationInitValue)
                    options[index].selected = "selected";
            }
            SetAllocationHidden(alloc);
        }
    }        
}
/*----------------------------------------------------------------------------------------------------
  11/19/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/
function displayError(title, msg, error, type) {
    var myAlert = new Alert(_options);
    var image   = 'icon_exclamation';
    switch (type) {
        case 1: // exclamation
            image = 'icon_exclamation';
            break;
        case 2: // information
            image = 'icon_information';
            break;
        case 3: // question
            image = 'icon_question';
            break;
        case 4: // stop
            image = 'icon_stop';
            break;
        default: // exclamation
            image = 'icon_exclamation';
            break;                
    }
    var ex      = (error != null)? '<br /> Error description:' + error.description:'';
    myAlert.Dialog(title, 
                   '<div style=\'float:left;\'><img src=\'images/' + 
                   image + 
                   '.gif\' style=\'width:32px;height:32px;padding-right:15px;\' /></div><div style=\'\'>' + 
                   msg + 
                   ex + 
                   '</div>', 
                   'Ok');
}

/*----------------------------------------------------------------------------------------------------
  11/19/2007 Sweatt - Add Spec Scenarios
 <remarks>
 1.	Institution has System Option 140 set to 0 and System Option 141 to N.  
     Parameter for Allocation HOCKSCHOL (Hockey Scholarship Fund) is passed.  
     When donor goes to Make a Gift form, only Hockey Scholarship is shown in the Designation dropdown, 
     and the donor may not change it.
 2.	Institution has System Option 140 set to 0 and System Option 141 to Y.  
     Parameter for Allocation HOCKSCHOL (Hockey Scholarship Fund) is passed.  
     When donor goes to Make a Gift form, Hockey Scholarship is shown in the Designation dropdown, but the donor 
     may select another allocation from the dropdown.
 3.	Institution has System Option 140 set to 1 and System Option 141 set to N.  
     Parameter for Allocation Category ATH (Athletics) is passed.  
     When donor goes to Make a Gift form, only ATH category allocations are shown in the Designation dropdown, 
     and the donor may only select from the allocations displayed in this list.  
     Designation Category and Sub-Category are not displayed.
 4.	Institution has System Option 140 set to 1 and System Option 141 set to Y.  
     Parameter for Allocation Category ATH (Athletics) is passed.  
     When donor goes to Make a Gift form, Designation Category is displayed with ATH selected, and only ATH 
     category allocations are shown in the Designation dropdown.  
     However, the donor may select a different Designation Category, which would cause the available Designation 
     options to change.
 5.	Institution has System Option 140 set to 2 and System Option 141 to N.  
     Parameter for Allocation Category ATH (Athletics) is passed.  
     When donor goes to Make a Gift form, the Designation Category field is displayed, and only Allocation 
     Sub-Categories corresponding to the Allocation Category ATH are shown in the Designation Category dropdown.  
     The donor may select only from these Allocation Sub-Categories.
 6.	Institution has System Option 140 set to 2 and System Option 141 to Y.  
     Parameter for Allocation Category ATH (Athletics) is passed.  
     When donor goes to Make a Gift form, the Designation Category field is displayed, with ATH selected, and only Allocation 
     Sub-Categories corresponding to the Allocation Category ATH are shown in the Designation Sub-Category dropdown, 
     and corresponding Allocations are displayed in the Designation dropdown.  
     However, the donor may select a different Designation Category, which would cause the available Designation 
     Sub-Category and Designation options to change.
 7.	Institution has System Option 140 set to 2 and System Option 141 to N.  
     Parameters for Allocation Category ATH (Athletics) and Sub-Category HKY (Hockey) are passed.  
     When donor goes to Make a Gift form, only Athletics/Hockey allocations are shown in the Designation dropdown.  
     Designation Category and Sub-Category are not displayed.
 8.	Institution has System Option 140 set to 2 and System Option 141 to Y.  
     Parameters for Allocation Category ATH (Athletics) and Sub-Category HKY (Hockey) are passed.  
     When donor goes to Make a Gift form, the Designation Category and Sub-Category fields are displayed, set to ATH and HKY, 
     respectively, and only Athletics/Hockey allocations are shown in the Designation dropdown.  
     However the donor may change the Designation and Designation Category selections, thereby changing the allocations 
     available in the Designation dropdown.
 9.	Institution has System Option 140 set to 2 and System Option 141 to N.  
     Parameter for Allocation Category ATH (Athletics), Sub-Category HKY (Hockey), and Allocation HOCKSCHOL are passed.  
     When donor goes to Make a Gift form, only Hockey Scholarship is shown in the Designation dropdown, and the donor may 
     not change it.  
     Designation Category and Sub-Category are not displayed.
 10.	Institution has System Option 140 set to 2 and System Option 141 to Y.  
     Parameter for Allocation Category ATH (Athletics), Sub-Category HKY (Hockey), and Allocation HOCKSCHOL are passed.  
     When donor goes to Make a Gift form, Designation Category is displayed and set to ATH, Designation Sub-Category is 
     displayed and set to HKY, and Designation is set to HOCKSCHOL.  
     However, the donor may change any of these filters.
 11.	Institution has System Option 140 set to 0.  
     Parameter for Allocation Category ATH (Athletics) is passed.  
     he parameter is ignored, and all allocations display in the Designation dropdown.  
     Designation Category and Designation Sub-Category do not display.  
     This is regardless of the setting for System Option 141.
 12.	Institution has System Option 140 set to 1 and System Option 141 to N.  
     Parameters for Allocation Category ATH (Athletics) and Sub-Category HKY (Hockey) are passed.  
     The Sub-Category parameter is ignored, and when the donor goes to the Make a Gift form, only ATH category 
     allocations are shown in the Designation dropdown.  
     Designation Category and Sub-Category are not displayed.
 13.	Institution has System Option 140 set to 1 and System Option 141 to Y.  
     Parameters for Allocation Category ATH (Athletics) and Sub-Category HKY (Hockey) are passed.  
     The Sub-Category parameter is ignored, and when the donor goes to the Make a Gift form, Designation Category is 
     displayed and set to ATH, and allocations corresponding to the ATH Category are displayed in the Designation dropdown.  
     The donor may change this filter.
 </remarks>
----------------------------------------------------------------------------------------------------*/
function SetDropdownFromFilterParams(content) {
    try {
        // content is the Sytem Option 140 (Allocation Category and Sub-Category)
        //                Sytem Option 141 (Override Allocation Filtering Parameters) this will disable of enable the dropdowns
        var sys         = content.split('|');
        var ddCat       = document.getElementById('Cat');
        var ddSubCat    = document.getElementById('SubCat');
        var ddAlloc     = document.getElementById('Allocation');
        var cat         = queryString('catg');
        var subCat      = queryString('subg');
        var alloc       = queryString('alloc');
        var hasCat      = (cat     == null || cat     == 'false')? false:true;
        var hasSubCat   = (subCat  == null || subCat  == 'false')? false:true;
        var hasAlloc    = (alloc   == null || alloc   == 'false')? false:true;
                        
        switch (parseInt(sys[0])) {
            case 0: // Allocation Only
                if (hasAlloc) {
                    var options = ddAlloc.options;
                    for(var index = 0; index < options.length; index++) {
	                    if(options[index].value == alloc)
		                    options[index].selected = "selected";
                    }
                }
                // Set the hidden control Allocation text/value
                SetAllocationHidden(ddAlloc);
                // Override Control disabled, Remarks #11
                if (hasAlloc && sys[1] == "N")
                    ddAlloc.disabled = true;
                
                break;
            case 1: // Category and Allocation only
                // first select the Category option filter
                if (hasCat) {
                     var options = ddCat.options;
                     for(var index = 0; index < options.length; index++) {
	                    if(options[index].value == cat)
		                    options[index].selected = "selected";
                     }
                    // Need to fill the allocation dropdown with the categories of Category 
                    _ajax.callWebPage('AjaxServer.aspx?method=3', 
                                      Populate, 
                                      'POST', 
                                      ddCat.id + '=' + ddCat.value + '|' + ((ddSubCat == null)?'':ddSubCat.value), 
                                      ((ddSubCat == null)?3:1));
                }     
            
                // 11/19/2007 Sweatt - params will determine the controls on the form for Allocation filtering
                // Remarks #3, #12  hide, lblCategory, Cat controls
                if (((hasCat && sys[1] == "N") && (!hasSubCat && !hasAlloc)) ||
                    ((hasCat && sys[1] == "N") && (!hasAlloc))) {
                    var lblCat      = document.getElementById('lblCategory');
                    if (lblCat != null) {
                        if (lblCat.style.display == "none")
                            lblCat.style.display = "";
                        else
                            lblCat.style.display = "none";
                    }
                    if (ddCat != null) {
                        if (ddCat.style.display == "none")
                            ddCat.style.display = "";
                        else
                            ddCat.style.display = "none";
                    }
                }
                // Override Control disabled
                if ((!hasCat && sys[1] == "N") && hasAlloc) {
                    ddAlloc.disabled    = true;
                }             
                break;
            case 2: // Category, SubCategory and Allocation
                // first select the Category option filter
                // Remarks #8
                if ((hasCat && !hasSubCat) || 
                    (sys[1] == "Y" && (hasCat && hasSubCat))) {
                     var options = ddCat.options;
                     for(var index = 0; index < options.length; index++) {
	                    if(options[index].value == cat)
		                    options[index].selected = "selected";
                     }
                    // Need to fill the allocation dropdown with the categories of Category 
                    _ajax.callWebPage('AjaxServer.aspx?method=1', 
                                      Populate, 
                                      'POST', 
                                      'populatesubcat=' + ddCat.value + '|' + ((ddSubCat == null)?'':ddSubCat.value), 
                                      ((ddSubCat == null)?3:1));
                }    
                // 11/19/2007 Sweatt - params will determine the controls on the form for Allocation filtering
                // Remarks #5  hide, lblCategory, Cat controls
                if ((hasCat && sys[1] == "N") && (!hasSubCat && !hasAlloc)) {
                    var lblCat      = document.getElementById('lblCategory');
                    if (lblCat != null) {
                        if (lblCat.style.display == "none")
                            lblCat.style.display = "";
                        else
                            lblCat.style.display = "none";
                    }
                    if (ddCat != null) {
                        if (ddCat.style.display == "none")
                            ddCat.style.display = "";
                        else
                            ddCat.style.display = "none";
                    }
                }                    
                if (hasCat && hasSubCat) {
                    var options = ddSubCat.options;
                    for(var index = 0; index < options.length; index++) {
                        if(options[index].value == subCat)
                            options[index].selected = "selected";
                    }
                    // Need to fill the allocation dropdown with the SubCategories
                    _ajax.callWebPage('AjaxServer.aspx?method=2', 
                                      Populate, 
                                      'POST', 
                                      'populatealloc=' + ddCat.value + '|' + ddSubCat.value, 
                                      2);
                }   
                // Remarks #7  hide, lblCategory, Cat controls, lblSubCategory, SubCat controls
                if (((hasCat && hasSubCat) && sys[1] == "N")) {
                    var lblCat      = document.getElementById('lblCategory');
                    var lblSubCat   = document.getElementById('lblSubCategory');
                    if (lblCat != null) {
                        if (lblCat.style.display == "none")
                            lblCat.style.display = "";
                        else
                            lblCat.style.display = "none";
                    }
                    if (ddCat != null) {
                        if (ddCat.style.display == "none")
                            ddCat.style.display = "";
                        else
                            ddCat.style.display = "none";
                    }
                    if (lblSubCat != null) {
                        if (lblSubCat.style.display == "none")
                            lblSubCat.style.display = "";
                        else
                            lblSubCat.style.display = "none";
                    }
                    if (ddSubCat != null) {
                        if (ddSubCat.style.display == "none")
                            ddSubCat.style.display = "";
                        else
                            ddSubCat.style.display = "none";
                    }
                }
                // remarks #9, have the Allocation Dropdown be selected, using the populate function
                if (hasCat && hasSubCat && hasAlloc) {
                    _ajax.callWebPage('AjaxServer.aspx?method=3', 
                                      Populate, 
                                      'POST', 
                                      'populatesubcat=' + ddCat.value + '|' + ddSubCat.value, 
                                      3);
                }
                // Override allocation dropdown Control to be disabled
                if (((!hasCat || !hasSubCat) && sys[1] == "N") && hasAlloc)
                    ddAlloc.disabled    = true;
                else if ((sys[1] == "N" && hasAlloc) && (hasCat && hasSubCat))
                    ddAlloc.disabled    = true;
                    
                break;        
        }
    } catch (ex) {
        displayError('Make A Gift','unsuccessful setting dropdown values from filtered query string parameters', ex, 1) 
        return;
    }
}
//var cookie;
function PopulateFromQueryParams() {
    try {
        var qCat        = '';
        var qSubCat     = '';
        var qAlloc      = '';
        var hasCat      = false;
        var hasSubCat   = false;
        var hasAlloc    = false;
        // Get Value from the querystring
        qCat        = queryString('catg');
        qSubCat     = queryString('subg');
        qAlloc      = queryString('alloc');
        hasCat      = (qCat     == null || qCat     == 'false')? false:true;
        hasSubCat   = (qSubCat  == null || qSubCat  == 'false')? false:true;
        hasAlloc    = (qAlloc   == null || qAlloc   == 'false')? false:true;
        if (hasCat || hasSubCat || hasAlloc)
            _ajax.callWebPage("AjaxServer.aspx?method=4", SetDropdownFromFilterParams, "POST", null, null, 2); 
    } catch (ex) {
        displayError('Make A Gift','unsuccessful populate controls from query parameters', ex, 1); 
        return;
    }
}
/*----------------------------------------------------------------------------------------------------
 10/26/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 Removes leading and ending whitespaces
 10/30/2007 Sweatt - Add trim function
----------------------------------------------------------------------------------------------------*/
function trim(value) {
	return LTrim(RTrim(value));
}
/*----------------------------------------------------------------------------------------------------
 10/30/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------
 Added Cookie Support to Gift 
 11/14/2007 Sweatt - Cookie Function
----------------------------------------------------------------------------------------------------*/
function AWCCookie(name, duration, path, domain, secure) {
    this.affix = "";
    if(duration) {
        var date        = new Date();
        var curTime     = new Date().getTime();
        date.setTime(curTime + (1000 * 60 * duration));
        this.affix      = "; expires=" + date.toGMTString();
    }
    if(path)
        this.affix += "; path=" + path;
    if(domain)
        this.affix += "; domain=" + domain;
    if(secure)
        this.affix += "; secure=" + secure;

    function getValue() {
        var match       = document.cookie.match(new RegExp("(" + name + "=[^;]*)(;|$)"));
        return match ? match[1] : null;
    }
    this.cookieExists       = function() {
        return ((getValue())? true:false);
    }
    this.cookieEnabled      = function() {
        return ((document.cookie == '')? true:false);
    }
    this.expire             = function() {
        var date        = new Date();
        date.setFullYear(date.getYear() - 1);
        document.cookie = name + "=noop; expires=" + date.toGMTString();
    }
    this.setSubValue        = function(key, value) {
        var check       = getValue();
        if(/[;, ]/.test(value))
            value       = window.encodeURI ? encodeURI(value) : escape(value);  // mac/IE doesn't support encodeURI

        if(value) {
            var attributes = "@" + key + value;
            if(check) {
                if(new RegExp("@" + key).test(check))
                    document.cookie = check.replace(new RegExp("@" + key + "[^@;]*"), attributes) + this.affix;
                else
                    document.cookie = check.replace(new RegExp("(" + name + "=[^;]*)(;|$)"), "$1" + attributes) + this.affix;
            } else
                document.cookie = name + "=" + attributes + this.affix;
        } else {
            if(new RegExp("@" + key).test(check))
                document.cookie = check.replace(new RegExp("@" + key + "[^@;]*"), "") + this.affix;
        }
    }
    this.getSubValue        = function(key) {
        var check       = getValue();
        if(check) {
            var match   = check.match(new RegExp("@" + key + "([^@;]*)"));
            if(match) {
                var value = match[1];
                if(value)
                    return window.decodeURI ? decodeURI(value) : unescape(value); //mac/IE doesn't support decodeURI
            }
        }
    }
}
/*----------------------------------------------------------------------------------------------------
 11/14/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------
 Added the Class Notes View Picture code for Metadata drive search system 163 = Y TT# 
 11/14/2007 Sweatt 
----------------------------------------------------------------------------------------------------*/
function iFramePicture(id, seq) {
    iFrameDisplay("iframePictures", 
                  GetFullyQualifiedPath() + 
                  "iFrame.aspx?AppId=825&id_number=" + 
                  id + 
                  "&xsequence=" + 
                  seq, 
                  "600", 
                  "700");
}
/*----------------------------------------------------------------------------------------------------
 11/14/2007 Sweatt - End
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
 Added the Class Notes View Picture code To pass the source to Iframe to FIX TT-1988
 11/29/2007 RS[SOS]
----------------------------------------------------------------------------------------------------*/
function iFramePicture(id, seq, src) {
    iFrameDisplay("iframePictures", 
                  GetFullyQualifiedPath() + 
                  "iFrame.aspx?AppId=825&id_number=" + 
                  id + 
                  "&xsequence=" + 
                  seq + 
                  "&note_src=" + 
                  src, 
                  "600", 
                  "700");
}

/*----------------------------------------------------------------------------------------------------
 11/15/2007 Sweatt - Javascript Encryption
----------------------------------------------------------------------------------------------------*/
