function setTextDefault(aelem, adef) {
	var atxt1 = trim(aelem.value);
	var atxt2 = trim(adef);
	if (!isNotEmpty(aelem) || (atxt1.toUpperCase() == atxt2.toUpperCase())) { aelem.value = adef; aelem.style.color = '#666666'} else aelem.style.color = 'black';
}

function clearTextDefault(aelem, adef) {
	aelem.style.color = 'black';
	if (trim(aelem.value) == adef) aelem.value = '';
}

function copyValue (asrcelem, adestelem) {
	adestelem.value = asrcelem.value
}

function procDefault (aelem_mrr, adef, aelem, adef2, event) {
	//try {
	if (event.type == 'focus') {
		clearTextDefault(aelem_mrr, adef);
	} else if (event.type == 'blur') {
		setTextDefault(aelem_mrr, adef); // set default if text is blank
		if (aelem) {
			if (aelem_mrr.value == adef)
				aelem.value = adef2;
			else 
				aelem.value = aelem_mrr.value;
		}
	} else if (event.type == 'load') {
		setTextDefault(aelem_mrr, adef);
		setTextDefault(aelem, adef2);
	}
	//} catch (e) { alert (e.description); }
}

function isNotEmpty(aelem) {
	if (!aelem) { return true; }
    	var astr = trim(aelem.value);
    	if(astr == null || astr.length == 0) {
		return false;
	} else {
		return true;
	}
}

function trim(astr){
	try {
		while(astr.charAt(0) == " "){
			astr = astr.substring(1);
		}
		
		while(astr.charAt(0) == " "){
			astr = astr.substring(0, astr.length - 1);
		}
		return astr;
		
	}catch(e){
		alert(e.description);
	}
}

function resetDefault(aelem_mrr, adef, aelem, adef2) {
	//try {
	setTextDefault(aelem_mrr, adef);
	setTextDefault(aelem, adef2);
	//} catch (e) { alert (e.description); }
}
