var brushState = "block";
var existingClassNames = new Array();

function surfToEditNavigationItem(key)
{
    ShowDialog_NoReturnValue(gAdminWebRoot + "/iMIS/ContentManagement/NavigationItemProperties.aspx?iUniformKey=" + key, null, '800', '600', 'Navigation Designer', '~/AsiCommon/Images/icon_nav.gif', 'E');
    CancelEvent();
}

function surfToEditContentItem(contentRecordKey, contentItemKey)
{
    surfToEditContentRecord(contentRecordKey, '&ContentItemKey=' + contentItemKey);
}

function surfToEditContentRecord(key, queryStringParams)
{
    var url = gAdminWebRoot + '/iMIS/ContentManagement/ContentDesigner.aspx?TemplateType=E&ShowMenu=true&DialogMode=true&ShowHierarchyTree=false&Mode=EditContent&ShowAddress=false&ContentHierarchyKey=' + key;
    if (queryStringParams != null && queryStringParams.length > 0)
    {
        if (queryStringParams.substr(0,1) == '?')
            queryStringParams = queryStringParams.substr(1);
        
        if (queryStringParams.substr(0,1) != '&')
            queryStringParams = '&' + queryStringParams;
            
        url += queryStringParams;
    }
    //ShowDialog_NoReturnValue(url, null, '95%', '95%', 'Content Designer', '~/AsiCommon/Images/icon_con.gif', 'E');
    NewWindow(url, 'ContentDesigner', 'current', 'nonmodal', false);
    
    CancelEvent();
}

function contentRecordChangeRequest(key, queryStringParams)
{
    var url = gAdminWebRoot + '/AsiCommon/Controls/ContentManagement/ContentDesigner/ContentChangeRequestEdit.aspx?CloseWindowOnCommit=true&PageOperation=New&ContentRecordKey=' + key;
    if (queryStringParams != null && queryStringParams.length > 0)
    {
        if (queryStringParams.substr(0,1) == '?')
            queryStringParams = queryStringParams.substr(1);
        
        if (queryStringParams.substr(0,1) != '&')
            queryStringParams = '&' + queryStringParams;
            
        url += queryStringParams;
    }
    ShowDialog_NoReturnValue(url, null, '600', '400', 'Content Designer', '~/AsiCommon/Images/icon_con.gif', 'E');
    
    CancelEvent();
}

function emailAFriend(pageTitle)
{
    var url = gWebRoot + '/iMIS/ContentManagement/EmailAFriend.aspx?PageTitle=' + pageTitle + '&PreserveStatefulBusinessContainer=true';
    ShowDialog_NoReturnValue(url, null, 600, 400, 'E-mail a friend', '~/AsiCommon/Images/icon_email.gif', 'E');
    
    return CancelEvent();    
}

function printThisPage()
{
    window.open(gWebRoot + '/iMIS/Print.aspx');
}

function printThisPageTemplate()
{
    var url = window.location.href;
    var re = new RegExp('[?&]TemplateType=[A-Za-z]', "g");
    url = url.replace(re, "");
    if (url.indexOf("?") < 0)
        url += "?";
    else
        url += "&";
    url += "TemplateType=P";
    window.location.href = url;
}

function showHideBrush()
{
	var links = document.getElementsByName("editlink");

	if (links == null || links.length == 0)
	{
	    alert('There are no Screen Designer Panels to edit on this page.');
	    return;
	}

	for (i=0;i<links.length;i++)
	{
		links[i].style.display = brushState;
		links[i].className = "";
		if (brushState == "block")
		{
		    existingClassNames[i] = getParent(links[i]).className;

		    getParent(links[i]).className = "PanelEditLink";
			var title = links[i].getAttribute("panelName");
			getParent(links[i]).title = title;
		}
		else
		{
		    getParent(links[i]).className = existingClassNames[i];
		    getParent(links[i]).title = "";
		}
	}
	if (brushState == "none")
		brushState = "block";
	else
		brushState = "none";
}

