function openNew(url, name, parms) {
	window.open(url, name, parms);
}

function checkdata(listagiorno,listamese,listaanno) {

	var errors='';
	var Giorno;
	var Mese;
	var Anno;
	var MeseStr;

	MeseStr=listamese.options[listamese.selectedIndex].text;
	Mese=listamese.options[listamese.selectedIndex].value;
	Giorno=listagiorno.options[listagiorno.selectedIndex].value;
	if ((Mese==4 | Mese==6 | Mese==9 | Mese==11) & Giorno==31) {
		errors += '- Attenzione. ' + MeseStr + ' non ha 31 giorni.\n';
		listagiorno.selectedIndex=listagiorno.selectedIndex-1;
	}
	//controllo febbraio se deve avere 28 o 29
	Anno=listaanno.options[listaanno.selectedIndex].value;
	if ((Anno % 4)==0) {
		if ((Mese==2) && ((Giorno==30) || (Giorno==31))) {
			errors += '- Attenzione. ' + MeseStr + ' non ha ' + Giorno + ' giorni.\n';
			listagiorno.selectedIndex=28
		}
	}
	else {
		if ((Mese==2) && ((Giorno==30) || (Giorno==31) || (Giorno==29))) {
			errors += '- Attenzione. ' + MeseStr + ' non ha ' + Giorno + ' giorni.\n';
			listagiorno.selectedIndex=27
		}
	}

	return(errors);

}

function compareData(	DaGiornoL,DaMeseL,DaAnnoL,DaOreL,DaMinutiL,
						AGiornoL,AMeseL,AAnnoL,AOreL,AMinutiL) {

	DaGiorno=DaGiornoL.options[DaGiornoL.selectedIndex].value;
	DaMese	=DaMeseL.options[DaMeseL.selectedIndex].value;
	DaAnno	=DaAnnoL.options[DaAnnoL.selectedIndex].value;
	if (DaOreL && DaOreL.options[DaOreL.selectedIndex].value!='') DaOre=DaOreL.options[DaOreL.selectedIndex].value;
	else DaOre = '00';
	if (DaMinutiL && DaMinutiL.options[DaMinutiL.selectedIndex].value!='') DaMinuti=DaMinutiL.options[DaMinutiL.selectedIndex].value;
	else DaMinuti = '00';

	AGiorno	=AGiornoL.options[AGiornoL.selectedIndex].value;
	AMese	=AMeseL.options[AMeseL.selectedIndex].value;
	AAnno	=AAnnoL.options[AAnnoL.selectedIndex].value;
	if (AOreL && AOreL.options[AOreL.selectedIndex].value!='') AOre=AOreL.options[AOreL.selectedIndex].value;
	else AOre = '00';
	if (AMinutiL && AMinutiL.options[AMinutiL.selectedIndex].value!='') AMinuti=AMinutiL.options[AMinutiL.selectedIndex].value;
	else AMinuti = '00';

	DaMese=DaMese.toString();
	for (i=DaMese.length;i<2;i++) DaMese="0"+DaMese;

	DaGiorno=DaGiorno.toString();
	for (i=DaGiorno.length;i<2;i++) DaGiorno="0"+DaGiorno;

	DaOre=DaOre.toString();
	for (i=DaOre.length;i<2;i++) DaOre="0"+DaOre;

	DaMinuti=DaMinuti.toString();
	for (i=DaMinuti.length;i<2;i++) DaMinuti="0"+DaMinuti;

	AMese=AMese.toString();
	for (i=AMese.length;i<2;i++) AMese="0"+AMese;

	AGiorno=AGiorno.toString();
	for (i=AGiorno.length;i<2;i++) AGiorno="0"+AGiorno;

	AOre=AOre.toString();
	for (i=AOre.length;i<2;i++) AOre="0"+AOre;

	AMinuti=AMinuti.toString();
	for (i=AMinuti.length;i<2;i++) AMinuti="0"+AMinuti;

	var dalData = DaAnno + DaMese + DaGiorno + DaOre + DaMinuti;
	var alData = AAnno + AMese + AGiorno + AOre + AMinuti;

	if (dalData > alData) return(false);

	return(true);

}

function ValidateFormArchivio(ModuloForm) {
	var errors='';

	if (ModuloForm.Intervallo[0].checked) {

		errors+=checkdata(ModuloForm.DaGiorno,ModuloForm.DaMese,ModuloForm.DaAnno);

		errors+=checkdata(ModuloForm.AGiorno,ModuloForm.AMese,ModuloForm.AAnno);

		if (!compareData(
			ModuloForm.DaGiorno,ModuloForm.DaMese,ModuloForm.DaAnno,ModuloForm.DaOre,ModuloForm.DaMinuti,
			ModuloForm.AGiorno,ModuloForm.AMese,ModuloForm.AAnno,ModuloForm.AOre,ModuloForm.AMinuti
		)) errors+='- Controllare le date selezionate: la data contenuta in "Al" deve essere maggiore di quella contenuta in "Dal".\n';

	}

	if (ModuloForm['Page']) ModuloForm['Page'].selectedIndex = 0;

	if (errors) alert('Impossibile effettuare la ricerca:\n'+errors);
	document.ReturnValue = (errors == '')
}

function change_check_state(check_index) {
	var the_form = document.archivio_form;
	if (the_form['categoria_' + check_index].checked) {
		if (!$('label_' + check_index).hasClassName('selected')) {
			$('label_' + check_index).addClassName('selected');
		}
	}
	else {
		if ($('label_' + check_index).hasClassName('selected')) {
			$('label_' + check_index).removeClassName('selected');
		}
	}
}

function openShadowbox(content, player, title)
{
	Shadowbox.open({
		content:    content,
		player:     player,
		title:      title
	});
}

function openShadowboxImage(obj)
{
	Shadowbox.open({
		content:    obj.href,
		player:     'img',
		title:      obj.title
	});
	return false;
}

