/*
?2003 Bullhorn, Inc. All rights reserved<BR>
*/
var isNS = (navigator.appName == "Netscape");
var isMacIE = ( navigator.userAgent.indexOf("Mac") > -1 );
var layerRef = (isNS) ? "document" : "document.all";
var styleRef = (isNS) ? "" : ".style";

var originalWindowName = window.name;
var isWindowPinned = false;
var pinImgOn = new Image();
var pinImgOff = new Image();

var currentSpellCheckObj = null;
var bhsWindowManagerObj = null;

var topWindow = top;
var i = 0;

try {
    while (topWindow.frameElement) {
        if (i++ > 20) break;
        topWindow = topWindow.frameElement.document.parentWindow;    
    } 
} catch(e) {
    // do nothing
}    

if (typeof(topWindow.getBHSWindowManager) != "undefined") {
    try {
        bhsWindowManagerObj = topWindow.getBHSWindowManager();
    } catch (e) {
        //alert(e.description);
        //can't attach to window manager.
    }
}

pinImgOn.src = '/BullhornStaffing/images/icons/pinDown.gif';
pinImgOff.src = '/BullhornStaffing/images/icons/pinUp.gif';

var bhHeadingNavActiveMenuItem = null;

var objOffsetX = 0;
var objOffsetY = 0;

var bodyIsLoaded = false;

function bhWindowOpen(sLocation, sName, sOptions) {
    if (bhsWindowManagerObj == null) {
        if (sOptions == null) {
            sOptions = "toolbar,menubar,location,scrollbars,resizable";
        }
        
        if (sName == null) {
            sName = "";
        }
        return window.open(sLocation, sName, sOptions);
    } else {
        var windowType = "tracked";
        if (sOptions != null) {
            if (sOptions.indexOf("height") > -1
                || sOptions.indexOf("width") > -1
                || sOptions.indexOf("toolbar") > -1
                || sOptions.indexOf("menubar") > -1) {
                windowType = "new";
            }
        }
        return bhsWindowManagerObj.openWindow(sName, sLocation, windowType, sOptions, window);
    }
}

function dragStartObject(obj) {
    objOffsetX = event.offsetX;
    objOffsetY = event.offsetY;
}

function dragObject(obj) { 
    obj.style.pixelLeft = Math.max(obj.style.pixelLeft + event.offsetX - objOffsetX, 0);
    obj.style.pixelTop = Math.max(obj.style.pixelTop + event.offsetY - objOffsetY, 0);
}

function bhBodyOnLoad() {
    if (! bodyIsLoaded 
        && ! isNS) {
        
        bodyIsLoaded = true;
        
        if (window == topWindow
            || typeof(topWindow.showPopWindowIFRAME) == "undefined") {
            document.body.insertAdjacentHTML('beforeEnd','<table width="630" height="400" cellpadding="0" cellspacing="0" border="0" style="z-index:100; display:none; position:absolute; border:outset 1px; top:0;" id="popWindowIFRAMEContainer" isMinimized="FALSE"><tr><td><table cellpadding=0 cellspacing=0 border=0 width="100%" height="100%"><tr style="background-color:#cc3333;"><td height="16" width="100%"><a href="#" style="width:100%;" onclick="return false;" ondragStart="dragStartObject(popWindowIFRAMEContainer);" ondrag="dragObject(popWindowIFRAMEContainer);"><img src="/BullhornStaffing/Images/TopBanner/IFRAMELeft.gif" width="17" height="16" border="0"></a></td><td align="right" valign="top"><a href="#" onclick="minimizePopWindowIFRAME(); return false;" onmouseover="document.images[\'popWindowRedIFRAMEMinimizeImg\'].src = \'/BullhornStaffing/Images/TopBanner/RedIFRAMEMinimizeOn.gif\';" onmouseout="document.images[\'popWindowRedIFRAMEMinimizeImg\'].src = \'/BullhornStaffing/Images/TopBanner/RedIFRAMEMinimizeOff.gif\';"><img name="popWindowRedIFRAMEMinimizeImg" src="/BullhornStaffing/Images/TopBanner/RedIFRAMEMinimizeOff.gif" width="14" height="14" border="0"></a>&nbsp;<a href="#" onclick="restorePopWindowIFRAME(); return false;" onmouseover="document.images[\'popWindowIFRAMERestoreImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMERestoreOn.gif\';" onmouseout="document.images[\'popWindowIFRAMERestoreImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMERestoreOff.gif\';"><img name="popWindowIFRAMERestoreImg" src="/BullhornStaffing/Images/TopBanner/IFRAMERestoreOff.gif" width="14" height="14" border="0"></a>&nbsp;<a href="#" onclick="document.all.popWindowIFRAMEContainer.style.display=\'none\'; popWindowIFRAME.window.location=\'/Blank.htm\'; return false;" onmouseover="document.images[\'popWindowIFRAMECloseImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMECloseOn.gif\';" onmouseout="document.images[\'popWindowIFRAMECloseImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMECloseOff.gif\';"><img name="popWindowIFRAMECloseImg" src="/BullhornStaffing/Images/TopBanner/IFRAMECloseOff.gif" width="14" height="14" border="0"></a>&nbsp;</td></tr><tr><td colspan=2><iframe id="popWindowIFRAME" name="popWindowIFRAME" src="/Blank.htm" width="100%" height="100%" scrolling="Auto" style="border: 1px outset;" frameborder="0"></iframe></td></tr></table></td></tr></table>');
        } 
        
        if (window.name != 'pickerWindowIFRAME') {
            document.body.insertAdjacentHTML('beforeEnd','<table width="450" height="250" cellpadding="0" cellspacing="0" border="0" style="z-index:100; display:none; position:absolute; border:outset 1px; top:0;" id="spellCheckerIFRAMEContainer"><tr><td><table cellpadding=0 cellspacing=0 border=0 width="100%" height="100%"><tr style="background-color:#cc3333;"><td height="16" width="100%"><a href="#" style="width:100%;" onclick="return false;" ondragStart="dragStartObject(spellCheckerIFRAMEContainer);" ondrag="dragObject(spellCheckerIFRAMEContainer);"><img src="/BullhornStaffing/Images/TopBanner/IFRAMELeft.gif" width="17" height="16" border="0"></a></td><td align="right" valign="top"><a href="#" onclick="document.all.spellCheckerIFRAMEContainer.style.display=\'none\'; spellCheckerIFRAME.window.location=\'/Blank.htm\'; return false;" onmouseover="document.images[\'spellCheckerIFRAMECloseImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMECloseOn.gif\';" onmouseout="document.images[\'spellCheckerIFRAMECloseImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMECloseOff.gif\';"><img name="spellCheckerIFRAMECloseImg" src="/BullhornStaffing/Images/TopBanner/IFRAMECloseOff.gif" width="14" height="14" border="0"></a>&nbsp;</td></tr><tr><td colspan=2><iframe id="spellCheckerIFRAME" name="spellCheckerIFRAME" src="/Blank.htm" width="100%" height="100%" scrolling="Auto" style="border: 1px outset;" frameborder="0"></iframe></td></tr></table></td></tr></table>');
        } 
        
        if (window.name != 'pickerWindowIFRAME') {
            document.body.insertAdjacentHTML('beforeEnd','<table width="530" height="400" cellpadding="0" cellspacing="0" border="0" style="z-index:100; display:none; position:absolute; border:outset 1px; top:0;" id="pickerWindowIFRAMEContainer"><tr><td><table cellpadding=0 cellspacing=0 border=0 width="100%" height="100%"><tr style="background-color:#cc3333;"><td height="16" width="100%"><a href="#" style="width:100%;" onclick="return false;" ondragStart="dragStartObject(pickerWindowIFRAMEContainer);" ondrag="dragObject(pickerWindowIFRAMEContainer);"><img src="/BullhornStaffing/Images/TopBanner/IFRAMELeft.gif" width="17" height="16" border="0"></a></td><td align="right" valign="top"><a href="#" onclick="document.all.pickerWindowIFRAMEContainer.style.display=\'none\'; pickerWindowIFRAME.window.location=\'/Blank.htm\'; return false;" onmouseover="document.images[\'pickerWindowIFRAMECloseImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMECloseOn.gif\';" onmouseout="document.images[\'pickerWindowIFRAMECloseImg\'].src = \'/BullhornStaffing/Images/TopBanner/IFRAMECloseOff.gif\';"><img name="pickerWindowIFRAMECloseImg" src="/BullhornStaffing/Images/TopBanner/IFRAMECloseOff.gif" width="14" height="14" border="0"></a>&nbsp;</td></tr><tr><td colspan=2><iframe id="pickerWindowIFRAME" name="pickerWindowIFRAME" src="/Blank.htm" width="100%" height="100%" style="border: 1px outset;" scrolling="Auto" frameborder="0"></iframe></td></tr></table></td></tr></table>');
        } 
        
        if (currentURL == null) var currentURL = window.location;
            
        if (! isMacIE) { 
            if (bhsWindowManagerObj != null) {
                bhsWindowManagerObj.registerChild(window);
                document.attachEvent("onmousedown", mouseDownHandle);
                document.attachEvent("onkeydown", keyDownHandle);
            } 

            document.attachEvent("onkeypress", keyPressHandle);
            
            window.attachEvent("onbeforeprint", beforePrintHandle);
            window.attachEvent("onafterprint", afterPrintHandle);
            
            if (typeof(writeMenus) != 'undefined') writeMenus();
        }
        //bhInitTextBlocks();
            
        focusFirstTextBox();
    
    }
}

function beforePrintHandle() {
    
    /* return if you're not the active window*/
    if (bhsWindowManagerObj != null
        && typeof(bhsWindowManagerObj.getActiveWindow) != undefined) {
        if (bhsWindowManagerObj.getActiveWindow().windowObj != window
            && window.location.toString().toLowerCase().indexOf("usermessage_preview.cfm") <= 0) {
            return;
        }
    }
    
    var col = document.all.tags("span");
    var i = 0;
    var obj = null;
    colLen = col.length;
    for (i=0;i<col.length;i++) {
        obj = col[i];
        switch (obj.className) {
        	case "ExpandableSection":
        		obj.style.overflowY="visible";
        		break;
			case "HideOnPrint":
        		obj.style.display="none";
        		break;
        	case "ShowOnPrint":
        		obj.style.display="block";
        		break;
        }        
    }
    
    var col = document.all.tags("table");
    var i = 0;
    var obj = null;
    colLen = col.length;
    for (i=0;i<col.length;i++) {
        obj = col[i];
        switch (obj.className) {
        	case "cfdebug":
        		obj.parentNode.removeChild(obj);
        		break;
        }        
    }           
    
    //if this page should not be printable, hide the document body
    if (typeof(document.all.bhDisablePrintingOnThisPage) != "undefined") {
        alert("You do not have sufficient entitlements to print this page. Only a blank page will be printed");
        document.body.style.display = "none";
    }
}

function afterPrintHandle() {
	
    if (bhsWindowManagerObj != null
        && typeof(bhsWindowManagerObj.getActiveWindow) != undefined) {
        if (bhsWindowManagerObj.getActiveWindow().windowObj != window
            && window.location.toString().toLowerCase().indexOf("usermessage_preview.cfm") <= 0) {
            return;
        }
    }
    var col = document.all.tags("span");
    var i = 0;
    var obj = null;
    colLen = col.length;
    for (i=0;i<col.length;i++) {
        obj = col[i];
        switch (obj.className) {
        	case "ExpandableSection":
        		obj.style.overflowY="auto"; 
        		break;
			case "HideOnPrint":
        		obj.style.display="block";
        		break;
        	case "ShowOnPrint":
        		obj.style.display="none";
        		break;        		
        }            
    }       
    
    //un-hide the screen after printing
    if (document.body.style.display == "none"
        && typeof(document.all.bhDisablePrintingOnThisPage) != "undefined") {
        document.body.style.display = "";
    } else {
        //log the print to the server
        var printXMLHttp=getXMLHTTP();
    
        url = "/BullhornSTAFFING/Update/UpdPagePrintRequest.cfm?pageTitle=" + URLEncodedFormat(document.title) + "&pageURL=" + URLEncodedFormat(window.location) + "&nocachetoken=" + new Date().getTime();
        printXMLHttp.open("GET", url, true);
        printXMLHttp.send();
    }
}

function expandExpandableSection(element, button) {
    if (element.style.overflowY.toLowerCase() != "visible") {
        element.style.overflowY = "visible";
        element.title = "Double-click to collapse this section";
        if (button != null
            && button.innerText == "Expand") {
            button.innerText = "Collapse";
            button.title = "Click to collapse this section";
        }
    } else {
        element.style.overflowY = "auto";
        element.title = "Double-click to expand this section";
        if (button != null
            && button.innerText == "Collapse") {
            button.innerText = "Expand";
            button.title = "Click to expand this section";
        }
    }
}

