function move(fbox,tbox)
{
var i = 0;
if(fbox.value != "")
	{
	var no = new Option();
	no.value = fbox.value;
	no.text = fbox.value;
	tbox.options[tbox.options.length] = no;
	fbox.value = "";
   }
}


function remove(box)
{
for(var i=0; i<box.options.length; i++)
	{
	if(box.options[i].selected && box.options[i] != "")
		{
		box.options[i].value = "";
		box.options[i].text = "";
   	}
	}
BumpUp(box);
}


function BumpUp(abox)
{
for(var i = 0; i < abox.options.length; i++)
   {
   if(abox.options[i].value == "")
      {
      for(var j = i; j < abox.options.length - 1; j++)
         {
         abox.options[j].value = abox.options[j + 1].value;
         abox.options[j].text = abox.options[j + 1].text;
         }
      var ln = i;
      break;
      }
   }
if(ln < abox.options.length)
   {
   abox.options.length -= 1;
   BumpUp(abox);
   }
}


function Moveup(dbox)
{
for(var i = 0; i < dbox.options.length; i++)
   {
   if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0])
      {
      var tmpval = dbox.options[i].value;
      var tmpval2 = dbox.options[i].text;
      dbox.options[i].value = dbox.options[i - 1].value;
      dbox.options[i].text = dbox.options[i - 1].text
      dbox.options[i-1].value = tmpval;
      dbox.options[i-1].text = tmpval2;
      }
   }
}


function Movedown(ebox)
{
for(var i = 0; i < ebox.options.length; i++)
	{
	if (ebox.options[i].selected && ebox.options[i] != "" && ebox.options[i+1] != ebox.options[ebox.options.length])
		{
		var tmpval = ebox.options[i].value;
		var tmpval2 = ebox.options[i].text;
		ebox.options[i].value = ebox.options[i+1].value;
		ebox.options[i].text = ebox.options[i+1].text
		ebox.options[i+1].value = tmpval;
		ebox.options[i+1].text = tmpval2;
      }
   }
}


function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
   	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
   }
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

var browser_ver = "";
var browser = "";
var mouseoversupport = "";
var browsername = navigator.appName;
var browserversion = parseInt(navigator.appVersion);

var textFieldSize = 45;
var textFieldSmallSize = 15;
var textFieldLargeSize = 60;
var textFieldXLargeSize = 85;
var textAreaCols = 55;
var textAreaLargeCols = 80;
var textAreaRows = 3;
var textAreaWrap = '';

if (browsername == "Netscape")
{
   browser = "ns";
   browser_ver = "ns" + browserversion;

    if (browserversion <=  4) {
   textFieldSize = 25;
   textFieldSmallSize = 8;
   textFieldLargeSize = 30;
   textFieldXLargeSize = 42;
   textAreaCols = 27;
   textAreaLargeCols = 37;
   textAreaWrap='wrap="soft"';
}
}
else if (browsername == "Microsoft Internet Explorer")
{
   browser = "ie";
	if (browserversion >= 4)
   {
      browser_ver = "ie" + browserversion;
   }
   else
   {
      browser_ver = "ie3";
   }
}
else if (browsername == "Opera")
{
   browser = "op";
	browser_ver = "op" + browserversion;
}
else
{
      // If no browser is identified, assume IE v. 5.0
   browser_ver = "ie5";
}

function PopupHelp(url)
{
   if (browser_ver=="ns3" || browser_ver=="ns4")
   {
	newWindow = window.open("",'Help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=395,height=400');
   mouseoversupport = "yes";
   }
   else if (browser_ver=="ns5")
   {
	newWindow = window.open("",'Help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=395,height=400');
   mouseoversupport = "yes";
   }
   else if (browser_ver=="ie3" || browser_ver=="ie4" || browser_ver=="ie5")
   {
	newWindow = window.open("",'Help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=400,height=410');
   mouseoversupport = "yes";
   }
   else if (browser_ver=="op5")
   {
	newWindow = window.open("",'Help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=390,height=400');
   mouseoversupport = "yes";
   }
   else
   {
	newWindow = window.open("",'Help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=390,height=450');
   mouseoversupport = "no";
   }
   newWindow.focus();
   newWindow.location.href = url;
}

