function do_menu_select( a_elem )
{
	/*  Deselect all previously selected links  */
	var links_array = a_elem.parentNode.getElementsByTagName('a'), i=0;
	for( i=0; i < links_array.length; i++ )
	{
		if( links_array[i].className == 'normal' || links_array[i].className == 'normalunderline')
			links_array[i].className = 'normal';
	}
	a_elem.className = 'normalunderline';
}



function reverse( string )
{
	var newStr = '';
	var i;
	for(i=0; i < string.length; i++)
		newStr = string.charAt(i) + newStr;
	return newStr;
}

function right(string, ammount)
{
	var newStr = '';
	var i = 0;
	var startIndex = 0;
	if( string.length - ammount >= 0)
		startIndex = string.length - ammount;

	for(i = startIndex; i < string.length; i++ )
		newStr = newStr + string.charAt(i);

	return newStr;
}

function formatNumber( number )
{
	var fraction = 0;
	var whole;
	if( isNaN(number) )
		return 0;
	else
		if( (number+"").indexOf(".") != -1) {
			whole = parseInt(number);
			fraction = Math.round((parseFloat(number) - parseInt(number) ) * 100);

			if( fraction.toString().length == 3)
				whole = whole + 1;

			fraction = right(fraction.toString(), 2);
			if( fraction.toString().length == 1)
				fraction = "0" + fraction;

			whole = reverse( reverse(whole.toString()).replace(/(\d{3,3})/gi, "$1 ") );
			return "" + whole + "," + fraction + " &euro;";
		}
		else {
			whole = reverse( reverse(number.toString()).replace(/(\d{3,3})/gi, "$1 ") );
			return "" + whole + ",00 &euro;";
		}
}


/*HACK While weinhof.cc is hosted at another site there is an extra frame from that hosting company.
Take that into account.*/
function getTopFrame( windowElem )
{
	if( windowElem.top.topFrame )
		return windowElem.top.topFrame;
	else
		if( windowElem.top.frames['www.ifo.net'].topFrame )
			return windowElem.top.frames['www.ifo.net'].topFrame;
		else
			return null;
}

function getMainFrame( windowElem )
{
	if( windowElem.top.mainFrame )
		return windowElem.top.mainFrame;
	else
		if( windowElem.top.frames['www.ifo.net'].mainFrame )
			return windowElem.top.frames['www.ifo.net'].mainFrame;
		else
			return null;
}

