/*
general site functions
20061110
v0.8
*/

function openWindow(mypage, width, height)
{
	var myname = 'universal';
	if(width == '') var width = 650;
	if(height == '') var height = 500;
	var scroll = 'yes';
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if(!win)
		{
		// popup blocker
		alert("Inhalte wurden von Ihrem Popup-Blocker blockiert.");
		}
		else
		{
		// focus
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}
}

function reloadnav(adr)
	{
	return;
	calling_url = adr.split("?");
	if(calling_url[1])
		{ url_params = '?' + calling_url[1]; } else { url_params = ''; }
	parent.frames['mkl_nav'].document.location.href = 'nav.php' + url_params;
	}

function detailview(id)
	{
	popup=window.open('details.php?navid='+id,'pop_mkl','width=560,height=350,toolbar=0,location=0,directories=0,status=0,scrollbars=1,menubar=0,resizable=1');
	if(!popup) alert("Bitte deaktivieren Sie Ihren Popup-Blocker um diese Seite zu betrachten.");
	}
	
// global functions
function getval(name)
	{
	  if (document.getElementById(name)) return document.getElementById(name).firstChild.nodeValue;
	  return false;
	}

// get value from id and return as number	
function getnumval(name)
	{
	  if (document.getElementById(name)) {
	  	x = document.getElementById(name).firstChild.nodeValue;
		x = x.replace(',','.');
		x = parseFloat(x);
		return x;
	  	}
	  return false;
	}

function setnumval(name, n)
	{
	  if (document.getElementById(name)) {
	  	document.getElementById(name).firstChild.nodeValue = formatnum(n, 2);
		}
	}
	
function setnumvalextra(name, n)
	{
	  if (document.getElementById(name)) {
	  	document.getElementById(name).firstChild.nodeValue = formatnum(n, 3);
		}
	}

function setchanged(name)
	{
	  if (document.getElementById(name)) {
	  	document.getElementById(name).style.color = '#990000';
		}
	}

function setunchanged(name)
	{
	  if (document.getElementById(name)) {
	  	document.getElementById(name).style.color = '';
		}
	}

// format number with 2.00	
function formatnum(n, dec)
	{
	if(n.toFixed) n = n.toFixed(dec);
	n = n+'';
	n = n.replace('.',',');
	return n;
	}	

function cleannum(n)
	{
	if(n.toFixed) n = n.toFixed(1);
	return n;
	}	

	
function hide(name) {
  if (document.getElementById(name)) document.getElementById(name).style.display = "none"; 
}

function show(name) {
  if (document.getElementById(name)) document.getElementById(name).style.display = "block"; 
}