var textBlocksInitialized = false;

function bhInitTextBlocks() {
    try {
        if (! textBlocksInitialized
            && typeof(bhTextBlockInitalizers) != "undefined"
            && bhTextBlockInitalizers != null) {
            for (i = 0; i < bhTextBlockInitalizers[0].length; i++) {
                bhTextBlockInitalizers[0][i].setHTML(bhTextBlockInitalizers[1][i].value);
            }
            
            textBlocksInitialized = true;
        }    
    } catch (e) {
        alert(e.description);
        // do nothing
    }
}

function getMiniPickerObj() {
    if (window.miniPickerObj == null) {
        window.miniPickerAttributes = new Object();
        window.miniPickerAttributes.activeObject = null;
        
        window.miniPickerObj = document.createElement("<DIV style=\"display:inline;\"/>");        
    }
    
    return window.miniPickerObj;
}

function mouseDownHandle() {
    if (window != topWindow
        && typeof(topWindow.childWindowMouseDownHandle) != "undefined") {
        topWindow.childWindowMouseDownHandle(event);
    }
}

function keyDownHandle() {
    if (typeof(userMessage_keyDownHandle) != "undefined"
        && userMessage_keyDownHandle != null) {
        userMessage_keyDownHandle(window.event);
    }
    
    if (window != topWindow
        && typeof(topWindow.childWindowKeyDownHandle) != "undefined") {
        topWindow.childWindowKeyDownHandle(event);
    }
    if (event.keyCode == 112) {
        showBullhornHelp();
        event.cancelBubble = true;
        event.returnValue = false;
        return false;
    }
}

function keyPressHandle() { 
    var ignoreForward = false;
    var ignoreNext = false;
    if (typeof(userMessage_keyPressHandle) != "undefined"
        && userMessage_keyPressHandle != null) {
        userMessage_keyPressHandle(window.event);
        ignoreForward = true;
        ignoreNext = true;
    }
    
    if (window.event.ctrlKey) {
        if (window.event.shiftKey) {
            switch (window.event.keyCode) {
                case 1: // A is for Appointment
                    showPopWindowIFRAME("/BullhornStaffing/Schedule/Forms/EditSchedule.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE");
                    event.cancelBubble = true;
                    event.returnValue = false;
                    return false;
                    break;
                case 20: // T is for Task
                    showPopWindowIFRAME("/BullhornStaffing/Schedule/Forms/EditSchedule.cfm?noLogo=TRUE&closeOnFinish=TRUE&isTask=1&reloadOpener=FALSE");
                    event.cancelBubble = true;
                    event.returnValue = false;
                    return false;
                    break;
                case 3: // C is for Compose a message
                    showPopWindowIFRAME("/BullhornStaffing/Portfolio/Forms/EditUserMessage.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE");
                    event.cancelBubble = true;
                    event.returnValue = false;
                    return false;
                    break;
                case 14: // N is for add a note
                    if (! ignoreNext) {
                        showPopWindowIFRAME("/BullhornStaffing/Forms/EditUserComment.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE");
                    }
                    event.cancelBubble = true;
                    event.returnValue = false;
                    return false;
                    break;
                case 6: // F is for forward a page
                    if (! ignoreForward) {
                        showPopWindowIFRAME("/BullhornStaffing/Portfolio/Forms/EditUserMessage.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&presignatureComments=" + escape("<a href=\"" + window.location + "\">" + document.title + "</a>"));
                        //forwardCurrentURLForm.submit();
                    }
                    event.cancelBubble = true;
                    event.returnValue = false;
                    return false;
                    break;
                case 7: // G is for forward a page
                    showPopWindowIFRAME("/BullhornStaffing/QuickFind.cfm");
                    event.cancelBubble = true;
                    event.returnValue = false;
                    return false;
                    break;
            }
        }
    }
    
    if (window.event.keyCode == 27) {
    
        if (window.name == "popWindowIFRAME") {     
            hideME(0, false);
        }
        
        if (bhsWindowManagerObj != null) 
        {
            windowObj = bhsWindowManagerObj.findWindow(window.name);
            if (windowObj != null) {
                if (windowObj.windowType == "tabbed") {
                    hideME(0, false);
                }                
            }
            
        }

    } 
    
    if (window != topWindow
        && typeof(topWindow.childWindowKeyPressHandle) != "undefined") {
        topWindow.childWindowKeyPressHandle(event);
    }
    return true;
}

function showBullhornHelp(helpIndex,pageIndex) {
    if (helpIndex == null) {
        helpIndex = "";
    } else {
        helpIndex = "/" + helpIndex;
    }
    if (pageIndex == null) {
        pageIndex = "";
    } else {
        pageIndex = "#" + pageIndex;
    }
    bhWindowOpen("http://www.bullhornstaffing.com/BullhornHelp" + helpIndex + "/Bullhorn_Online_Help.htm" + pageIndex, 'BHHelpWindow', 'scrollbars,height=600,width=870,resizable');
}

function showPopWindowIFRAME(sLocation, smallIFRAME, tabbedIFRAME, newWindowID) {    
    
    // default optional parameters
    if (smallIFRAME == null) smallIFRAME = false;   
    if (tabbedIFRAME == null) tabbedIFRAME = false;           
                        
    // handle messages, schedules and quickfind seperately ...
    if (bhsWindowManagerObj != null
        && ( sLocation.toLowerCase().indexOf("/portfolio/forms/editusermessage.cfm") > -1
        || sLocation.toLowerCase().indexOf("/schedule/forms/editschedule.cfm") > -1
        || sLocation.toLowerCase().indexOf("/schedule/schedule.cfm") > -1
	|| sLocation.toLowerCase().indexOf("/calendar/schedule.cfm") > -1
        || sLocation.toLowerCase().indexOf("/jobposting/sendjobposting.cfm") > -1
        || sLocation.toLowerCase().indexOf("/quickfind.cfm") > -1)
        || tabbedIFRAME
        ) {        
                    
        // ... by launching them in their own window
        if (tabbedIFRAME) {
        
            // if where was a windowID passed in, use that!!!
            if (newWindowID != null) {
                var windowID = newWindowID;   
                return bhsWindowManagerObj.openWindow(windowID, sLocation, 'tabbed', null, window);
            } else {
                var windowID = 'TabbedWindowIFRAMEWnd' + Math.round(Math.random() * 1000);        
                return bhsWindowManagerObj.openWindow(windowID, sLocation, 'tabbed', null, window);            
            }
        } else {
            var windowID = 'PopWindowIFRAMEWnd' + Math.round(Math.random() * 1000);        
            return bhsWindowManagerObj.openWindow(windowID, sLocation, 'tracked', null, window);
        }
    }           
        
    // this is not a reusable window
    if (window.name != 'popWindowIFRAME') {    
       
        // if this window is not the top window, and it's not undefined
        if (window != topWindow && typeof(topWindow.showPopWindowIFRAME) != "undefined") {        

            return topWindow.showPopWindowIFRAME(sLocation, smallIFRAME, tabbedIFRAME);
        }        
        
        popWindowIFRAMEContainer.style.top = document.body.scrollTop + 10 + (bhsWindowManagerObj?50:0);
        popWindowIFRAMEContainer.style.left = document.body.scrollLeft + 10 + (bhsWindowManagerObj?140:0);
                
        if (smallIFRAME) {
            popWindowIFRAMEContainer.style.height = 150;
            popWindowIFRAMEContainer.style.width = 250;
        } else {
            popWindowIFRAMEContainer.style.height = 525;
            popWindowIFRAMEContainer.style.width = 630;
        }
        
        popWindowIFRAMEContainer.style.display = "block";
        popWindowIFRAME.window.location.replace(sLocation);
        popWindowIFRAME.focus();
        
    // if the window name is popWindowIFRAME, then this is a "generic window" == reusable
    } else {
        topWindow.document.all.popWindowIFRAMEContainer.style.display = "block";
        window.location = sLocation;
    }
    
}

function minimizePopWindowIFRAME() {
    if (popWindowIFRAMEContainer) {
            
        popWindowIFRAMEContainer.style.height = 45;
        popWindowIFRAMEContainer.style.width = 200;
        popWindowIFRAMEContainer.style.top = document.body.clientHeight - 45;
        popWindowIFRAME.document.body.style.overflow = "hidden";
            
    }
}

function restorePopWindowIFRAME() {
    if (popWindowIFRAMEContainer) {
        popWindowIFRAMEContainer.style.height = 525;
        popWindowIFRAMEContainer.style.width = 630;
        popWindowIFRAMEContainer.style.top = document.body.scrollTop + 10 + (bhsWindowManagerObj?50:0);
        
        popWindowIFRAME.document.body.style.overflow = "auto";
        
    }
}

function showSpellCheckerWithSubjectIFRAME(sObjRef, sAttributeRef, confirmComplete, subjectRef, subjectAttributeRef) {
    
    if (typeof(confirmComplete) == "undefined") {
        confirmComplete = true;
    }

    try {
        var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
        subObj = eval(subjectRef);
        isComplete = tmpis.CheckDocumentNode2(subObj, true);
        
        //Check whether user cancels spellcheck. If not, continue to spellcheck email body.
        if (isComplete > 0) {
            obj = eval(sObjRef);
            isComplete = tmpis.CheckDocumentNode2(obj, !confirmComplete);                                     
        } 
        
        if (isComplete > 0) {
            //let the calling page know that the spell checker is done
            try { 
                if (typeof(spellCheckComplete) != "undefined") {
                    spellCheckComplete(); 
                }
            } catch(e) {
                //do nothing
                //alert("Error completing spellchecker" + e.description);
            }
        } else {
            //let the calling page know that the spell checker is done
            try { 
                if (typeof(spellCheckCancel) != "undefined") {
                    spellCheckCancel(); 
                }
            } catch(e) {
                //do nothing
                //alert("Error completing spellchecker" + e.description);
            }
        }
        
        return;
    } catch(e) {
        //activeX control IESpell not found, use old spell checker
        //alert("activeX control IESpell not found, use old spell checker\n\n" + e.description);
    }
    
    currentSpellCheckObj = null;
    try {
        currentSpellCheckObj = eval(sObjRef);
    } catch(e) {
        alert("Error in call to showSpellCheckerIFRAME:" + e.description);
    }
    var spellCheckURL = "/Activedit/inc/spellchecker/window.cfm?jsvar=" + URLEncodedFormat(sObjRef + "." + sAttributeRef) + "&subjectvar=" + URLEncodedFormat(subjectRef + "." + subjectAttributeRef);
    
    if (window.name != 'spellCheckerIFRAME') {
        spellCheckerIFRAMEContainer.style.display = "block";
        spellCheckerIFRAMEContainer.style.top = document.body.scrollTop + 10 + (bhsWindowManagerObj?100:0);
        spellCheckerIFRAMEContainer.style.left = document.body.scrollLeft + 10 + (bhsWindowManagerObj?200:0);
        
        spellCheckerIFRAME.window.location.replace(spellCheckURL);
        //spellCheckerIFRAME.window.document.body.focus();
    } else {
        parent.spellCheckerIFRAMEContainer.style.display = "block";
        location.replace(spellCheckURL);
    }    
}

function showSpellCheckerIFRAME(sObjRef, sAttributeRef, confirmComplete) {
    
    if (typeof(confirmComplete) == "undefined") {
        confirmComplete = true;
    }

    try {
        var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
        obj = eval(sObjRef);
        isComplete = tmpis.CheckDocumentNode2(obj, !confirmComplete);
        
        if (isComplete > 0) {
            //let the calling page know that the spell checker is done
            try { 
                if (typeof(spellCheckComplete) != "undefined") {
                    spellCheckComplete(); 
                }
            } catch(e) {
                //do nothing
                //alert("Error completing spellchecker" + e.description);
            }
        } else {
            //let the calling page know that the spell checker is done
            try { 
                if (typeof(spellCheckCancel) != "undefined") {
                    spellCheckCancel(); 
                }
            } catch(e) {
                //do nothing
                //alert("Error completing spellchecker" + e.description);
            }
        }
        
        return;
    } catch(e) {
        //activeX control IESpell not found, use old spell checker
        //alert("activeX control IESpell not found, use old spell checker\n\n" + e.description);
    }
    
    currentSpellCheckObj = null;
    try {
        currentSpellCheckObj = eval(sObjRef);
    } catch(e) {
        alert("Error in call to showSpellCheckerIFRAME:" + e.description);
    }
    
    if (window.name != 'spellCheckerIFRAME') {
        spellCheckerIFRAMEContainer.style.display = "block";
        spellCheckerIFRAMEContainer.style.top = document.body.scrollTop + 10 + (bhsWindowManagerObj?100:0);
        spellCheckerIFRAMEContainer.style.left = document.body.scrollLeft + 10 + (bhsWindowManagerObj?200:0);
        spellCheckerIFRAME.window.location.replace("/Activedit/inc/spellchecker/window.cfm?jsvar=" + URLEncodedFormat(sObjRef + "." + sAttributeRef));
        //spellCheckerIFRAME.window.document.body.focus();
    } else {
        parent.spellCheckerIFRAMEContainer.style.display = "block";
        location.replace("/Activedit/inc/spellchecker/window.cfm?jsvar=" + URLEncodedFormat(sObjRef + "." + sAttributeRef));
    }    
}

