/**
 * @author bnelson
 */
var identity = "asc";

$( document ).ready( function()
{
	if( $.browser.msie && parseInt( $.browser.version ) < 7 ) $(document).pngFix();
	changeIdentity( identity );
	fixMenu( identity );
	$( "label.hint" ).labelHint('hinted');
	$("input.numeric").numeric();
	
	jQuery( "a[href*='contact-us.html']" ).attr( "href", jQuery( "a[href*='contact-us.html']" ).attr( "href" ) + "#" + identity );	
} );	
	
function fixMenu( i )
{
	/* 
	 *	space & format main menu	
	 */
	var remainingWidth 	= 758;
	var remainingItems 	= $( "#wrapper-menu-main a" ).size();
	var extraPadding 	= 0;
	var oddButtonBg		= "/CTE/templates/cte/common/css/images/wrapper-menu-main-background-red.gif";
	
	switch( i )
	{
		case "asc" :
		break;
		case "mp" :
			oddButtonBg = "/CTE/templates/cte/common/css/images/wrapper-menu-main-background-blue.gif"; 
		break;
		default : break;
	}
	
	$( "#wrapper-menu-main a" ).each( function(){ remainingWidth = remainingWidth - $( this ).width(); } );
	$( "#wrapper-menu-main a" ).each( function(i)
	{
		remainingItems = $( "#wrapper-menu-main a" ).size() - i;
		extraPadding = ( remainingItems != 1 ) ? Math.round( remainingWidth / remainingItems ) : ( Math.round( remainingWidth ) - 1 );
		$( this ).css( "width", ( extraPadding + $( this ).width() ) + "px" );
		remainingWidth = remainingWidth - extraPadding;
	});
	
	$( "#wrapper-menu-main a:last" ).css( { background: "url('" + oddButtonBg + "') repeat-x", borderLeft: ".1em solid #B8B8BA" } );
}

function changeIdentity( i )
{
	/*
	 *	change the look of the site based on the identity
	 */
	var _bodyBackground 		= "#7690B4 url('/CTE/templates/cte/common/css/images/body-background-blue.gif')";
	var _headerBackground 		= "url('/CTE/templates/cte/common/css/images/wrapper-header-background-blue.png') no-repeat";
	var _mainMenuBackground		= "url('/CTE/templates/cte/common/css/images/wrapper-menu-main-background-blue.gif') repeat-x";
	var _footerBackground		= "#1956AD";
	var _mainMenuHover			= "#5D94D6";
	var _originalBackground 	= "";
	var _memberLoginBackground 	= "url('/CTE/templates/cte/common/css/images/wrapper-member-login-background-blue.gif') repeat-y";
	var _memberLoginTop 		= "url('/CTE/templates/cte/common/css/images/member-login-top-background-blue.gif') no-repeat";
	var _memberLoginBottom 		= "url('/CTE/templates/cte/common/css/images/member-login-bottom-background-blue.gif') no-repeat";
		
	switch( i )
	{
		case "asc" :
		break;
		case "mp" :
			_bodyBackground 		= "#B47676 url('/CTE/templates/cte/common/css/images/body-background-red.gif')"; 
			_headerBackground 		= "url('/CTE/templates/cte/common/css/images/wrapper-header-background-red.png') no-repeat";
			_mainMenuBackground		= "url('/CTE/templates/cte/common/css/images/wrapper-menu-main-background-red.gif') repeat-x";
			_footerBackground		= "#AC1A1D";
			_mainMenuHover			= "#D65C60";
			_memberLoginBackground 	= "url('/CTE/templates/cte/common/css/images/wrapper-member-login-background-red.gif') repeat-y";
			_memberLoginTop 		= "url('/CTE/templates/cte/common/css/images/member-login-top-background-red.gif') no-repeat";
			_memberLoginBottom 		= "url('/CTE/templates/cte/common/css/images/member-login-bottom-background-red.gif') no-repeat";
		break;
		default : break;
	}
	 
	$( "body" ).css( "background", _bodyBackground );
	$( "#wrapper-header" ).css( "background", _headerBackground );
	$( "#wrapper-menu-main .moduletable" ).css( "background", _mainMenuBackground );
	$( "#wrapper-footer" ).css( "background", _footerBackground );
	$( "#wrapper-menu-main li a" ).hover( function()
	{ 
		_originalBackground = ( $( this ).css( "background" ) ) ? $( this ).css( "background" ) : "";
		$( this ).css( "background", _mainMenuHover ); 
	}, function(){ $( this ).css( "background", _originalBackground ); } );
	$( "#member-login-top" ).css( "background", _memberLoginTop );
	$( "#wrapper-member-login" ).css( "background", _memberLoginBackground );
	$( "#member-login-bottom" ).css( "background", _memberLoginBottom );
}