/** add_page_load_event.js allows us to run one or multiple functions on page load
The advantage of this funtion is it won't override any previously set onload functions,
and also that it will trigger at the point of HTML being ready, rather than waiting for every image to load */

/** Code to run on page load, including image rollovers and anything else fancy */
function page_setup()
{
	$('#mainmenu').supersubs({ 
		minWidth:    12,   // minimum width of sub-menus in em units 
		maxWidth:    27,   // maximum width of sub-menus in em units 
		extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish();
	
	if( document.getElementById( 's' ) )
	{
		textfield_setDefaultValue( 's', 'Search...' );
	}
	
	if( document.getElementById( 'asxCodes' ) )
	{
		textfield_setDefaultValue( 'asxCodes', 'ASX Code...' );
	}
	
	if( document.getElementById( 'membemail' ) )
	{
		textfield_setDefaultValue( 'membemail', 'you@youremail.com' );
	}
	
	if( document.getElementById( 'membemail_rhs' ) )
	{
		textfield_setDefaultValue( 'membemail_rhs', 'you@youremail.com' );
	}
	
	if( $( '.featured_testimonials_list').eq(0).length > 0 )
	{
		$('.featured_testimonials_list .testimonials_tmpl_rhs_wrapper')
			.animate({ opacity: 0.5 }, 500 )
			.animate({ opacity: 1 }, 500 )
			.hover( function(){ $(this).animate({ opacity: 0.5 }); }, function(){ $(this).animate({ opacity: 1 }); } )
			.cycle({
				fx		: 'fade',
				timeout	: 20000,
				pause	: 1
			}); 
	}
	
	if( $( '.featured_experts_list').eq(0).length > 0 )
	{
		$('.featured_experts_list')
			.animate({ opacity: 0.5 }, 500 )
			.animate({ opacity: 1 }, 500 )
			.hover( function(){ $(this).animate({ opacity: 0.5 }); }, function(){ $(this).animate({ opacity: 1 }); } )
			.cycle({
				fx		: 'fade',
				timeout	: 20000,
				//delay	: 5000,
				pause	: 1,
				random	: 1
			}); 
	}
	
	if( $( '.proud_members_list').eq(0).length > 0 )
	{
		$('.proud_members_list')
			.animate({ opacity: 0.5 }, 500 )
			.animate({ opacity: 1 }, 500 )
			.hover( function(){ $(this).animate({ opacity: 0.5 }); }, function(){ $(this).animate({ opacity: 1 }); } )
			.cycle({
				fx		: 'fade',
				timeout	: 20000,
				//delay	: 5000,
				pause	: 1,
				random	: 1
			}); 
	}
	
	if( $( '.home_page_banner').eq(0).length > 0 )
	{
		$('.home_page_banner')
			.animate({ opacity: 0.5 }, 500 )
			.animate({ opacity: 1 }, 500 )
			.hover( function(){ $(this).animate({ opacity: 0.5 }); }, function(){ $(this).animate({ opacity: 1 }); } )
			.cycle({
				fx		: 'fade',
				timeout	: 20000,
				//delay	: 5000,
				pause	: 1,
				random	: 0
			}); 
	}
}

$(document).ready( page_setup );