function Rollover(obj, image)
{
	obj.src = image;
}

function printWindow()
{
	var bV = parseInt(navigator.appVersion)
	if (bV >= 4) window.print()
}

function emailWindow()
{
	alert('email window');
}

function showInfoCenter()
{
	alert('InfoCenter');
}

/* CDR - 11/29/2006 - window.showHelp is a standard javascript func - commenting out b/c it was killing help links
function showHelp()
{
	alert('Help!');
}*/

//
// Same thing as ShowDialog except that it doesn't return the Dialog Window at the end of the function.  This is necessary
// if you want to hook up this function directly to <a href="javascript:ShowDialog(...)">.
//
function ShowDialog_NoReturnValue(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject) 
{
    ShowDialog(url, args, width, height, title, iconUrl, templateType, callBackFunction, windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject);
}
var RadWindowInformation = new Object();
//
// Opens a modal dialog given the parameters
//
function ShowDialog(url, args, width, height, title, iconUrl, templateType, callBackFunction,
windowName, closeWindowOnCommit, preserveStatefulBusinessContainer, dialogCloseFunction, sourceObject) 
{
    if (url.indexOf('~') == 0)
        url = gWebRoot + url.substring(1);
        
    if (windowName == null || windowName.length == 0)
        windowName = 'GenericWindow';
        
    if (url.indexOf("TemplateType=") < 0)
    {
        if (templateType == null || templateType.length == 0)
            templateType = "E";
        var separator = url.indexOf("?") > -1 ? "&" : "?";
        url += separator + "TemplateType=" + templateType;
    }
    if (closeWindowOnCommit && url.indexOf("CloseWindowOnCommit") < 0)
    {
        var separator = url.indexOf("?") > -1 ? "&" : "?";
        url += separator + "CloseWindowOnCommit=" + closeWindowOnCommit;
    }
    if (preserveStatefulBusinessContainer && url.indexOf("PreserveStatefulBusinessContainer") < 0)
    {
        var separator = url.indexOf("?") > -1 ? "&" : "?";
        url += separator + "PreserveStatefulBusinessContainer=" + preserveStatefulBusinessContainer;
        var parentPageInstanceKey = $get('PageInstanceKey');
        if (parentPageInstanceKey != null)
            url += "&ParentPageInstanceKey=" + parentPageInstanceKey.value;
    }
    if (url.indexOf("DialogCacheParam") < 0)
    {
        var separator = url.indexOf("?") > -1 ? "&" : "?";
        url += separator + "DialogCacheParam=" + Math.random();
    }

    var pageWidth = livePageWidth();
    if ((width + '').indexOf('%') > -1)
        width = pageWidth * (parseInt(width) / 100);
    else if (width > pageWidth)
        width = pageWidth;

    var pageHeight = livePageHeight();
    if ((height + '').indexOf('%') > -1)
        height = pageHeight * (parseInt(height) / 100);
    else if (height > pageHeight)
        height = pageHeight;

    RadWindowInformation.windowName = windowName;
    RadWindowInformation.url = url;
    RadWindowInformation.args = args;
    RadWindowInformation.width = width;
    RadWindowInformation.height = height;
    RadWindowInformation.title = title;
    RadWindowInformation.iconUrl = iconUrl;
    RadWindowInformation.callBackFunction = callBackFunction;
    RadWindowInformation.dialogCloseFunction = dialogCloseFunction;
    RadWindowInformation.sourceObject = sourceObject;
    RadWindowInformation.dialogWindow = null;

    var windowManager = GetRadWindowManager();
    if (windowManager == null)
    {
        DelaySetupRadWindow();
        return null;
    }
    var dialogWindow = windowManager.getWindowByName(windowName);
    if (dialogWindow != null && dialogWindow.IsClosed())
    {
        dialogWindow.Name = null;
        dialogWindow = null;
    }

    if (dialogWindow == null)
        dialogWindow = window.radopen(null, windowName);
    if (dialogWindow == null)
    {
        DelaySetupRadWindow();
        return null;
    }

    RadWindowInformation.dialogWindow = dialogWindow;
    return SetupRadWindow();
}

