$('document').ready(function(){
	//The design of the Blogroll and Find Us right-rail modules
	//calls for a two column layout.
	//A table is being used to control column alignment in the
	//event a link label wraps to one or more new lines.
	
	//The CMS does not provide a simple way to present links in a two
	//column table. Consequently the JavaScript solution that follows
	//removees the list of Blogroll and Find US links from the DOM and 
	//reassembles them in a table format, which is inserted back into
	//the DOM.
	var blogroll = $( 'ul#blogroll-list' ).remove(),
		blogrollLinkList = $( 'li', blogroll ),
		blogrollTableElement = TM.getLinksTable( blogrollLinkList ),
		findUs = $( 'ul#findUs-list' ).remove(),
		findUsLinkList = $( 'li', findUs ),
		findUsTableElement = TM.getLinksTable( findUsLinkList );
		
	$( '#blogroll-dynamic' ).append( $( blogrollTableElement ) );
	$( '#findUs' ).append( $( findUsTableElement ) );
		
	$('#sideMenu a img').rollover({overStateSuffix:'Over'});
	$('#back a img').rollover({overStateSuffix:'Over'});
	$('select[name=archiveSelect]').bind('change', nav);
	
});
var TM = ( function(){
	function getLinksTable( anchorList ){
		var tableElement = '<table class="sidebarLinks">';
		anchorList.each( function( index ){
			if( index % 2 === 0 ){
				tableElement += '<tr>';
			}
			tableElement += '<td valign="top">';
			tableElement += this.innerHTML;
			tableElement += '</td>';
			if( index % 2 !== 0 ){
				tableElement += '</tr>';
			}
		} );
		tableElement += '</table>';
		return tableElement;
	}
	return { getLinksTable : getLinksTable }
}() );

function nav(){
   var w = document.formArchive.archiveSelect.selectedIndex;
   var url_add = document.formArchive.archiveSelect.options[w].value;
   window.location.href = url_add;
}
