/*
width			 la larghezza della finestra in pixel
height			 l'altezza della finestra in pixel
left			 la distanza dalla sinistra del monitor
top			 la distanza dal lato superiore del monitor
resizable		 indica se la finestra può essere ridimensionata o no
fullscreen		 indica se la finestra va aperta a tutto schermo
channelmode		 indica se la finestra deve essere aperta "in modalità canale" (solo per ie)
menubar			 la barra del menu (quella con scritto "file", "modifica", ecc.)
toolbar			 la barra degli strumenti del browser (con i pulsanti "indietro", "avanti")
location		 la barra degli indirizzi del browser
scrollbars		 le barre di scorrimento laterali
status			 la barra di stato (quella in basso)
*/
function apri(url) {
	popup = window.open(url, '','scrollbars=yes,resizable=no, width=1200,height=700,status=no,location=no,toolbar=no, left=50, top=50');
}

function CheckCheckBox(frm)
{
	if (!frm.CheckThis.checked)
		frm.CheckThis.focus();
}

function msgbox(varString)
{
	alert('MSG BOX :'+varString);
}

function conferma(){
	return confirm('Vuoi salvare?');
}

function pdf(url) 
{
	w = window.open(url,'','fullscreen=0,scrollbars=1,menubar=1');
	w.window.moveTo(0,0);
	w.window.resizeTo(screen.availWidth,screen.availHeight);
}

function stampa(url) 
{
	w = window.open(url,'','fullscreen=0,scrollbars=1,menubar=1');
	w.window.moveTo(0,0);
	w.window.resizeTo(screen.availWidth,screen.availHeight);
}

function espandi_sottomenu(elem_ID)
{
	var vocemenu = document.getElementById(elem_ID);
	/*if (vocemenu.className == 'LOL')
		elem_ID.className = "due";
	else
		alert(elem_ID.parentNode.parentNode.parentNode.parentNode.tagName);*/
	var sottomenu = document.getElementById('tabella_gruppi_' + elem_ID);
	if (!document.getElementById) return;
	var ob = sottomenu.style;
	ob.display = (ob.display == 'block')?'none': 'block';
}

function chiudi_sottomenu()
{
	/*
	TODO futuro sviluppo
	Ancora in fase di sviluppo...qusta funzione si pefigge l'obiettivo di chidere tutti
	gli elementi del menu prima di aprire quello selezionato nel GET con id nella URL...
	*/
	var tabella = document.getElementById('tabella_menu');
	alert(tabella.id);
	var tr_cat = tabella.firstChild;
	alert(tr_cat.id);
	var td_grp = document.getElementById('container_gruppi');
	alert(td_grp.id);
	var tabella_grp = td_grp.firstChild;
	alert(tabella_grp.id);
	for (i = 0; i < tabella_grp.length; i++)
		tabella_grp[i].display = 'none';
	/*var stringa = 'test_ciao1 test_prova';
	var pattern = / (test_)[a-zA-Z0-9]* /;
	result = stringa.match(pattern);
	alert (result.toString());*/
	/*if(is_array(result))
		alert('yes');
	alert(echo(result));
	alert(print_r(result));*/
	alert('ciao');
	/*for  (i = 0; i < result.length; i++) {
		alert(i + ' ' + result[i]);
	}*/
	/*
	var tohide ;
	for (i = 0; i < tohide.lenght; i++)
		tohide[i].display = 'none';
	*/
}

var hexDigits = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');

//Function to convert hex format to a rgb color
function rgb2hex(rgb) {
	rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
	return '#' + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}

function hex(x) {
	return isNaN(x) ? '00' : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
}
