
function btnMakeHilite(o)

{

	var n=o.src.slice(0,-4)+'_hi.gif';

	o.orig=o.src;

	o.hi=n;

	o.onmouseover=function(){o.src=o.hi;};

	o.onmouseout=function(){o.src=o.orig;};

	o.onmousedown=function(){o.src=o.orig;};

	o.onmouseup=function(){o.src=o.hi;};

	o.onload=null;



	(new Image()).src=n; // preload

}





function fixedSubmit(form)
{

	if (form.onsubmit==null || form.onsubmit()) form.submit();

}



function setPointer(theRow, thePointerColor) {

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {

        return false;

    }

    if (typeof(document.getElementsByTagName) != 'undefined') {

        var theCells = theRow.getElementsByTagName('td');

    } else if (typeof(theRow.cells) != 'undefined') {

        var theCells = theRow.cells;

    } else {

        return false;

    }

    var rowCellsCnt=theCells.length;

    for (var c=0;c<rowCellsCnt;c++) {

        theCells[c].style.backgroundColor = thePointerColor;

    }

    return true;

}



function setPointer(theRow, thePointerColor) {

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {

        return false;

    }

    if (typeof(document.getElementsByTagName) != 'undefined') {

        var theCells = theRow.getElementsByTagName('td');

    } else if (typeof(theRow.cells) != 'undefined') {

        var theCells = theRow.cells;

    } else {

        return false;

    }

    var rowCellsCnt=theCells.length;

    for (var c=0;c<rowCellsCnt;c++) {

        theCells[c].style.backgroundColor = thePointerColor;

    }

    return true;

}


function isodate_to_eur(s) {
	return lpad(s, 2, '0');
}

function paddate(s) {
	return lpad(s, 2, '0');
}

function lpad(st, siz, padchar) {
	st = st.toString();
	t = siz - st.length;
	if (t>0) {st = repeatchar(t, padchar) + st;}
	return st;
}

function repeatchar(len, padchar) {
	s = padchar;
	for (i=1; i<len; i++) {s = s + padchar;}
	return s;
}






function setElemValue(id, value) {
	var e = document.getElementById(id);
	if (e==null) alert('setElemValue(): Error getting element id ' + id);
	e.value = value;
}


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 euro_money(v)
{
	if (v==0) return '';
	return '&euro; ' + addCommas(v);
}

function getElemProp(id, prop) {
	e = document.getElementById(id);
	return e[prop];
}



// common

function createAsyncObject()
{
	try {
		x = new XMLHttpRequest();
	} catch(e) {
		try {
			x = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e2) {
			alert('Unsupported Browser');
		}
	}
	return x;
}

function async_get(url, callback)
{
	var x = new createAsyncObject();
	x.open("GET", url, true);
	x.onreadystatechange = function()
	{
		if(x.readyState == 4) {
			callback(x.responseText);
		}
	}
	x.send(null);
}

function sync_get(url)
{
	var x = new createAsyncObject();
	x.open("GET", url, false);
	x.send(null);
	if (x.status==200) {
	    return x.responseText;
	}
	else {
	    alert('Sorry. There was an error retrieving data. Please retry.');
	}
}

function getElemValue(id) {
	return document.getElementById(id).value;
}

function setElemValue(id, value) {
	var e = document.getElementById(id);
	if (e==null) alert('setElemValue(): Error getting element id ' + id);
	if (value==null || value==undefined) value = '';
	e.value = value;
}

function setElemProp(id, prop, value) {
	e = document.getElementById(id);
	e[prop] = value;
}

function focusElem(id) {
	document.getElementById(id).focus();
}

function hideElem(id) {
	document.getElementById(id).style.display = 'none';
}
function showElem(id) {
	document.getElementById(id).style.display = 'inline';
}

function isNotBlank(v)
{
	return (v!='' && v!=null && v!=undefined);
}