// JavaScript Document

$( document ).ready ( init_diamond );
function init_diamond () {
	//alert ( 'init_diamond ()' );
	$( '.page_item_img > a > img' ).mouseover ( pgnav_over, this );
	$( '.page_item_img > a > img' ).mouseout ( pgnav_out, this );
	set_header_pos ();
	set_b2top_display ();
}
// ---	Rollover on the main nav
function pgnav_over ( obj ) {
	//alert ( 'pgnav_over ( obj:' +obj +' )' );
	var imgsrc 		= $( this ).attr ( 'src' );
	var is_currpg 	= $( this ).parent ().parent ().hasClass ( 'current_page_item' );
	if ( !is_currpg ) {
		imgsrc 	= imgsrc.replace ( '-off.png', '-over.png' );
		$( this ).attr ( 'src', imgsrc );
	}
}
// ---	Rollout on the main nav
function pgnav_out ( obj ) {
	//alert ( 'pgnav_out ( obj:' +obj +' )' );
	var imgsrc 		= $( this ).attr ( 'src' );
	var is_currpg 	= $( this ).parent ().parent ().hasClass ( 'current_page_item' );
	if ( !is_currpg ) {
		imgsrc 	= imgsrc.replace ( '-over.png', '-off.png' );
		$( this ).attr ( 'src', imgsrc );
	}
}
// ---	Move the header blurb down if there is only one line of text. 
//		It was easier to check for height of container than to detect word wrap
function set_header_pos () {
	//alert ( 'set_header_pos ()' );
	if ( $( '#page-hdrblurbtxt' ).height () < 21 ) {
		$( '#page-hdrblurbtxt' ).css ( 'margin-top', '12px' );
	}
}
// ---	Hide the 'Back to Top' link if the content container is 
//		so short that there is no need for it.
function set_b2top_display () {
	//alert ( 'set_b2top_display ()' );
	if ( $( '#page-cont' ).height () < 400 ) {
		$( '#b2top' ).css ( 'display', 'none' );
	}
}