function spellCheckerComplete() { 
    if (currentSpellCheckObj != null) { 
        currentSpellCheckObj.focus(); 
    } else { 
        window.focus(); 
    } 
    
    currentSpellCheckObj = null;
}

function hideME(sWait, sReloadParent, sParentLocation) {
    var waitTimeout = 0;
    var reloadParent = false;
    var parentLocation = null;
    
    if (hideME.arguments.length > 0) {
        waitTimeout = sWait;
    } 
    if (hideME.arguments.length > 1) {
        reloadParent = sReloadParent;
    } 
    if (hideME.arguments.length > 2) {
        parentLocation = sParentLocation;
    } 
        
    if (bhsWindowManagerObj != null) {
        var action = "";
        if (reloadParent) {
            if (window.name == 'popWindowIFRAME'
                || window.name == 'pickerWindowIFRAME') {
                bhsWindowManagerObj.refreshActiveWindow(parentLocation);
            } else {
                bhsWindowManagerObj.refreshActiveWindowParent(parentLocation);                
            }
        } 
        
        
        if (window.name == 'popWindowIFRAME') {
            action += "topWindow.focus(); topWindow.document.all.popWindowIFRAMEContainer.style.display = 'none'; window.location = '/Blank.htm';";
        } else if (window.name == 'pickerWindowIFRAME') {
            action += "parent.document.all.pickerWindowIFRAMEContainer.style.display = 'none'; window.location = '/Blank.htm';";
        } else if (window.name == 'spellCheckerIFRAME') {
            action += "parent.spellCheckerComplete(); parent.document.all.spellCheckerIFRAMEContainer.style.display = 'none'; window.location = '/Blank.htm';" 
        } else {
            action += "bhsWindowManagerObj.closeActiveWindow();";
        }
        
        if (waitTimeout > 0) {
            setTimeout(action, waitTimeout); 
        } else {
            eval(action);
        }
    } else {
        if (window.name == 'popWindowIFRAME') {
            var action = " topWindow.document.all.popWindowIFRAMEContainer.style.display = 'none'; window.location = '/Blank.htm';";
            //parent.focus();
            if (reloadParent) {
                if (parentLocation != null) {
                    action = "window.parent.location = '" + parentLocation + "'; " + action;
                } else {
                    action = "window.parent.location.reload(); " + action;
                }
            } 
            setTimeout(action, waitTimeout);
        } else if (window.name == 'pickerWindowIFRAME') {
            var action = "parent.document.all.pickerWindowIFRAMEContainer.style.display = 'none'; window.location = '/Blank.htm';";
            //window.parent.focus(); 
            if (reloadParent) {
                if (parentLocation != null) {
                    action = "window.parent.location = '" + parentLocation + "'; " + action;
                } else {
                    action = "window.parent.location.reload(); " + action;
                }
            } 
            if (waitTimeout > 0) {
                setTimeout(action, waitTimeout); 
            } else {
                eval(action);
            }
        } else if (window.name == 'spellCheckerIFRAME') {
            action = "parent.spellCheckerComplete(); parent.document.all.spellCheckerIFRAMEContainer.style.display = 'none'; window.location = '/Blank.htm';";
            
            if (waitTimeout > 0) {
                setTimeout(action, waitTimeout); 
            } else {
                eval(action);
            }
        } else {
            if (window.opener && 
                ! window.opener.closed) {
                if (reloadParent) {
                    // try to find the window manager for the opener.
                    var openerWindowManagerObj = null;
                    if (typeof(window.opener.getBHSWindowManager) != "undefined") {
                        try {
                            openerWindowManagerObj = window.opener.getBHSWindowManager();
                        } catch (e) {
                            //can't attach to window manager.
                        }
                    }

                    if (openerWindowManagerObj != null) {
                        openerWindowManagerObj.refreshActiveWindow(parentLocation);
                    } else {
                        if (parentLocation != null) {
                            window.opener.location = parentLocation;
                        } else {
                            window.opener.location.reload();
                        }
                    }
                }
            } 
            
            if (waitTimeout > 0) {
                setTimeout("window.close();", waitTimeout); 
            } else {
                window.close();
            }
        } 
    }
    
}

function checkBackToList() {
    if (window.name == 'popWindowIFRAME') { 
        hideME(); 
        return false; 
    }
    
    if (bhsWindowManagerObj != null) {
        
        bhsWindowManagerObj.closeActiveWindow(C_ACTIVATE_PARENT);
        return false;
    } else {
        hideME(0, false);
    }
}

function ignoreErrors(sMsg,sUrl,sLine) {
    window.status = "Error: " + sMsg;
    window.status += "; Line: " + sLine;
    window.status += "; URL: " + sUrl;
    return true;
}

function checkBHSFrameState() {
    if (bhsWindowManagerObj == null) {
        window.location = "/BullhornSTAFFING/MainFrame.cfm?goToURL=" + URLEncodedFormat(currentURL);
    }
}

function focusFirstTextBox() {
    if (isNS || isMacIE) return true;
    
    if (window.location.hash.length <= 0) {
        if (bhsWindowManagerObj != null) {
            if (bhsWindowManagerObj.getActiveWindow().windowObj != window
                && window.name != 'pickerWindowIFRAME'
                && window.name != 'popWindowIFRAME'
                && window.name != 'spellCheckerIFRAME') {
                return;
            }
        }
        
        if (typeof(document.all["donotfocusfirsttextbox"]) != "undefined") {
            return;
        }
        
                                        
        for (i = 0; i < document.forms.length; i++) {
            for (j = 0; j < document.forms[i].elements.length; j++) {
                if (document.forms[i].elements[j].tagName == "INPUT") {
                        
                    if (document.forms[i].elements[j].type == "text"
                        && document.forms[i].elements[j].style.display != 'none'
                        && document.forms[i].elements[j].style.visibility != 'hidden'
                        && document.forms[i].name != 'BHQuickLinkBarForm' ) {
                        
                        try {
                            document.forms[i].elements[j].focus();
                            return true;
                        } catch(e) {
                            // do nothing;
                        }
                        
                    }
                } else if (document.forms[i].elements[j].tagName == "TEXTAREA") {
                    if (document.forms[i].elements[j].style.display != 'none'
                        && document.forms[i].elements[j].style.visibility != 'hidden') {
                        
                        try {
                            document.forms[i].elements[j].focus();
                            return true;
                        } catch(e) {
                            // do nothing;
                        }
                    }
                }
            }
        }
    }
}

function confirmDelete()
{
    return window.confirm("Are you sure that you wish to delete this record?");
}

function confirmAction(msg)
{
    return window.confirm(msg);
}

function confirmActionYesNo(msg, yesText, noText, heightPx)
{
	
	if (yesText == null) yesText = 'Yes';
	if (noText  == null)  noText  = 'No';	
	if (heightPx  == null) heightPx  = '180';	
	
    var retVal = window.showModalDialog("/BullhornSTAFFING/Forms/SelectActionYesNo.htm?questionHeading=Select%20an%20Option&questionText=" + escape(msg) + "&yesText=" + escape(yesText) + "&noText=" + escape(noText), null, "center:yes;dialogHeight:" + heightPx + "px;dialogWidth:400 px;status:off;resizable:off;scroll:off;");
    if (retVal != true) retVal = false;
    return retVal;
    //return window.confirm(msg);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
		}
	}
}

function getCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName.toUpperCase() == aCrumb[0].toUpperCase()) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function setCookie(sName, sValue, sPersist)
{
    if (setCookie.arguments.length < 2) {
        sPersist = false;
    }
    var now = new Date();
    
    if (sPersist) {
        sDate = new Date(now.getYear() + 10, now.getMonth(), now.getDate());
    } else {
        sDate = new Date(now.getYear(), now.getMonth(), now.getDate() + 1);
    }
    
    document.cookie = sName + "=" + escape(sValue) + "; expires=" + sDate;
    
}

function delCookie(sName)
{
    var now = new Date();
    sDate = new Date(now.getYear() - 10, now.getMonth(), now.getDay());
    document.cookie = sName + "=; expires=" + sDate.toGMTString();
}

function positionLayerAtEvent(layerID) {
    layerObj = eval(layerRef + '.' + layerID + styleRef);
    if (layerObj 
        && typeof(layerObj) != 'undefined') {
        
        if (isNS) {
            if (event) {
        	    layerObj.top = event.pageY - 5;
        	    layerObj.left = event.pageX - 5;
            }
    	} else {
            if (window.event) {
                layerObj.top = window.event.clientY - 5 + document.body.scrollTop;
        	    layerObj.left = window.event.clientX + 5 + document.body.scrollLeft;
            }
    	}        
    }
}

function updateBHEntity(formObj, column) {
    url = "/BullhornStaffing/Update/UpdEntities.cfm?updKey=" 
        + formObj.updKey.value
        + "&keyColumn=" + escape(formObj.keyColumn.value)
        + "&" + escape(formObj.keyColumn.value) + "="
        + formObj.id.value
        + "&ID="
        + formObj.id.value
        + "&"
        + column
        + "="
        + escape(formObj.updValue.value)
        + "&entity=" + escape(formObj.entity.value)
        + "&updColumns="
        + column
        + "&updTypes=" + escape(formObj.updateType.value)
        + "&doNotAlert=TRUE&reloadOpener=FALSE&closeOnFinish=TRUE&nocache=" 
        + new Date().getTime();
        
    if (! isNS) {
        window.showModelessDialog(url, "updateWnd", "dialogLeft:0px; dialogTop:0px; dialogHeight:140 px;dialogWidth:200 px;status:off;resizable:on;scroll:off;");                      
    } else {
        bhWindowOpen(url, '', 'height=140,width=200,resizable');
    }
    
    if (formObj.link && 
        formObj.link.value.length > 0) {
        eval(layerRef + '.' + formObj.link.value).innerHTML = formObj.updDisplay.value;
    }
}