function PopupWiz(url)
{
   if (browser_ver=="ns3" || browser_ver=="ns4")
   {
	window.open(url,'Ad','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=650,height=380');
   mouseoversupport = "yes";
   }
   else if (browser_ver=="ns5")
   {
	newWindow = window.open(url,'Ad','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=650,height=330');
   mouseoversupport = "yes";
   }
   else if (browser_ver=="ie3" || browser_ver=="ie4" || browser_ver=="ie5")
   {
	window.open(url,'Ad','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=390,height=400');
   mouseoversupport = "yes";
   }
   else if (browser_ver=="op5")
   {
	window.open(url,'Ad','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=390,height=400');
   mouseoversupport = "yes";
   }
   else
   {
	window.open(url,'Ad','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=390,height=450');
   mouseoversupport = "no";
   }
   newWindow.focus();
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

  if (document.images) {
  masthead_dqm = new Image(413 ,28); masthead_dqm.src = "../images/masthead_dqm.gif";
  }

function pviiClassNew(obj, new_style) { //v2.7 by PVII
  obj.className=new_style;
}

var webSurfWindowName = "DQMWebSurfWindow";

function loadDocIntoWebSurfWindow2(documentUrl, form) {

    // Init settings.

    // Each browserOptionsXxxx value is a string, either "true" or "false".
    var settings =
        initSettings(
                     form.windowHeight.value,
                     form.windowWidth.value,
                     form.windowTop.value,
                     form.windowLeft.value,
                     form.browserOptionsDirectories.value == "true",
                     form.browserOptionsLocation.value == "true",
                     form.browserOptionsMenubar.value == "true",
                     form.browserOptionsResizable.value == "true",
                     form.browserOptionsScrollbars.value = "true",
                     form.browserOptionsStatus.value == "true",
                     form.browserOptionsToolbar.value == "true"
                     );

    // Open window and load document.

    var newWindow = window.open("", webSurfWindowName, settings);
    if ((newWindow != null) && (newWindow != 0)) {
        // New window was created.
        newWindow.focus();
        newWindow.location.href = documentUrl;

    } else {
        // New window was not created.  Display in current window.
        window.location.href = documentUrl;
    }
    return false;
}

function loadDocIntoWebSurfWindowByName(documentUrl, form, name) {

    // Init settings.

    // Each browserOptionsXxxx value is a string, either "true" or "false".
    var settings =
        initSettings(
                     form.windowHeight.value,
                     form.windowWidth.value,
                     form.windowTop.value,
                     form.windowLeft.value,
                     form.browserOptionsDirectories.value == "true",
                     form.browserOptionsLocation.value == "true",
                     form.browserOptionsMenubar.value == "true",
                     form.browserOptionsResizable.value == "true",
                     form.browserOptionsScrollbars.value = "true",
                     form.browserOptionsStatus.value == "true",
                     form.browserOptionsToolbar.value == "true"
                     );

    // Open window and load document.

    var newWindow = window.open("", name, settings);
    if ((newWindow != null) && (newWindow != 0)) {
        // New window was created.
        newWindow.focus();
        newWindow.location.href = documentUrl;

    } else {
        // New window was not created.  Display in current window.
        window.location.href = documentUrl;
    }
    return false;
}

function setSetting(settings, setting) {

    if (settings.length != 0) {
        settings = settings + "," + setting;
    } else {
        settings = setting;
    }
    return settings;
}

function initSettings(height,width,top,left,directories,location,menubar,resizable,scrollbars,status,toolbar) {

    var settings = "";
    var varName;

    if ((height.length > 0) && (height > 0)) {
        settings = setSetting(settings, "height="+height);
    }
    if ((width.length > 0) && (width > 0)) {
        settings = setSetting(settings, "width="+width);
    }
    if ((top.length > 0) && (top >= 0)) {
        if (browser == "ie") {
            varName = "top";
        } else {
            varName = "screenY";
        }
        settings = setSetting(settings, varName + "=" + top);
    }
    if ((left.length > 0) && (left >= 0)) {
        if (browser == "ie") {
            varName = "left";
        } else {
            varName = "screenX";
        }
        settings = setSetting(settings, varName + "=" + left);
    }

    // The value for each attribute should be a boolean value.

    if (directories) {
        settings = setSetting(settings, "directories");
    }
    if (location) {
        settings = setSetting(settings, "location");
    }
    if (menubar) {
        settings = setSetting(settings, "menubar");
    }
    if (resizable) {
        settings = setSetting(settings, "resizable");
    }
    if (scrollbars) {
        settings = setSetting(settings, "scrollbars");
    }
    if (status) {
        settings = setSetting(settings, "status");
    }
    if (toolbar) {
        settings = setSetting(settings, "toolbar");
    }

    if (settings.length == 0) {
        // By setting "settings" to something, this forces all of the
        // attributes to be false.  Note that "noAttributes" is not a
        // valid attribute.
        settings = "noAttributes";
    }
    return settings;
}
var currentDate = new Date();
// Use milliseconds in the window name so that we create a unique window
// whenever this file is loaded.  This prevents the focus call below from
// failing when we use a static name and the previous window exists.
var webSurfTestWindowName = "DQMWebSurfTestWindow" + currentDate.getTime();
var newTestWindow = 0;

function testWebSurfWindow(settings) {

    if (newTestWindow != 0) {
        newTestWindow.close();
    }

    newTestWindow = window.open("", webSurfTestWindowName, settings);
    if ((newTestWindow != null) && (newTestWindow != 0)) {
        // New window was created.
        newTestWindow.focus();

    } else {
        // New window was not created.  Display in current window.
        alert("Could not create test window.");
    }
    return false;
}

/*
var submitFlag;

function formOnSubmitHandler() {

    // Don't submit the form automatically when the user presses a
    // submit button.  Simply return the "submitFlag" value.  If
    // a button has an "onClick" handler, the handler can set the
    // flag's value.
    //return submitFlag;
    return true;
}
*/

function submitForm(form, event, nextPage, theSubmitFlag) {

    //alert("form: " + form.name + ", event: " + event + ", nextPage: " + nextPage);
    form.successPage.value=nextPage;
    form.event.value=event;

    //submitFlag = theSubmitFlag;
    form.submit();
}

function expandCollapsePanel(form, event, panelName) {

    form.panelName.value = panelName;

    submitForm(form, event, form.thisPage.value, true);
}

function displayFileDialog(path, type, filterType, callback, form, successPage, serverName, contextPath) {

    var url = contextPath + "/fileData?successPage=" + escape(successPage) + "&errorPage=" + escape("/error.jsp") + "&loginRedirectPage=" + escape("/popupLoginRedirect.jsp") + "&serverName=" + escape(serverName);

    if (path.length > 0) {
        // Path
        url = url + "&event=" + escape("getParentDescListEvent") + "&path=" + escape(path) + "&filterType=" + escape(filterType);
    } else {
        // No path.  Default to caller's preference.
        url = url + "&event=" + escape("getRootDescListEvent") +  "&filterType=" + escape(filterType);
    }
    // This is in includes/FileListCaller.js
    popupFileDialog(url, callback, form, type);
}

function notImplemented() {

    //submitFlag = false;
    alert("This feature is not implemented.");
}

function verifyChecked(count, checkboxList) {

    var checked;

    if (count == 1) {
        // Single check box.
        checked = checkboxList.checked;
    } else {
        // Multiple check boxes.
        checked = false;
        for (var i = 0; i < checkboxList.length; i++) {
            if (checkboxList[i].checked) {
                checked = true;
                break;
            }
        }
    }
    return checked;
}

function setClearCheckboxValue(checkbox, value) {

    // Set or clear the checkbox value.  When it has a value, it is sent
    // to the server.
    if (checkbox.checked) {
        // Set the checkbox value.
        checkbox.value = value;
    } else {
        // Clear the checkbox value.
        checkbox.value = "";
    }
}

function setCheckboxAll(count, checkboxAll, checkboxList) {

    if (count == 0) {
        // Nothing to do.
        return;
    }

    // Set the state of each check box based on the state of "checkboxAll".
    if (count == 1) {
        // Single check box.
        checkboxList.checked = checkboxAll.checked;
        setClearCheckBoxValue(checkboxList, 0);
    } else {
        // Multiple check boxes.
        for (var i = 0; i < checkboxList.length; i++) {
            checkboxList[i].checked = checkboxAll.checked;
            setClearCheckboxValue(checkboxList[i], i);
        }
    }
}

function cancelSubmitWithConfirmHandler() {

    var CONFIRM_CANCEL = "Are you sure you want to close the popup?";

    if (!confirm(CONFIRM_CANCEL)) {
        // Nope, don't cancel.
        return;
    }
    cancelSubmitHandler();
}

function cancelSubmitHandler() {

    window.opener.focus();
    window.close();

    return false;
}

function checkName(name) {

    var validCharsRE = "^[A-Za-z0-9_\\- '&]+$";

    // Verify that the user entered a non-zero length name.
    if (name.length <= 0) {
        // No name was entered.
        alert("You must enter a name in the 'name' text field.");
        return false;
    }
    // Verify that the user entered valid characters.
   if (name.search(validCharsRE) == -1) {
        // Not a valid name.
        alert("The name you have entered has one or more illegal characters.  The legal characters are alphabetic (upper and lower case), numeric, underscore, dash, space, apostrophe and ampersand.");
        return false;
    }
    return true;
}

function baseOnLoadHandler(form) {

    if (form.errorFlag.value.length > 0) {
        // The response to the request returned the error flag.
        var url = form.errorFlag.value;
        PopupSmall(url, "error");
    }
}

function optionListToList(optionList, omitLastFlag) {

    var list = new Array(optionList.length - 1);
    var length = optionList.length;
    if (omitLastFlag) {
        length--;
    }
    for (i = 0; i < length; i++) {
        list[i] = optionList.options[i].text;
    }
    return list;
}

function listToString(list, delim) {

    // Convert the list into a string.
    var text = "";
    for (i = 0; i < list.length; i++) {
        if (text.length > 0) {
            text = text + delim + list[i];
        } else {
            text = list[i];
        }
    }
    return text;
}

function optionListToString(optionList, omitLastFlag, delim) {

    // Convert the option list into a string.

    var text = "";
    var length = optionList.length;
    if (omitLastFlag) {
        length--;
    }
    for (i = 0; i < length; i++) {
        if (text.length > 0) {
            text = text + delim + optionList.options[i].text;
        } else {
            text = optionList.options[i].text;
        }
    }
    return text;
}