function DelaySetupRadWindow()
{
    // Have to delay a little bit to give the RadWindowManager time to open the window.
    addAjaxLoadEvent(SetupRadWindow);
}

function SetWindowTitle(oWindow, args) 
{
    oWindow.set_title(RadWindowInformation.title);
}

function SetupRadWindow()
{
    var dialogWindow = RadWindowInformation.dialogWindow;
    if (dialogWindow == null)
        dialogWindow = GetRadWindowManager().getWindowByName(RadWindowInformation.windowName);

    // SBI 7448 - Need to set title in page load (for Safari)
    //dialogWindow.set_title(RadWindowInformation.title);
    dialogWindow.remove_pageLoad(SetWindowTitle);
    dialogWindow.add_pageLoad(SetWindowTitle);
    
    // TODO: after Telerik decides to implement SetIcon we need to use it instead of 
    // this hack
    //actionWindow.SetIcon(result.IconUrl);
    //dialogWindow.ii = iconUrl;
    //dialogWindow.Ii = iconUrl;
    //ctl00_ctl02[result.WindowName].children(0).children(0).children(1).children(1).children(0).children(0).children(0).children(0).src = result.IconUrl;

    dialogWindow.Argument = RadWindowInformation.args;
    dialogWindow.dialogArguments = RadWindowInformation.args;
    if (RadWindowInformation.callBackFunction != null)
        dialogWindow.add_beforeClose(RadWindowInformation.callBackFunction);
    if (RadWindowInformation.dialogCloseFunction != null)
        dialogWindow.add_close(RadWindowInformation.dialogCloseFunction);
    dialogWindow.SourceObject = RadWindowInformation.sourceObject;

    dialogWindow.setUrl(RadWindowInformation.url);
    dialogWindow.SetVisible(true); //DT6174 - Show() moved here in order to resolve issue with display of scrollbars
    // fix; ensure the dialog never starts out larger than the browser window.
    var viewWidth = GetViewportWidth();
    var viewHeight = GetViewportHeight();
    if (RadWindowInformation.width > viewWidth) RadWindowInformation.width = viewWidth;
    if (RadWindowInformation.height > viewHeight) RadWindowInformation.height = viewHeight;
    dialogWindow.setSize(RadWindowInformation.width, RadWindowInformation.height);
    dialogWindow.set_visibleStatusbar(false);
    // Set the window icon
    var oTitle = dialogWindow.GetTitlebar();
    var oAnchor = oTitle.getElementsByTagName('a');
    oAnchor[0].style.background = "url(about:blank)";
    
    dialogWindow.center();
        
    return dialogWindow;
}

// opens a dialog window
// Parameters:
//	contentCode - the ContentCode of the content to show in the dialog.  Required.
//	modal - if true the dialog is modal, if false it is pseudo modal, meaning it can postback etc.  If not supplied, false (pseudo) is assumed
//  urlParamString - any url params to pass to the window (e.g., the server).  Should be a string like param1=value1&param2=value2 etc.
//  args - any arguments passed to the client as dialogArguments (for modal), or accessible in opener.dialogWin.args if pseudo
//	width - the width of the dialog.  If not supplied, 600 is assumed
//	height - the width of the dialog.  If not supplied, 400 is assumed
//  returnFunc -- reference to the function (on this caller) to be called when the dialog is done
//  navigationCode - If specified, this value is put into the query string.  This is to allow the IQD to
//    utilize this function.
//  title - the title to appear on the pop-up window
function CMOpenDialog(contentCode, modal, width, height, urlParamString, args, returnFunc, navigationCode, title) 
{
    // contentCode is required
    if (contentCode != null) {
        // initialize any parameters not sent
        if (urlParamString == null)
            urlParamString = "";
        else if (urlParamString.substr(0, 1) != "&")
            urlParamString = "&" + urlParamString;
        if (width == null)
            width = 600;
        if (height == null)
            height = 400;
        if (title == null)
            title = '';

        var url = gWebRoot + "/iMIS/ContentManagement/Template.aspx?ContentCode=" + contentCode + urlParamString;
        if (typeof gWebsiteKey != 'undefined' && gWebsiteKey != 'null' && url.indexOf('&WebsiteKey=') < 0)
            url += '&WebsiteKey=' + gWebsiteKey;

        if (navigationCode != null)
            url = url + "&NavigationCode=" + navigationCode;

        ShowDialog(url, args, width, height, title, '', 'E', returnFunc);
    }
    else
        alert('contentCode is required!');
}

