// Suport pentru toolbar cu diacritice
// (c) 2003 Ionut Nechita, Alpinet.org
//

var g_oDiacritice = null;

function dia_show(el) { // attach this to onFocus
	
	try {

		if((g_oDiacritice != null) && (el != g_oDiacritice.forElement)) {		
			g_oDiacritice.parentElement.removeChild(g_oDiacritice.div);
			g_oDiacritice = null;
		}
		if(g_oDiacritice == null) {
			g_oDiacritice = new diaToolbar(el);	
		}
	} catch(e) {
		window.alert("Exception occurred: " + e.toString());
	}
}

function dia_hide(el) { // attach this to onBlur
	
}
// ---- user form helpers

function diaToolbar_onclick(ev) {
	
	var el;
	if (!ev) var ev = window.event;
	if (ev.target) el = ev.target;
	else if (ev.srcElement) el = ev.srcElement;

	var theButton = el;
	var theValue = theButton.value.substr(1, 1);
		
	g_oDiacritice.forElement.value += theValue;
		
	g_oDiacritice.forElement.focus();
	return true;
}

function diaToolbar(oElement) {
	
	this.div = window.document.createElement("SPAN");
	this.div.className = "toolbar";	
	
	this.parentElement = oElement.parentNode;
	this.forElement = oElement;
	this.div.appendChild(window.document.createElement("BR"));
	var diachars = new Array('ã', 'Ã', 'â', 'Â', 'î', 'Î', 'º', 'ª', 'þ', 'Þ');
	for(i = 0; i<diachars.length; i++) {
		var theInput = window.document.createElement("INPUT");
		theInput.type = "button";
		theInput.id = diachars[i];
		theInput.value = " " + diachars[i] + " ";
		theInput.onclick = diaToolbar_onclick;
		this.div.appendChild(theInput);
	}
	oElement.parentNode.appendChild(this.div);
	
	return this;
}
