//---------- required field colors
function setRequiredColors(fieldName) {
	var fieldText = fieldName + "Label";
	if (document.getElementById(fieldName).value == "") {
		document.getElementById(fieldText).style.color="red";
	} else {
		document.getElementById(fieldText).style.color="black";
	}
}

//---------- format currency
function formatCurrency(amount){
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

//---------- valid email
function validEmail(email) {
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) {
		return true;
	} else {
		return false;
	}
}

function newWin(URL, w, h, scroll) {
    if (scroll == '') {
        scroll = 0;
    }
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scroll+',location=0,statusbar=0,menubar=0,resizable=1,width=" + w + ",height=" + h + ",left = 0,top = 0');");
}

function newPositionedWindow(URL, w, h, scroll, left, top) {
    if (scroll == '') {
        scroll = 0;
    }
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars='+scroll+',location=0,statusbar=0,menubar=0,resizeable=1,width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + "');");
}
	
