var w3c = (document.getElementById) ? true : false;
var ns4 = (document.layers && !w3c) ? true : false;
var ie4 = (document.all && !w3c) ? true : false;
var opera = (window.opera) ? true : false;


function UBS_refreshImage( id )
{
	if ( id && document[id] ) // ie bug: refresh image
	{
		var image = document[id].src;
		document[id].src = image;
	}
}

function UBS_openWindow( url, name, width, height, toCenter )
{
	function getCenterPos( type, winSize, scrDefault )
	{
		if (!winSize) return "";
		
		var scrSize = (screen[type]) ? screen[type] : scrDefault;
		var winPos  = (scrSize - winSize)/2;
		
		return (type=="width") ? ",screenX="+winPos+",left="+winPos : ",screenY="+winPos+",top="+winPos;
	}
	
	var pars = "dependent=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
	
	if ( width ) pars += ",width="+width;
	if ( height ) pars += ",height="+height;
	
	if ( toCenter )
	{
		pars += getCenterPos("width",width,800);
		pars += getCenterPos("height",height,600);
	}
	
	var w = window.open(url, name, pars);
	w.focus();
}

// keep UBS_open() for compatibility reasons
function UBS_open( url, pars, name )
{
	var w = window.open( url, name, pars );
	w.focus();
}

function UBS_close()
{
	if ( opener ) opener.focus();
	window.close();
}

function UBS_linkToSelected( formname, fieldname )
{
	var form = document.forms[formname];

	if ( form )
	{
		var obj = form[fieldname];
		var url = obj.options[obj.selectedIndex].value;

		if (url!="")
		{
			document.location.href = url;
		}
	}
}


function UBS_search( formname )
{
	var form = document.forms[formname];
	form.submit();
	return true;
}


function UBS_searchAction( formname, dropname, loname )
{
	var form = document.forms[formname];
	var lg = form[dropname].value;
	
	if (lg == 'a') {
		form[loname].value = 'f';
	} else {
		form[loname].value = 't';
		form.action = '/3/'+lg;	
	}
	return false;
}


var UBS_oldImage = "";

function UBS_imageOn( imageId, newImage )
{
	if ( !document.images ) return;
	UBS_oldImage = document.images[ imageId ].src;
	document.images[ imageId ].src = newImage;
}

function UBS_imageOff( imageId )
{
	if ( document.images && UBS_oldImage )
	{
		document.images[ imageId ].src = UBS_oldImage;
		UBS_oldImage = "";
	}
}

function redirectToPage(selection) {
   var index = selection.selectedIndex
   var value = selection.options[index].value;
   if (value != "") {
      location.href = value;
   }
}

function UBS_redirectPage(url) {
   window.location.replace(url); 
}