function handleBHListAction(action, elementObj) {
    var targetFormField = "userID";
    var formAction = "";
    var currentURLVarName = null;
    var dataContainer = null;
    var formObj = null;
    
    if (elementObj.dataContainer.length > 0) {
        dataContainer = document.all[elementObj.dataContainer];
    } else {
        formObj = eval(elementObj.userIDForm);
    }
    
    var userIDList = "";
    var firstUserID = -1;
    if (dataContainer != null) {
        numRecords = dataContainer.getSelectedRows().getNumSelected();
        if (numRecords > 200) {
            if (! confirmActionYesNo("You have selected " + numRecords + " records. This operation may take a long time to complete. Are you sure you want to continue?")) {
                return false;
            }
        }
        
        var keyArr = dataContainer.getSelectedRows().getKeys();
        if (keyArr
            && keyArr.length > 0) {
            userIDList = keyArr.join(",");
            firstUserID = listFirst(userIDList);
        } 
    } else {
        if (typeof(formObj.selectedUserIDList) != "undefined") {
            userIDList = formObj.selectedUserIDList.value;
            firstUserID = listGetAt(userIDList, 0);
        } else { 
            for( i = 0; i < formObj.elements.length; i++) {
                if ( formObj.elements[i].name == elementObj.userIDFieldName
                    && formObj.elements[i].checked ) {
                    
                    if (userIDList.length > 0) {
                        userIDList += ",";
                    } else {
                        firstUserID = formObj.elements[i].value;
                    }
                    userIDList += formObj.elements[i].value;
                }
            } 
        }
    }
    
    if (userIDList.length <= 0) {
        alert("In order to perform this action, you must first select a " + elementObj.profileType + ".");
        return false;
    }
    
    var formTarget = "popWindowIFRAME";
    switch (action) {
        case "Add Note": 
            formAction = "/BullhornStaffing/Forms/EditUserComment.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&multipleNotes=1&userID=" + firstUserID;
            targetFormField = "referenceUserID";
            break;
        case "Export to Outlook/Palm": 
            //alert('Calling Wync on /BullhornStaffing/Sync/WynxExportContacts.cfm?userIDList=' + userIDList);            
            //Wync('/BullhornStaffing/Sync/WynxExportContacts.cfm?userIDList=' + userIDList);
            showPopWindowIFRAME( '/BullhornStaffing/Sync/Wyncs.cfm?userIDList=' + userIDList , true );
            //WyncTest();
            return;
            break;
        case "Export Candidate":
            formAction = "/BullhornStaffing/Export/Candidates_export.cfm";
            targetFormField = "candidateExportIDs";
            formTarget = "_blank";
            break;
        case "Export Client":
            formAction = "/BullhornStaffing/Export/Clients_export.cfm";
            targetFormField = "clientExportIDs";
            formTarget = "_blank";
            break;
        case "Map Users": 
            bhsWindowManagerObj.openWindow('GoogleMapsWnd' + Math.round(Math.random() * 1000), '/BullhornStaffing/GoogleMaps.cfm?type=users&userIDList=' + userIDList, "tracked", null, window);                        
            return;
            break;                                                  
        case "Forward Candidates": 
            formAction = "/BullhornStaffing/SendUserProfile.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&jobPostingID=" + elementObj.jobPostingID;
            if (bhsWindowManagerObj != null) {
                formTarget = 'PopWindowIFRAMEWnd' + Math.round(Math.random() * 1000); 
            }
            break;
        case "Forward Job": 
            formAction = "/BullhornStaffing/JobPosting/SendJobPosting.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&jobPostingID=" + elementObj.jobPostingID;
            targetFormField = "recipientUserIDs";
            if (bhsWindowManagerObj != null) {
                formTarget = 'PopWindowIFRAMEWnd' + Math.round(Math.random() * 1000); 
            }
            break;
        case "Submit to Job": 
            formAction = "/BullhornStaffing/JobPosting/Forms/AddJobResponse.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&jobPostingID=" + elementObj.jobPostingID;
            break;
        case "Save to Distribution List": 
            if (elementObj.profileType == "Candidate") {
                formAction = "/BullhornStaffing/Portfolio/Forms/AddDistributionListMembers.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&type=Candidate&groupName=Candidates";
            } else {
                formAction = "/BullhornStaffing/Portfolio/Forms/AddDistributionListMembers.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&type=Client&groupName=Clients";
            }
            targetFormField = "userID";
            
            break;
        case "Create Task List": 
            if (elementObj.profileType == "Candidate") {
                formAction = "/BullhornStaffing/Schedule/Forms/AddTaskList.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&listType=Candidate";
                targetFormField = "candidateUserID";
            } else {
                formAction = "/BullhornStaffing/Schedule/Forms/AddTaskList.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&listType=Client";
                targetFormField = "clientUserID";
            }
            break;
        case "Remove from Tearsheet":  
            if (! confirmDelete()) return false;
            formAction = "/BullhornStaffing/Portfolio/Update/UpdShortListGroupings.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=TRUE&sqlType=DEL&shortListID=" + elementObj.shortListID;
            break;
        case "Assign Ownership": 
            formAction = "/BullhornStaffing/Forms/EditOwnershipAssignment.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&profileType=" + elementObj.profileType;
            break;
        case "Print Overview": 
            formAction = "/BullhornStaffing/PrintOverview.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&profileType=" + elementObj.profileType;
            break;  
        case "Change Status": 
            formAction = "/BullhornStaffing/Forms/EditRecordStatus.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&profileType=" + elementObj.profileType;
            break;
        case "Change Client Corporation": 
            formAction = "/BullhornStaffing/Forms/EditRecordClientCorporation.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&profileType=" + elementObj.profileType;
            break;
        case "Delete": 
            if (! confirmAction("Are you sure you wish to delete these records? This action is irreversable.")) return false;
            formAction = "/BullhornStaffing/Update/DelUserProfiles.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&isDeleted=1&profileType=" + elementObj.profileType;
            break;
        case "Save to Tearsheet": 
            formAction = "/BullhornStaffing/Portfolio/Update/AddShortListGroupings.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            currentURLVarName = "searchURL";
            break;
        case "Move to Submissions": 
            formAction = "/BullhornStaffing/JobPosting/Update/UpdJobResponsesStatus.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&sqlType=UPD&jobPostingID=" + elementObj.jobPostingID + "&status=" + escape(elementObj.jobResponseStatus);
            break;
        case "Delete Responses": 
            if ( !confirmDelete()) return false;
            formAction = "/BullhornStaffing/JobPosting/Update/DelJobResponses.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&sqlType=DEL&jobPostingID=" + elementObj.jobPostingID;
            break;
        default:
            if (bhsWindowManagerObj != null) {
                formTarget = 'PopWindowIFRAMEWnd' + Math.round(Math.random() * 1000); 
            }
            
            formAction = "/BullhornStaffing/Portfolio/Forms/EditUserMessage.cfm?messageType=MASSMAILING&noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            targetFormField = "recipientUserIDs";
            break;
    }
    
    var formObj = null;
    if (document.BHListActionForm != null) {
        formObj = document.BHListActionForm;
    } else {
        formObj = document.createElement("<FORM name=BHListActionForm action=#>");
        document.body.appendChild(formObj);
    }
    
    formObj.method = "post";
    formObj.action = formAction;
    formObj.target = formTarget;
    
    for ( i = formObj.children.length - 1; i >= 0; i--) {
        formObj.removeChild(formObj.children[i]);
    }
    
    userIDFormFieldObj = document.createElement("<input name=\"" + targetFormField + "\" value=\"\">");
    userIDFormFieldObj.type = "hidden";
    userIDFormFieldObj.value = userIDList;
    formObj.appendChild(userIDFormFieldObj);
    
    if (currentURLVarName != null) {
        userIDFormFieldObj = document.createElement("<input name=\""+ currentURLVarName + "\" value=\"\">");
        userIDFormFieldObj.type = "hidden";
        userIDFormFieldObj.value = currentURL;
        formObj.appendChild(userIDFormFieldObj);
    }
    
    if (formTarget == "popWindowIFRAME") {
        showPopWindowIFRAME('/Blank.htm'); 
    } else {
        if (formTarget != "_blank") {
            bhsWindowManagerObj.openWindow(formTarget, "/Blank.htm", "tracked", null, window);
        }
    }
    formObj.submit();

    return true;
}

// "Select An Action" for job posting list 
function handleJobPostingBHListAction(action, elementObj) {
    
    var targetFormField = "jobPostingID";
    var formAction = "";
    var currentURLVarName = null;
    
    var formObj = eval(elementObj.jobPostingIDForm);
    var jobPostingIDList = "";
    var firstJobPostingID = -1;
    
    for( i = 0; i < formObj.elements.length; i++) {
        if ( formObj.elements[i].name == elementObj.jobPostingIDFieldName
            && formObj.elements[i].checked ) {
            
            if (jobPostingIDList.length > 0) {
                jobPostingIDList += ",";
            } else {
                firstJobPostingID = formObj.elements[i].value;
            }
            jobPostingIDList += formObj.elements[i].value;
        }
    } 
    
    if (jobPostingIDList.length <= 0) {
        alert("In order to perform this action, you must first select a " + elementObj.listType + ".");
        return false;
    }
    
    var formTarget = "popWindowIFRAME";
    switch (action) {
        case "Assign Ownership": 
            formAction = "/BullhornStaffing/JobPosting/Forms/EditJobPostingOwnership.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;
        case "Change Assignment":
            formAction = "/BullhornStaffing/JobPosting/Forms/EditJobPostingOwnership.cfm?editJobAssignment=TRUE&noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;
        case "Change Status":
            formAction = "/BullhornStaffing/JobPosting/Forms/EditMassJobPosting.cfm?noLogo=FALSE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;
        case "Delete":
            formAction = "/BullhornStaffing/JobPosting/Forms/EditMassJobPosting.cfm?&noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;
        case "Close":
            formAction = "/BullhornStaffing/JobPosting/Forms/EditMassJobPosting.cfm?&noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;
        case "Publish":
            formAction = "/BullhornStaffing/JobPosting/Forms/EditMassJobPosting.cfm?&noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;
        case "Email":
            if (bhsWindowManagerObj != null) {
                formTarget = 'PopWindowIFRAMEWnd' + Math.round(Math.random() * 1000); 
            }
            
            formAction = "/BullhornStaffing/JobPosting/GetJobContactsForEmail.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE"
            break;
        case "Forward Jobs": 
            if (bhsWindowManagerObj != null) {
                formTarget = 'PopWindowIFRAMEWnd' + Math.round(Math.random() * 1000); 
            }
            formAction = "/BullhornStaffing/JobPosting/SendJobPosting.cfm?&noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE";
            break;             
        case "Save to Tearsheet": 
            targetFormField = "entityID";
            formAction = "/BullhornStaffing/Portfolio/Forms/AddShortListEntities.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&entity=Job%20Posting";
            currentURLVarName = "searchURL";
            break;
        case "Remove from Tearsheet":  
            if (! confirmDelete()) return false;
            targetFormField = "entityID";
            formAction = "/BullhornStaffing/Portfolio/Update/UpdShortListEntities.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=TRUE&sqlType=DEL&entity=Job%20Posting&shortListID=" + elementObj.shortListID;
            break;
        case "Map Jobs": 
            bhsWindowManagerObj.openWindow('GoogleMapsWnd' + Math.round(Math.random() * 1000), '/BullhornStaffing/GoogleMaps.cfm?type=jobs&jobsPostingIDList=' + jobPostingIDList, "tracked", null, window);                        
            return;
            break;             
        case "Add Placements": 
            bhsWindowManagerObj.openWindow('BatchPlacementsWnd' + Math.round(Math.random() * 1000), '/BullhornStaffing/JobPosting/UpdOrdersDone.cfm?jobPostingIDList=' + jobPostingIDList + '&candidateUserID=' + elementObj.candidateUserID, "tracked", null, window);                        
            return;
            break;   
		case "Disable Jobcast":
			if (window.confirm("This will remove the records from your local published list, but will not remove \nthem from the remote boards. That will need to be done manually. \n\nAre you sure you want to continue?")) {
    	        formAction = '/BullhornStaffing/JobBoard/API/BHJobBoard.cfc?method=DisablePublishing&jobPostingIDList=' + jobPostingIDList;
            } else {
            	return;
            }
            break;  
        default:
            formAction = "/BullhornStaffing/JobPosting/Forms/AddJobResponse.cfm?noLogo=TRUE&closeOnFinish=TRUE&reloadOpener=FALSE&userID=" + elementObj.userID;
            break;
    }
    
    var formObj = null;
    if (document.JobPostingBHListActionForm != null) {
        formObj = document.JobPostingBHListActionForm;
    } else {
        formObj = document.createElement("<FORM name=\"JobPostingBHListActionForm\" action=\"#\">");
        document.body.appendChild(formObj);
    }
    
    formObj.method = "post";
    formObj.action = formAction;
    formObj.target = formTarget;
    
    for ( i = formObj.children.length - 1; i >= 0; i--) {
        formObj.removeChild(formObj.children[i]);
    }
    
    jobPostingIDFormFieldObj = document.createElement("<input name=\"" + targetFormField + "\" value=\"\">");
    jobPostingIDFormFieldObj.type = "hidden";
    jobPostingIDFormFieldObj.value = jobPostingIDList;
    formObj.appendChild(jobPostingIDFormFieldObj);
    
    actionFormFieldObj = document.createElement("<input name=\"selectedAction\" value=\"" + action + "\">" );
    actionFormFieldObj.type = "hidden";
    formObj.appendChild(actionFormFieldObj);
    
    if (currentURLVarName != null) {
        jobPostingIDFormFieldObj = document.createElement("<input name=\""+ currentURLVarName + "\" value=\"\">");
        jobPostingIDFormFieldObj.type = "hidden";
        jobPostingIDFormFieldObj.value = currentURL;
        formObj.appendChild(jobPostingIDFormFieldObj);
    }
    
    if (formTarget == "popWindowIFRAME") {
        showPopWindowIFRAME('/Blank.htm'); 
    } else {
        bhsWindowManagerObj.openWindow(formTarget, "/Blank.htm", "tracked", null, window);
    }
    formObj.submit();

    return true;
}

function SortDBList(formObj, parameterPrefix, key, defaultSort) {

    if (typeof defaultSort == 'undefined') defaultSort = 1;

    // reset start row
    eval("formObj." + parameterPrefix + "startRow").value = 1;
    
    // if we are re-sorting the same column
    if (key == eval("formObj." + parameterPrefix + "sortKey").value) {
        eval("formObj." + parameterPrefix + "sortDir").value = -1 * eval("formObj." + parameterPrefix + "sortDir").value;
    } else {
        // otherwise, ALWAYS sort ascending
        eval("formObj." + parameterPrefix + "sortDir").value = defaultSort;
    }
    eval("formObj." + parameterPrefix + "sortKey").value = key;
    
    formObj.submit();
    document.body.style.cursor = 'wait'; 
}

