function rpopup( url, w, h, name )
{
	width = window.screen.width;
	height = window.screen.height;
	l = (width-w)/2;
	t = (height-h)/2;

	var popup = window.open(url,name,"scroolbars=no, resiseable=no, width="+w+", height="+h+", left="+l+", top="+t);
	if (popup) popup.focus();
}

function popup( url, w, h, name ){
	width = window.screen.width;
	height = window.screen.height;
	
	l = (width-w)/2;
	t = (height-h)/2;
	
	var popup = window.open(url,name,"scroolbars=yes, resiseable=yes, width="+w+", height="+h+", left="+l+", top="+t);
	popup.focus();
}

function openCenteredWindow(url, height, width, name, parms) {
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   return win;
}

//charCounter() parameters are:  text field, count field, max length 
function charCounter(field, countfield, maxlimit) {
	var field = document.getElementById(field);
	var countfield = document.getElementById(countfield);
	if (field.value.length < maxlimit) {
		countfield.style.color = '#666666';
	}
	if (field.value.length == maxlimit) {
		countfield.style.color = 'red';
	}
	if (field.value.length > maxlimit) {
		// if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	} 
	// otherwise, update 'characters left' counter
	else {
		// countfield.innerHTML = maxlimit - field.value.length;
		countfield.innerHTML = field.value.length;
	}
}

function setValue( id, type, val )
{
	var obj = document.getElementById(id);
	if (obj==undefined) return false;
	switch( type )
	{
		case "inputHidden":
			obj.value=val;
			break;
		case "img":
			obj.src=val;
			break;
	}
}
