function loadWorkspaceGraphics() {

    preloadImages();
    
    tabSpacer                = newImage("/resource/graphics/workspace/spacer.gif");
    groupFrameLeft           = newImage("/resource/graphics/workspace/tabs/model/groupFrameLeft.gif");

    cellFillerCenter           = newImage("/resource/graphics/workspace/tabs/model/cellFillerCenter.gif");
    cellFillerLeft             = newImage("/resource/graphics/workspace/tabs/model/cellFillerLeft.gif");
    cellLeftSideBottom         = newImage("/resource/graphics/workspace/tabs/model/cellLeftSideBottom.gif");
    cellLeftSide               = newImage("/resource/graphics/workspace/tabs/model/cellLeftSide.gif");
    cellLeftSideTop            = newImage("/resource/graphics/workspace/tabs/model/cellLeftSideTop.gif");
    cellLeftTop                = newImage("/resource/graphics/workspace/tabs/model/cellLeftTop.gif");
    cellRightSideBottom        = newImage("/resource/graphics/workspace/tabs/model/cellRightSideBottom.gif");
    cellRightTop               = newImage("/resource/graphics/workspace/tabs/model/cellRightTop.gif");
    cellRightSideTop           = newImage("/resource/graphics/workspace/tabs/model/cellRightSideTop.gif");

    groupFrameLeft             = newImage("/resource/graphics/workspace/tabs/model/groupFrameLeft.gif");

    tabBottomClosed            = newImage("/resource/graphics/workspace/tabs/model/tabBottomClosed.gif");
    tabBottomOpen              = newImage("/resource/graphics/workspace/tabs/model/tabBottomOpen.gif");
    tabFillBottom              = newImage("/resource/graphics/workspace/tabs/model/tabFillBottom.gif");
    tabFillBottomShort         = newImage("/resource/graphics/workspace/tabs/model/tabFillBottomShort.gif");
    tabIconEdit                = newImage("/resource/graphics/workspace/tabs/model/tabIconEdit.gif");
    tabIconEditBG              = newImage("/resource/graphics/workspace/tabs/model/tabIconEditBG.gif");
    tabLeftSideBottomClosed    = newImage("/resource/graphics/workspace/tabs/model/tabLeftSideBottomClosed.gif");
    tabLeftSideBottomOpen      = newImage("/resource/graphics/workspace/tabs/model/tabLeftSideBottomOpen.gif");
    tabLeftSideTop             = newImage("/resource/graphics/workspace/tabs/model/tabLeftSideTop.gif");
    tabLeftTopSmall            = newImage("/resource/graphics/workspace/tabs/model/tabLeftTopSmall.gif");

    tabRightSideBottomClosed   = newImage("/resource/graphics/workspace/tabs/model/tabRightSideBottomClosed.gif");

    tabRightSideBottomOpen     = newImage("/resource/graphics/workspace/tabs/model/tabRightSideBottomOpen.gif");
    tabRightSideTop            = newImage("/resource/graphics/workspace/tabs/model/tabRightSideTop.gif");
    tabRightTopSmall           = newImage("/resource/graphics/workspace/tabs/model/tabRightTopSmall.gif");
    tabTopBig                  = newImage("/resource/graphics/workspace/tabs/model/tabTopBig.gif");
    tabTopSmall                = newImage("/resource/graphics/workspace/tabs/model/tabTopSmall.gif");

}

function shoebox(file) {
    var screenWidth = screen.availWidth -20;
    childWindow = window.open(file,'ShoeBox','width=' + screenWidth + ',height=170,directories=0,location=0,menubar=0,scrollbars=0,status=1,toolbar=0,resizable=0,screenX=0,screenY=0,top=0,left=0').focus();
    self.name="opener";
}

function shoeboxImage(file,callingWindow) {
    if (callingWindow != null) {
        callingWindow.location.href=file;
        callingWindow.location.replace(file);
    }
}

