var fname=""
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function wstatus(txt){
	window.status=txt
		//else {window.status=''};
}

function prima(obj,statustext,clr,ctext){
	obj.style.backgroundColor=clr;
	window.status=statustext
}

function seconda(obj){
	obj.style.backgroundColor='transparent';
	window.status=''
}
function terza(obj,statustext){
	obj.style.backgroundColor='transparent';
	window.status=statustext
}
function quarta(){
	window.status=''
}

function pgen(pg, ind){
	fpage='global.html?' + pg + '.html&' + ind;
	parent.location=fpage;
}

function dynpage(){

	fname=location.search.substring(1).split("&");
	if (fname[1] == 1){ //seminari
	document.open();
	document.write('<frameset  rows="87,*" border="0">'+
    			   '<frame name="hcrs" src="topsem.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">'+
    			   '<frame name="mainsem" src="' + fname[0] + '" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">'+
				   '</frameset>');
	document.close();
	}
	if (fname[1] == 2){ //biblioteche
	document.open();
	document.write('<frameset  rows="89,*" border="0">'+
    			   '<frame name="topbib" src="topbib.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">'+
    			   '<frame name="bodybib" src="' + fname[0] + '" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">'+
				   '</frameset>');
	document.close();
	}
	if (fname[1] == 3){ //corsi istituzionali
	document.open();
	document.write('<frameset  rows="109,*" border="0">'+
    			   '<frame name="hcrs" src="topcorsi.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">'+
    			   '<frame name="mcrs" src="' + fname[0] + '" marginwidth="10" marginheight="10" scrolling="auto" frameborder="0">'+
				   '</frameset>');
	document.close();
	}	
}

function vai(){
	document.mod.submit();
	setTimeout("self.location.replace('thk.html')",10000);

}

function confirmform(form1){
	
	if (document.registrazione.ind_via.value=="" ) {
		alert("ATTENZIONE: manca l'INDIRIZZO")
		document.registrazione.ind_via.focus();
		return false
	}

	if (document.registrazione.ind_cap.value.length<5 ) {
		alert("ATTENZIONE: C.A.P. errato o mancante")
		document.registrazione.ind_cap.focus();
		document.registrazione.ind_cap.select()
		return false
	}

	if (document.registrazione.ind_citta.value=="" ) {
		alert("ATTENZIONE: manca la CITTĀ")
		document.registrazione.ind_citta.focus();
		return false
	}

	if (document.registrazione.ind_prov.selectedIndex==0 ) {
		alert("ATTENZIONE: selezionare la provincia")
		document.registrazione.ind_prov.focus();
		return false
	}
	if (document.registrazione.ind_stato.selectedIndex==0 ) {
		alert("ATTENZIONE: selezionare lo stato");
		document.registrazione.ind_stato.focus();
		return false
	}
	
	if (document.registrazione.email.value=="" ) {
		alert("ATTENZIONE: per proseguire devi inserire il tuo indirizzo EMAIL")
		document.registrazione.email.focus();
		return false
	}

	return true;
}

function Ucase(obj){

	if (obj.value!='');
	obj.value=obj.value.toUpperCase();
}
 function Fcase(obj){
 	
	objtxt=String(obj.value).substr(0,1).toUpperCase()+String(obj.value).substr(1).toLowerCase(); 
 	obj.value=objtxt;
 }
 
 function ControllaMail()
   {
   EmailAddr = document.registrazione.email.value;
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (Filtro.test(EmailAddr))
      return true;
   else if (EmailAddr !='')
      {
      alert("Controllare l'indirizzo di e-mail inserito");
      document.registrazione.email.focus();
      return false;
      }
	else{
		alert("Il campo e-mail č un campo obbligatorio")
	}
   }
 function controllaNome(nomeutente){
	nom=''
	flag=1;
	for (i=0;i<nomeutente.value.length;i++){
		chr=String(nomeutente.value.substring(i,i+1));
		if (chr !=" "){
			if (flag){
				chr=chr.toUpperCase();
			}
			flag=0;
		}
		else {
			flag=1;
		}

	nom=String(nom+chr);
	}
nomeutente.value=nom
 }
function ccap (cap){

   	a=cap.value;
   	var RegExp=/\D/;
   	if (RegExp.test(a) || a.length != 5){
   		alert("Campo CAP errato");
	document.registrazione.ind_cap.focus()
	document.registrazione.ind_cap.select()
	return false
	}

}  
  
