// image rollover
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' ); }
}

// image rollout
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' ); }
}



// class name rollover
function navover( aobj )
{
	var mystring	= aobj.className;
	aobj.className	= mystring + '-on';
}

// class name rollout
function navout( aobj )
{
	var mystring	= aobj.className;
	aobj.className	= mystring.replace( /-on/gi, '' );
}



// default field values
var defvals = new Array();

// clear field
function clear_field( field )
{
	if( field.value == 'username' )
	{
		defvals[field.id]	= field.value;
		field.value		= '';
	}
}

// unclear field
function unclear_field( field )
{
	if( field.value == '' )
	{
		field.value	= defvals[field.id];
	}
}

function clear_pwfield( field )
{
	field.className		= 'password';
}

// unclear field
function unclear_pwfield( field )
{
	if( field.value == '' )
	{
		field.className		= 'passwordempty';
	}
}

// launch the player window
function launchplayer( stream )
{
	playerwindw = window.open( '/player/?s='+stream,'playerwindow', 'left=20,top=20,width=770,height=232,toolbar=0,resizable=0,scrollbars=0,menubar=0,status=0,location=0,directories=0');
}


function fixH(one,two)
{
	if( document.getElementById(one) )
	{
		// get height
		var lh	= document.getElementById(one).offsetHeight;
		var rh	= document.getElementById(two).offsetHeight;
		var nh	= Math.max(lh, rh);
		
		// set height
		document.getElementById(one).style.height	= nh+"px";
		document.getElementById(two).style.height	= nh+"px";
	}
}


// 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( 'dd-'	+ 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 ); }

	// show the new menu
	//if( thismenu ) { thismenu.style.visibility = 'visible'; }
	if( thismenu) { thismenu.style.display = 'block'; }

	// 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( 'dd-'	+ currentMenu );

	// hide the menu - only if it exists
	//if( thismenu ) { thismenu.style.visibility = 'hidden'; }
	if( thismenu ) { thismenu.style.display = 'none'; }
}

function increaseFontSize()
{
	increase_font_for_element( 'p',	 18 );
	increase_font_for_element( 'h3', 24 );
}

function increase_font_for_element( element, limit )
{
	// generate a list of all elements
	var elems = document.getElementsByTagName( element );

	// loop through each element of in the array
	for( i=0; i<elems.length; i++ )
	{
		// find the new font size
      	var s = ( elems[i].style.fontSize ) ? parseInt( elems[i].style.fontSize.replace('px','') ) : 12;
			s = ( s != limit ) ? s + 1 : s;

		// set the new font size
		elems[i].style.fontSize = s + 'px';
	}
}

function decreaseFontSize()
{
	decrease_font_for_element( 'p',		8  );
	decrease_font_for_element( 'h3',	12 );
}

function decrease_font_for_element( element, limit )
{
	// generate a list of all elements
	var elems = document.getElementsByTagName( element );
	
	// loop through each element of in the array
	for( i=0; i<elems.length; i++ )
	{
		// find the new font size
		var s = ( elems[i].style.fontSize ) ? parseInt(elems[i].style.fontSize.replace('px','')) : 12;
		    s = ( s != limit ) ? s - 1 : s;
		
		// set the new font size
		elems[i].style.fontSize = s + 'px';
	}
}


function bookmark( url, title )
{
	// Mozilla Firefox Bookmark
	if( window.sidebar )
	{
		window.sidebar.addPanel(title, url,"");
	}
	
	// IE Favorite
	else if( window.external )
	{
		window.external.AddFavorite( url, title );
	}
	
	// Opera Hotlist
	else if( window.opera && window.print )
	{
		return true;
	}
}