function calDateWrite( formName, formField, dateYr, dateMo, dateDa) {

    form = opener.document[formName];

    fieldYr = formField + '_yr';
    fieldMo = formField + '_mo';
    fieldDa = formField + '_da';

    form[fieldYr].value = dateYr;
    form[fieldDa].value = dateDa;
    form[fieldMo].value = dateMo;

    form[fieldDa].focus();
    form[fieldMo].focus();
    form[fieldDa].blur();

    todayMDY = dateMo + '/' + dateDa + '/' + dateYr;

    window.close();

}

function calDisableRepeat( formName, todayMDY) {

    form = window.document[formName];

    select_mo = form.event_date_mo.value -1;
    select_da = form.event_date_da.value;
    select_yr = form.event_date_yr.value;

    selectDate = new Date(select_yr,select_mo,select_da);

    todayDate = new Date(todayMDY);

    if (selectDate >= todayDate) {
        form.isrecurring.disabled=false;
        form.recur_times.disabled=false;
        form.recur_type_id.disabled=false;
        form.recur_end_mo.disabled=false;
        form.recur_end_da.disabled=false;
        form.recur_end_yr.disabled=false;
    } else {
        form.isrecurring.checked=false;
        form.isrecurring.disabled=true;
        form.recur_times.disabled=true;
        form.recur_type_id.disabled=true;
        form.recur_end_mo.disabled=true;
        form.recur_end_da.disabled=true;
        form.recur_end_yr.disabled=true;
    }
 
}


function popupCalendarShell() {
    return false;
}

function popupCalendar(returnURL,whichOne) {

    var title = 'SelectDate' + whichOne;

    newWindow = window.open(returnURL,title,'width=300,height=305,menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,dependent=yes,directories=no,screenX=0,screenY=0,top=0,left=0');

    newWindow.location = returnURL;

    newWindow.focus();

    return false;

}


function popupCalendarRefresh(returnURL,whichOne) {

    window.location = returnURL;

    window.focus();

}


function popupWindowMedium(returnURL) {

    var title = 'Media';

    newWindow = window.open(returnURL,title,'width=300,height=400,menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,dependent=yes,directories=no,screenX=0,screenY=0,top=0,left=0');

    newWindow.location = returnURL;

    newWindow.focus();

    return false;

}

function popupWindowBig(returnURL,boxWidth,boxHeight) {

    var title = 'Media';

    newWindow = window.open(returnURL,title,'width='+boxWidth+',height='+boxHeight+',menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,dependent=yes,directories=no,screenX=0,screenY=0,top=0,left=0');

    newWindow.location = returnURL;

    newWindow.focus();

    return false;

}

function fileTypes(returnURL) {

    var title = 'AllowableFileTypes';

    newWindow = window.open(returnURL,title,'width=250,height=400,menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no,dependent=yes,directories=no,screenX=0,screenY=0,top=0,left=0');

    newWindow.location = returnURL;

    newWindow.focus();

    return false;

}

function closeMediaWindow(thisWindow) {

    thisWindow.close();

    return false;

}

