/**
 * @version $Id: global.js,v1.0 - 10-lug-2005 9.53.35 $
 * @author Massimino
 * @package package_name
 * @subpackage admin
 * 
 */

var d = document;

// gestisce i pulsanti per le maschere di inserimento  
function submitbutton(task)
{
	document.forms['adminform'].task.value = task;

	try { document.forms['adminform'].onsubmit(); }
	catch(e){}

	document.forms['adminform'].submit();
}

// invia modifica/cancellazione di un elemento dalla maschera "view"
function submititem(task, id)
{
	document.forms['adminform'].id.value = id;
	submitbutton(task);
}

// pulsante ordinamento
function submitorder(order_by, order_how)
{
	document.forms["adminform"].elements["search[page]"].value = "0"; // resetta la paginazione
	document.forms["adminform"].elements["search[order_by]"].value = order_by;
	document.forms["adminform"].elements["search[order_how]"].value = order_how;
	submitbutton("view");
}


function updateCounter(field)
{
	// ottieni i caratteri inseriti
	value = document.getElementById(field).value;

	valuelength = document.getElementById(field).value.length;
	maxlength = document.getElementById(field).maxLength;

	// aggiorna i conteggio caratteri
	document.getElementById(field+"_char").innerHTML = maxlength-valuelength;

	// aggiorna il testo dell'anteprima	
	document.getElementById(field+"_preview").innerHTML = value;
}