function activateBHHeadingNavMenu(defaultMenuInd) {
    if (bhHeadingNavActiveMenuItem != null) { 
        bhHeadingNavActiveMenuItem.className = "SubTierNav"; 
    } 
   
    if (defaultMenuInd > 0) { 
        defaultMenuElement = eval("HeadingNavCell" + defaultMenuInd);
        defaultMenuElement.className = "SubTierNav"; 
    } 
   
    bhHeadingNavActiveMenuItem = window.event.srcElement.parentElement; 
    
    if (bhHeadingNavActiveMenuItem != null) {
       bhHeadingNavActiveMenuItem.className = "SubTierNavSelected"; 
    }
}
        
function toggleWindowPin(imageElement) {
    if (! isWindowPinned) {
        if (window.name.indexOf("pinned__") < 0) {
            newWindowName = "pinned__" + window.name + Math.round(Math.random() * 1000);
            if (bhsWindowManagerObj != null) {
                //bhsWindowManagerObj.openWindow(window.name, window.location, "tracked-unique");
                
                bhsWindowManagerObj.changeWindowID(window.name, newWindowName)
            } else {
                window.name = newWindowName;
            }
        } 
        if (imageElement != null) imageElement.src = pinImgOn.src;
        isWindowPinned = true;
    } else {
        if (bhsWindowManagerObj == null) {
            window.name = originalWindowName; 
            if (imageElement != null) imageElement.src = pinImgOff.src;
            isWindowPinned = false;                                                
        } else {
            if (imageElement != null) imageElement.src = pinImgOn.src;
        }
    }
}

function toggleRowDetail(cell) {
    try {
        var row = cell.parentElement;
        row = row.nextSibling;
        row.style.display = (row.style.display != "none"?"none":"block");
        
        if (cell.children.length > 0
            && cell.children[0].tagName == "IMG") {
            cell.children[0].src = "/BullhornSTAFFING/Images/Icons/" 
                + (row.style.display != "none"?"true":"false") 
                + ".gif";
        }
    } catch(e) {
        alert("Error in toggleRowDetail()\n\n" + e.description);
    }
}

function toggleAllRowDetails(cell, tbl) {
    try {
        var isExpanded = (cell.children[0].src.indexOf('true.gif') >= 0);
         
        cell.children[0].src = '/BullhornSTAFFING/Images/Icons/' + (isExpanded?'false':'true') + '.gif'; 
        for (i=0; i < tbl.rows.length; i++) { 
            row = tbl.rows[i]; 
            
            if (row.isDetail == 'FALSE') { 
                var isRowExpanded = (row.cells[0].children[0].src.indexOf('true.gif') >= 0); 
                
                if (isRowExpanded == isExpanded) { 
                    row.cells[0].click(); 
                }
            }
        }
    } catch(e) {
        alert('Error in toggleAllRows\n\n' + e.description);
    }
}

function toggleDivDisplay(divLayerName, displayType) {
    try {
        var curLayer, curStyle;
        
        curLayer = eval(layerRef + "." + divLayerName);
        curStyle = eval(layerRef + "." + divLayerName + styleRef);
        
        if (displayType != null) {
            curStyle.display = displayType;
        }
        else {
            curStyle.display = (curStyle.display == "none") ? "block" : "none";
        }
    } catch(e) {
        alert("Error in toggleDivDisplay()\n\n" + e.description);
    }
}
function checkAllElements(formObj, fieldName, newValue) {
    len = formObj.elements.length;
    
    for( i=0 ; i<len ; i++) {
        if (formObj.elements[i].name == fieldName) {
            formObj.elements[i].checked = newValue;
        }
    }   
}

function BHLayerSelectAddToList(newListElement, newDisplayListElement, formField, displayFormField, appendValue, delimiter) {
    
    var formFieldValue = formField.value;
    if (displayFormField != null) {
        var displayFormFieldValue = displayFormField.value;
    }
    
    if (appendValue == null) {
        appendValue = false;
    }
    
    if (delimiter == null) {
        delimiter = ",";
    }
    
    if (appendValue) {
        
        if (BHLayerSelectLayerListFind(formFieldValue, newListElement) < 0) {
            if (formFieldValue.length == 0) {
                formFieldValue = newListElement;
                if (displayFormField != null) {
                    displayFormFieldValue = newDisplayListElement;
                }
            }
            else {
                formFieldValue = formFieldValue + delimiter + newListElement;
                if (displayFormField != null) {
                    displayFormFieldValue = displayFormFieldValue + delimiter + newDisplayListElement;
                }
            }
        }
    } else {
        formFieldValue = newListElement;
        if (displayFormField != null) {
            displayFormFieldValue = newDisplayListElement;
        }
    }
    
    formField.value = formFieldValue;            
    if (displayFormField != null) {
        displayFormField.value = displayFormFieldValue;
    }
    
    if (formField.tagName == "INPUT"
        && formField.maxLength > 0) {
        
        formField.value = formField.value.substring(0, formField.maxLength);
    }
}

function BHLayerSelectLayerListFind(list, element) {
    var listPosition = -1;
    var listArray = new Array();
    
    list = list.replace(/, /g, ",");
    listArray = list.split(',');
    for (var i = 0; i < listArray.length; i++) {
        if (element == listArray[i]) {
            listPosition = i;
            break;
        }
    }
    
    return listPosition;
}

function dismissPageContent(pageName, isDismissed) {
    var sURL = "/BullhornSTAFFING/Update/UpdHelpSnippets.cfm?pageContent=" + URLEncodedFormat(pageName) + "&isDismissed=" + isDismissed + "&nocache=" + new Date().getTime();
    var sProps = "dialogLeft:0px; dialogTop:0px;dialogHeight:2px;dialogWidth:2px;status:off;resizable:on;scroll:on;";
    
    window.showModelessDialog(sURL, '',sProps);
}
// Data Picker Functions

// Global picker container obj
window.BHDataPickers = new Object();

//BHDataPicker Class
function BHDataPicker( pickerType, 
                       formElement,
                       displayType,
                       formName, 
                       formFieldName, 
                       allowClear,
                       showSearch, 
                       userLevelList, 
                       defaultFilter,
                       defaultValue,
                       defaultDisplayValue,
                       returnValue,
                       returnDisplay,
                       columnHeadings,
                       columnDisplays,
                       columnTypes,
                       columnSortKeys,
                       app_dir,
                       returnType,
                       onchange, 
                       entityID,
                       secondaryFilter ) {                  
	this.pickerType = pickerType;
    this.formElement = formElement.toUpperCase();
    this.displayType = displayType.toUpperCase();
    this.formName = formName;
    this.formFieldName = formFieldName;
    this.showSearch = showSearch.toUpperCase();
    this.allowClear = allowClear.toUpperCase();
    this.userLevelList = userLevelList;
    this.defaultFilter = defaultFilter;
    this.returnValue = returnValue;
    this.returnDisplay = returnDisplay;
    this.columnHeadings = columnHeadings;
    this.columnDisplays = columnDisplays;
    this.columnTypes = columnTypes;
    this.columnSortKeys = columnSortKeys;
    this.app_dir = app_dir;
    this.returnType = returnType.toUpperCase();
    this.onchange = onchange;
    this.entityID = entityID;    
    this.secondaryFilter = secondaryFilter;
    
    this.valueDelimiter = ",";
    this.displayValueDelimiter = ";";
    
    if (this.returnType == "DISPLAY") {
        this.valueDelimiter = this.displayValueDelimiter;
    }

    this.valueField = document.forms[formName].elements[formFieldName];
    this.displayValueField = document.forms[formName].elements[formFieldName + "_display"];
    this.selectButton = document.all[formName + "_" + formFieldName + "_selectButton"];
    
    this.displayLayer = document.all[formName + "_" + formFieldName + "_displayLayer"];
    
    this.setValue(defaultValue);
    this.setDisplayValue(defaultDisplayValue);
    
    if (this.allowClear == "TRUE") {
        this.clearButton = document.all[formName + "_" + formFieldName + "_clearButton"];
        if (this.value.length == 0) {
            this.clearButton.style.display = "none";
        }
    } else {
        this.clearButton = null;
    }
    
    window.BHDataPickers[this.formName + "_" + this.formFieldName] = this;    
}

//open the data picker for edits
BHDataPicker.prototype.open = function(filter, invalidInput) {
    if (filter == null 
        || typeof(filter) == "undefined") {
        filter = this.defaultFilter;
    }
    if (invalidInput == null 
        || typeof(invalidInput) != "boolean") {
        invalidInput = false;
    }
    
    // sync edit and actual values
    this.editValue = this.value;
    this.editDisplayValue = this.displayValue;
    
    var pickerURL = this.app_dir 
        + "/Forms/EditPicker.cfm?pickerType=" + URLEncodedFormat(this.pickerType) 
        + "&formName=" + URLEncodedFormat(this.formName) 
        + "&formFieldName=" + URLEncodedFormat(this.formFieldName) 
        + "&showSearch=" + URLEncodedFormat(this.showSearch) 
        + "&userLevelList=" + URLEncodedFormat(this.userLevelList)
        + "&displayType=" + URLEncodedFormat(this.displayType)
        + "&returnValue=" + URLEncodedFormat(this.returnValue)
        + "&returnDisplay=" + URLEncodedFormat(this.returnDisplay)
        + "&columnHeadings=" + URLEncodedFormat(this.columnHeadings)
        + "&columnDisplays=" + URLEncodedFormat(this.columnDisplays)
        + "&columnTypes=" + URLEncodedFormat(this.columnTypes)
        + "&columnSortKeys=" + URLEncodedFormat(this.columnSortKeys)
        + "&entityID=" + URLEncodedFormat(this.entityID)        
        + "&filter=" + URLEncodedFormat(filter)
        + "&invalidInput=" + (invalidInput?"TRUE":"FALSE")
        + "&secondaryFilter=" + URLEncodedFormat(this.secondaryFilter);
        
    // open picker
    if (window.name != 'pickerWindowIFRAME') {
        document.all.pickerWindowIFRAMEContainer.style.display = "block";
        document.all.pickerWindowIFRAMEContainer.style.top = document.body.scrollTop + 10;
        document.all.pickerWindowIFRAMEContainer.style.left = document.body.scrollLeft + 10;
        pickerWindowIFRAME.window.location.replace(pickerURL);
    } else {
        window.parent.document.all.pickerWindowIFRAMEContainer.style.display = "block";
        window.location = pickerURL;
    }
}

BHDataPicker.prototype.checkInput = function () {
    this.editValue = "";
    this.editDisplayValue = "";
    
    for (var cind = 0; cind < this.displayLayer.children.length; cind++) {
        var curElem = this.displayLayer.children[cind];  
               
        if (typeof(curElem.pickerValue) != "undefined") {            
            // if the inner text has been modified, then treat it as a new entry.
            if (curElem.pickerDisplayValue == curElem.innerText) {
                this.addEditValue(curElem.pickerValue, curElem.pickerDisplayValue);
                curElem.innerText = "";
            } 
        } 
        
        if (typeof(curElem.isDelimiter) != "undefined"
            && curElem.isDelimiter) {
            curElem.innerText = curElem.innerText.replace(curElem.delimiterDisplayValue, "");
        }                
    }
    
    newTextEntered = trimSpaces(this.displayLayer.innerText);
    
    this.setValue(this.editValue);
    this.setDisplayValue(this.editDisplayValue);
     
    if (newTextEntered.length > 0) {
        
        this.validateInput(newTextEntered);
        //return false;
    }
    //alert(newTextEntered);
    
    return true;
}
 
BHDataPicker.prototype.validateInput = function(filter) {
    // sync edit and actual values
    this.editValue = this.value;
    this.editDisplayValue = this.displayValue;
 
    var pickerURL = this.app_dir 
        + "/Forms/ValidatePickerData.cfm?pickerType=" + URLEncodedFormat(this.pickerType) 
        + "&formName=" + URLEncodedFormat(this.formName) 
        + "&formFieldName=" + URLEncodedFormat(this.formFieldName) 
        + "&userLevelList=" + URLEncodedFormat(this.userLevelList)
        + "&displayType=" + URLEncodedFormat(this.displayType)
        + "&returnValue=" + URLEncodedFormat(this.returnValue)
        + "&returnDisplay=" + URLEncodedFormat(this.returnDisplay)
        + "&filter=" + URLEncodedFormat(filter)
        + "&secondaryFilter=" + URLEncodedFormat(this.secondaryFilter);
        
    // open picker
    if (window.name != 'pickerWindowIFRAME') {
        //document.all.pickerWindowIFRAMEContainer.style.display = "block";
        document.all.pickerWindowIFRAMEContainer.style.top = document.body.scrollTop + 10;
        document.all.pickerWindowIFRAMEContainer.style.left = document.body.scrollLeft + 10;

        pickerWindowIFRAME.window.location = pickerURL;        
    } else {
        //document.all.pickerWindowIFRAMEContainer.style.display = "block";
        window.location = pickerURL;
    }
    
}

