function disableWaiter()
{
	if( etherPlanes.waiter )
	{
		setTimeout( 'hideWaiter()', 1500 );
	}
}

function hideWaiter()
{
	waiterEl	=	document.getElementById( 'waiter' );
	waiterEl.style.visibility	=	'hidden';
}

function chgMisc( picName, picFile )
{
	if( document.images && document[picName] )
		document[picName].src	=	"img/"+picFile;
}

function displayPopup( title, text )
{
	var html	=		'<table width="367" cellpadding="0" cellspacing="0" border="0">'+
						'	<tr>'+
						'		<td>'+
						'			<img src="img/popup_top.gif" width="367" height="7" alt="" border="0"><br>'+
						'			<table width="367" cellpadding="0" cellspacing="0" border="0">'+
						'				<tr valign="top">'+
						'					<td width="9" background="img/popup_bgleft.gif"><img src="img/popup_bgleft.gif" width="9" height="50" alt="" border="0"></td>'+
						'					<td width="342" class="text" background="img/popup_bg.gif" valign="middle">';
	if( title != "" )
	{
		html	+=		'						<b>'+title+'</b><br>'+
						'						<img src="img/px.gif" width="1" height="8" alt="" border="0"><br>';
	}

	html		+=		'						<span class="descr">'+text+'</span><br>'+
						'						<img src="img/px.gif" width="1" height="6" alt="" border="0"><br>'+
						'						<div align="center">'+
						'							<a href="javascript:hidePopup();" onmouseover="chgMisc( \'popupBtn\', \'av_btnbox_ok_1.gif\' );" onmouseout="chgMisc( \'popupBtn\', \'av_btnbox_ok_0.gif\' );"><img name="popupBtn" src="img/av_btnbox_ok_0.gif" width="22" height="24" alt="" border="0"></a><br>'+
						'						</div>'+
						'						<img src="img/px.gif" width="1" height="6" alt="" border="0"><br>'+
						'					</td>'+
						'					<td width="16" background="img/popup_bgright.gif"><img src="img/popup_bgright.gif" width="16" height="50" alt="" border="0"></td>'+
						'				</tr>'+
						'			</table>'+
						'			<img src="img/popup_bottom.gif" width="367" height="11" alt="" border="0"><br>'+
						'		</td>'+
						'	</tr>'+
						'</table>';
	
	setElementContent( popupLayer, html );
	
	moveElementTo( popupLayer, 270, mouseY-40 );
	showElement( popupLayer );
}

function linkedHi( el, linkedId )
{
	var lel	=	getElement( linkedId );

	typedHi( el );
	typedHi( lel );
}

function typedHi( el )
{
	switch( el.nodeName )
	{
		case 'IMG':
			var source	=	el.src;
			var ext		=	source.substring( source.length - 4, source.length );
			var img		=	source.substring( 0, source.length - 5 );
			el.src		=	img + '1' + ext;
			break;
		
		case 'DIV':
		case 'TD':
		case 'TR':
		case 'TABLE':
			if( el.className.indexOf( 'Active' ) < 0 )
				el.className	=	el.className + 'Active';
			break;
	}
}

function typedLo( el )
{
	switch( el.nodeName )
	{
		case 'IMG':
			var source	=	el.src;
			var ext		=	source.substring( source.length - 4, source.length );
			var img		=	source.substring( 0, source.length - 5 );
			el.src		=	img + '0' + ext;
			break;
		
		case 'DIV':
		case 'TD':
		case 'TR':
		case 'TABLE':
			className		=	el.className.substring( 0, el.className.length - 6 );
			el.className	=	'';	// dirty hack to make background transparent again
			el.className	=	className;
			break;
	}
}

function linkedLo( el, linkedId )
{
	var lel	=	getElement( linkedId );

	typedLo( el );
	typedLo( lel );
}

function hidePopup()
{
	hideElement( popupLayer );
}

function playSound()
{
	return true;
}

function getRaceNr( raceName )
{
	for( var i=0; i < races.length; i++ )
		if( races[i] == raceName )
			return i;
}

function upList( nr, trEl )
{
	var imgEl	=	getElement( 'list'+nr );
	imgEl.src	=	"img/activator_list.gif";

	trEl.style.backgroundColor	=	"#1C2829";
}

function dnList( nr, trEl )
{
	var imgEl	=	getElement( 'list'+nr );
	imgEl.src	=	"img/px.gif";

	trEl.style.backgroundColor	=	"#151F1F";
}
function upComm( nr )
{
	if( document.images && document.images['crc'+nr] )
		document.images['crc'+nr].src	=	"img/activator_list.gif";
}

function dnComm( nr )
{
	if( document.images && document.images['crc'+nr] )
		document.images['crc'+nr].src	=	"img/px.gif";
}

function getUrl( uri )
{
	document.location	=	uri;
}

