
var decimalSep = ',';
var thousandSep = '.';

function openWindow(url, w, h, win, x, y) {
	var win_name = win ? win : 'popup';
	if (! x) x = 0;
	if (! y) y = 0;
	if (! w) w = 647;
	if (! h) h = 600;
	var new_win = window.open(url, win_name, 'left='+x+',top='+y+',width='+w+',height='+h+',menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,status=yes');
	new_win.focus();
}

function Trim(s) {
	var tmp = new String(s);
	while (tmp.substr(0, 1) == ' ') tmp = tmp.substr(1);
	while (tmp.substr(tmp.length-1) == ' ') tmp = tmp.substr(0, tmp.length-1);
	return tmp;
}

function CheckEmailAddress(a){
	a = Trim(a);
	var re = /^[A-Za-z0-9_\-\.]+@[A-Za-z0-9\-\.]+\.[A-Za-z]+$/;
	if (re.exec(a)) return true;
	else return false;
}

function checkDigit(e) {
	var keynum;
	var keychar;
	var numcheck;
	if (window.event) { // IE
		keynum = e.keyCode;
	} else if (e.which) { // Netscape/Firefox/Opera
		keynum = e.which;
	}
	if (keynum > 31) {
		keychar = String.fromCharCode(keynum);
		numcheck = /\d/;
		return numcheck.test(keychar);
	} else {
		return true;
	}
}

function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? decimalSep + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + thousandSep + '$2');
	}
	return x1 + x2;
}

function addCommas_formatFloat(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? decimalSep + x[1] : decimalSep + '00';
	while (x2.length < 3) { x2 += '0'; }
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + thousandSep + '$2');
	}
	return x1 + x2;
}

function remCommas(nStr) {
	nStr += '';
	x = nStr.split(decimalSep);
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = new RegExp("\\"+thousandSep, "g");
	x1 = x1.replace(rgx, '');
	return x1 + x2;
}

function add_favorite() {
  if (document.all) {
    window.external.AddFavorite(location.href, document.title);
  } else if (window.sidebar) {
    window.sidebar.addPanel(document.title, location.href, "");
  }
}

function selectChanged(sb) {
	if (sb.options[sb.selectedIndex].value != '') {
		document.location = sb.options[sb.selectedIndex].value;
	}
}

function getSelectedValue(sb) {
	if (sb.options[sb.selectedIndex].value != '') {
		return sb.options[sb.selectedIndex].value;
	}
}

function resetForm(f) {
	for (var e = 0; e < document.forms[f].length; e++) {
		if (document.forms[f].elements[e].type == 'checkbox' || document.forms[f].elements[e].type == 'radio') {
			document.forms[f].elements[e].checked = false;
		}
		else if (document.forms[f].elements[e].type == 'text' || document.forms[f].elements[e].type == 'textarea') {
			document.forms[f].elements[e].value = '';
		}
		else if (document.forms[f].elements[e].type == 'select-one') {
			document.forms[f].elements[e].selectedIndex = 0;
		}
//		else alert(document.forms[f].elements[e].type);
	}
}

  function nospam() {
    var a = document.getElementsByTagName("a");
    for (var i = a.length-1; i >= 0; i--) {
      if (a[i].className.search(/\bemail\b/) != -1) {
        var email = a[i].firstChild.data + "@" + a[i].lastChild.data;
        a[i].innerHTML = email;
        a[i].href = "mailto:" + email;
      }
    }
  }
window.onload=nospam;