function setFocus(setFocusLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var layerForFocus = document.getElementById(setFocusLayer);
		// set focus
		layerForFocus.focus();
	} else if (document.all) {
		// this is the way old msie versions work{
		var layerForFocus = document.all[setFocusLayer];
		layerForFocus.focus();
	} else if (document.layers) {
		// this is the way nn4 works
		var layerForFocus = document.layers[setFocusLayer];
		layerForFocus.focus();
	}
}

function reload_opener() {
	self.opener.location.reload(1);
}

function jsProbe() {
	document.form_jsProbe.jsActive.value = "true";
}

function jsCookieProbe() {
	/* check for a cookie */
	if (document.cookie == "") {
		/* if a cookie is not found - alert user -
		change cookieexists field value to false */
		alert("COOKIES need to be enabled!");

		/* If the user has Cookies disabled an alert will let him know 
        that cookies need to be enabled to log on.*/ 

		document.form_jsProbe.cookieexists.value ="false"  
	} else {
	/* this sets the value to true and nothing else will happen,
	** the user will be able to log on*/
		document.form_jsProbe.cookieexists.value ="true"
	}
}

function ConfirmBox(msg,url)
{
	var answer = confirm(msg);
	if (!answer)
	{
		history.back();
	} else {
		alert(url);
		window.location(url);
	}
}

function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function getKeyCode(e) {
	if (e.keyCode) {
		keycode=e.keyCode;
	} else {
		keycode=e.which;
	}
	character=String.fromCharCode(keycode);
	//window.status += character;
	return character;
}

function setFieldFocus(whichLayer) {
	if (document.getElementById) {
		document.getElementById(whichLayer).focus();
	}
}

function insertDateNow() {
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 1000)
	year+=1900
	var day=mydate.getDay()
	var month=mydate.getMonth()+1
	if (month<10)
	month="0"+month
	var daym=mydate.getDate()
	if (daym<10)
	daym="0"+daym
	
	return dateNow = year+"-"+month+"-"+daym
}

function rs(n,u,w,h,addMargin) {
	var remote = null;
	if ((w == null || w == 0) || (h == null || h == 0)) {
		if (w == null || w == 0) {
			w = 800;
		}
		if (h == null || h == 0) {
			h = 800;
		}
	// Add a margin when image dimensions are sent for w and h
	} else {
		if (addMargin) {
			w = w + 160;
			h = h + 250;
		}
	}
	if ( w < 800 ) {
		w = 800;
	}
	if ( h < 600 ) {
		h = 600;
	}
	remote = window.open(u, n, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
	if (remote != null) {
		if (remote.opener == null)
		remote.opener = self;
		window.name = 'main';
		remote.location.href = u;
	}
	remote.focus();
}