
//requires jQuery


//wait for the DOM to be loaded
jQuery( document ).ready( function() {
	
	//GENERIC SITE ELEMENTS
	GenSiteElements.init();
	
	//Set layout.
	SetLayout.init();
	
} );

SetLayout = 
{
	init : function()
	{
		//Add backgrounds.
		$( 'body' ).append( '<div id="headerBg"></div>' );
		$( 'body' ).append( '<div id="contentBg"></div>' );
		//$( 'body' ).append( '<div id="footerBg"></div>' );
		$( 'body' ).append( '<div id="bannerBg"></div>' );
		
		var myElement = $( 'div#content' );
		//var myMarginBottom = myElement.css( "margin-bottom" );
		//myMarginBottom = myMarginBottom.replace( /px/, "" );
		//var myMarginTop = myElement.css( "margin-top" );
		//myMarginTop = myMarginTop.replace( /px/, "" );
		//var myPaddingTop = myElement.css( "padding-top" );
		//myPaddingTop = myPaddingTop.replace( /px/, "" );
  		//var myPaddingBottom = myElement.css( "padding-bottom" );
		//myPaddingBottom = myPaddingBottom.replace( /px/, "" );
		//var myHeight = $( 'div#footer' ).offset().top;//myElement.height();//myElement.height() + parseInt( myMarginBottom ) + parseInt( myPaddingTop ) + parseInt( myPaddingBottom );
		//myHeight = myHeight - $( 'div#header' ).outerHeight();
		var myHeight = $( 'div#content' ).outerHeight();
		$( 'div#contentBg' ).height( myHeight );
		//$( 'div#contentBg' ).css( 'height', myHeight + 'px' );
		
		//Set footer.
		//SetLayout.setFooter();
		
		//Reset footer on browser resize.
		//$( window ).bind( "resize", SetLayout.setFooter );
		
		$( 'div#nav ul li a' ).append( '<span class="left"></span><span class="right"></span>' );
	}
	,
	setFooter : function()
	{
		//var myPosY = $( 'div#footer' ).position().top;
		//$( 'div#footerBg' ).css( 'top', myPosY + 'px' );
		//var myHeight = $( window ).height() - myPosY;
		//$( 'div#footerBg' ).css( 'height', myHeight + 'px' );
	}
}



//handles setting site elements
GenSiteElements =
{
	//handles setting up site elements
	init : function()
	{
		GenSiteElements.setBlockquotes();
		GenSiteElements.setOrderedLists();
		GenSiteElements.setExternalLinks();
	}//end function init
	,
	//handles setting up block quotes
	setBlockquotes : function()
	{
		jQuery( 'blockquote' ).each( function(){
			var myTitle = jQuery( this ).attr( 'title' );
			var myCite = jQuery( this ).attr( 'cite' );
			jQuery( this ).prepend( '<h3>' + myTitle + '</h3>' );
			jQuery( this ).append( '<p class="cite"><a href=\"' + myCite + '\">Source</a></p>' );
		} );
	}//end function setBlockquotes
	,
	//handles setting ordered list
	setOrderedLists : function()
	{
		//edit ordered list dom to allow styling
		jQuery( 'ol li' ).wrapInner( '<span class="olItemContent"></span>' );
		//activate ordered list styling via adding class - edit styles in stylesheet
		jQuery( 'ol' ).addClass( 'javaScriptStyled' );
	}
	,
	//handles external links
	setExternalLinks : function()
	{
		jQuery( 'a[rel="external"]' ).each( function(){
			jQuery( this ).addClass( 'externalLink' );
			
		} );
		
		//jQuery( 'a[rel="external"]' ).click( function(){
			
			//window.open( jQuery( this ).attr( 'href' ) );
			//return( false );
		//} );
	}//end function setExternalLinks
	
	
};//end object literal siteElements

