var NU_link_divs = new Array();
var NU_link_html = new Array();
var NU_link_targ = new Array();
var NU_link_link = new Array();
var NU_curr_pictdiv;
var NU_void_div  = ' ';
var NU_active_div= -1;

var NU_onload_fun	= NU_NULL;
var NU_onunload_fun	= NU_NULL;
var NU_RealWinOpen	= window.open;

window.open = NU_InitWinOpen();

// ===============================================================================

var nu_dom = 1;
if (!(document.getElementById)) {
	if			(document.all)		nu_dom=2;
	else if	(document.layers)	nu_dom=3;
	else							nu_dom=0;
	}

// ===============================================================================

function NU_body_onload() {
	if (NU_onload_fun != NU_NULL) rc=eval(NU_onload_fun);
	else rc=true;
	return rc;
}

function NU_onload_fake() {
	window.alert("Onload function");
}

function NU_body_onunload() {
	if (NU_onunload_fun != NU_NULL) rc=eval(NU_onunload_fun);
	else rc=true;
	window.open=NU_RealWinOpen;
	return rc;
}

function NU_onunload_fake() {
	window.alert("Onunload function");
}

// ===============================================================================

function NU_InitWinOpen() {
	rc=window.open;
	try {if (SymRealWinOpen) NU_RealWinOpen=SymRealWinOpen;}
	catch(err) {
		NU_RealWinOpen=window.open;
		rc = NU_FakeWinOpen();
		}
	return rc;
}

function NU_FakeWinOpen(url, name, attributes)
{
  return (new Object());
}


// ===============================================================================

function NU_show_pictdiv(pict_htm,pict_div) {
	
	pict_div.innerHTML='<table border=0 cellpadding=2 cellspacing=0 class="small bg-silver">'+
						'<tr><td valign="top" align="right" >'+
						'<a href="javascript:NU_close_pictdiv();" '+
						'class="btnclose">&nbsp;</a></td></tr><tr><td valign="top" align="center" >'+
						pict_htm+
						'</td></tr></table>';
	NU_open_blockdiv(pict_div);
}

function NU_close_pictdiv() {
	NU_close_blockdiv(NU_curr_pictdiv);
}

// ===============================================================================

function NU_open_blockdiv(mydiv) {
	mydiv.style.display="block";
	NU_curr_pictdiv=mydiv;
}

function NU_close_blockdiv(mydiv) {
	mydiv.style.display="none";
}

// ===============================================================================

function NU_getelement(id) {

	if (NU_getelement.arguments.length > 1)	var mode=NU_getelement.arguments[1];
	else									var mode="Id";

	switch(nu_dom) {

		case 1:
			if		(mode === "Id")		return document.getElementById(id);
			else if	(mode === "Name")	return document.getElementsByName(id);
			else						return false;
			break;
		case 2:
			if		(mode === "Id")		return document.all[id];
			else if	(mode === "Name")	return document.all[id];
			else						return false;
			break;
		case 3:
			if		(mode === "Id")		return document.layers[id];
			else if	(mode === "Name")	return document.layers[id];
			else						return false;
			break;
		default :
										return false;
		}
}

// ===============================================================================

function NU_ext_link_prep(grp,item) {
	w=NU_RealWinOpen(NU_link_link[grp][item],NU_link_targ[grp]);
	w.focus();
}


function NU_ext_link(url,wname) {
	w=NU_RealWinOpen(url,wname);
	w.focus();
}

// ===============================================================================

function NU_switch_style(iddiv,divset,divhtml,divdef) {
	for (id=0; id<divset.length; id++) {
		divid=NU_getelement(divset[id]);
		if (id == iddiv) {
			if (id == NU_active_div) {
				divid.innerHTML=divdef;
				NU_active_div = -1;
				}
			else {
				divid.innerHTML=divhtml;
				NU_active_div = id;
				}
			}
		else divid.innerHTML=divdef;
		}
}

// --------------------------------------------------------------------

function NU_preload(img) {
	var a=new Image();
	a.src=img;
	return a;
}

// --------------------------------------------------------------------

function NU_maxim_window() {
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
}

// --------------------------------------------------------------------

function NU_ucfirst(text) {
	var lett1=text.substr(0,1);
	return lett1.toUpperCase()+text.substr(1);
}

// --------------------------------------------------------------------

function NU_trim(text) {
	if (NU_trim.arguments.length > 1)	var blank=NU_trim.arguments[1];
	else								var blank=" ";
	var len=text.length-1;
	for (var lastc=len; lastc>0; lastc--) {
		if (text.substr(lastc,1) != blank) break;	
		}
	for (var firstc=0; firstc<=lastc; firstc++) {
		if (text.substr(firstc,1) != blank) break;	
		}
	return text.substring(firstc,lastc+1);
}