function ctrlpsw(){

	if (pswd.length<5){
		alert("Il campo deve essere di almeno 5 caratteri")
	}

}

function autoTab(input, e) {

	len=input.getAttribute("maxlength")
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		Ucase(input)
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}

function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
	return found;
}


function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
			return index;
		}
	return true;
}

function isNum(chr,nl){
	a=chr.value;
	b=a.length;
    aa=a.substring(0,b-1)
	a=a.substring(b-1,b)
	//alert("a : "+a+"   b : "+b+"   aa : "+aa)
	len=chr.getAttribute("name")
	if(a=='') return false
	if (!isNaN(a) && nl==0){
		alert("Inserire solo lettere");
		chr.value=aa
		return false;
	}
	if (isNaN(a) && nl){
		alert("Inserire solo numeri");
		chr.value=aa
		return false;
	}
}
function isOra(chr){
	a=chr.value;
	if (isNaN(a) || a>23){
		alert("Valori ammessi: 00 - 23");
		chr.value='';
		chr.focus();
		//chr.select
		return false;
	}
}
function isMin(chr){
	a=chr.value;
	if (isNaN(a) || a>59){
		alert("Valori ammessi: 00 - 59");
		chr.value='';
		chr.focus();
		return false;
	}
}

function aggiornaloc() {
	indsem = document.seminari.sede.options[document.seminari.sede.selectedIndex].value;
  	//alert(indsem)
  	switch (indsem){
  	case 'Milano':
		document.seminari.indirizzo.value='c/o SIAT, via Mazzini, 16 - MILANO';
		break;
	case 'Roma':
		document.seminari.indirizzo.value='Via delle Botteghe Oscure, 54 al II piano presso Ist. Pantheon';
		break;
	case 'Genova':
		document.seminari.indirizzo.value='';
		break;
	case 'Torino':
		document.seminari.indirizzo.value='';
		break;
	case 'Firenze':
		document.seminari.indirizzo.value='';
		break;
	case 'Napoli':
		document.seminari.indirizzo.value='';
		break;
	}
}
function bibtype(tipo){
	//alert()
	tlibri = document.getElementById('libri');
	tlibri.className = 'nopress';
	tdisp  = document.getElementById('dispense');
	tdisp.className = 'nopress';
	tabstr = document.getElementById('abstract');
	tabstr.className = 'nopress';
	ttesi  = document.getElementById('tesi');
	ttesi.className = 'nopress';
	selezione = document.getElementById(tipo);
	selezione.className = 'press';
	auth = document.getElementById("autore");
	auth.href = 'lista_bibroma.asp?orderType=autore&bibType='+tipo+'&ascDescType=DESC'
	tit = document.getElementById("titolo");
	tit.href = 'lista_bibroma.asp?orderType=titolo&bibType='+tipo+'&ascDescType=ASC'
	year = document.getElementById("anno");
	year.href = 'lista_bibroma.asp?orderType=anno&bibType='+tipo+'&ascDescType=DESC'
	edit = document.getElementById("editore");
	edit.href = 'lista_bibroma.asp?orderType=editore&bibType='+tipo+'&ascDescType=DESC'
	imgname = document.getElementById(2).src;
	fpartimg = imgname.substr(0,imgname.length - 6);
	strimg =imgname.substr(imgname.length - 6, 2);
	for (i=1;i<5;i++){
		document.getElementById(i).src = fpartimg + 'tr.gif';		
	}
	document.getElementById(2).src = fpartimg + 'up.gif';
}

function changeord(type,ord){
	activelink = document.getElementById(type).href;
	firstpartlink = activelink.substr(0, activelink.length - 4);
	strlink = activelink.substr(activelink.length - 4);
	imgname = document.getElementById(ord).src;
	fpartimg = imgname.substr(0,imgname.length - 6);
	strimg =imgname.substr(imgname.length - 6, 2);
	for (i=1;i<5;i++){
		document.getElementById(i).src = fpartimg + 'tr.gif';		
	}
	if (strlink == 'DESC'){
		document.getElementById(type).href = firstpartlink + 'ASC';
		document.getElementById(ord).src = fpartimg + 'up.gif';
	}
	if (strlink == '=ASC'){
		document.getElementById(type).href = firstpartlink + '=DESC';
		document.getElementById(ord).src = fpartimg + 'dw.gif';
	}
}
function checkon(obj){
	document.getElementById(obj).checked = true

}
