function OpenWin(url, width, height) {
	// Apertura di pop up
	window.open(url, "popup", 'toolbar = 0, location = 0, directories = 0, status = 0, menubar = 0, scrollbars = 0, resizable = 0, width = ' + width + ', height = ' + height);
}

function Conferma() {
	// Richiede la conferma per compiere un'azione
	var richiesta = window.confirm("Una volta eliminati i record non saranno pi\u00F9 recuperabili");
	return richiesta;
}

function AllCheck(questo, id, pulsante) {
	// Seleziona e deseleziona tutte le checkbox
	var chkbox = document.getElementsByTagName('input');
	
	for(i = 0; i < chkbox.length; i++) {
		if (chkbox.item(i).getAttribute('id') == id) {
			if (questo.checked == false) {
				chkbox.item(i).checked = false; 
				chkbox.item(i).value   = "ceccato";
				pulsante.disabled       = true;
			}
			else  {
				chkbox.item(i).checked = true;
				chkbox.item(i).value   = "non ceccato";
				pulsante.disabled       = false;
			}
		}
	}
}

function Trova_e_imposta(tag, prop, nome, mess) {
	// trova la proprietà in un tag di un dato nome e ne imposta il valore
	var tagname = document.getElementsByTagName(tag);
 	for(i = 0; i < tagname.length; i++) {
		if (tagname.item(i).getAttribute('id') == nome) {
			switch (prop)
			{
				case 'rel':
					tagname.item(i).rel = mess
				break;
				default: break;
			}
		}
 	}
}

function Checked(id, pulsante) {
	// Identifica quale checkbox è stata selezionata
	var chkhdn = document.getElementsByTagName('input');
	var j 	= 0;
		
	for(i = 0; i < chkhdn.length; i++) {
		if (chkhdn.item(i).getAttribute('id') == id) {
			if (chkhdn.item(i).checked == true) {
				j++;
				chkhdn.item(i).value = true; 
				pulsante.disabled     = false;
			}
			else {
				chkhdn.item(i).value = false;
				pulsante.disabled     = true;
			}
		}
	}
	
	if (j > 0) {
		pulsante.disabled = false;
	}
	else {
		pulsante.disabled = true;	
	}
}