BHDataPicker.prototype.getValue = function() {
    return this.value;
}

BHDataPicker.prototype.getDisplayValue = function() {
    return this.displayValue;
}

BHDataPicker.prototype.setValue = function(sValue, fireOnChangeEvent) {
    if (fireOnChangeEvent == null) {
        fireOnChangeEvent = false;
        if (typeof(this.value) != "undefined"
            && this.value != sValue) {
            fireOnChangeEvent = true;
        }
    }
    
    this.value = sValue;
    this.valueField.value = sValue;
    this.editValue = this.value;
    
    if (fireOnChangeEvent
        && this.onchange != null
        && this.onchange.length > 0) {
        eval(this.onchange);
    }
    
    return this.value;
}

BHDataPicker.prototype.setDisplayValue = function(sValue) {
    this.displayValue = sValue;
    this.displayValueField.value = this.displayValue;
    this.editDisplayValue = this.displayValue;

    this.displayLayer.innerHTML = "";

    if (this.value.length > 0) {
        valueArr = this.value.split(this.valueDelimiter);
        displayArr = this.displayValue.split(this.displayValueDelimiter);
        
        for (var vind = 0; vind < valueArr.length && vind < displayArr.length; vind++) {
            var newElem = document.createElement("<DIV style=\"text-decoration:underline; display:inline;\">");
            newElem.pickerValue = valueArr[vind];
            newElem.pickerDisplayValue = trimSpaces(displayArr[vind]);
            newElem.innerText = trimSpaces(displayArr[vind]);
            
            this.displayLayer.appendChild(newElem);
            
            if (this.displayType == "CHECKBOX") {
                // add a delimiter
                newElem = document.createElement("<DIV style=\"display:inline;\">");
                newElem.innerHTML = this.displayValueDelimiter + " ";
                newElem.isDelimiter = true;
                newElem.delimiterDisplayValue = newElem.innerText;
                this.displayLayer.appendChild(newElem);
            }
        }
    }
    else
    {
        /* KGU 20060906 Ticket #119410 | bullhorn default email client page not tracking in notes 
           set display value only when value is not provided.   
        */
        displayArr = this.displayValue.split(this.displayValueDelimiter);
        
        for (var vind = 0;  vind < displayArr.length; vind++) {
            var newElem = document.createElement("<DIV style=\"text-decoration:underline; display:inline;\">");
            newElem.pickerDisplayValue = trimSpaces(displayArr[vind]);
            newElem.innerText = trimSpaces(displayArr[vind]);            
            this.displayLayer.appendChild(newElem);    
        }
    }
    
    if (this.formElement == "TEXTAREA") {
		try{
			this.displayLayer.style.overflow = 'hidden';
       		this.displayLayer.style.pixelHeight = (18 * Math.round(
			Math.max(1, 
				Math.min(
					(this.displayLayer.innerText.length * parseInt(this.displayLayer.currentStyle.fontSize)*0.8) / this.displayLayer.getWidth(), 5))))+3;			
			
			if(this.displayLayer.style.pixelHeight > 89) this.displayLayer.style.overflowY = 'auto';	
		}
		catch(e){
			this.displayLayer.style.pixelHeight = 18 * Math.round(
			Math.max(1, 
				Math.min(
					(this.displayLayer.innerText.length * parseInt(this.displayLayer.currentStyle.fontSize)*0.8) / this.displayLayer.style.pixelWidth, 5)));
    		}
		}

    return this.displayValue;
}


BHDataPicker.prototype.clear = function () {
    this.setValue("");
    this.setDisplayValue("");
    
    this.clearButton.style.display = "none";
}

BHDataPicker.prototype.getEditValue = function() {
    return this.editValue;
}

BHDataPicker.prototype.getEditDisplayValue = function() {
    return this.editDisplayValue;
}

BHDataPicker.prototype.setEditValue = function(sValue) {
    this.editValue = sValue;
    return this.editValue;
}

BHDataPicker.prototype.setEditDisplayValue = function(sValue) {
    this.editDisplayValue = sValue;
    return this.editDisplayValue;
}

BHDataPicker.prototype.isEditValueChecked = function (sValue) {
    return ((listFind(this.editValue, sValue, this.valueDelimiter) >= 0)?true:false);
}

BHDataPicker.prototype.addEditValue = function (sValue, sDisplayValue) {
    sValue = sValue.replace(new RegExp(this.valueDelimiter,"g"), '');
    sDisplayValue = sDisplayValue.replace(new RegExp(this.displayValueDelimiter,"g"), '');

    var ind = listFind(this.editValue, sValue, this.valueDelimiter);
    if (ind < 0) {
        this.editValue = listAppend(this.editValue, sValue, this.valueDelimiter);
        this.editDisplayValue = listAppend(this.editDisplayValue, sDisplayValue, this.displayValueDelimiter);
    }
}

BHDataPicker.prototype.removeEditValue = function (sValue) {
    sValue = sValue.replace(new RegExp(this.valueDelimiter,"g"), '');
    
    var ind = listFind(this.editValue, sValue, this.valueDelimiter);
    
    if (ind >= 0) {
         this.editValue = listDeleteAt(this.editValue, ind, this.valueDelimiter);
         this.editDisplayValue = listDeleteAt(this.editDisplayValue, ind, this.displayValueDelimiter);
    }
}

// function to handle values returned by picker
BHDataPicker.prototype.commitEdits = function () {
    if (this.editValue.length > 0) {
        // unhide layer containing textbox/textarea for data picker
        if (this.clearButton) {
            this.clearButton.style.display = "inline";
        }
    }
    
    //set value but don't fire onchange
    this.setValue(this.editValue, false);
    this.setDisplayValue(this.editDisplayValue);
    
    if (this.onchange != null
        && this.onchange.length > 0) {
        
        eval(this.onchange);
    }
}

BHDataPicker.prototype.cancel = function () {
    this.setValue(this.value);
    this.setDisplayValue(this.displayValue);
    
    setTimeout(this.selectButton.id + ".focus();", 0);
}

//global data picker functions

function GetBHDataPicker(formName, formFieldName) {
    if (window.name != 'pickerWindowIFRAME') {
        return window.BHDataPickers[formName + "_" + formFieldName];
    } else {
        return window.parent.BHDataPickers[formName + "_" + formFieldName];
    }
}

function BHDataPickerReady () {
    if (window.name != 'pickerWindowIFRAME') {
        document.all.pickerWindowIFRAMEContainer.style.display = "block";
    } else {
        window.parent.document.all.pickerWindowIFRAMEContainer.style.display = "block";
    }
}

function URLEncodedFormat(stringObj) {
    if (! isMacIE) {
        return encodeURIComponent(stringObj)
    } else {
        return escape(stringObj);
    }
}

// trim function
function trimSpaces(stringObj) {
    var spaceChars = " \240[]\t\n\r";
    var startChar = 0;
    var endChar = stringObj.length;
    
    if (stringObj.length > 0) {
        for (var i = 0; i < endChar; i++) {
            if (spaceChars.indexOf(stringObj.substring(i, i+1)) > -1) {
                startChar++;
            }
            else {
                break;
            }
        }
        
        for (i = endChar; i > startChar; i--) {
            if (spaceChars.indexOf(stringObj.substring(i-1, i)) > -1) {
                endChar--;
            }
            else {
                break;
            }
        }
        
        return stringObj.substring(startChar, endChar);
    }
    else {
        return "";
    }
}

//function to append a value to a list
function listAppend(stringObj, value, delimiter) {
    
    if (stringObj == null) stringObj = "";
    if (! delimiter) delimiter = ",";
    if (stringObj.length > 0) {
        stringObj += delimiter;
    }
    
    stringObj += value;
    
    return stringObj;
}

// fucntion to remove element from list
function listDeleteAt(stringObj, position, delimiter) {
    if (! delimiter) delimiter = ",";
    var stringArray = new Array();
    var newList = '';
    
    stringArray = stringObj.split(delimiter);
    
    for (var i = 0; i < stringArray.length; i++) {
        if (i != position) {
            if (newList.length == 0) {
                newList = stringArray[i];
            }
            else {
                newList = newList + delimiter + stringArray[i];
            }
        }
    }
    
    return newList;
}

// function to find an element in list - stringObj is list, subStringObj is desired substring
function listFind(stringObj, subStringObj, delimiter) {
    if (! delimiter) delimiter = ",";
    var stringArray = new Array();
    //var subStringExist = false;
    var subStringPosition = -1;
    
    stringArray = stringObj.split(delimiter); // create array of strings from default list
    
    for (var j = 0; j < stringArray.length; j++) {
        if (subStringObj == stringArray[j]) {
            //subStringExist = true;
            subStringPosition = j;
            break;
        }
    }
    
    return subStringPosition;
}

function listGetAt(stringObj, position, delimiter) {
    if (! delimiter) delimiter = ",";
    return stringObj.split(delimiter)[position];
}

function listFirst(stringObj, delimiter) {
    if (! delimiter) delimiter = ",";
    return stringObj.split(delimiter)[0];
}

function listLen(stringObj, delimiter) {
    if (stringObj.length <= 0) return 0;
    if (! delimiter) delimiter = ",";
    return stringObj.split(delimiter).length;
}

function listLast(stringObj, delimiter) {
    if (! delimiter) delimiter = ",";
    var listArr = stringObj.split(delimiter);
    return listArr[listArr.length - 1];
}

function SetURLVariable(urlString, urlVariable, value) {
    var re = new RegExp("([?&])" + urlVariable + "=([^&]*)", "i");
    
    if (urlString.search(re) == -1) {
        urlString += ((urlString.indexOf("?") >= 0)?"&":"?") + urlVariable + "=" + escape(value);
    } else {
        urlString = urlString.replace(re, "$1" + urlVariable + "=" + escape(value), "i");
    }
    
    return urlString;    
}

function formatPhone (field) {
    field.value = trimSpaces(field.value);

    var ov = field.value;
    var v = "";
    var x = -1;

    // is this phone number 'escaped' by a leading plus?
    if (0 < ov.length && '+' != ov.charAt(0)) { // format it
        // count number of digits
        var n = 0;
        if ('1' == ov.charAt(0)) {  // skip it
            ov = ov.substring(1, ov.length);
        }

        for (i = 0; i < ov.length; i++) {
            var ch = ov.charAt(i);

            // build up formatted number
            if (ch >= '0' && ch <= '9') {
                if (n == 0) v += "";
                else if (n == 3) v += "-";
                else if (n == 6) v += "-";
                v += ch;
                n++;
            }
            // check for extension type section;
            // are spaces, dots, dashes and parentheses the only valid non-digits in a phone number?
            if (! (ch >= '0' && ch <= '9') && ch != ' ' && ch != '-' && ch != '.' && ch != '(' && ch != ')') {
                x = i;
                break;
            }
        }
        // add the extension
        if (x >= 0) v += ((ov.substr(x,1)!="x")?" ":"") + ov.substring(x, ov.length);

        // if we recognize the number, then format it
        if (n == 10 && v.length <= 40) field.value = v;
    }
    return true;
}


// Was function jb...
// returns an XMLHttp object... gets it in an IE/Mozilla friendly way..
function getXMLHTTP(){
  var A=null;
  try{
    A=new ActiveXObject("Msxml2.XMLHTTP")
  }catch(e){
    try{
      A=new ActiveXObject("Microsoft.XMLHTTP")
    } catch(oc){
      A=null
    }
  }
  if(!A && typeof XMLHttpRequest != "undefined") {
    A=new XMLHttpRequest()
  }
  return A
}

//scroll up/down functionality
var scrollUpCanceled = true;
var scrollDownCanceled = true;
var scrollingObj = null;

function startScrollingDown(obj) {
    stopScrolling();
    scrollDownCanceled = false;
    scrollingObj = obj;
    scrollDown();
}

function startScrollingUp(obj) {
    stopScrolling();
    scrollUpCanceled = false;
    scrollingObj = obj;
    scrollUp();
}

function scrollDown() {
    if (! scrollDownCanceled && 
        scrollingObj.scrollTop <= scrollingObj.scrollHeight) {
        scrollingObj.scrollTop += 5;
        setTimeout("scrollDown()", 40);
    }
}

