

//**********************************
//funzione per stampare una schermata
//***********************************
function printit()
	{  
	if (NS) 
		{
   		 window.print() ;  
		} 
	else 
		{
    	var WebBrowser = '<object id="WebBrowser1" width=0 height=0 classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    	WebBrowser1.ExecWB(6, 2);
		WebBrowser1.outerHTML = "";  
		}
	}
	
function test()
	{
	alert('test');	
	}
	
//********************************************
//funzione per verificare un numero in un form
//********************************************
function verifica_numero(value)
	{
	var ammessi = "0123456789";
	var c;
	for(i=0; i<value.length; i++)
		{
		c=value.charAt(i);
		if(ammessi.indexOf(c) == -1)
			{
			return false;
			}
		}
		return true;
	}

//*******************************************************
//funzione per verificare un numero telefonico in un form
//*******************************************************
function verifica_telefono(tel)
	{
	var ammessi = "0123456789+/-, ";
	var c;
	for(i=0; i<tel.length; i++)
		{
		c=tel.charAt(i);
		if(ammessi.indexOf(c) == -1)
			{
			return false;
			}
		}
		return true;
	}

//********************************************
//funzione per verificare un email in un form
//********************************************
function verifica_email(posta)
	{
	var c;
	var ok=0;
	for(i=0; i < posta.length; i++)
		{
		c=posta.charAt(i);
		if(c == '@')
			{
			ok++;
			}
		}
		if (ok > 1)
			{
			return false;
			}
		if(posta.indexOf('@', 0) == -1)
			{
			return false;
			}
		else if(posta.indexOf('@', 0) == 0 || posta.indexOf('@', 0) == posta.length-1)
			{
			return false;
			}
		else if(posta.indexOf('.', 0) == 0 || posta.indexOf('.', 0) == posta.length-1)
			{
		return false;
		}
		else if(posta.indexOf('.', 0) == -1)
		{
		return false;
		}
	return true;
	}
	

//**********************************
//funzione per verificare una data
//***********************************
function VerificaData(data)
	{
	giorno=parseFloat(data.substring(0,2));
	mese=parseFloat(data.substring(3,5));
	anno=parseFloat(data.substring(6,10));
	separatorea=data.substring(2,3);
	separatoreb=data.substring(5,6);
	//dataOggi = new Date();
	if (separatorea != '-' || separatoreb != '-')
		{
		alert ("Il formato della data deve essere gg-mm-aaaa");
		return false;
		}
	else if (data.length < 10 )
		{
		alert ("Il formato della data deve essere gg-mm-aaaa");
		return false;
		}
	else if (isNaN(giorno) || isNaN(mese) || isNaN(anno))
		{
		alert ("Il formato della data deve essere gg-mm-aaaa");
		return false;
		}
	else if (giorno < 01 || giorno > 31)
		{
		alert ("Il giorno della data e' sbagliato");
		return false;
		}
	if (giorno == 31)
		{
		if (mese == '02' || mese == '04' || mese == '06' || mese == '09' || mese == '11')
			{
			alert ("Il mese non ha 31 giorni");
			return false;
			}
		}
	else if (giorno > 29 && mese == 02)
		{
		alert ("I giorni sono errati");
		return false;
		}
	return true
	}
	
	
//****************************************************
//              FUNZION VERIFICA FORM
//****************************************************

function verificaForm()
	{
	if (document.lista.off_datainizio.value == '')
		{
		alert ("scrivere la data di inizio dell'offerta");
		document.lista.off_datainizio.focus();
		return false;
		}
	else if (!VerificaData(document.lista.off_datainizio.value))
		{
		alert ("La data di inizio offerta deve essere gg-mm-aaa (es. 31-12-2006)");
		document.lista.off_datainizio.focus();
		return false
		}
	else if (document.lista.off_datafine.value == '')
		{
		alert ("scrivere la data di fine offerta");
		document.lista.off_datafine.focus();
		return false;
		}
	else if (!VerificaData(document.lista.off_datafine.value))
		{
		alert ("La data di fine offerta deve essere gg-mm-aaa (es. 31-12-2006)");
		document.lista.off_datafine.focus();
		return false
		}
	return true;
	}
	

