if( window.name == "" )
{
	window.name = "industripension";
}

var printBrowserId = 7;
var printBrowserUrl = "print";

function openLogin(url)
{
	window.open('?url='+(url ? escape(url) : ''), 'Login', 'width=300,height=300,location=no,resizable=yes,menubar=no,statusbar=no');
}

function createPopup(url, width, height)
{
	var w = window.open(url, 'popup', 'width='+width+',height='+height+',location=no,menubar=no,status=no,resizable=yes,scrollbars=no');
}
function createPopupScrollable(url, width, height)
{
	var w = window.open(url, 'popup', 'width='+width+',height='+height+',location=no,menubar=no,status=no,resizable=yes,scrollbars=yes');
}

function openPrintWindow(url)
{
	var w = window.open((url ? url : 'about:blank'), 'print', 'width=600,height=550,resizable=yes,menubar=no,status=yes,location=no,scrollbars=yes');
	return w;
}
function printPage()
{
	var p = openPrintWindow(document.location.href+(document.location.href.indexOf('?') == -1 ? '?' : '&')+'browser='+printBrowserId);
	return false;
}
function printFormPage(form)
{
	var p = openPrintWindow();
	
	p.document.open();
	p.document.write('<link rel="stylesheet" type="text/css" href="base.css" />');
	p.document.write('<link rel="stylesheet" type="text/css" href="ip_colors_print.css" />');
	p.document.write('<link rel="stylesheet" type="text/css" href="bf_layout_print.css" />');
	p.document.write('<link rel="stylesheet" type="text/css" href="bf_text_regular.css" title="small" />');
	p.document.write('<body style="cursor: wait;"><div style="text-align:center" class=".text"><br/><br/><br/><strong>Loading...</strong></div></body>');
	p.document.close();
	
	var action = form.action;

	form.target='print';
	form.action='/'+printBrowserUrl+'/'+action;
	form.submit();
	
	form.target = '_self';
	form.action = action;
	
	return false;
}

function resizeToFit(width)
{
	width = width || 322;
	ns4 = (document.layers)? true:false;
	ie4 = (document.all)? true:false;
	winH = (ns4)? document.height+20 : document.body.scrollHeight+32;
	winW = (ns4)? width : width+12;
	if(winH>screen.height-50) {
		winH = screen.height-50;
	}
	parent.window.resizeTo(winW, winH);
}

function formatFloat(value, decimals, decimal_char)
{
	decimal_char = decimal_char || '.';
	
	var f = Math.pow(10, decimals);
	var r = Math.round(value * f) / f;

	var integer = Math.floor(r) + '';
	var deci = Math.round((r - Math.floor(r)) * f);
	deci = (deci < 10 ? '0'+deci : deci + '')

	for(var i = 0; i < decimals-deci.length; i++)
	{
		deci += '0';
	}
	return integer + decimal_char + deci;
}

// initialize form by setting the cursor in the first available form element
function focusFirstForm()
{
	notset=true;
	for(j=0; j<document.forms.length; j++){
		if(notset)
			for(i=0; i<document.forms[j].elements.length; i++){
				typ=document.forms[j].elements[i].type;
				if(notset&&(typ=='password'||typ=='text'||typ=='textarea')) {
					document.forms[j].elements[i].focus();
					document.forms[j].elements[i].select();
					notset=false;
				}
			}
	}
}

function setTableRowVisibility(id, visible)
{
	var tr = document.getElementById(id);
	if(tr)
	{
		tr.className = (visible ? '': 'hidden');
	}
}