function scrollUp() {
    if (! scrollUpCanceled && 
        scrollingObj.scrollTop >= 0) {
        scrollingObj.scrollTop -= 5;
        setTimeout("scrollUp()", 40);
    }
}

function stopScrolling() {
    scrollUpCanceled = true;
    scrollDownCanceled = true;
}

/// Flag for follow up functions
function getFlagColorCode(flagColor) {
    if (flagColor == null) {
        flagColor = "";
    }
    switch (flagColor.toLowerCase()) {
        case "red":
            return "#CF5D60";
        break;
        case "blue":
            return "#5C83B4";
        break;
        case "yellow":
            return "#FFC160";
        break;
        case "green":
            return "#8BB467";
        break;
        case "orange":
            return "#FF8C5A";
        break;
        case "purple":
            return "#A5587C";
        break;
        default:
            return "#ffffff";
        break;
    }
}

function getFlagColorIcon(flagColor) {
    if (flagColor == null) {
        flagColor = "";
    }
    switch (flagColor.toLowerCase()) {
        case "complete":
            return "FlagComplete";
        break;
        default:
            return "ClearFlag";
        break;
    }
}

function downloadFile(downloadURL) {
    window.open(downloadURL);
    
}

var previewPopUpXmlHttp = getXMLHTTP();
var previewPopUp = window.createPopup();

var popUpHeight =  600;
var popUpWidth = 400;

var previewPopUp_options = new Object();
        
function showPreviewPopUp(url, options){
    try {
        if (options == null) {
            options = new Object();
        }
        previewPopUp_options = options;
              
        if (previewPopUpXmlHttp
            && previewPopUpXmlHttp.readyState!=0) {
            previewPopUpXmlHttp.abort();
        } 
        
        previewPopUpXmlHttp.open("GET", url, true);    
                        
        previewPopUpXmlHttp.onreadystatechange=function() {
            if(previewPopUpXmlHttp.readyState==4
                && previewPopUpXmlHttp.responseText) {
                
                var html = "<link rel=STYLESHEET type=\"text/css\" href=\"/BullhornSTAFFING/Styles/Default.css\">"
                    + "<div id=\"previewPopUpContent\">" + previewPopUpXmlHttp.responseText + "</div>";
                
                if (previewPopUp_options.isTextOnlyContent) {
                    html = "<pre>" + html + "</pre>";
                }
                
                var buttonHTML = "";
                
                if (previewPopUp_options.parseAsNewCandidate) {
                    buttonHTML += "<input type=button class=Button onclick=\"parent.parseContentAsNew(document.all.previewPopUpContent.innerHTML, true);\" value=\"Parse as New\">";
                } else if (previewPopUp_options.parseAsNewClient) {
                    buttonHTML += "<input type=button class=Button onclick=\"parent.parseContentAsNew(document.all.previewPopUpContent.innerHTML, false);\" value=\"Parse as New\">";
                }
                if (previewPopUp_options.parseAsNewCandidate || previewPopUp_options.parseAsNewClient) {
                    buttonHTML += "<input type=button class=Button onclick=\"parent.parseContentAsExisting(document.all.previewPopUpContent.innerHTML, '" 
                                + previewPopUp_options.userMessageFileID + "','" 
                                + previewPopUp_options.filename + "','" 
                                + previewPopUp_options.fileType + "','" 
                                + previewPopUp_options.directory + "','" 
                                + previewPopUp_options.extension + "','"
                                + previewPopUp_options.encryptedKey + "','"  
                                + previewPopUp_options.userMessageID + "');\" value=\"Parse as Existing\">";
                }
                if (previewPopUp_options.copyToClipboardButton) {
                    buttonHTML += "<input type=button class=Button onclick=\"parent.copyPreviewPopupContentToClipBoard(document.all.previewPopUpContent);\" value=\"Copy to Clipboard\">";
                }
                
                if (buttonHTML.length > 0) {
                    html = buttonHTML + "<br>" + html;
                }
                
                setPreviewPopUpHTML(html);
                
            }
        }
        
        openPreviewPopUpWindow();

        previewPopUpXmlHttp.send();
                
    } catch (e) {
        alert("Error in showPreviewPopUp\n\n" + e.description);
    }
}

function openPreviewPopUpWindow() {
    popUpHeight =  document.body.clientHeight - 11;
    popUpWidth = Math.round((document.body.clientWidth * 0.60));
    xPos = window.screenLeft + (document.body.clientWidth - popUpWidth);
    yPos = window.screenTop + 24;
    
    previewPopUp.document.body.innerHTML = "<div style=\"padding:20px; font-family:arial; font-size:12px; font-weight:bold;\">Loading...</div>";
    previewPopUp.show(xPos, yPos, popUpWidth, popUpHeight, null);
}

function setPreviewPopUpHTML(html) {
	
    previewPopUp.document.body.innerHTML = "<div style=\"background-color:white; border:solid 6px #777777;\">"
        + "<div id=previewPopupContentBorder style=\"padding:10px; border:2px solid #333366; width:" + (popUpWidth - 12) + "px;height:" + (popUpHeight - 12) + "px; overflow:auto;\">"
        + "<img align=right style=\"\" src=\"/DHTMLWindow/close.gif\" width=12 height=12 onclick=\"parent.closePreviewPopUp(); event.cancelBubble = true; event.returnValue = false;\"><br>" 
        + html
        + "<img align=right style=\"\" src=\"/DHTMLWindow/close.gif\" width=12 height=12 onclick=\"parent.closePreviewPopUp(); event.cancelBubble = true; event.returnValue = false;\"><br>" 
        + "</div></div>";  
    
    var highlightButton = previewPopUp.document.getElementById('Highlight');
    if (highlightButton != null) highlightButton.click();
}

function showPreviewPopUp_image(imgURL) {
    openPreviewPopUpWindow();
    
    setPreviewPopUpHTML("<html><body><img src=" + imgURL + "></body></html>")
}

function copyPreviewPopupContentToClipBoard(obj) {
    savedHTML = previewPopUp.document.body.innerHTML;
    previewPopUp.document.body.innerHTML = obj.innerHTML;
    
    textRange = previewPopUp.document.body.createTextRange(); 
    textRange.execCommand('copy');
    previewPopUp.document.body.innerHTML = savedHTML;
}

function parseContentAsNew(sVal, isCandidate) {
    
    if (isCandidate == null) {
        isCandidate = true;
    }
    
    var _form = document.all["parseContentAsNewCandidateForm"];
    
    if (! _form) {
        _form = document.createElement("FORM");
        _form.ID = "parseContentAsNewForm";
        _form.method = "POST"
        _form.target = "parseContentAsNewWnd";
        _form.style.display = "none";
        document.body.appendChild(_form);
        _form.innerHTML = "<input name=resumeText type=hidden><input name=clientInfoText type=hidden><input type=hidden name=resumeParse value=TRUE><input type=hidden name=clientInfoParse value=TRUE>";
    }
    _form.resumeText.value = "";
    _form.clientInfoText.value = "";
    
    if (isCandidate) {
        _form.action = "/BullhornSTAFFING/Candidate/Forms/EditCandidate.cfm";
        _form.resumeText.value = sVal;
    } else {
        _form.action = "/BullhornSTAFFING/Client/Forms/EditClient.cfm";
        _form.clientInfoText.value = sVal;
    }
    
    closePreviewPopUp();
    
    bhWindowOpen("/Blank.htm", "parseContentAsNewWnd");
    _form.submit();
}

function parseContentAsExisting(sVal, userMessageFileID, filename, filetype, directory, extension, encryptedKey, userMessageID) {
    
    var _form = document.all["parseContentAsExistingCandidateForm"];
    
    if (! _form) {
        _form = document.createElement("FORM");
        _form.ID = "parseContentAsExistingCandidateForm";
        _form.method = "POST"
        _form.target = "parseContentAsExistingWnd";
        _form.style.display = "none";
        document.body.appendChild(_form);
        _form.innerHTML = "<input name=resumeText type=hidden>" + 
                          "<input name=parseType  type=hidden value=TEXT>" +
                          "<input name=id         type=hidden value=" + userMessageFileID + ">" +
                          "<input name=filename   type=hidden value=" + filename          + ">" + 
                          "<input name=filetype   type=hidden value=" + filetype          + ">" + 
                          "<input name=directory  type=hidden value=" + directory         + ">" + 
                          "<input name=key        type=hidden value=" + encryptedKey      + ">" + 
                          "<input name=userMessageID type=hidden value=" + userMessageID  + ">" +
                          "<input name=extension  type=hidden value=" + extension         + ">";
    }
    
    // defaults
    _form.resumeText.value = "";
    
    _form.action = "/BullhornSTAFFING/Forms/ParseExistingResume.cfm";
	_form.resumeText.value = sVal;
	    
    closePreviewPopUp();
    
    bhWindowOpen("/Blank.htm", "parseContentAsExistingWnd");
    _form.submit();
}

function copyPreviewPopupContentToClipBoard(obj) {
    savedHTML = previewPopUp.document.body.innerHTML;
    previewPopUp.document.body.innerHTML = obj.innerHTML;
    
    textRange = previewPopUp.document.body.createTextRange(); 
    textRange.execCommand('copy');
    previewPopUp.document.body.innerHTML = savedHTML;
}


function closePreviewPopUp() {
    if (previewPopUp.isOpen) previewPopUp.hide();
}

function previewUserResume(userID){
    try {
        if (parseInt(userID) > 0) { 
            showPreviewPopUp("/BullhornSTAFFING/UserProfile_ResumeOverview.cfm?userID=" + userID + "&nocache=" + new Date().getTime());
        }
    } catch (e) {
        alert("Error in previewUserResume\n\n" + e.description);
    }
}

function previewOneSourceResume(jobboard, resumeId, accountId, dateLastModified){
    var url = "/BullhornStaffing/UserProfile_Athens.cfm?"
        + "jobboard=" + escape(jobboard)
        + "&resumeId=" + escape(resumeId)
        + "&accountId=" + escape(accountId)
        + "&dateLastModified=" + escape(dateLastModified)
        + "&nocachetoken=" + new Date().getTime();
        
    showPreviewPopUp(url);                           
}

function previewJobDescription(jobPostingID){
    try {
        if (parseInt(jobPostingID) > 0) { 
            showPreviewPopUp("/BullhornSTAFFING/JobPosting/JobPosting_Description.cfm?jobPostingID=" + jobPostingID + "&nocache=" + new Date().getTime());
        }
    } catch (e) {
        alert("Error in previewJobDescription\n\n" + e.description);
    }
}

function previewJobAgentResult(jobAgentResultID){
    try {
        if (parseInt(jobAgentResultID) > 0) { 
            showPreviewPopUp("/BullhornSTAFFING/JobPosting/JobAgentResult_ResumeBody.cfm?jobAgentResultID=" + jobAgentResultID + "&nocache=" + new Date().getTime());
        }
    } catch (e) {
        alert("Error in previewJobDescription\n\n" + e.description);
    }
}

function showPreviewPopUpPost(url, postValues){

    try {
        
        if (previewPopUpXmlHttp 
            && previewPopUpXmlHttp.readyState!=0) {
            previewPopUpXmlHttp.abort();
        } 
            
        // compile post params
        var postParams = "";
        for (thisKey in postValues) {
        	postParams += thisKey + "=" + encodeURIComponent(postValues[thisKey]);
        }
                
        previewPopUpXmlHttp.open("POST", url, true);
		previewPopUpXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		previewPopUpXmlHttp.setRequestHeader("Content-length", postParams.length);
		previewPopUpXmlHttp.setRequestHeader("Connection", "close");	           
                                  
        previewPopUpXmlHttp.onreadystatechange=function() {
            if(previewPopUpXmlHttp.readyState==4
                && previewPopUpXmlHttp.responseText) {
                
                setPreviewPopUpHTML(previewPopUpXmlHttp.responseText);
                
            }
        }
        
        openPreviewPopUpWindow();

		previewPopUpXmlHttp.send(postParams);	        

    } catch (e) {
    
        alert("Error in showPreviewPopUpPost\n\n" + e.description);
    }
}

function previewHtmlToText(htmlContents){

	var postValues = new Array();
	postValues["htmlContents"] = htmlContents;
	
    try {
	    showPreviewPopUpPost("/BullhornSTAFFING/JobBoard/HTMLToTextPreview.cfm?&nocache=" + new Date().getTime(), postValues);
    } catch (e) {
        alert("Error in previewHtmlToText\n\n" + e.description);
    }
}

