function rollover( imageobj )
{
	var mystring = imageobj.src;

	if( mystring.indexOf( ".gif" ) >= 1)
	{
		imageobj.src = mystring.replace( /\.gif/gi, '_over.gif' );
	}

	else
	{
		imageobj.src = mystring.replace( /\.jpg/gi, '_over.jpg' );
	}
}

function rollout( imageobj )
{
	var mystring = imageobj.src;
	if( mystring.indexOf( ".gif" ) >= 1 )
	{
		imageobj.src = mystring.replace( /\_over\.gif/gi, '.gif' );
	}
	else
	{
		imageobj.src = mystring.replace( /\_over\.jpg/gi, '.jpg' );
	}
}



// declare variables for dropdown navigation
var sTimer		= new Array();
var currentMenu		= '';

// show drop-down sub navigation
function showSub( i )
{
	// kill timer to hide this menu
	window.clearTimeout( sTimer[currentMenu] );
	window.clearTimeout( sTimer[i] );
	
	// declare menus
	var thismenu	= document.getElementById( 'menu'	+ i );
	var thislabel	= document.getElementById( 'label'	+ i );
	var thiscontain	= document.getElementById( 'container'	+ i );
	var thisbold	= document.getElementById( 'bold'	+ i );
	
	// if the menu we're about to show is different than the menu currently opened, lets close that one first.
	if( currentMenu != '' && currentMenu != i ) { revertSub( currentMenu ); }

	// change the rollover style
	if( thislabel.className != 'primarylive' )
	{
		thislabel.className	= 'primaryover';
		thiscontain.className	= 'whitebg';
		thisbold.className	= 'btop';
	}

	// show the new menu
	if( thismenu ) { thismenu.style.visibility = 'visible'; }
	
	// set current menu to this menu
	currentMenu = i;
}

// start a timer to hide the drop down menu if we mouse off of it
function hideSub( i )
{
	//window.clearTimeout( sTimer[i] );
	sTimer[i] = window.setTimeout("revertSub('" + i + "')", 1000);
}


// hide the drop down menu
function revertSub( i )
{
	// declare local variables
	var thismenu	= document.getElementById( 'menu'	+ currentMenu );
	var thislabel	= document.getElementById( 'label'	+ currentMenu );
	var thiscontain	= document.getElementById( 'container'	+ currentMenu );
	var thisbold	= document.getElementById( 'bold'	+ currentMenu );

	// revert the classnames
	if( thislabel.className != 'primarylive' )
	{
		thislabel.className	= 'primary';
		thiscontain.className	= 'nobg';
		thisbold.className	= 'btopoff';
	}
	
	// hide the menu - only if it exists
	if( thismenu ) { thismenu.style.visibility = 'hidden'; }
}


// declare local variables
var perpage	= 0;
var lastpage	= 0;

// initialize naviation
function subnav_initialize( newperpage )
{
	// set perpage
	perpage		= newperpage ? newperpage : 10;
	
	// declare local variables
	lastpage	= perpage;

	// show first level navigation
	subnav_toggle( 1, perpage, 'block' );

	// determine if we can go down
	document.getElementById( 'subnav_down' ).style.visibility	= ( document.getElementById( 'subnav_' + (lastpage  + 1) ) ) ? 'visible' : 'hidden';
}

// move navigation up
function subnav_up()
{
	// declare local variables
	var starthide	= lastpage - perpage + 1;
	var endhide		= lastpage;
	var startshow	= starthide - perpage;
	var endshow		= starthide - 1;
	lastpage		= endshow;

	// run hide then show
	subnav_toggle( starthide, endhide, 'none'  );
	subnav_toggle( startshow, endshow, 'block' );

	// determine if we can go up / down
	document.getElementById( 'subnav_up' ).style.visibility		= ( document.getElementById( 'subnav_' + (startshow - 1) ) ) ? 'visible' : 'hidden';
	document.getElementById( 'subnav_down' ).style.visibility	= ( document.getElementById( 'subnav_' + (lastpage  + 1) ) ) ? 'visible' : 'hidden';
}

// move navigation down
function subnav_down()
{
	// declare local variables
	var starthide	= lastpage - perpage + 1;
	var endhide		= lastpage;
	var startshow	= lastpage + 1;
	var endshow		= lastpage + perpage;
	lastpage		= endshow;

	// run hide then show
	subnav_toggle( starthide, endhide, 'none'  );
	subnav_toggle( startshow, endshow, 'block' );

	// determine if we can go up / down
	document.getElementById( 'subnav_up' ).style.visibility		= ( document.getElementById( 'subnav_' + (startshow - 1) ) ) ? 'visible' : 'hidden';
	document.getElementById( 'subnav_down' ).style.visibility	= ( document.getElementById( 'subnav_' + (lastpage  + 1) ) ) ? 'visible' : 'hidden';
}

// toggle status of a group of elements
function subnav_toggle( begin, finish, status )
{
	// loop through each element from 'begin' to 'finish'
	for( var i = begin; i <= finish; i++ )
	{
		// set it's display 'status'
		if( document.getElementById( 'subnav_' + i ) ) { document.getElementById( 'subnav_' + i ).style.display = status; }
	}
}

// return the lastpage variable
function subnav_getlastpage()
{
	return lastpage;
}


// default field values
var defvals = new Array();

// clear field
function clear_field( field )
{
	defvals[field.id]	= field.value;
	field.value			= '';
	field.className		= 'full';
}

// unclear field
function unclear_field( field )
{
	if( field.value == '' )
	{
		field.value		=	defvals[field.id];
		field.className	= 'empty';
	}
}