function GetViewportWidth()
{
    var viewportwidth;

    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
    if (typeof window.innerWidth != 'undefined')
    {
        viewportwidth = window.innerWidth;
    }
    else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
    {
        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
        viewportwidth = document.documentElement.clientWidth;
    }
    else
    {
        // older versions of IE
        viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
    }
    
    return viewportwidth;
}

function GetViewportHeight()
{
    var viewportheight;

    if (typeof window.innerWidth != 'undefined')
    {
        viewportheight = window.innerHeight;
    }
    else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
    {
        viewportheight = document.documentElement.clientHeight;
    }
    else
    {
        viewportheight = document.getElementsByTagName('body')[0].clientHeight;
    }
    
    return viewportheight;
}

// One object tracks the current modal dialog opened from this window.
var dialogWin = new Object()

// Generate a pseudo modal dialog that can do postback etc. i.e., it is a real window that acts modal
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the dialog
//    args -- [optional] any data you need to pass to the dialog
function ShowPseudoDialog(url, args, width, height, returnFunc) {
    // set the window events on the parent so that trying to go back there set focus back to the dialog
	window.attachEvent('onclick',checkModal);
	window.attachEvent('onfocus',checkModal);
	
	// SAT - 11/9/2006 - DT18027
	// Added the following try/catch to handle the exception which occurs when the parent of the 
	// dialog is hosted in c/s.
	var newDialog = false;
	try {
	    if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed))
	        newDialog = true;
	}
	catch(e) {
	    if(e.message == 'The remote server machine does not exist or is unavailable')
	        newDialog = true;
	}
	
	if (newDialog) {
		// Initialize properties of the modal dialog object.
		dialogWin.returnFunc = returnFunc
		dialogWin.returnedValue = ""
		dialogWin.args = args
		if (typeof(returnFunc) == "string" && returnFunc != "")
		{
			if (url.indexOf("?") < 0)
				url += "?" + "iCallbackFunction=" + returnFunc;
			else
				url += "&" + "iCallbackFunction=" + returnFunc;
		}
		dialogWin.url = url
		dialogWin.width = width
		dialogWin.height = height
		// Keep name unique so Navigator doesn't overwrite an existing dialog.
		dialogWin.name = (new Date()).getSeconds().toString()
		// Assemble window attributes and center on the screen
		dialogWin.left = (screen.width - dialogWin.width) / 2
		dialogWin.top = (screen.height - dialogWin.height) / 2
		var attr = "left=" + dialogWin.left + ",top=" + 
			dialogWin.top + ",scrollbars=yes,resizable=yes,width=" + dialogWin.width + 
			",height=" + dialogWin.height
		
		// Generate the dialog and make sure it has focus.
		dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr)
		dialogWin.win.focus()
	} else {
		dialogWin.win.focus()
	}
}

// Invoked by onFocus event handler of EVERY frame,
// return focus to dialog window if it's open.
function checkModal() {
	setTimeout("finishChecking()", 50)
	return true;
}

function finishChecking() {
    // try-catch required to handle exception when dialog's parent is hosted in omnis.
    try {
	    if (dialogWin.win && !dialogWin.win.closed) {
		    dialogWin.win.focus() 
	    }
    }
    catch(e) {
        if(e.message == 'The remote server machine does not exist or is unavailable')
            return;
    }	 
}

