// include localization testing in mockup // document.write(''); var iframeHistory = 0; var ieVersion; var detectedBrowser = navigator.appName; var columns; var nested_columns; var content_containers; var margins; var padding; var columnWidthDifference; var ieColumnWidth; var ieNestedColumnWidth; var columnImages; var columnImagesWidth; var windowWidth; var sendCurrentTab; document.observe('dom:loaded', function() { browserDetection(); storeElements(); renderColumns(); mobileDisplay(); contentDecorations(); eventHandlers(); initializeWebApp(); renderColumns(); if (typeof window.customJavaScript == 'function') { customJavaScript(); } }); window.onload = function() { pngFix(); } function pngFix() { if (ieVersion == null) { browserDetection(); } if (ieVersion == 6) { $$('img').each( function(img) { currentImage = img; imgName = currentImage.src.toUpperCase(); if (imgName.endsWith("PNG")) { imgID = (currentImage.id) ? "id='" + currentImage.id + "' " : ""; imgClass = (currentImage.className) ? "class='" + currentImage.className + "' " : ""; imgTitle = (currentImage.title) ? "title='" + currentImage.title + "' " : "title='" + currentImage.alt + "' "; imgStyle = "display:inline-block;" + currentImage.style.cssText; if (currentImage.align == "left") { imgStyle = "float:left;" + imgStyle; } if (currentImage.align == "right") { imgStyle = "float:right;" + imgStyle; } if (currentImage.parentElement.href) { imgStyle = "cursor:hand;" + imgStyle; } if (ieVersion == 6) { strNewHTML = ""; } else { strNewHTML = ""; } currentImage.outerHTML = strNewHTML; } }); } } function storeElements() { // store the columns columns = $$('.column'); nested_columns = $$('.nested_column'); // read margins and padding from css, and remove px. margin / padding not supported in all browsers, so we have to have margin-left, padding-left if ($$('.content_container') != "") { margins = parseInt(($$('.content_container')[0]).getStyle('margin-left').substring(0, ($$('.content_container')[0]).getStyle('margin-left').length-2)); padding = parseInt(($$('.content')[0]).getStyle('padding-left').substring(0, ($$('.content')[0]).getStyle('padding-left').length-2)); columnWidthDifference = (margins+padding)+15*2; } // store initial column width for ie. ie returns style, ff returns offsetWidth? if (columns != "") { ieColumnWidth = parseInt(columns[columns.length-1].getStyle('width')); ieNestedColumnWidth = parseInt(columns[columns.length-1].getStyle('width')); } content_containers = $$('.content_container'); if(content_containers.length < 1) { return; } // slideshow image resizing. we want to resize images to be the width of the column they are displayed in // check to see if slideshow images exist on page, then store if ( $$('.slideShowImage') || $$('.scaleImage') ) { // array of slideshow image objects columnImages = ($$('.slideShowImage, .scaleImage')); // original image size columnImagesWidth = ($$('.slideShowImage, .scaleImage')); for (i = 0; i < columnImages.length; i++) { if (columnImages[i].width == 0) { columnImages[i].style.display = "block"; columnImagesWidth[i] = columnImages[i].width; columnImages[i].style.display = "none"; } else { columnImagesWidth[i] = columnImages[i].width; } } } if ($$('.slideshow_titles')[0]) { titles = $$('.slideshow_titles .slideshow_title'); slides = $$('.slideshow_images img'); description = $$('.slideshow_description .slideshow_text'); slideshow_images_container = slides[0].getOffsetParent(); slideshow_images_container.style.height = slides[0].offsetHeight+"px"; slideshow_description_container = description[0].getOffsetParent(); slideshow_description_container.style.top = slideshow_images_container.offsetHeight+90+"px"; slideshow_parent = ($$('.slideshow_footers')[0]).getOffsetParent(); ($$('.slideshow_footers')[0]).style.top = slideshow_images_container.offsetHeight+slideshow_description_container.offsetHeight+95+"px"; slideshow_parent.style.height = slideshow_images_container.offsetHeight+slideshow_description_container.offsetHeight+($$('.slideshow_footers')[0]).offsetHeight+95+"px"; } } function eventHandlers() { // event handlers to check if window has been resized. IE is slow // to do this, so we do a manual check, and then set a timeout to // do the update. actual behavior with resizing close to other // browsers now. updateScreen = self.setInterval("renderColumns()", 1000); if ( $$('.tabs_container li') ){ tabs = $$('.tabs_container li'); tabClasses = $$('.tabs_container li'); for (i=0; i < tabs.length; i++) { tabClasses[i] = tabClasses[i].classNames().toString(); } if (tabs[0]) { tabs[0].addClassName('selected_tab'); } if ((sendCurrentTab != undefined) && ($('currentTab') != undefined)) { // for elibrary to load last tab clicked from hidden input if ($('currentTab').value == "") { tabs[0].addClassName('selected_tab'); } else { tabs[0].removeClassName('selected_tab'); displayTabPanels($('currentTab').value, tabs, tabClasses); } } tabs.each( function(tab) { tab.observe('click', function() { panel = tab.classNames().toString(); displayTabPanels(panel, tabs, tabClasses); }); }); } } function displayTabPanels(panel, tabs, tabClasses) { var bFoundTab = false; // only passing in the name of the panel to display; ie from a link in the panel itself; not a tab if (tabs == undefined) { tabs = $$('.tabs_container li'); tabClasses = $$('.tabs_container li'); for (i=0; i < tabs.length; i++) { tabClasses[i] = tabClasses[i].classNames().toString(); } for (i = 0; i < tabClasses.length; i++) { $(panel).style.display = "block"; if (tabClasses[i].match(/selected_tab/)) { // we don't know the current panel. remove the classname from the selected tab, then extract classname from that to find panel to hide tabs[i].removeClassName('selected_tab'); $(tabs[i].classNames().toString()).style.display = "none"; } if (tabClasses[i] == panel) { tabs[i].addClassName('selected_tab'); if ((sendCurrentTab) && ($('currentTab') != undefined)) { // for elibrary to keep track of current tab through cgi sendCurrentTab(tabClasses[i]); } } } } else { // tab is clicked for (i = 0; i < tabClasses.length; i++) { if ((tabClasses[i] == panel) || (tabClasses[i]+" selected_tab" == panel)) { bFoundTab = true; if ($(panel) != null) { $(panel).style.display = "block"; } tabs[i].addClassName('selected_tab'); if($('currentTab') != undefined) { $('currentTab').value = tabClasses[i]; } if ((sendCurrentTab != undefined) && ($('currentTab') != undefined)) { // for elibrary to keep track of current tab through cgi sendCurrentTab(tabClasses[i]); } } else { $(tabClasses[i]).style.display = "none"; tabs[i].removeClassName('selected_tab'); } } if (bFoundTab == false) { tabs[0].addClassName('selected_tab'); $(tabClasses[0]).style.display = "block"; if($('currentTab') != undefined) { $('currentTab').value = tabClasses[0]; } if ((sendCurrentTab) && ($('currentTab') != undefined)) { // for elibrary to keep track of current tab through cgi sendCurrentTab(tabClasses[i]) } } } } function browserDetection() { // check the browser version so we can run conditional code later. // needs to be expanded to return all browsers. if (detectedBrowser == 'Microsoft Internet Explorer') { var searchFor = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (searchFor.exec( navigator.userAgent) != null) ieVersion = parseFloat( RegExp.$1 ); } else { ieVersion = -1; } } function contentDecorations() { // add in content decorations - only if greater than ie6 if (ieVersion > 6 || ieVersion == -1) { content_containers.each( function(content_container) { content_container.insert('
'); }); } } function renderColumns() { // some outside scripts may try to call renderColumns before data is loaded if (columns == null) { storeElements(); } if (ieVersion == null) { browserDetection(); } // resize all images with class slideShowImage to size of parent column if the width of the image is less than the width of the column if (columnImages != null && columnImages[0]) { columns.each( function(column) { var testColumnWidth = 0; var testColumnWidth = (column.offsetWidth)-columnWidthDifference; for (j = 0; j < columnImages.length; j++) { if (columnImages[j].descendantOf(column)) { if (columnImagesWidth[j] > testColumnWidth) { columnImages[j].style.width = testColumnWidth-columnWidthDifference+"px"; } else { columnImages[j].style.width = columnImagesWidth[j]+"px"; } } } }); } // make the columns all the same height // reset column heights if ($$('.footer_container')[0] != undefined) { columns.each( function(column) { column.style.height = ""; }); column_container_height = columns[0].offsetHeight; // set to current column container height columns.each( function(column) { column.style.height = ""; }); column_container_height = columns[0].offsetHeight; columns.each( function(column) { if (column.offsetHeight > column_container_height) { column_container_height = column.offsetHeight; } }); if (ieVersion == 6) { column_container_height = column_container_height + margins; } columns.each( function(column) { if (!column.className.match(/pct100/)) { column.style.height = column_container_height + "px"; } }); if (nested_columns != '') { nested_columns.each( function(nested_column) { nested_column.style.height = ""; }); nested_column_container_height = nested_columns[0].offsetHeight; nested_columns.each( function(nested_column) { if (nested_column.offsetHeight > nested_column_container_height) { nested_column_container_height = nested_column.offsetHeight; } }); if (ieVersion == 6) { nested_column_container_height = nested_column_container_height + margins; } nested_columns.each( function(nested_column) { if (!nested_column.className.match(/pct100/)) { nested_column.style.height = nested_column_container_height + "px"; } }); } // fix last column width to prevent ie from moving columns around if (ieVersion == 6 || ieVersion == 7) { if (columns[columns.length-1].hasClassName("middle")) { // right to left support. turn off column borders based on orientation if (columns[columns.length-1].getStyle("float") == "left") { columns[columns.length-1].style.borderRight = "none"; } else { columns[columns.length-1].style.borderLeft = "none"; } } columns[columns.length-1].style.width = ieColumnWidth-.1+"%"; if (nested_columns[0]) { nested_columns[nested_columns.length-1].style.width = ieNestedColumnWidth-.1+"%"; } } } } function mobileDisplay() { iphone = navigator.userAgent.toLowerCase(); if (iphone.indexOf('iphone')!=-1) { // iphone specific code goes here // convert menus to dropdowns $$('.header_menu_container ul')[0].style.display = "none"; getSelectedIndex="this.options[this.selectedIndex].value"; $$('.header_menu_container')[0].insert(""); $('header_menu_dropdown').insert(""); $$('.header_menu_container ul li a').each( function(link) { $('header_menu_dropdown').insert(""); }); $('header_menu_dropdown').selectedIndex = 0; } } /*--- MODAL DIALOG BOX ---*/ function createModalDialogBox(content, contentTitle, isIframe, hasIframeControls, isDraggable, isClosable, canMaximize, width, height) { // content -> url to load through ajax or iframe // contentTitle -> Title to display in modal window // isIframe -> load content into an iframe (true/false) // hasIframeControls -> display controls for Iframe navigation. forward, back, and open initial url in new window (true/false) // isDraggable -> modal window can be moved by the user // isClosable -> modal window has a close button // canMaximize -> modal window has a button that will maximize the window // width -> width of modal window in pixels or percentage (100px, 50%) // height -> height of modal window in pixels or percentage (100px, 50%) var modalBackground = document.createElement('div'); modalBackground.setAttribute('id', 'modalBackground'); Element.extend(modalBackground); document.body.appendChild(modalBackground); if (modalBackground) { // get total height of document var documentHeight = 0; documentHeight += $$('.header_container')[0].offsetHeight; for (i = 0; i < $$('.header_menu_container').length; i++) { documentHeight += $$('.header_menu_container')[i].offsetHeight; } for (i = 0; i < $$('.columns_container').length; i++) { documentHeight += $$('.columns_container')[i].offsetHeight; } documentHeight += $$('.footer_container')[0].offsetHeight; $('modalBackground').style.height = documentHeight+"px"; // insert modal window into the main container which is modalBackground $('modalBackground').insert(''); $('modalTitle').update(contentTitle); if (isDraggable == true) { new Draggable('modalWindow', {handle: 'modalTitleBar', starteffect: null, endeffect:null} ); } } if (isIframe == false) { Effect.Appear('modalWindow', { duration: 1.0, queue: 'end' }); $('modalContentContainer').style.overflow = 'auto'; new Ajax.Request(content, { // prevent caching method: 'post', onSuccess: function(transport) { var response = transport.responseText; $('modalContentContainer').insert(response); }, onFailure: function() { $('modalContentContainer').insert(msg_failedAjax); }, onComplete: function() { initializeLoadedAjax(); } }); } else { // fade doesn't play well with iframes. $('modalWindow').style.display = "block"; var initialHistoryLength = history.length; iframeHistory = history.length; iframeHeight = $('modalWindow').offsetHeight - $('modalTitleBar').offsetHeight - 26; sizeModification = 0; $('modalContentContainer').insert(''); if (hasIframeControls == true) { $('modalContentContainer').insert('
'); if (ieVersion == 6) { sizeModification = 54; $('modalIframe').style.height = $('modalContentContainer').offsetHeight - $('modalIframeControls').offsetHeight - sizeModification + "px"; } else { $('modalIframe').style.height = $('modalContentContainer').offsetHeight - $('modalIframeControls').offsetHeight + "px"; } } } } function modalIframeGoBack(initialHistoryLength) { if (iframeHistory < history.length) { iframeHistory++; frames['modalIframe'].history.go(-1); } } function modalIframeGoForward(initialHistoryLength) { frames['modalIframe'].history.go(1); } function modalIframeRemoveFrame(initialURL) { window.open(initialURL, "sdPopup"); } function modalMaximize(width, height) { if (width != $('modalWindow').style.width) { $('modalWindow').style.width = width; $('modalWindow').style.height = height+"px"; } else { if (ieVersion == 6) { $('modalWindow').style.width = document.body.clientWidth-40+"px"; $('modalWindow').style.height = document.body.clientHeight-40+"px"; } else { $('modalWindow').style.width = document.viewport.getWidth()-60+"px"; $('modalWindow').style.height = document.viewport.getHeight()-60+"px"; } } if ($('modalIframe')) { if ($('modalIframeControls')) { if (ieVersion == 6) { sizeModification = 50; $('modalIframe').style.height = $('modalWindow').offsetHeight - $('modalIframeControls').offsetHeight - sizeModification + "px"; } else { $('modalIframe').style.height = $('modalContentContainer').offsetHeight - $('modalIframeControls').offsetHeight + "px"; } } else { $('modalIframe').style.height = $('modalWindow').offsetHeight - $('modalTitleBar').offsetHeight - 26 + "px"; } } } function modalClose(closeMessage) { if (closeMessage) { // if calling closeMessage from outside createModalDialogBox, there will be no message // makes automatic closing possible var confirmClose = confirm(closeMessage); if (confirmClose) { Effect.Fade('modalBackground', { duration: 1.0, queue: 'end', afterFinish: function() {$('modalBackground').remove();} } ); } else { } } else { Effect.Fade('modalBackground', { duration: 1.0, queue: 'end', afterFinish: function() {$('modalBackground').remove();} } ); } } function submitForm(formName, submitAndMaximize, submitAndClose) { // formName -> id of form to submit // submitAndMaximize -> submit the form using id and maximize the window // submitAndClose -> submit the form using id and close modal window if ($('modalContentContainer')) { $(formName).request( { method: 'post', onSuccess: function(transport) { var response = transport.responseText; $('modalContentContainer').innerHTML = response; }, onFailure: function() { $('modalContentContainer').innerHTML = msg_failedAjax; }, onComplete: function() { initializeLoadedAjax(); if (submitAndMaximize) { modalMaximize(); } if (submitAndClose) { modalClose(); } } }); } else { // not in a modal dialog box. submit form normally $(formName).request(); } } function initializeLoadedAjax() { // this is for running code on the dom we just loaded through ajax // if a wizard panel is available on page load, show the first one, and the navigation if ($$('.wizard_panel')[0]) { ($$('.wizard_panel')[0]).style.display = "block"; ($$('.wizard_navigation')[0]).style.display = "block"; if ($$('.wizard_previous')[0]) { ($$('.wizard_previous')[0]).style.display = "none"; } } } /*--- WIZARD ---*/ function wizard_validate(wizardContainer, currentPanel) { var wizard_panels = ($$('.'+wizardContainer+' .wizard_panel')); // modify this to false if needed. valid = true; if (wizard_panels[currentPanel]) { // passed in panel exists. do some validation here. // we can do custom validation based on the wizardContainer name // passed in. // if validation is not successful, return valid = false, // and mark invalid fields. $('previous_panel').value = currentPanel; } return valid; } function wizard_next(wizardContainer) { // pass in wizard container class. this allows for generic functions var wizard_panels = ($$('.'+wizardContainer+' .wizard_panel')); for (i = 0; i < wizard_panels.length; i++) { //find currently displayed panel if (wizard_panels[i].style.display == "block") { wizard_validate(wizardContainer, i); if (wizard_validate() == true) { // validation successful if (wizard_panels[i].getElementsBySelector('[class="select_a_panel"]')) { // branching inputs available on current panel. // check to see which panel to jump to var selectedInputForBranching = wizard_panels[i].getElementsBySelector('[class="select_a_panel"]'); for (j = 0; j < selectedInputForBranching.length; j++) { if (selectedInputForBranching[j].checked) { wizard_panels[i].style.display = "none"; wizard_panels[selectedInputForBranching[j].value].style.display = "block"; ($$('.'+wizardContainer)[0]).style.height = "90%"; // displayed selected panel. stop looping. j = 999; } else { if (i < wizard_panels.length-1) { // validation was successful. hide this panel and show next wizard_panels[i].style.display = "none"; i++; wizard_panels[i].style.display = "block"; ($$('.'+wizardContainer)[0]).style.height = "90%"; } } } } else { // just go to the next panel if (i < wizard_panels.length-1) { wizard_panels[i].style.display = "none"; i++; wizard_panels[i].style.display = "block"; ($$('.'+wizardContainer)[0]).style.height = "90%"; } } if (i == wizard_panels.length-1) { ($$('.wizard_finish')[0]).style.display = "inline"; ($$('.wizard_next')[0]).style.display = "none"; } if (i == 0) { ($$('.wizard_previous')[0]).style.display = "none"; } else { ($$('.wizard_previous')[0]).style.display = "inline"; } } } } } function wizard_previous(wizardContainer) { // pass in wizard container class. this allows for generic functions var wizard_panels = ($$('.'+wizardContainer+' .wizard_panel')); for (i = 0; i < wizard_panels.length; i++) { //find currently displayed panel if (wizard_panels[i].style.display == "block") { // don't validate current panel if trying to go to previous panel // user may be trying to view previous information to make the // current form valid, so we don't want them to get stuck. if (i > 0) { wizard_panels[i].style.display = "none"; i--; wizard_panels[i].style.display = "block"; } if (i < wizard_panels.length-1) { ($$('.wizard_next')[0]).style.display = "inline"; ($$('.wizard_finish')[0]).style.display = "none"; } if (i == 0) { ($$('.wizard_previous')[0]).style.display = "none"; } else { ($$('.wizard_previous')[0]).style.display = "inline"; } } } } /*--- Slideshow ---*/ function nextSlideShow(id) { var currentSlide; var nextSlide; titles = $$('.'+id+' .slideshow_titles .slideshow_title'); slides = $$('.'+id+' .slideshow_images img'); description = $$('.'+id+' .slideshow_description .slideshow_text'); for (i=0; i < slides.length; i++) { if (slides[i].style.display != "none") { currentSlide = i; nextSlide = i; nextSlide++; if (nextSlide >= slides.length) { nextSlide = 0; } } } titles[currentSlide].style.display = "none"; slides[currentSlide].style.display = "none"; description[currentSlide].style.display = "none"; new Effect.Appear(titles[nextSlide], { duration:0.5 }); new Effect.Appear(slides[nextSlide], { duration:0.5, afterFinish: function() { slideshow_images_container = slides[nextSlide].getOffsetParent(); slideshow_images_container.style.height = slides[nextSlide].offsetHeight+"px"; new Effect.Appear(description[nextSlide], { duration:0.5, afterFinish: function() { slideshow_description_container = description[nextSlide].getOffsetParent(); slideshow_description_container.style.top = slideshow_images_container.offsetHeight+90+"px"; ($$('.'+id+' .slideshow_footers')[0]).style.top = slideshow_images_container.offsetHeight+slideshow_description_container.offsetHeight+95+"px"; ($$('.'+id)[0]).style.height = slideshow_images_container.offsetHeight+slideshow_description_container.offsetHeight+($$('.'+id+' .slideshow_footers')[0]).offsetHeight+95+"px"; } }); } }); } function previousSlideShow(id) { var currentSlide; var nextSlide; titles = $$('.'+id+' .slideshow_titles .slideshow_title'); slides = $$('.'+id+' .slideshow_images img'); description = $$('.'+id+' .slideshow_description .slideshow_text'); for (i=0; i < slides.length; i++) { if (slides[i].style.display != "none") { currentSlide = i; nextSlide = i; nextSlide--; if (nextSlide <= -1 ) { nextSlide = slides.length-1; } } } titles[currentSlide].style.display = "none"; slides[currentSlide].style.display = "none"; description[currentSlide].style.display = "none"; new Effect.Appear(titles[nextSlide], { duration:0.5 }); new Effect.Appear(slides[nextSlide], { duration:0.5, afterFinish: function() { slideshow_images_container = slides[nextSlide].getOffsetParent(); slideshow_images_container.style.height = slides[nextSlide].offsetHeight+"px"; new Effect.Appear(description[nextSlide], { duration:0.5, afterFinish: function() { slideshow_description_container = description[nextSlide].getOffsetParent(); slideshow_description_container.style.top = slideshow_images_container.offsetHeight+90+"px"; ($$('.'+id+' .slideshow_footers')[0]).style.top = slideshow_images_container.offsetHeight+slideshow_description_container.offsetHeight+95+"px"; ($$('.'+id)[0]).style.height = slideshow_images_container.offsetHeight+slideshow_description_container.offsetHeight+($$('.'+id+' .slideshow_footers')[0]).offsetHeight+95+"px"; } }); } }); } function playSlideShow(id) { play = self.setInterval("nextSlideShow(\'"+id+"\')", 2000); } function stopSlideShow(id) { window.clearInterval(play); } /*--- WEB APP SPECIFIC JS ----------------------------------------------------*/ /* web app specific initialization code goes here */ function initializeWebApp() { required(); $$('.content_container').each( function(data) { if (data.firstDescendant().empty()) { data.style.display = "none"; } if (data.firstDescendant().offsetHeight < 32) { data.style.display = "none"; } }); if ($('keep_all_button')) { $('keep_all_button').style.display = "inline"; } if ($('perm_keep_all_button')) { $('perm_keep_all_button').style.display = "inline"; } } // used by environment and labels var LocalizedValues = new Array(); // month name for display purposes // used to convert localized month back to numeric var DisplayMonthName = new Array(); var CheckDisplayMonth = new String(); // used by dynamic table sorting var currentCol = 0; function show_permalink_from_url() { var reURL; var strBegin; var strEnd; var strWork; var intLocation; var strURL; reURL = new RegExp("http(.|\n)+?/cgisirsi/"); strBegin = reURL.exec(window.location.href); strWork = new String(strBegin); strWork = strWork.split(","); strBegin = strWork[0]; strEnd = window.location.href; intLocation = strEnd.indexOf("/28/"); strEnd = strEnd.substring(intLocation); strURL = strBegin + "x/0/0" + strEnd; show_permalink(strURL); } function show_permalink(inURL) { var heading = getLocalizedValue("PERMALINK"); var message = getLocalizedValue("TO_LINK"); var height = 150; var width = 400; var left = screen.width - width - 50; var top = 50; var myURL = inURL; myURL = myURL.replace(/'/g,"'"); var strParam = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + width; strParam = strParam + ",height=" + height; strParam = strParam + ",left=" + left; strParam = strParam + ",top=" + top; aWindow = window.open('','',strParam); aWindow.document.open("text/html"); aWindow.document.write(""); aWindow.document.write(heading); aWindow.document.write(""); aWindow.document.write(""); aWindow.document.write(message); aWindow.document.write("

"); aWindow.document.write("Permalink "); aWindow.document.write(""); aWindow.document.close(); } function CreateBookmarkLinkfromURL(inTitle) { var reURL; var strBegin; var strEnd; var strWork; var intLocation; var strURL; reURL = new RegExp("http(.|\n)+?/cgisirsi/"); strBegin = reURL.exec(window.location.href); strWork = new String(strBegin); strWork = strWork.split(","); strBegin = strWork[0]; strEnd = window.location.href; intLocation = strEnd.indexOf("/28/"); strEnd = strEnd.substring(intLocation); strURL = strBegin + "x/0/0" + strEnd; CreateBookmarkLink(inTitle,strURL); } function CreateBookmarkLink(inTitle,inURL,securityWarning) { var workTitle = new String(inTitle); if (workTitle.length == 0) workTitle = document.title; if (window.sidebar) { // Mozilla Firefox Bookmark window.sidebar.addPanel(workTitle, inURL,""); } else if( window.ActiveXObject ) { // IE Favorite window.external.AddFavorite( inURL, workTitle); } else if(window.opera && window.print) { // Opera Hotlist var mbm = document.createElement('a'); mbm.setAttribute('rel','sidebar'); mbm.setAttribute('href',inURL); mbm.setAttribute('title',workTitle); mbm.click(); } else { //chrome and safari alert(securityWarning+inURL); } } function setLocalizedValue(inName,inValue) { LocalizedValues[inName] = inValue; } function getLocalizedValue(inName) { return LocalizedValues[inName]; } function open_win(url) { new_win = window.open(url,"new_win",'toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=750,height=250'); if (new_win) { new_win.focus(); } } function open_bare_win(url) { new_b_win = window.open(url,"new_b_win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=620,height=450'); if (new_b_win) { new_b_win.focus(); } } function open_hyperion_image_win(url) { hyperion_image_win = window.open(url,"hyperion_image_win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=600,height=450,screenX=410,screenY=210'); } function open_hyperion_info_win(url) { hyperion_info_win = window.open(url,"hyperion_info_win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=400,height=450,screenX=0,screenY=210'); } function open_win_timeout(url,timeout) { new_win = window.open(url,"new_win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=750,height=250'); setTimeout("new_win.close()",timeout); } function open_help_win(url) { new_win = window.open(url,"help_win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=640,height=480'); if (new_win) { new_win.focus(); } } function open_bounce_win(url) { new_win = window.open(url,"bounce_win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=620,height=450'); } /* Obsolete Function for icon-type search form action */ function orig_form_action(searchEngineUrlPt1,searchEngineUrlPt2) { if (!document.searchform.search_type[0].checked) { return true; } else { document.url_form.url.value = searchEngineUrlpt1 + document.searchform.searchdata1.value + searchEngineUrlPt2; open_win(document.url_form.url.value); return false; } } function combine_fields() { document.getElementById("searchdata3").value="{LEXILE}>" + document.getElementById("lexilemin").value + "<" + document.getElementById("lexilemax").value; //alert (document.getElementById("searchdata3").value); } /* Function for icon-type search form action */ function search_form_action(searchEngineUrlPt1,searchEngineUrlPt2) { var search_engine_checked = 0; var temp_str; for (var i = 0; i < document.searchform.search_type.length; i++) { if (document.searchform.search_type[i].value == "searchengine") if (document.searchform.search_type[i].checked) search_engine_checked = 1; } if (!search_engine_checked) { return true; } else { temp_str = document.searchform.searchdata1.value; temp_str = temp_str.replace(/\s+/g,"+"); document.url_form.url.value = searchEngineUrlPt1 + temp_str + searchEngineUrlPt2; open_win(document.url_form.url.value); return false; } } function put_admin_help_button(langDir, alttextHelp) { document.writeln(''+alttextHelp+'<\/a>'); } function open_admin_help_win(langDir, alttextHelp) { if ($("currentTab")) { var selected_tab = $("currentTab").value; if (selected_tab) { selected_tab = selected_tab.replace(/ /g,"_"); selected_tab = selected_tab.toLowerCase(); open_help_win("/iBistro_helps/Admin/" + langDir + "/index.htm?context=elibrary_admin&topic=" + selected_tab); } } } function getNonJavaHelpFileUrl(langDir, file) { if (file == "ibistro_overview") { return '/iBistro_helps/User/' + langDir + '/index.htm'; } else { return '/iBistro_helps/User/' + langDir + '/index.htm?context=elibrary&topic=' + file; } } function put_help_button(langDir, alttextHelp, file) { document.writeln(''+alttextHelp+'<\/a>'); } /* function put_keepremove_button(ckey,value,imgOther,alttextKeep,webcatUrl,session,alttextRemove) { document.writeln(''); document.writeln(''); } */ /* keep button as check box */ function put_keepremove_button(ckey,value,imgOther,alttextKeep,webcatUrl,session,alttextRemove) { document.writeln(''); document.writeln(''); document.writeln(''); } function updatekeptlist(alttextKeep,webcatUrl,session,imgOther,alttextRemove,myButton,ckey) { key = "i" + myButton.name; if (myButton.value == alttextKeep) { myImage = new Image(); myImage.src = webcatUrl + '/' + session + '/125/ADD?kept-' + ckey + '=on'; document.images[key].src=myImage.src; myImage = new Image(); myImage.src = imgOther + '/clear.gif'; myImage.alt = myButton.value; document.images[key].src=myImage.src; document.images[key].alt=alttextRemove; myButton.value = alttextRemove; $('keep_label_ickey-'+ckey).innerHTML = alttextRemove; myButton.className = 'put_keepremove_cb'; } else { myImage = new Image(); myImage.src = webcatUrl + '/' + session + '/125/REMOVE?kept-' + ckey + '=on'; document.images[key].src=myImage.src; myImage = new Image(); myImage.src = imgOther + '/clear.gif'; myImage.alt = myButton.value; document.images[key].src=myImage.src; document.images[key].alt=alttextKeep; myButton.value = alttextKeep; $('keep_label_ickey-'+ckey).innerHTML = alttextKeep; myButton.className = 'put_keepremove_cb'; } } function put_keepremove_perm_button(list_id,ckey,value,imgOther,alttextKeep,webcatUrl,session,alttextRemove) { document.writeln(''); document.writeln(''); document.writeln(''); } function updatepermkeptlist(alttextKeep,webcatUrl,session,imgOther,alttextRemove,myButton,ckey,listid) { var mylist = new String(listid); if (mylist.length == 0) { $('pckey-'+ckey).checked = false; // reset checkbox alert(getLocalizedValue("CREATE_A_LIST")); } else { key = "p" + myButton.name; if (myButton.value == alttextKeep) { myImage = new Image(); myImage.src = webcatUrl + '/' + session + '/154?list_id=' + listid + '&ckeys=' + ckey; document.images[key].src=myImage.src; myImage = new Image(); myImage.src = imgOther + '/clear.gif'; myImage.alt = myButton.value; document.images[key].src=myImage.src; document.images[key].alt=alttextRemove; myButton.value = alttextRemove; $('keep_label_ppckey-'+ckey).innerHTML = alttextRemove; myButton.className = 'put_keepremove_cb'; } else { myImage = new Image(); myImage.src = webcatUrl + '/' + session + '/155?list_id=' + listid + '&ckeys=' + ckey; document.images[key].src=myImage.src; myImage = new Image(); myImage.src = imgOther + '/clear.gif'; myImage.alt = myButton.value; document.images[key].src=myImage.src; document.images[key].alt=alttextKeep; myButton.value = alttextKeep; $('keep_label_ppckey-'+ckey).innerHTML = alttextKeep; myButton.className = 'put_keepremove_cb'; } } } function put_keepremove_all_button(imgOther,webcatUrl,session,alttextRemove) { document.writeln(''); document.writeln(''); } function put_keepremove_all_perm_button(list_id,imgOther,webcatUrl,session,alttextRemove) { document.writeln(''); document.writeln(''); } function updatekeptlist_all(webcatUrl,session,imgOther,alttextRemove,myButton,ckeys_array) { var ckey_str = new String(""); for (i=0; i list, set the search input fields. var opt_idx; var i = 0; opt_idx = form.srch_history.selectedIndex; // The history "value" is formatted: "term^label^library" valueArray = form.srch_history.options[opt_idx].value.split("^"); // Set the search term form.searchdata1.value = valueArray[0]; // Set the search type - if it is present if (form.srchfield1 != null) { for (i<0; i cutoff) { var prefix = inData.slice(0, cutoff); var index = prefix.lastIndexOf(","); inData = prefix.substring(0,index); var count = 0; var index = inData.indexOf(","); while (index >= 0) { count += 1; index = inData.indexOf(",",index+1); } alert( "There are too many bills to process as a single group." + "\n" + "\n" + "Forming the largest possible group." + "\n" + "\n" + "Paying the first " + (count+1) + " bills." ); } nFORM=document.createElement('form'); document.body.appendChild(nFORM); nFORM.action=webcatUrl + '/' + session + '/144'; nFORM.target="_self"; nFORM.method="post"; nFORM.name="Payment"; nUser=document.createElement('input'); nUser.name='user_id'; nUser.value=inUser; nUser.type='hidden'; nFORM.appendChild(nUser); nData=document.createElement('input'); nData.name='data'; nData.value=inData; nData.type='hidden'; nFORM.appendChild(nData); nFORM.submit(); } function OpenGateway(inURL,inGateway,needToReplace,userID,password) { if (need_to_replace) { inURL = inURL.replace(":///","://"+location.host+"/"); } aWindow = window.open('','','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=600,height=600'); inUserId = userID; inPassword = password; if (aWindow.document.body == null) { aBody = aWindow.document.createElement('body'); aWindow.document.appendChild(aBody); } nFORM=aWindow.document.createElement('form'); nFORM.action=inURL; nFORM.target="_self"; nFORM.method="post"; nFORM.name="Gateway"; if (inGateway.length != 0) { nGateway=aWindow.document.createElement('input'); nGateway.name='new_gateway_db'; nGateway.value=inGateway; nGateway.type='hidden'; nFORM.appendChild(nGateway); } if (inUserId.length != 0) { nUser=aWindow.document.createElement('input'); nUser.name='user_id'; nUser.value=inUserId; nUser.type='hidden'; nFORM.appendChild(nUser); } if (inPassword.length != 0) { nPIN=aWindow.document.createElement('input'); nPIN.name='password'; nPIN.value=inPassword; nPIN.type='hidden'; nFORM.appendChild(nPIN); } aWindow.document.body.appendChild(nFORM); nFORM.submit(); aWindow.document.body.removeChild(nFORM); } function OnlineUserRegistrationCheck(formobj,ourMissingFields,ourPinDoesNotMatch){ // Enter name of mandatory fields var fieldRequired = Array("firstname", "lastname", "street", "city", "state", "zip", "pin", "validatepin"); // Enter field description to appear in the dialog box var fieldDescription = Array("First Name", "Last Name", "Street", "City", "State", "Zip", "PIN", "Re-Type PIN"); // dialog message var alertMsg = ourMissingFields + ":\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg) { if(formobj.pin.value != formobj.validatepin.value) { alert (ourPinDoesNotMatch); return false; } return true; } else { alert(alertMsg); return false; } } function OnlineUserActivationCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("user_id", "pin", "new_user_id"); // Enter field description to appear in the dialog box var fieldDescription = Array("Temporary ID", "PIN", "New User ID"); // dialog message var alertMsg = "Please complete the following required fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } function selectAll(inForm,inBox) { var checkboxes = document.getElementById(inForm).length; var stronclick; var bprocess; if (document.getElementById(inBox).checked == true) { for (i=0; i < checkboxes; i++) { if (document.getElementById(inForm)[i].onclick == null) { bprocess = true; } else { stronclick = new String(document.getElementById(inForm)[i].onclick); if (stronclick.indexOf("selectAll") != -1) { bprocess = true; } else { bprocess = false; } } if (bprocess && document.getElementById(inForm)[i].type == "checkbox") document.getElementById(inForm)[i].checked = true; } } else { for (i=0; i < checkboxes; i++) { if (document.getElementById(inForm)[i].onclick == null) { bprocess = true; } else { stronclick = new String(document.getElementById(inForm)[i].onclick); if (stronclick.indexOf("selectAll") != -1) { bprocess = true; } else { bprocess = false; } } if (bprocess && document.getElementById(inForm)[i].type == "checkbox") document.getElementById(inForm)[i].checked = false; } } } function NewCalHold(pCtrl,pFormat,pShowTime,pTimeMode,inCheckbox,inLocalizedNever) { var myCheckbox; myCheckbox = document.getElementById(inCheckbox); if (myCheckbox.checked != true) NewCal(pCtrl,pFormat,pShowTime,pTimeMode,inLocalizedNever); } function cancelSelected() { var myCheckbox; var mySubmit; var mySubmitTop; myCheckbox = document.getElementById("cancelselected"); mySubmit = document.getElementById("submitholdsbutton"); mySubmitTop = document.getElementById("submitholdsbuttontop"); mySelect = document.getElementById("pickup_library"); myExpiration = document.getElementById("hold_expiration_date"); if (myCheckbox != null && (myCheckbox.checked == true || myCheckbox.type == "hidden")) { if (mySubmit != null) mySubmit.value = getLocalizedValue("CANCEL_HOLDS_BUTTON"); if (mySubmitTop != null) mySubmitTop.value = getLocalizedValue("CANCEL_HOLDS_BUTTON"); if (mySelect != null) mySelect.disabled = true; if (myExpiration != null) myExpiration.disabled = true; } else { if (mySubmit != null) mySubmit.value = getLocalizedValue("EDIT_SELECTED_HOLD_TEXT"); if (mySubmitTop != null) mySubmitTop.value = getLocalizedValue("EDIT_SELECTED_HOLD_TEXT"); if (mySelect != null) mySelect.disabled = false; if (myExpiration != null) myExpiration.disabled = false; } } function processholdform(inToday,inNever) { var myCheckbox; var myForm; var checkboxes; var conirmeditall; var count; var editall; var strWork; var strID; var pieces; var sometoedit; var nFORM; var nField; var myHoldExpiration; var myPickupLibrary; myCheckbox = document.getElementById("cancelselected"); if (myCheckbox.checked == true || myCheckbox.type == "hidden") { myForm = document.getElementById("holds_list"); if (myForm != null) { if (someChecked("holds_list")) { editall = allChecked("holds_list"); if (editall) confirmeditall = confirm(getLocalizedValue("21501")); if (!editall || (editall && confirmeditall)) { myForm.submit(); } } else { window.alert(getLocalizedValue("13094")); } } } else { // The edit portion myForm = document.getElementById("holds_list"); if (myForm != null) { sometoedit = someChecked("holds_list"); if (sometoedit) { editall = allChecked("holds_list"); if (editall) confirmeditall = confirm(getLocalizedValue("21501")); if (!editall || (editall && confirmeditall)) { if (document.getElementById("hold_expiration_date") != null) myHoldExpiration = new String(document.getElementById("hold_expiration_date").value); else myHoldExpiration = new String(""); if (myHoldExpiration == getLocalizedValue(inToday)) myHoldExpiration = 'TODAY'; if (myHoldExpiration == getLocalizedValue(inNever)) myHoldExpiration = 'NEVER'; if (document.getElementById("pickup_library") != null) myPickupLibrary = new String(document.getElementById("pickup_library").value); else myPickupLibrary = new String(""); nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/136"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="EditHolds"; checkboxes = myForm.length; for (count = 0; count < checkboxes; count++) { if (myForm[count].id.indexOf("HLD") != -1) { if (myForm[count].checked == true) { strWork = myForm[count].id; pieces = strWork.split("^"); strID = pieces[0] + "^" + pieces[5]; strID = strID + "^" + pieces[3] + "^" + pieces[2]; nField=document.createElement('input'); nField.name=strID; nField.id=strID; nField.value='on'; nField.type='hidden'; nFORM.appendChild(nField); } } } if (myHoldExpiration.length > 0) { nField=document.createElement('input'); nField.name='hold_expiration_date'; nField.id='hold_expiration_date'; nField.value=myHoldExpiration; nField.type='hidden'; nFORM.appendChild(nField); } if (myPickupLibrary.length > 0) { nField=document.createElement('input'); nField.name='pickup_library'; nField.id='pickup_library'; nField.value=myPickupLibrary; nField.type='hidden'; nFORM.appendChild(nField); } document.body.appendChild(nFORM); nFORM.submit(); } } else { window.alert(getLocalizedValue("SELECTHOLDSTOEDIT")); } } } } function processSuspend(inStart,inEnd) { var myCheckbox; var myStartDate; var myEndDate; var myButton; myCheckbox = document.getElementById("activate"); myStartDate = document.getElementById("suspend_start_date"); myEndDate = document.getElementById("suspend_end_date"); myButton = document.getElementById("submitactivatebutton"); if (myCheckbox != null && myCheckbox.checked) { if (myStartDate != null) { myStartDate.disabled = true; myStartDate.value = getLocalizedValue(inStart); } if (myEndDate != null) { myEndDate.disabled = true; myEndDate.value = getLocalizedValue(inEnd); } if (myButton != null) myButton.value = getLocalizedValue("ACTIVATESELECTEDTEXT"); } else { if (myStartDate != null) { myStartDate.disabled = false; myStartDate.value = getLocalizedValue(inStart); } if (myEndDate != null) { myEndDate.disabled = false; myEndDate.value = getLocalizedValue(inEnd); } if (myButton != null) myButton.value = getLocalizedValue("SUSPENDSELECTEDTEXT"); } } function processactivateform(inToday,inNever) { var myCheckbox; var myForm; var checkboxes; var count; var confirmeditall; var editall; var strWork; var strID; var pieces; var sometoedit; var nFORM; var nField; var myStartDate; var myEndDate; // The edit portion myForm = document.getElementById("holds_list"); if (myForm != null) { sometoedit = someChecked("holds_list"); if (sometoedit) { editall = allChecked("holds_list"); if (editall) confirmeditall = confirm(getLocalizedValue("21501")); if (!editall || (editall && confirmeditall)) { myStartDate = document.getElementById("suspend_start_date").value; if (myStartDate == getLocalizedValue(inToday)) myStartDate = 'TODAY'; if (myStartDate == getLocalizedValue(inNever)) myStartDate = 'NEVER'; myEndDate = document.getElementById("suspend_end_date").value; if (myEndDate == getLocalizedValue(inToday)) myEndDate = 'TODAY'; if (myEndDate == getLocalizedValue(inNever)) myEndDate = 'NEVER'; nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/136"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="SuspendHolds"; checkboxes = myForm.length; for (count = 0; count < checkboxes; count++) { if (myForm[count].id.indexOf("HLD") != -1) { if (myForm[count].checked == true) { strWork = myForm[count].id; pieces = strWork.split("^"); strID = pieces[0] + "^" + pieces[5]; strID = strID + "^" + pieces[3] + "^" + pieces[2]; nField=document.createElement('input'); nField.name=strID; nField.id=strID; nField.value='on'; nField.type='hidden'; nFORM.appendChild(nField); } } } nField=document.createElement('input'); nField.name='suspend_start_date'; nField.id='suspend_end_date'; nField.value=myStartDate; nField.type='hidden'; nFORM.appendChild(nField); nField=document.createElement('input'); nField.name='suspend_end_date'; nField.id='suspend_end_date'; nField.value=myEndDate; nField.type='hidden'; nFORM.appendChild(nField); document.body.appendChild(nFORM); nFORM.submit(); } } else { window.alert(getLocalizedValue("SELECTHOLDSTOACTIVATE")); } } } function sendCurrentTab(inTab) { var myImage; var aImage; aImage = document.getElementById("settab"); myImage = new Image(); myImage.src = getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/148/" + inTab; aImage.src=myImage.src; myImage = new Image(); myImage.src = getLocalizedValue("IMG_OTHER") + "/clear.gif"; aImage.src=myImage.src; } function verifyAndSubmit(inForm) { if (!someChecked(inForm)) ask_to_select(inForm); else { if (allChecked(inForm)) { if (ask_for_confirmation(inForm)) { submitForm(inForm); } } else { submitForm(inForm); } } } function allChecked(inForm) { var allselected = false; var myForm; myForm = document.getElementById(inForm); if (myForm != null) { allselected = true; checkboxes = myForm.length; for (count = 0; count < checkboxes; count++) if (myForm[count].type == 'checkbox') if (myForm[count].onclick == null) if (myForm[count].checked == false) allselected = false; } return allselected; } function someChecked(inForm) { var somechecked = false; var myForm; myForm = document.getElementById(inForm); if (myForm != null) { checkboxes = myForm.length; for (count = 0; count < checkboxes; count++) if (myForm[count].type == 'checkbox') if (myForm[count].onclick == null) if (myForm[count].checked == true) somechecked = true; } return somechecked; } function ask_to_select(inForm) { var strMessage; strMessage = getLocalizedValue("21504"); if (inForm == "renewitems") strMessage = getLocalizedValue("13066"); if (inForm == "rsvns_list") strMessage = getLocalizedValue("13096"); window.alert(strMessage); } function ask_for_confirmation(inForm) { var strMessage; strMessage = getLocalizedValue("21503"); if (inForm == "renewitems") strMessage = getLocalizedValue("21502"); if (inForm == "avail_list") strMessage = getLocalizedValue("21500"); return confirm(strMessage); } function submitForm(inForm) { var myForm; myForm = document.getElementById(inForm); if (myForm != null) myForm.submit(); } function stripLeading(inString) { while (inString.indexOf(" ") == 0 || inString.indexOf("\n") == 0 || inString.indexOf("\t") == 0) { inString = inString.substr(1); } return inString; } function removeExtra(inString) { inString = inString.replace(/<(.|\n)+?>/g,""); inString = inString.replace(/ /g,""); inString = inString.replace(/\n/g,""); return inString; } function pullAmount(inString) { var reMoney; var result; var strWork; var portion; var strTemp; strTemp = "^\\" + getLocalizedValue("CURRENCY") + "\\d+(\\.\\d\\d)?$"; reMoney = new RegExp(strTemp); result = reMoney.exec(inString); if (!reMoney.test(inString)) { result = "$0.00,"; } strWork = new String(result); strTemp = getLocalizedValue("CURRENCY"); strWork = strWork.replace(strTemp,""); portion = strWork.split(","); inString = portion[0]; return inString; } function CompareAlpha(a, b) { var strA = a[currentCol].toLowerCase(); var strB = b[currentCol].toLowerCase(); var pieces; var i; var reDontConsider; // remove html wrappers to sort the title strA = strA.replace(/<(.|\n)+?>/g,""); strB = strB.replace(/<(.|\n)+?>/g,""); // remove items we don't want the sort to consider var strDontConsider = getLocalizedValue("DONT_SORT_ON_THESE"); pieces = strDontConsider.split(","); for (i = 0; i < pieces.length; i++) { reDontConsider = new RegExp(pieces[i],"g"); strA = strA.replace(reDontConsider,""); strB = strB.replace(reDontConsider,""); } strA = stripLeading(strA); strB = stripLeading(strB); if (strA < strB) { return -1; } else { if (strA > strB) { return 1; } else { return 0; } } } function CompareDate(a, b) { var pattern; var pieces; var result; var workdate; var portion; var datetype; var displaymonthasalpha; var dateone; var datetwo; var workstring; datetype = getLocalizedValue("DATE_TYPE"); displaymonthasalpha = getLocalizedValue("DISPLAY_MONTH_AS_ALPHA"); if (displaymonthasalpha == "1") { datetype = datetype + 10; } switch(datetype) { case 0: // American style dates MM/DD/YYYY pattern = new RegExp("([1-9]|0[1-9]|1[012])[/]([1-9]|0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d"); result = pattern.exec(a[currentCol]); if (!pattern.test(a[currentCol])) result = "01/01/2035"; workdate = new String(result); portion = workdate.split(","); dateone = new Date(portion[0]); result = pattern.exec(b[currentCol]); if (!pattern.test(b[currentCol])) result = "01/01/2035"; workdate = new String(result); portion = workdate.split(","); datetwo = new Date(portion[0]); break; case 1: // European style date DD/MM/YYYY pattern = new RegExp("([1-9]|0[1-9]|[12][0-9]|3[01])[/]([1-9]|0[1-9]|1[012])[/](19|20)\\d\\d"); result = pattern.exec(a[currentCol]); if (!pattern.test(a[currentCol])) result = "01/01/2035"; workdate = new String(result); portion = workdate.split(","); workstring = new String(portion); pieces = workstring.split("/"); dateone = new Date(); dateone.setDate(parseInt(pieces[0])); dateone.setMonth(parseInt(pieces[1]) - 1); dateone.setFullYear(parseInt(pieces[2])); result = pattern.exec(b[currentCol]); if (!pattern.test(b[currentCol])) result = "01/01/2035"; workdate = new String(result); portion = workdate.split(","); workstring = new String(portion); pieces = workstring.split("/"); datetwo = new Date(); datetwo.setDate(parseInt(pieces[0])); datetwo.setMonth(parseInt(pieces[1]) - 1); datetwo.setFullYear(parseInt(pieces[2])); break; case 2: // Asian style dates YYYY/MM/DD pattern = new RegExp("(19|20)\\d\\d[/]([1-9]|0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01]|[1-9])"); result = pattern.exec(a[currentCol]); if (!pattern.test(a[currentCol])) result = "2035/01/01,"; workdate = new String(result); portion = workdate.split(","); workstring = new String(portion); pieces = workstring.split("/"); dateone = new Date(); dateone.setDate(parseInt(pieces[2])); dateone.setMonth(parseInt(pieces[1]) - 1); dateone.setFullYear(parseInt(pieces[0])); result = pattern.exec(b[currentCol]); if (!pattern.test(b[currentCol])) result = "2035/01/01,"; workdate = new String(result); portion = workdate.split(","); workstring = new String(portion); pieces = workstring.split("/"); datetwo = new Date(); datetwo.setDate(parseInt(pieces[2])); datetwo.setMonth(parseInt(pieces[1]) - 1); datetwo.setFullYear(parseInt(pieces[0])); break; case 10: // American style dates MMM DD, YYYY pattern = new RegExp("(" + CheckDisplayMonth + ") ([12][0-9]|3[01]|[1-9]|0[1-9]), (19|20)\\d\\d"); result = pattern.exec(a[currentCol]); if (!pattern.test(a[currentCol])) { result = "01/01/2035"; workstring = new String(result); } else { workstring = new String(result); workstring = workstring.replace(/,/,""); for (count = 1; count <= 12; count++) if (workstring.indexOf(DisplayMonthName[count]) != -1) { workstring = workstring.replace(DisplayMonthName[count],count); workstring = workstring.replace(/ /g,"/"); } } portion = workstring.split(","); dateone = new Date(portion[0]); result = pattern.exec(b[currentCol]); if (!pattern.test(b[currentCol])) { result = "01/01/2035"; workstring = new String(result); } else { workstring = new String(result); workstring = workstring.replace(/,/,""); for (count = 1; count <= 12; count++) if (workstring.indexOf(DisplayMonthName[count]) != -1) { workstring = workstring.replace(DisplayMonthName[count],count); workstring = workstring.replace(/ /g,"/"); } } portion = workstring.split(","); datetwo = new Date(portion[0]); break; case 11: // European style date DD MMM YYYY pattern = new RegExp("([12][0-9]|3[01]|[1-9]|0[1-9]) (" + CheckDisplayMonth + ") (19|20)\\d\\d"); result = pattern.exec(a[currentCol]); if (!pattern.test(a[currentCol])) { result = "01/01/2035"; workstring = new String(result); } else { workstring = new String(result); for (count = 1; count <= 12; count++) if (workstring.indexOf(DisplayMonthName[count]) != -1) { workstring = workstring.replace(DisplayMonthName[count],count); workstring = workstring.replace(/ /g,"/"); } } portion = workstring.split(","); workstring = new String(portion); pieces = workstring.split("/"); dateone = new Date(); dateone.setDate(parseInt(pieces[0])); dateone.setMonth(parseInt(pieces[1]) - 1); dateone.setFullYear(parseInt(pieces[2])); result = pattern.exec(b[currentCol]); if (!pattern.test(b[currentCol])) { result = "01/01/2035"; workstring = new String(result); } else { workstring = new String(result); for (count = 1; count <= 12; count++) if (workstring.indexOf(DisplayMonthName[count]) != -1) { workstring = workstring.replace(DisplayMonthName[count],count); workstring = workstring.replace(/ /g,"/"); } } portion = workstring.split(","); workstring = new String(portion); pieces = workstring.split("/"); datetwo = new Date(); datetwo.setDate(parseInt(pieces[0])); datetwo.setMonth(parseInt(pieces[1]) - 1); datetwo.setFullYear(parseInt(pieces[2])); break; case 12: // Asian style dates YYYY MMM DD pattern = new RegExp("(19|20)\\d\\d (" + CheckDisplayMonth + ") ([12][0-9]|3[01]|[1-9]|0[1-9])"); result = pattern.exec(a[currentCol]); if (!pattern.test(a[currentCol])) { result = "2035/01/01"; workstring = new String(result); } else { workstring = new String(result); for (count = 1; count <= 12; count++) if (workstring.indexOf(DisplayMonthName[count]) != -1) { workstring = workstring.replace(DisplayMonthName[count],count); workstring = workstring.replace(/ /g,"/"); } } portion = workstring.split(","); workstring = new String(portion); pieces = workstring.split("/"); dateone = new Date(); dateone.setDate(parseInt(pieces[2])); dateone.setMonth(parseInt(pieces[1]) - 1); dateone.setFullYear(parseInt(pieces[0])); result = pattern.exec(b[currentCol]); if (!pattern.test(b[currentCol])) { result = "2035/01/01"; workstring = new String(result); } else { workstring = new String(result); for (count = 1; count <= 12; count++) if (workstring.indexOf(DisplayMonthName[count]) != -1) { workstring = workstring.replace(DisplayMonthName[count],count); workstring = workstring.replace(/ /g,"/"); } } portion = workstring.split(","); workstring = new String(portion); pieces = workstring.split("/"); datetwo = new Date(); datetwo.setDate(parseInt(pieces[2])); datetwo.setMonth(parseInt(pieces[1]) - 1); datetwo.setFullYear(parseInt(pieces[0])); break; default: dateone = new Date(); datetwo = new Date(); break; } if (dateone < datetwo) { return -1; } else { if (dateone > datetwo) { return 1; } else { return 0; } } } function CompareNumeric(a, b) { var numA = a[currentCol]; var numB = b[currentCol]; numA = stripLeading(numA); numA = removeExtra(numA); numA = parseInt(numA); if (isNaN(numA)) numA = 0; numB = stripLeading(numB); numB = removeExtra(numB); numB = parseInt(numB); if (isNaN(numB)) numB = 0; return numA - numB; } function CompareMoney(a, b) { var numA = a[currentCol]; var numB = b[currentCol]; numA = stripLeading(numA); numA = removeExtra(numA); numB = stripLeading(numB); numB = removeExtra(numB); numA = pullAmount(numA); numB = pullAmount(numB); numA = parseFloat(numA); numB = parseFloat(numB); numA = numA * 100; numB = numB * 100; numA = Math.round(numA); numB = Math.round(numB); if (isNaN(numA)) { return 0;} else { if (isNaN(numB)) { return 0; } else { return numA - numB; } } } function TableSort(myTable, myCallingObject, myType) { // this function will determine the column number for // rectangular tables that have one column header // for each column. var aColumn = myCallingObject.cellIndex; TableSortByColumn(myTable, aColumn, myType, myCallingObject, 1); } function switchImage(myCallingObject) { var aColumn = myCallingObject; var aPath= getLocalizedValue("IMG_OTHER"); var reImage; var result; var strTemp; strTemp = myCallingObject.innerHTML; // check if arrow is up or down reImage = new RegExp("DOWN.gif\">"); if (!reImage.test(strTemp)) result = 1; else result = 0; // remove the current image string strTemp = strTemp.replace(//gi,""); if (result == 0) { strTemp = " " + strTemp; } else { strTemp = " " + strTemp; } myCallingObject.innerHTML = strTemp; } function setImageDown(myCallingObject, myStepBack) { var aColumn = myCallingObject; var aPath = getLocalizedValue("IMG_OTHER"); var aRow; var aTableSection; var myCells; var myChildren; var myCount; var myCountToo; var strTemp; var strWork; strTemp = myCallingObject.innerHTML; if (myStepBack == 1) { // remove images from all columns aRow = myCallingObject.parentNode; myCells = aRow.childNodes; for (myCount = 0; myCount < myCells.length; myCount++) { if (strTemp != myCells[myCount].innerHTML) { strWork = myCells[myCount].innerHTML; if (strWork != null) { strWork = strWork.replace(//gi,""); myCells[myCount].innerHTML = strWork; } } } } else { // have to get all rows in the multiple level column headers aTableSection = myCallingObject.parentNode.parentNode; myCells = aTableSection.childNodes; for (myCount = 0; myCount < myCells.length; myCount++) { if (myCells[myCount] != null) { if (myCells[myCount].nodeType == 1) { myChildren = myCells[myCount].childNodes; for (myCountToo = 0; myCountToo < myChildren.length; myCountToo++) { if (myChildren[myCountToo] != null && myChildren[myCountToo].nodeType == 1) { if (strTemp != myChildren[myCountToo].innerHTML) { strWork = myChildren[myCountToo].innerHTML; if (strWork != null) { strWork = strWork.replace(//gi,""); myChildren[myCountToo].innerHTML = strWork; } } } } } } } } strTemp = myCallingObject.innerHTML; strTemp = strTemp.replace(//gi,""); strTemp = " " + strTemp; myCallingObject.innerHTML = strTemp; } function check_for_sorted(myCallingObject) { // If the column has an arrow then it is sorted var reImage; var result; var strTemp; strTemp = myCallingObject.innerHTML; // check if arrow is up or down reImage = new RegExp("","i"); if (reImage.test(strTemp)) result = true; else result = false; return result; } function TableSortByColumn(myTable, myColumn, myType, myCallingObject, myStepBack) { var mySource = document.getElementById(myTable); var myRows = mySource.rows.length; var myCols = mySource.rows[0].cells.length; var i; var j; currentCol = myColumn; var myArray = new Array(myRows); for (i=0; i < myRows; i++) { myArray[i] = new Array(myCols); for (j=0; j < myCols; j++) { if (mySource.rows[i].cells[j] != null) myArray[i][j] = mySource.rows[i].cells[j].innerHTML; else myArray[i][j] = ""; } } if (check_for_sorted(myCallingObject)) { switchImage(myCallingObject); myArray.reverse(); } else { setImageDown(myCallingObject,myStepBack); switch (myType) { case "a": myArray.sort(CompareAlpha); break; case "d": myArray.sort(CompareDate); break; case "n": myArray.sort(CompareNumeric); break; case "m": myArray.sort(CompareMoney); break; default: myArray.sort(CompareAlpha); break; } } for (i=0; i < myRows; i++) { for (j=0; j < myCols; j++) { if (mySource.rows[i].cells[j] != null) mySource.rows[i].cells[j].innerHTML = myArray[i][j]; } } } function verifyDateAndSubmit(inForm,inField,inLocalizedNever) { var fields = inField.split(","); var localizedNever = inLocalizedNever.split(","); var theDate; for (count = 0; count < fields.length; count++) { theDate = document.getElementById(fields[count]); if (theDate != null && theDate.value == getLocalizedValue(localizedNever[count])) theDate.value = "NEVER"; } submitForm(inForm); } function setDisplayMonthName(inMonth,inLocalizedName) { DisplayMonthName[inMonth] = inLocalizedName; if (CheckDisplayMonth.length == 0) CheckDisplayMonth = inLocalizedName; else CheckDisplayMonth = CheckDisplayMonth + "|" + inLocalizedName; } function createList() { var nForm; var nValue; nValue = document.getElementById("list_description").value; nValue = new String(nValue); if (nValue.length == 0) alert(getLocalizedValue("CREATE_LIST")); else { nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/150"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="createlistform"; nField=document.createElement('input'); nField.name='description'; nField.id='description'; nField.value=document.getElementById("list_description").value; nField.type='hidden'; nFORM.appendChild(nField); document.body.appendChild(nFORM); nFORM.submit(); } } function removeList() { var nForm; var portion; var nValue; nValue = document.getElementById("current_list").value; nValue = new String(nValue); portion = nValue.split("^"); nValue = portion[0]; if (confirm(getLocalizedValue("DELETE_LIST") + " " + portion[1])) { nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/151"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="removelistform"; nField=document.createElement('input'); nField.name='list_id'; nField.id='list_id'; nField.value=nValue; nField.type='hidden'; nFORM.appendChild(nField); document.body.appendChild(nFORM); nFORM.submit(); } } function renameList() { var nForm; var portion; var nValue; var nNewDescription; nValue = document.getElementById("current_list").value; nValue = new String(nValue); portion = nValue.split("^"); nValue = portion[0]; nNewDescription = prompt(getLocalizedValue("LD_RENAME") + " " + portion[1],""); if (nNewDescription != null && nNewDescription != "") { if (nNewDescription.length > 80) { var alertMsg = getLocalizedValue("LD_RENAME"); alertMsg += getLocalizedValue("21493"); alert(alertMsg); } else { nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/153"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="renamelistform"; nField=document.createElement('input'); nField.name='list_id'; nField.id='list_id'; nField.value=nValue; nField.type='hidden'; nFORM.appendChild(nField); nField=document.createElement('input'); nField.name='description'; nField.id='description'; nField.value=nNewDescription; nField.type='hidden'; nFORM.appendChild(nField); document.body.appendChild(nFORM); nFORM.submit(); } } } function makeListActive() { var nForm; nValue = document.getElementById("current_list").value; nValue = new String(nValue); portion = nValue.split("^"); nValue = portion[0]; nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/156/" + nValue; nFORM.target="_self"; nFORM.method="post"; nFORM.name="setcurrentform"; document.body.appendChild(nFORM); nFORM.submit(); } function removeCheckedTitles(inList) { var nForm; var myForm; var workString; var ckeys = new String(); myForm = document.getElementById("captureform"); if (myForm != null) { checkboxes = myForm.length; for (count = 0; count < checkboxes; count++) if (myForm[count].type == 'checkbox') if (myForm[count].checked == true) { workString = new String(myForm[count].name); if (workString.indexOf("kept-") != -1) { workString = workString.substring(5); if (ckeys.length == 0) ckeys = workString; else ckeys = ckeys + ":" + workString; } } } if (ckeys.length != 0) { nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/155"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="removelistform"; nField=document.createElement('input'); nField.name='list_id'; nField.id='list_id'; nField.value=inList; nField.type='hidden'; nFORM.appendChild(nField); nField=document.createElement('input'); nField.name='ckeys'; nField.id='ckeys'; nField.value=ckeys; nField.type='hidden'; nFORM.appendChild(nField); document.body.appendChild(nFORM); nFORM.submit(); } } function removeAllTitles(inList) { var nForm; var myForm; var workString; var ckeys = new String(); myForm = document.getElementById("captureform"); if (myForm != null) { checkboxes = myForm.length; for (count = 0; count < checkboxes; count++) if (myForm[count].type == 'checkbox') { workString = new String(myForm[count].name); if (workString.indexOf("kept-") != -1) { workString = workString.substring(5); if (ckeys.length == 0) ckeys = workString; else ckeys = ckeys + ":" + workString; } } } if (ckeys.length != 0 && confirm(getLocalizedValue("REMOVE_ALL_TITLES"))) { nFORM=document.createElement('form'); nFORM.action=getLocalizedValue("WEBCAT_URL") + "/" + getLocalizedValue("SESSION") + "/155"; nFORM.target="_self"; nFORM.method="post"; nFORM.name="removelistform"; nField=document.createElement('input'); nField.name='list_id'; nField.id='list_id'; nField.value=inList; nField.type='hidden'; nFORM.appendChild(nField); nField=document.createElement('input'); nField.name='ckeys'; nField.id='ckeys'; nField.value=ckeys; nField.type='hidden'; nFORM.appendChild(nField); document.body.appendChild(nFORM); nFORM.submit(); } } function setEnterpriseReturn(inLogoutURL, inReturnURL) { window.location = inLogoutURL; window.location = inReturnURL; } function required() { date = new Date; if ($('required') != undefined) { $('required').insert('Copyright © 2000 - '+date.getFullYear()+', SirsiDynix'); } } function setDisabled(inElement, inElementCB) { myElement = document.getElementById(inElement); myElementCB = document.getElementById(inElementCB); if (myElementCB.checked) myElement.disabled = true; else myElement.disabled = false; } function saveFirst(e) { if (getChangedAdmin()) { if(!e) e = window.event; e.cancelBubble = true; e.returnValue = getLocalizedValue("ADMIN_CHANGE"); if (e.stopPropagation) { e.stopPropagation(); e.preventDefault(); } return getLocalizedValue("ADMIN_CHANGE"); } } function setChangedAdminOff() { adminchanged = 0; } function setChangedAdmin() { adminchanged = 1; } function getChangedAdmin() { return adminchanged; } function saveAdmin() { setChangedAdminOff(); myform = document.getElementById("update_form"); myform.submit(); } function checkEnvnChange(inForm,inSelect) { var myform = document.getElementById(inForm); var rc; if (getChangedAdmin()) { rc = confirm(getLocalizedValue("ADMIN_CHANGE")); if (rc == true) { setChangedAdminOff(); myform.submit(); } else { var myselect = document.getElementById(inSelect); restoreSelect(myselect,getLocalizedValue("ADMIN_ENVN")); } } else myform.submit(); } function restoreSelect(inSelect,inValue) { var pos = -1; for (count = 0; count < inSelect.length && pos == -1; count++) { if (inValue == inSelect.options[count].value) pos = count; } inSelect.selectedIndex = pos; } function keep_alive(webcatUrl,session,imgOther) { var xRequest = null; if (window.XMLHttpRequest) { xRequest= new XMLHttpRequest(); } else if (typeof ActiveXObject != "undefined") { xRequest = new ActiveXObject("Microsoft.XMLHTTP"); } if (xRequest != null) { xRequest.open("GET",webcatUrl + "/" + session + "/302",true); xRequest.send(null); } } function loadEnterpriseSearch(event, enterprise_search_url) { var search_term = $('search_term').value; // var search_term = document.getElementById('search_term').value; // there is a quicker way to do this, but this is easier for modification search_term = search_term.replace(/\$/gi, '$002524'); search_term = search_term.replace(/ /gi, '$002b'); search_term = search_term.replace(/"/gi, '$002522'); search_term = search_term.replace(/'/gi, '$002527'); search_term = search_term.replace(/\//gi, '$00252F'); search_term = search_term.replace(/\\/gi, '$00255C'); search_term = search_term.replace(/\`/gi, '$002560'); search_term = search_term.replace(/\~/gi, '$00257E'); search_term = search_term.replace(/!/gi, '$002521'); search_term = search_term.replace(/@/gi, '$002540'); search_term = search_term.replace(/#/gi, '$002523'); search_term = search_term.replace(/%/gi, '$002525'); search_term = search_term.replace(/\^/gi, '$00255E'); search_term = search_term.replace(/&/gi, '$002526'); search_term = search_term.replace(/\*/gi, '$002a'); search_term = search_term.replace(/\(/gi, '$002528'); search_term = search_term.replace(/\)/gi, '$002529'); search_term = search_term.replace(/\+/gi, '$00252B'); search_term = search_term.replace(/\=/gi, '$00253D'); search_term = search_term.replace(/\[/gi, '$00255B'); search_term = search_term.replace(/\]/gi, '$00255D'); search_term = search_term.replace(/\{/gi, '$00257B'); search_term = search_term.replace(/\}/gi, '$00257D'); search_term = search_term.replace(/\|/gi, '$00257C'); search_term = search_term.replace(/\:/gi, '$00253A'); search_term = search_term.replace(/\;/gi, '$00253B'); search_term = search_term.replace(/\/gi, '$00253E'); search_term = search_term.replace(/\,/gi, '$00252C'); search_term = search_term.replace(/\?/gi, '$00253F'); var search_url = enterprise_search_url; if (event) { // check to see if enter was pressed if(event.keyCode=='13'){ window.location = search_url+search_term; } } else { // no key press. button was clicked. window.location = search_url+search_term; } }