function googleMapJob(jobPostingID)
    {
        bhsWindowManagerObj.openWindow('GoogleMapsWnd' + Math.round(Math.random() * 1000), '/BullhornStaffing/GoogleMaps.cfm?type=jobs&jobsPostingIDList=' + jobPostingID, "tracked", null, window);                        
    }

function googleMapUser(userID)
    {
        bhsWindowManagerObj.openWindow('GoogleMapsWnd' + Math.round(Math.random() * 1000), '/BullhornStaffing/GoogleMaps.cfm?type=users&userIDList=' + userID, "tracked", null, window);                        
    }

function googleMapClient(clientCorporationID)
    {
        bhsWindowManagerObj.openWindow('GoogleMapsWnd' + Math.round(Math.random() * 1000), '/BullhornStaffing/GoogleMaps.cfm?type=clients&clientCorporationIDList=' + clientCorporationID, "tracked", null, window);                        
    }

function linkToThisPage(linkBody) {
	
    if (! document.all.linkToThisPageDiv) {
    	
        var elem = document.createElement("<DIV>");
        elem.id = "linkToThisPageDiv";
        elem.style.position = "absolute"
        elem.style.pixelTop = 0;
        elem.style.pixelRight = 0;
        elem.style.border = "1px solid #999999";
        elem.style.padding = "5px";
        elem.style.backgroundColor = "#efefef";
        elem.style.pixelWidth = 300;
        
        elem.style.display = "none";        
	    
	    // format the link as relative
        var linkHref = this.location.toString();
        
        // this may not be possible with; the createTextRange() and subsequent copy seem to re-insert this. Very "helpful".
        //linkHref = linkHref.replace(/https?:\/\/[^\/]+/, '');
        
        // default the link body to the URL if not provided
        if (typeof linkBody == 'undefined') linkBody = linkHref;
                	    
	    // create an "A" DOM object, and populate the link text and url
	    var linkElement = document.createElement("a");	    
	    linkElement.setAttribute("href", linkHref);
	    linkElement.innerHTML = linkBody;
	    
		// create an editable DIV, this is crucial because a regular DIV will not preserve the link URL when copying from a createTextRange 
	    var linkSubElement = document.createElement("div");
	    with (linkSubElement) {
	    	contentEditable = true;
	    }     
	    linkSubElement.appendChild(linkElement);  	      
        
        // format the displayed DIV around the content
        elem.innerHTML = "<img src='/DHTMLWindow/close.gif' width=12 height=12 align=right onclick=\"this.parentElement.style.display='none'\">The link to this page has been copied to your clipboard.<br><strong>Note</strong>: Links will only be accessible to Bullhorn users.";	
       
        // create an empty DIV to deselect onto 
	    var nullDiv = document.createElement("div");
        
	    // add linkSubElement to the visible DIV
	    elem.appendChild(linkSubElement);	
	    elem.appendChild(nullDiv);
	           
        document.body.appendChild(elem);
    }    
    
    if (event) {
        document.all.linkToThisPageDiv.style.pixelTop = event.y + 15;
        document.all.linkToThisPageDiv.style.pixelLeft = Math.min(event.x, document.body.clientWidth - document.all.linkToThisPageDiv.style.pixelWidth);
    }
    
    document.all.linkToThisPageDiv.style.display = "block";
    
    // select the editable content and copy it to the clipboard
    var r = document.body.createTextRange();
    r.moveToElementText(linkSubElement);
    r.select();  
    r.execCommand("Copy");
    
    // "deselect"
    r.moveToElementText(nullDiv);
    r.select();   
        
	// Ticket #170128 - copy link breaks the second time you use the same one
	// need to actually delete the item from the DOM, rather than hide it. Otherwise, the second pass will create a dupe ID        
    setTimeout("var elem = document.getElementById('linkToThisPageDiv'); document.body.removeChild(elem);", 5000);
}

function getWordPlural(word) {
    var len = word.length;
    var right = word.substr(len -1, 1);
    var right2 = word.substr(len - 2, 2);
    //alert(word + "|" + right + "|" + right2);
    
    if (right.toLowerCase() == "y") {
        return (word.substr(0, len - 1) + "ies");
    } else if (right2.toLowerCase() == "ch") {
        return (word + "es");
    } else if (listFind("s,x", right.toLowerCase()) >= 0) {
        return (word + "es");
    } else {
        return (word + "s");
    }
}

function smartTagContent(obj) {
    
    var re = new RegExp("\(?[0-9]{3}\)?[\-\. ][0-9]{3}[\-\. ][0-9]{4}","g")
    
    obj.innerHTML = "<a href=\"javascript:window.location.reload();\">reload</a>" + obj.innerHTML.replace(re, "phone#");
}

function webSearchPerson(service, name)
{
    switch (service.toLowerCase()) {
        case "google":
            //person name in quotes
            window.open("http://www.google.com/search?q=%22" + URLEncodedFormat(name) + "%22", "BHGoogle");
        break;
        case "linkedin":
            window.open("http://www.linkedin.com/search?search=&kwname=" + URLEncodedFormat(name), "BHLinkedIn");
        break;
        case "zoominfo":
            window.open("http://www.zoominfo.com/Search/PersonQuery.aspx?SearchType=simple&SearchBy=name&searchParameters=" + URLEncodedFormat(name), "BHZoominfo");
        break;
    }
}

function webSearchPerson2(service, firstname, lastname)
{
    switch (service.toLowerCase()) {
        case "google":
            //person name in quotes
            window.open("http://www.google.com/search?q=%22" + URLEncodedFormat(firstname) + "%20" + URLEncodedFormat(lastname) + "%22", "BHGoogle");
        break;
        case "linkedin":
            window.open("http://www.linkedin.com/search?search=&lname=" + URLEncodedFormat(lastname) + "&fname=" + URLEncodedFormat(firstname), "BHLinkedIn");
        break;
        case "zoominfo":
            window.open("http://www.zoominfo.com/Search/PersonQuery.aspx?SearchType=simple&SearchBy=name&searchParameters=" + URLEncodedFormat(firstname) + "%20" + URLEncodedFormat(lastname), "BHZoominfo");
        break;
    }
}
function webSearchCompany(service, name)
{
    switch (service.toLowerCase()) {
        case "google":
            window.open("http://www.google.com/search?q=" + URLEncodedFormat(name), "BHGoogle");
        break;
        case "linkedin":
            window.open("http://www.linkedin.com/search?search=&currentCompany=currentCompany&company=" + URLEncodedFormat(name), "BHLinkedIn");
        break;
        case "zoominfo":
            window.open("http://www.zoominfo.com/Search/CompanyQuery.aspx?singleSearchBox=" + URLEncodedFormat(name), "BHZoominfo");
        break;
    }
}

var embeddedIntelFrame = null;

function hideEmbeddedIntelligence() {
    if (embeddedIntelFrame
        && embeddedIntelFrame.style.display != "visible") {
        embeddedIntelFrame.filters[0].Direction = "RIGHT";
        embeddedIntelFrame.filters[0].apply();
        embeddedIntelFrame.style.visibility = "hidden";
        embeddedIntelFrame.filters[0].play();
    }
}

function expandEmbeddedIntelligence() {
    if (embeddedIntelFrame
        && embeddedIntelWindow.contentWindow) {
        bhWindowOpen(embeddedIntelWindow.contentWindow.location, 'EmbeddedIntelligenceWnd' + (new Date().getTime()));
    }
}

function getEmbeddedIntelligence(tagList) {
    var url = "/BullhornSTAFFING/PageContent/EmbeddedIntelligenceByTag.cfm?tagList=" + URLEncodedFormat(tagList) + "&" + (new Date().getTime());
        
    if (! embeddedIntelFrame) {
        
        document.attachEvent("onmousedown", hideEmbeddedIntelligence);
        embeddedIntelFrame = document.createElement("DIV");
        embeddedIntelFrame.style.visibility = "hidden";
        embeddedIntelFrame.style.position = "absolute";
        embeddedIntelFrame.style.padding = 6;
        embeddedIntelFrame.style.pixelTop = 0;
        embeddedIntelFrame.style.pixelRight = 0;
        embeddedIntelFrame.style.pixelWidth = 350;
        embeddedIntelFrame.style.pixelHeight = document.body.offsetHeight - 30;
        embeddedIntelFrame.style.backgroundColor = "#777777";
        embeddedIntelFrame.style.borderLeft = "1px solid #333366";
        embeddedIntelFrame.style.borderBottom = "1px solid #333366";
        embeddedIntelFrame.style.filter="progid:DXImageTransform.Microsoft.Blinds(direction='LEFT', Bands=1, duration=0.25)"; 
    
        embeddedIntelFrame.innerHTML = "<div style=\"background-color: #ABCEF0; border-bottom:#cccccc; line-height:20px\" align=right>"
            + "<a onmousedown=\"event.cancelBubble = true\" href=\"javascript:expandEmbeddedIntelligence(); \">New Window</a>"
            + "&nbsp;&middot;&nbsp;"
            + "<a onmousedown=\"event.cancelBubble = true\" href=\"javascript:hideEmbeddedIntelligence()\">Close</a>"
            + "&nbsp;</div>";

        embeddedIntelWindow = document.createElement("IFRAME");
        embeddedIntelWindow.name = "BHEmbeddedIntelWnd"
        embeddedIntelWindow.style.pixelWidth = embeddedIntelFrame.style.pixelWidth - 15;
        embeddedIntelWindow.style.pixelHeight = embeddedIntelFrame.style.pixelHeight - 20;
        embeddedIntelWindow.scrolling = "auto";
        embeddedIntelWindow.frameBorder = "none";
        
        
        embeddedIntelFrame.appendChild(embeddedIntelWindow);
        document.body.appendChild(embeddedIntelFrame);
    }
    
    embeddedIntelWindow.contentWindow.location = url;
    _showEmbeddedIntelligence();
}

function _showEmbeddedIntelligence() {
    embeddedIntelFrame.filters[0].Direction = "LEFT";
    embeddedIntelFrame.filters[0].apply();
    embeddedIntelFrame.style.visibility = "visible";
    embeddedIntelFrame.filters[0].play();
}

function editCognosReport(reportID,reportType) {
    if (reportType=="Query")
    {       
        bhWindowOpen('/BullhornStaffing/BullhornReporting/Forms/EditBizAuthorReport.cfm?reportingID=' + reportID, 'bullhornReportEdit'+ reportID + 'Wnd');
    }
    if (reportType=="Report")
    {       
        bhWindowOpen('/BullhornStaffing/BullhornReporting/Forms/EditProAuthorReport.cfm?reportingID=' + reportID, 'bullhornReportEdit'+ reportID + 'Wnd');
    }
}

function deleteCognosReport(reportID,userID) {       
    if (confirmActionYesNo("Are you sure you wish to delete this report? You will no longer be able to access it, and will need to recreate it")) {
        showPopWindowIFRAME("/BullhornStaffing/BullhornReporting/Update/UpdReportingDefinition.cfm?sqlType=DEL&reportingID=" + reportID + "&userID=" + userID + "&reloadReturnToURL=TRUE&reloadOpener=TRUE&closeOnFinish=TRUE&noLogo=TRUE",true);
    }
}

function runCognosReport(reportID) {
    bhWindowOpen('/BullhornStaffing/BullhornReporting/RunReport.cfm?reportingID=' + reportID, 'bullhornReport'+ reportID + 'Wnd');
}

function viewNoteReferences(userCommentID,jobPostingID,userID,placementID)
{
    
    var dataValidateXmlHttp = getXMLHTTP();
    var url = "";
     
    // set url for template being called for data validation
    url = "/BullhornStaffing/UserCommentReferences.cfm?userCommentID=" + userCommentID + "&userID="+userID+"&jobPostingID="+jobPostingID+"&placementID="+placementID+"&nocachetoken=" + new Date().getTime();
    
    dataValidateXmlHttp.open("GET", url, false);
    dataValidateXmlHttp.send();
    
    if (dataValidateXmlHttp.readyState == 4 && dataValidateXmlHttp.responseText) {
        document.getElementById("userCommentReference"+userCommentID).innerHTML = dataValidateXmlHttp.responseText;
        document.getElementById("viewReferences" + userCommentID).style.display='none';
        document.getElementById("hideReferences" + userCommentID).style.display='block';
    }
    else {
        document.getElementById("userCommentReference"+userCommentID).innerHTML = "No Additional References";
        document.getElementById("viewReferences" + userCommentID).style.display='none';
        document.getElementById("hideReferences" + userCommentID).style.display='block';
    }
}

function hideNoteReferences(userCommentID)
{
    document.getElementById("userCommentReference"+userCommentID).innerHTML = "";
    document.getElementById("viewReferences" + userCommentID).style.display='block';
    document.getElementById("hideReferences" + userCommentID).style.display='none';
}