function wait()
{
    if ($("WaitProgressDiv") != null)
    {
        var waitDiv = $("WaitProgressDiv");
        waitDiv.style.display = "block";
        var divWidth = 277;
        var divHeight = 24;
        waitDiv.style.left = (document.body.offsetWidth - divWidth) / 2;
		waitDiv.style.top = (document.body.offsetHeight - divHeight) / 2;
    }
    
	window.document.body.style.cursor = "wait";
	
	//disable all input type=submit,img,button objects so user doesn't
	//inadvertantly click a button while page is posting
	var inputs = document.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++)
	{
		var type = inputs[i].getAttribute("type").toLowerCase();
		if ((type == "submit" || type == "image" || type == "button") && (window.event == null || window.event.srcElement != inputs[i]))
			inputs[i].disabled = true;
	}
}
function waitStop()
{
    if ($("WaitProgressDiv") != null)
    {
        var waitDiv = $('WaitProgressDiv');
        waitDiv.style.display = "none";
    }
    
	window.document.body.style.cursor = "default";
	
	//disable all input type=submit,img,button objects so user doesn't
	//inadvertantly click a button while page is posting
	var inputs = document.getElementsByTagName("input");
	for (var i=0;i<inputs.length;i++)
	{
		var type = inputs[i].getAttribute("type").toLowerCase();
		if ((type == "submit" || type == "image" || type == "button") && window.event.srcElement != inputs[i])
			inputs[i].disabled = false;
	}
}

function dropDownListNavigate(ddl) 
{
  var loc = ddl.options[ddl.selectedIndex].value;
  if(loc != "") {
    if(loc.substr(0, 1) == '~') {
      loc = gWebRoot + loc.substr(1);
    }
    location.href=loc;
  }
}

// opens the BSA object browser as a pop-up allowing the user to select one or more documents or folders for return to the caller
// Parameters:
//  urlParamString - any url params to pass to the browser (see list of available arguments in object browser documentation.  
//     Should be a string like param1=value1&param2=value2 etc.
//  returnFunc -- reference to the function (on the caller) to be called when the dialog is done.  This function will receive
//     the following parameters from the browser:
//        count - the number of keys selected by the user
//        keys - a comma delimited list of the keys selected: HierarchyKeys for folders or DocumentKeys for anything else
//		  type - the DocumentTypeCode of the document selected if there is only one.  Null if more than one
//		  name - the DocumentName of the document selected if there is only one.  Null if more than one
//        executeCallbackOnClose - whether to execute returnFunc anytime the dialog is closed (true), or only when it's closed after a commit operation (false).
function OpenObjectBrowserSized(urlParamString, returnFunc, singleSelect, publishedOnly, args, width, height, executeCallbackOnClose)
{
    var url = gWebRoot + '/AsiCommon/Controls/BSA/ObjectBrowser.aspx?TemplateType=E&DialogMode=true';

    if (urlParamString != null)
    {
        var paramsArray = urlParamString.split("&");
        
	    // we have a few defaults for the pop-up browser that differ from the browser's normal defaults. 
	    // Set them unless they are already in the urlParamString
	    if (FindParameterInArray("Mode", paramsArray) == null)
	        urlParamString += "&Mode=SelectContent";
	    if (singleSelect != null && singleSelect && FindParameterInArray("AllowMultiSelect", paramsArray) == null)
	        urlParamString += "&AllowMultiSelect=false";
	    if (publishedOnly != null && FindParameterInArray("PublishedOnly", paramsArray) == null)
	        urlParamString += "&PublishedOnly=" + publishedOnly;
    	    
	    if (urlParamString.substr(0, 1) != "&")
	        url += "&";
	    url += urlParamString;
	}
	else
	{
        url += "&Mode=SelectContent";
        if (singleSelect != null && singleSelect)
            url += "&AllowMultiSelect=false";
        if (publishedOnly != null)
            url += "&PublishedOnly=" + publishedOnly;
	}
	
	return ShowDialog(url, args, width, height, 'Document Browser', null, 'E', returnFunc, 'ObjectBrowser', false, false, (executeCallbackOnClose ? returnFunc : null));
}

