var featureFlash;

$(document).ready( function()
{
	var page = document.location.pathname;
	var page_sub = page.substring( page.lastIndexOf( '/' ) + 1 );
	
	/* if this isn't the homepage */
	
	if( page_sub != '' ) { applyStyle( page_sub ) }
	
	/* if this is the homepage */
	
	if( page_sub == 'Index.cfm' || page_sub == '' )
	{
		applyFeatureRolls();
		loadFlash( 0 );
		featureFlash = document.getElementById( 'feature' );
	}
});

/* this creates the current class for the main nav */

function applyStyle( pagename )
{	
	$( 'div#container div#nav a' ).each
	(
		function( i )
		{			
			var href_link = $( this ).attr( 'href' ).replace( '/', '' );
			
			$( this ).removeClass();
			
			if( pagename == href_link )
			{
				$( this ).addClass( 'current' );
			}
		}
	);
}

/* this function applies rollover for the feature projects section on the homepage */

function applyFeatureRolls()
{
	$( 'div#left div#feature-nav a[ id != "featured-projects" ]' ).each
	(
		function( i )
		{
			$( this ).hover( function() { featureFlash.setFeature( i ) } );
		}
	);
}

function loadFlash()
{
	var so = new SWFObject( "images/splash.swf", "feature", "581", "328", "8", "#FFF" );
	
	so.addVariable( "swf_1", "images/one_jul2711.swf" );
	so.addVariable( "swf_2", "images/two_jul2611.swf" );
	so.addVariable( "swf_3", "images/three.swf" );
	
	so.write( "feature-flash" );
}
