var M_strBaseAnchorName; var M_intCurrentPage; var M_strAnchorWrapper; var M_strContentContainer; var M_bHasViewAll; /* 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 ), "aPrevious" ); AdjustPositionLink( M_strBaseAnchorName + ( intIndex + 1 ), "aNext" ); } } catch( e ) { HandleError( "SnapContentPosition", e, M_strPageName ); } } /* We use this function to enable/disable the Prev and Next links. */ function AdjustPositionLink( strElementId, strLinkId ) { try { // Check for previous if( $(strElementId) == null ) { Element.setStyle(strLinkId, {color: '#666666',textDecoration: 'none', cursor: 'default'}); } else { Element.setStyle(strLinkId, {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, "aPrevious" ); AdjustPositionLink( strNext, "aNext" ); } _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 ); } }