// opens the BSA object browser as a pop-up allowing the user to select one or more documents or folders for return to the caller
// Parameters:
//  urlParamString - any url params to pass to the browser (see list of available arguments in object browser documentation.  
//     Should be a string like param1=value1&param2=value2 etc.
//  returnFunc -- reference to the function (on the caller) to be called when the dialog is done.  This function will receive
//     the following parameters from the browser:
//        count - the number of keys selected by the user
//        keys - a comma delimited list of the keys selected: HierarchyKeys for folders or DocumentKeys for anything else
//		  type - the DocumentTypeCode of the document selected if there is only one.  Null if more than one
//		  name - the DocumentName of the document selected if there is only one.  Null if more than one
function OpenObjectBrowser(urlParamString, returnFunc, singleSelect, publishedOnly, args)
{
    return OpenObjectBrowserSized(urlParamString, returnFunc, singleSelect, publishedOnly, args, 800, 600, false);
}

function OpenContentForEdit(contentHierarchyKey) 
{
    var url = gAdminWebRoot + '/iMIS/ContentManagement/ContentDesigner.aspx?TemplateType=E&ShowMenu=true&DialogMode=true';

    url += "&ContentHierarchyKey=" + contentHierarchyKey

    var obWindow = radopen(url, 'ObjectBrowser');
    return obWindow;
}
function EditContentItem(hierarchyKey)
{
    OpenContentForEdit(hierarchyKey);
}
function OpenFinderAdder(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, width, height)
{
    OpenFinderAdderWithQueryFilter(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, "", width, height, "");
}
function OpenFinderAdderWithQueryFilter(returnFunc, singleSelect, documentKey, documentPath, atomName, displayValueColumn, keyValueColumn, filterValue, width, height, addTargetUrl)
{
    var url = gWebRoot + '/AsiCommon/Controls/Shared/FinderAdder/FinderAdder.aspx?DialogMode=true';

    if (documentKey != null)
        url += "&DocumentKey=" + documentKey;
    else if (documentPath != null)
        url += "&DocumentPath=" + documentPath;
    else if (atomName != null)
        url += "&AtomName=" + atomName;
        
    if (displayValueColumn != null && displayValueColumn.length > 0)
        url += "&DisplayValueColumn=" + displayValueColumn;
    if (keyValueColumn != null && keyValueColumn.length > 0)
        url += "&DataKeyName=" + keyValueColumn;
        
    if (filterValue != null && filterValue.length > 0)
        url += "&filterValue=" + filterValue;
    
	// we have a few defaults for the pop-up browser that differ from the browser's normal defaults. 
	// Set them unless they are already in the urlParamString
	if (singleSelect != null && singleSelect)
	    url += "&AllowMultiSelect=false";
	else 
	    url += "&AllowMultiSelect=true&PagingEnabled=false";
	    
	if (addTargetUrl != null && addTargetUrl.length > 0)
	    url += "&AddTargetUrl=" + addTargetUrl;
	    	
    if (width == null)
        width = 600;
    if (height == null)
        height = 600;

    return ShowDialog(url, null, width, height, "Find/Add", null, 'E', returnFunc, 'ObjectBrowser', false, true);
}
function OpenFileUpload(returnFunc, documentStorageKey, documentServerPath, maxFileSize)
{
    var url = gWebRoot + '/AsiCommon/Controls/Shared/FileUpload/FileUpload.aspx';
    if (documentStorageKey != null && documentStorageKey.length > 0)
        url += "?DocumentStorageKey=" + documentStorageKey;
    if (documentServerPath != null && documentServerPath.length > 0) 
    {
        if (url.indexOf("?") < 0)
            url += "?DocumentServerPath=" + documentServerPath;
        else
            url += "&DocumentServerPath=" + documentServerPath;
    }
    if (maxFileSize != null && maxFileSize > 0)
    {
        if (url.indexOf("?") < 0)
            url += "?MaxFileUploadSize=" + maxFileSize;
        else
            url += "&MaxFileUploadSize=" + maxFileSize;
    }
        
    return ShowDialog(url, null, 400, 250, "File Upload", null, 'E', returnFunc, 'GenericWindow', false, true);
}