function validatePreviewFile(previewName) {

    previewMsg = 'Preview file extension not supported ';

    if (previewName.match(/;/)) {
        alert(formatMsg + ';');
        return false;
    }

    if (previewName.match(/\|/)) {
        alert(formatMsg + '|');
        return false;
    }

    if (previewName.match(/\&/)) {
        alert(formatMsg + '&');
        return false;
    }

    if (previewName.match(/\?/)) {
        alert(formatMsg + '?');
        return false;
    }

    if (previewName.match(/\*/)) {
        alert(formatMsg + '*');
        return false;
    }

    if (previewName.match(/^\s+/)) {
        alert('Filename cannot contain leading spaces');
        return false;
    }

    if (previewName.match(/\s+$/)) {
        alert('Filename cannot contain trailing spaces');
        return false;
    }

    if (previewName.match(/\s+/)) {
        alert('Filename cannot contain embedded spaces');
        return false;
    }

    previewOK = false;
    if (previewName.match(/\.jpg\"?$/i)) {previewOK = true;}
    if (previewName.match(/\.gif\"?$/i)) {previewOK = true;}
    if (previewName.match(/\.png\"?$/i)) {previewOK = true;}
    if (previewOK == false) {
        alert(previewMsg);
        return false;
    }

    return previewOK;

}

function validatePreviewImportTypes(formName) {

    previewPathName   = formName.preview_file.value;

    slen = previewPathName.split("/").length
    previewName = (previewPathName.split("/")[slen-1])

    previewLength = previewName.length;    

    if (previewLength > 0) {

        if (! validatePreviewFile(previewName) ) {
            return false;
        }

    }

    return true;

}

function validateMediaImportTypes(formName,contentType) {

    formatMsg  = 'Invalid character in filename: ';
    upfileMsg  = 'File extension not supported ';
    previewMsg = 'Preview file extension not supported ';

    var caption   = formName.caption.value;

    caption = caption.replace(/^\s+|\s+$/gi,"");

    if (caption.match(/^$/)) {
        alert('Caption must not be blank');
        return false;
    }

    filePathName   = formName.media_file.value;

    checkPathLen = filePathName.length;

    slen = filePathName.split("/").length
    fileName = (filePathName.split("/")[slen-1])

    if (checkPathLen == fileName.length) {
        slen = filePathName.split("\\").length
        fileName = (filePathName.split("\\")[slen-1])
    }

    fileLength = fileName.length;    

    if (contentType != 'image') {

        previewPathName   = formName.preview_file.value;
        slen = previewPathName.split("/").length
        previewName = (previewPathName.split("/")[slen-1])

        previewLength = previewName.length;    

        if (previewLength > 0) {
    
            if (! validatePreviewFile(previewName) ) {
                return false;
            }
    
        }

    }

    if (fileLength > 0) {

        if (fileName.match(/;/)) {
            alert(formatMsg + ';');
            return false;
        }

        if (fileName.match(/\|/)) {
            alert(formatMsg + '|');
            return false;
        }

        if (fileName.match(/\&/)) {
            alert(formatMsg + '&');
            return false;
        }

        if (fileName.match(/\?/)) {
            alert(formatMsg + '?');
            return false;
        }

        if (fileName.match(/\*/)) {
            alert(formatMsg + '*');
            return false;
        }

        if (fileName.match(/^\s+/)) {
            alert('Filename cannot contain leading spaces');
            return false;
        }

        if (fileName.match(/\s+$/)) {
            alert('Filename cannot contain trailing spaces');
            return false;
        }

        if (fileName.match(/\s+/)) {
            alert('Filename cannot contain embedded spaces ' + fileName);
            return false;
        }

        if (contentType == 'media') {
            contentTypeID = 0;
            contentTypes   = formName.content_group_id.length;
            for (i=0;i<contentTypes;i++) {
                if (formName.content_group_id[i].checked) {
                    contentTypeID = formName.content_group_id[i].value;
                }
            }
          
            if (contentTypeID == 1) {
                contentType = 'image'
            } else if (contentTypeID == 2) {
                contentType = 'video'
            } else if (contentTypeID == 3) {
                contentType = 'audio'
            } else if (contentTypeID == 4) {
                contentType = 'drawing'
            } else {
                alert('Content Type not recognized');
                return false;
            }
        }

        if (contentType == 'image') {
            if (fileName.match(/\.jpg\"?$/i)) {return true;}
            if (fileName.match(/\.gif\"?$/i)) {return true;}
            if (fileName.match(/\.png\"?$/i)) {return true;}
            alert(upfileMsg + ' for image');
            return false;
        } else if (contentType == 'video') {
            if (fileName.match(/\.mov\"?$/i)) {return true;}
            if (fileName.match(/\.qt\"?$/i))  {return true;}
            if (fileName.match(/\.mpg\"?$/i)) {return true;}
            if (fileName.match(/\.ram\"?$/i)) {return true;}
            if (fileName.match(/\.rm\"?$/i))  {return true;}
            alert(upfileMsg + ' for video');
            return false;
        } else if (contentType == 'audio') {
            if (fileName.match(/\.mp3\"?$/i)) {return true;}
            if (fileName.match(/\.ram\"?$/i)) {return true;}
            if (fileName.match(/\.ra\"?$/i))  {return true;}
            if (fileName.match(/\.rm\"?$/i))  {return true;}
            if (fileName.match(/\.ogg\"?$/i)) {return true;}
            alert(upfileMsg + ' for audio');
            return false;
        } else if (contentType == 'drawing') {
            if (fileName.match(/\.dwg\"?$/i)) {return true;}
            if (fileName.match(/\.psd\"?$/i)) {return true;}
            if (fileName.match(/\.ai\"?$/i))  {return true;}
            if (fileName.match(/\.ppt\"?$/i)) {return true;}
            if (fileName.match(/\.doc\"?$/i)) {return true;}
            alert(upfileMsg + ' for drawing');
            return false;
        } else {
            alert('Content Type not recognized');
            return false;
        }

    }

    return true;

}

function validateMultipleImageImportTypes(formName,contentType) {

    formatMsg  = 'Invalid character in filename: ';
    upfileMsg  = 'File extension not supported ';
    previewMsg = 'Preview file extension not supported ';

    var caption;
    var maxUploads;

    maxUploads = formName.maxUploads.value;

    for (i=0;i<maxUploads;i++) {

        z = i + 1;

        caption = eval("formName.caption_" + i + ".value");

        filePathName   = eval("formName.media_file_" + i + ".value");

        checkPathLen = filePathName.length;

        slen = filePathName.split("/").length
        fileName = (filePathName.split("/")[slen-1])

        if (checkPathLen == fileName.length) {
            slen = filePathName.split("\\").length
            fileName = (filePathName.split("\\")[slen-1])
        }

        fileLength = fileName.length;    

        if (fileLength > 0) {

            caption = caption.replace(/^\s+|\s+$/gi,"");

            if (caption.match(/^$/)) {
                alert('Caption must not be blank: #' + z);
                return false;
            }

            if (fileName.match(/;/)) {
                alert(formatMsg + '; for file: #' + z);
                return false;
            }

            if (fileName.match(/\|/)) {
                alert(formatMsg + '| for file: #' + z);
                return false;
            }
    
            if (fileName.match(/\&/)) {
                alert(formatMsg + '& for file: #' + z);
                return false;
            }

            if (fileName.match(/\?/)) {
                alert(formatMsg + '? for file: #' + z);
                return false;
            }

            if (fileName.match(/\*/)) {
                alert(formatMsg + '* for file: #' + z);
                return false;
            }

            if (fileName.match(/^\s+/)) {
                alert('Filename cannot contain leading spaces: #' + z);
                return false;
            }

            if (fileName.match(/\s+$/)) {
                alert('Filename cannot contain trailing spaces: #' + z);
                return false;
            }

            if (fileName.match(/\s+/)) {
                alert('Filename cannot contain embedded spaces: #' + z);
                return false;
            }

            if (contentType == 'image') {
                if (fileName.match(/\.jpg\"?$/i)) {return true;}
                if (fileName.match(/\.gif\"?$/i)) {return true;}
                if (fileName.match(/\.png\"?$/i)) {return true;}
                alert(upfileMsg + ' for image: #' + z);
                return false;
            } else {
                alert('Content Type not recognized: #' + z);
                return false;
            }

        }

    }

    return true;

}

function wsmPrintSelect(printURL,collection_id,actionkey,callerkey) {

    formItems = window.document.formItemSelect;

    delim     = "";
    mediaList = "";
    elements = formItems.elements.length; 
    for (i=0;i<elements;i++) {
        widget = formItems.elements[i];
        if (widget.name.match(/mediaitem_/)) {
            if (widget.checked) {
                mediaList = mediaList + delim + widget.value;
                delim = ',';
            }
       }
    }

    returnURL = printURL + 
                '?collection_id=' + collection_id + 
                '&actionkey='     + actionkey     + 
                '&callerkey='     + callerkey     +
                '&mediaList='     + mediaList;

    window.location = returnURL;

}

function wsmPrintSelectOne(printURL,collection_id,actionkey,callerkey) {

    formItems = window.document.formItemSelect;

    delim     = "";
    mediaList = "";
    elements = formItems.elements.length; 
    for (i=0;i<elements;i++) {
        widget = formItems.elements[i];
        if (widget.name.match(/mediaitem_/)) {
            mediaList = mediaList + delim + widget.value;
            delim = ',';
       }
    }

    returnURL = printURL + 
                '?collection_id=' + collection_id + 
                '&actionkey='     + actionkey     + 
                '&callerkey='     + callerkey     +
                '&mediaList='     + mediaList;

    window.location = returnURL;

}


function wsmPrintPreview(printURL,altPrintURL) {

    title = "PrintCollection";

    formSelect = window.document.wsmPrintSelect;

    print_option_id = 1;
    print_format_id = 1;
  
    for (i=0; i<formSelect.print_option_id.length; i++) {
        if (formSelect.print_option_id[i].checked) {
            print_option_id = formSelect.print_option_id[i].value;
        }
    }

    for (i=0; i<formSelect.print_format_id.length; i++) {
        if (formSelect.print_format_id[i].checked) {
            print_format_id = formSelect.print_format_id[i].value;
        }
    }

    print_range_from = formSelect.print_range_from.value;
    print_range_to   = formSelect.print_range_to.value;

    printURL += '&print_format_id='  + print_format_id
             +  '&print_option_id='  + print_option_id
             +  '&print_range_from=' + print_range_from
             +  '&print_range_to='   + print_range_to;

    altPrintURL += '&print_format_id='  + print_format_id
                +  '&print_option_id='  + print_option_id
                +  '&print_range_from=' + print_range_from
                +  '&print_range_to='   + print_range_to;

    if (window.print) {
        newWindow = window.open(printURL,title,'width=750,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=no,resizable=no,dependent=yes,directories=no,screenX=0,screenY=0,top=0,left=0');
    } else {
        newWindow = window.open(altPrintURL,title,'width=750,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=no,resizable=no,dependent=yes,directories=no,screenX=0,screenY=0,top=0,left=0');
    }

    newWindow.focus();


}

function wsmPrint() {
    parent.printpage.focus();
    if (window.print) {
        parent.printpage.print();
    } else {
        alert('Use the print function in your browser to print output');
    }
}

function wsmSlideShowSelect(slideshowURL) {

    formItems = window.document.formItemSelect;

    delim     = "";
    mediaList = "";
    elements = formItems.elements.length; 
    for (i=0;i<elements;i++) {
        widget = formItems.elements[i];
        if (widget.name.match(/mediaitem_/)) {
            if (widget.checked) {
                mediaList = mediaList + delim + widget.value;
                delim = ',';
            }
       }
    }

    returnURL = slideshowURL  +  
                '&mediaList=' + mediaList;

    window.location = returnURL;

}

function display_navigator_settings() {

    alert('\nappCodeName       '  + navigator.appCodeName     +
          '\nappMinorVersion   '  + navigator.appMinorVersion +
          '\nappName           '  + navigator.appName         +
          '\nappVersion        '  + navigator.appVersion      +
          '\nbrowserLanguage   '  + navigator.browserLanguage +
          '\ncookieEnabled     '  + navigator.cookieEnabled   +
          '\ncpuClass          '  + navigator.cpuClass        +
          '\nlanguage          '  + navigator.language        +
          '\nonLine            '  + navigator.onLine          +
          '\nplatform          '  + navigator.platform        +
          '\nsystemLanguage    '  + navigator.systemLanguage  +
          '\nuserAgent         '  + navigator.userAgent       +
          '\nuserLanguage      '  + navigator.userLanguage    +
          '\nuserProfile       '  + navigator.userProfile     
          );
}

function wsmSlideShow(launchURL) {

    title = "SlideShow";

    formSelect = window.document.slideshowOptions;

    opt_selections       = 1;
    metaList             = "";
    opt_timing           = 1;
    timing_seconds       = 6;
    selection_range_from = 0;
    selection_range_to   = 0;
    opt_format           = 2;

    for (i=0; i<formSelect.opt_selections.length; i++) {
        if (formSelect.opt_selections[i].checked) {
            opt_selections = formSelect.opt_selections[i].value;
        }
    }

    for (i=0; i<formSelect.opt_format.length; i++) {
        if (formSelect.opt_format[i].checked) {
            opt_format = formSelect.opt_format[i].value;
        }
    }

    for (i=0; i<formSelect.opt_timing.length; i++) {
        if (formSelect.opt_timing[i].checked) {
            opt_timing = formSelect.opt_timing[i].value;
        }
    }

    delim = '';
    for (i=0; i<formSelect.opt_metadata.length; i++) {
        if (formSelect.opt_metadata[i].checked) {
            metaList += delim + formSelect.opt_metadata[i].value;
            delim = ',';
        }
    }

    timing_seconds       = formSelect.timing_seconds.value;
    selection_range_from = formSelect.selection_range_from.value;
    selection_range_to   = formSelect.selection_range_to.value;

    screenWidth  = screen.width;
    screenHeight = screen.height;

    screenHeight = screenHeight - 100;

    vScreenX = (screen.width  - screenWidth) / 2;
    vScreenY = 0;
 
    launchURL += '&opt_format='            + opt_format
              +  '&opt_selections='        + opt_selections
              +  '&opt_timing='            + opt_timing
              +  '&timing_seconds='        + timing_seconds
              +  '&selection_range_from='  + selection_range_from
              +  '&selection_range_to='    + selection_range_to
              +  '&screen_width='          + screenWidth
              +  '&screen_height='         + screenHeight
              +  '&selection_range_to='    + selection_range_to
              +  '&metaList='              + metaList;

    newWindow = window.open(launchURL,title,'width=' + screenWidth + ',height=' + screenHeight + ',menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes,dependent=yes,directories=no,screenX='+vScreenX+',screenY='+vScreenY+',top='+vScreenY+',left='+vScreenX+'');

    newWindow.focus();

    return false;

}

function wsmProcessSelections(copyURL,collection_id,actionkey,callerkey) {

    formItems = window.document.formItemSelect;

    delim     = "";
    mediaList = "";
    elements = formItems.elements.length; 
    for (i=0;i<elements;i++) {
        widget = formItems.elements[i];
        if (widget.name.match(/mediaitem_/)) {
            if (widget.checked) {
                mediaList = mediaList + delim + widget.value;
                delim = ',';
            }
       }
    }

    returnURL = copyURL + 
                '?collection_id=' + collection_id + 
                '&actionkey='     + actionkey     + 
                '&callerkey='     + callerkey     +
                '&mediaList='     + mediaList;

    window.location = returnURL;

}

function toggle_all(value) {
  var f = document.formItemSelect;
  var flag=true;
  var i;
  if (value=='select')
    flag='1';
  else
    flag='';
  for (i=0;i<f.elements.length;i++) {
    if (f.elements[i].type == 'checkbox')
      f.elements[i].checked = flag;
  }
}




