var M_strBaseAnchorName; var M_intCurrentPage; var M_strAnchorWrapper; var M_strContentContainer; var M_bHasViewAll; var M_intMaxPages = 0; var M_intCurrentPage = 1; var M_arrNavs = new Array(); var M_arrPrev = new Array('aPrevious'); var M_arrNext = new Array('aNext'); function MovePage(pos) { try { if(pos <= M_intMaxPages && pos > 0) { MoveContentPosition(pos); M_arrNavs.each(function(node) { $(node).value = pos; }) } } catch( e ) { HandleError( "MovePage", e, M_strPageName ); } } function JumpTo(frm) { try { var objIntRegExp = /^\d{1,2}$/; var pageVal = frm.getElementsByTagName("input")[0].value.strip(); // do we have a num? if(pageVal.length > 0 && objIntRegExp.test(pageVal)) { MovePage(parseInt(pageVal)); } return false; } catch( e ) { HandleError( "JumpTo", e, M_strPageName ); } } /* When the page loads, we check how many MainText contributions we have. If we have more than one, we light up the next button. */ function EnableNextButton() { try { if( $( M_strAnchorWrapper ) != null ) { $( "aNext" ).removeAttribute( "style" ); } } catch( e ) { HandleError( "EnableNextButton", e, M_strPageName ); } } /* This lets us paginate through the content. */ function MoveContentPosition( intIndex ) { try { if( M_intCurrentPage == intIndex) return; var dvNext = $( M_strBaseAnchorName + intIndex ) // Next page exists, go to it if( dvNext != null ) { M_intCurrentPage = intIndex; ChangeIndexedContent( "a" + intIndex, M_strBaseAnchorName + ( intIndex - 1 ), M_strBaseAnchorName + ( intIndex + 1 ) ); } } catch( e ) { HandleError( "MoveContentPosition", e, M_strPageName ); } } function SnapContentPosition( intIndex ) { try { var dvNext = $( M_strBaseAnchorName + intIndex ) // Next page exists, go to it if( dvNext != null ) { M_intCurrentPage = intIndex; Element.update(M_strContentContainer, $( M_strBaseAnchorName + M_intCurrentPage ).innerHTML); AdjustPaginationLinks( "a" + intIndex ); AdjustPositionLink( M_strBaseAnchorName + ( intIndex - 1 ), M_arrPrev ); AdjustPositionLink( M_strBaseAnchorName + ( intIndex + 1 ), M_arrNext ); } } catch( e ) { HandleError( "SnapContentPosition", e, M_strPageName ); } } /* We use this function to enable/disable the Prev and Next links. */ function AdjustPositionLink( strElementId, arrLinks ) { try { // Check for previous if( $(strElementId) == null ) { arrLinks.each(function(node) { Element.setStyle(node, {color: '#666666',textDecoration: 'none', cursor: 'default'}); }); } else { arrLinks.each(function(node) { Element.setStyle(node, {color: '',textDecoration: '', cursor: ''}); }); } } catch( e ) { HandleError( "AdjustPositionLink", e, M_strPageName ); } } /* We swap out the contents of dvArticle here. */ function ChangeIndexedContent( strId, strPrev, strNext ) { try { // Replace content ReplaceContent($( M_strBaseAnchorName + M_intCurrentPage ).innerHTML, strId, strPrev, strNext ); } catch( e ) { HandleError( "ChangeIndexedContent", e, M_strPageName ); } } /* Needed on homepage*/ function HidePaginationContent() { try { $(M_strContentContainer).removeAttribute("style"); } catch( e ) { HandleError( "HidePaginationContent", e, M_strPageName ); } } function ReplaceContent( strContent, strId, strPrev, strNext ) { try { Element.setStyle(M_strContentContainer,{zoom:'1'}); var _objCanvas = new fx.Opacity( M_strContentContainer, {duration: 400}); _objCanvas.options.onComplete = function() { Element.update(M_strContentContainer, strContent); _objCanvas.options.onComplete = null; AdjustPaginationLinks( strId ); if(!IsEmpty(strId)) { AdjustPositionLink( strPrev, M_arrPrev ); AdjustPositionLink( strNext, M_arrNext ); } _objCanvas.toggle(); }; _objCanvas.toggle(); } catch( e ) { HandleError( "ReplaceContent", e, M_strPageName ); } } /* This function selects/deselects the current pagination link. Numerical links only ( RE: 1,2,3 - NOT ViewAll, Prev, Next)*/ function AdjustPaginationLinks( strSelectedLinkId ) { try { // Select proper link var arrLinks = $( M_strAnchorWrapper ).getElementsByTagName( "a" ); var nodes = $A(arrLinks); nodes.each(function(node) { if( !isNaN(node.innerHTML) ) { node.className = ( node.getAttribute( "id" ) == strSelectedLinkId ? "contentSelected" : "" ); } }); if( M_bHasViewAll ) { $( "aViewAll" ).className = ""; } if( strSelectedLinkId == null ) { $("aViewAll").className = "contentSelected"; } } catch( e ) { HandleError( "AdjustPaginationLinks", e, M_strPageName ); } } /* When we click ViewAll, we scoop up all of the MainText contributions, concatenate them and put them in the div tag. */ function ViewAll() { try { var arrDivs = $( M_strAnchorWrapper ).getElementsByTagName( "div" ); var nodes = $A(arrDivs); var strContents = ""; nodes.each(function(node) { strContents += node.innerHTML }); ReplaceContent( strContents, null, null, null ); } catch( e ) { HandleError( "ViewAll", e, M_strPageName ); } }