// opens the BSA object browser in Save mode
// Parameters:
//  urlParamString - any url params to pass to the browser (see list of available arguments in object browser documentation.  
//     Should be a string like param1=value1&param2=value2 etc.
//  returnFunc -- reference to the function (on the caller) to be called when the dialog is done.  This function will receive
//     the following parameters from the browser:
//        hierarchyKey - the hierarchy key of the folder selected by the user
//        filename - the name of the file to be saved
function OpenObjectSaver(urlParamString, returnFunc)
{
    var paramsArray = urlParamString.split("&");
    
	// we have one default for the saver that differs from the pop-up browser
	// Set it unless it is already in the urlParamString
	if (FindParameterInArray("ShowFilename", paramsArray) == null)
		urlParamString = urlParamString + "&ShowFilename=true";
	if (FindParameterInArray("Mode", paramsArray) == null)
		urlParamString = urlParamString + "&Mode=SelectContainer";
	
	OpenObjectBrowser(urlParamString, returnFunc);
}
function clickButton(e, buttonid)
{
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object')
    {
        var evt = navigator.appName.indexOf('Netscape')>(-1) ? e : event;
        if (evt.keyCode == 13)
        {
            bt.click();
            return cancelEvent();
        }
    }
    return true;
}

var dirty = true;
//window.onunload = finish;
function finish(buttonId)
{
    if (dirty && window.opener)
    {
        //		tryU
        {
            if (buttonId)
            {
                var button = window.opener.document.getElementById(buttonId);

                if (button == null && window.opener.dialogWin.args != null)
                {
                    button = window.opener.document.getElementById(window.opener.dialogWin.args);
                }
                if (button != null)
                    button.click();
            }

            if (button == null && window.opener.RefreshBySubmit)
                window.opener.RefreshBySubmit();

            if (window.opener.dialogWin.returnFunc != null)
                window.opener.dialogWin.returnFunc();

        }
        //	    catch(e)
        //	    {
        //	        // exception will happen when dialog opened from within Client/Server b/c of 
        //	        // security.  this will be a problem.
        //	    }
    }
    else if (dirty && parent)
    {
        // If we were opened in an iframe (for example, in the Edit Pane in ObjectBrowser2), notify the parent page
        // that we committed so that it can update any needed status.
        if (typeof parent.SubPage_Committed == 'function')
            parent.SubPage_Committed();
    }
}

/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com

How it works: just apply the CSS class of 'column' to your pages' main columns.
*/
var MatchColumnsSemaphore = false;
matchColumns=function()
{ 
    var divs,contDivs,maxHeight,divHeight,d; 

    // get all <div> elements in the document 
    divs=document.getElementsByTagName('div'); 
    contDivs=[]; 

     // initialize maximum height value 
     maxHeight=0; 

     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++)
     { 
          // make collection with <div> elements with class attribute 'column' 
          if(/\bcolumn\b/.test(divs[i].className))
          { 
                d=divs[i]; 
                contDivs[contDivs.length]=d; 
                // determine height for <div> element 
                if(d.offsetHeight) 
                    divHeight=d.offsetHeight; 					
                else if(d.style.pixelHeight)
                    divHeight=d.style.pixelHeight;					 
                else
                {
                    // added the time  out for use when resizing is happening onload (like in rad window)
                    if (MatchColumnsSemaphore)
                        MatchColumnsSemaphore = false;
                    else
                    {
                        window.setTimeout(matchColumns,500);
                        MatchColumnsSemaphore = true;
                        return;
                    }
                }
                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++)
          contDivs[i].style.height=maxHeight + "px"; 
} 

// Runs the script when page loads 
window.onload=function()
{ 
     if(document.getElementsByTagName)
          matchColumns();			 
} 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
