function showPic (whichpic)
{
	if (document.getElementById) 
  {
		document.getElementById('placeholder').src = whichpic.href;
	/*	if (whichpic.title)
    {
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
		}
    else
    {
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
		}*/
		return false;
	}
  else 
  {
		return true;
	}
}
function onchangetipo(tp)
{
	var grp_negozio = document.getElementById('negozio');
  var grp_privato = document.getElementById('privato');
	var grp_scelta = document.getElementById('scelta');
	if (tp=="")
	{
		grp_negozio.style.display="";
    grp_privato.style.display="none";
		grp_scelta.style.display="none";
	}
	if (tp=="N")
	{
		grp_negozio.style.display="";
		grp_scelta.style.display="none";
    grp_privato.style.display="none";
	}
	if (tp=="P")
	{
		grp_scelta.style.display="none";
		grp_negozio.style.display="none";
    grp_privato.style.display="";
	}
}
function controllo_CF(cf,idsp)
{
	var sp=0;
	codfis=cf.value.toUpperCase();
	carat=codfis.substr(15,1);
	//somma codificata di ogni posizione
	for (i=0; i<codfis.length-1;i++)
	{
		vc=codfis.substr(i,1);
		if ( (i % 2)==0 ) 
		{
			//dispari
			if ( (vc=='A') || (vc=='0')) 
				sp=sp+1
			else
				if ( (vc=='B') || (vc=='1') )
					sp=sp+0
				else
					if ( (vc=='C') || (vc=='2') )
						sp=sp+5
					else
						if ( (vc=='D') || (vc=='3') )
							sp=sp+7
						else
							if ( (vc=='E') || (vc=='4') )
								sp=sp+9
							else
								if ((vc=='F') || (vc=='5') )
									sp=sp+13
								else
									if ((vc=='G') || (vc=='6') )
										sp=sp+15
									else
										if ((vc=='H') || (vc=='7') )
											sp=sp+17
										else
											if ((vc=='I') || (vc=='8') )
												sp=sp+19
											else
												if ((vc=='J') || (vc=='9') )
													sp=sp+21
												else
													if ( vc=='K' )
														sp=sp+2
													else
														if ( vc=='L' )
															sp=sp+4
														else
															if ( vc=='M' )
																sp=sp+18
															else
																if ( vc=='N' )
																	sp=sp+20
																else
																	if ( vc=='O' )
																		sp=sp+11
																	else
																		if ( vc=='P' )
																			sp=sp+3
																		else
																			if ( vc=='Q' )
																				sp=sp+6
																			else
																				if ( vc=='R' )
																					sp=sp+8
																				else
																					if ( vc=='S' )
																						sp=sp+12
																					else
																						if ( vc=='T' )
																							sp=sp+14
																						else
																							if( vc=='U' )
																								sp=sp+16
																							else
																								if ( vc=='V' )
																									sp=sp+10
																								else
																									if ( vc=='W' )
																										sp=sp+22
																									else
																										if ( vc=='X' )
																											sp=sp+25
																										else
																											if ( vc=='Y' )
																												sp=sp+24
																											else
																												if( vc=='Z' )
																													sp=sp+23;
		}
		else
		{
			//pari
			if ( (vc=='A') || (vc=='0') )
				sp=sp+0
			else
				if ((vc=='B') || (vc=='1') )
					sp=sp+1
				else
					if( (vc=='C') || (vc=='2') )
						sp=sp+2
					else
						if ((vc=='D') || (vc=='3') )
							sp=sp+3
						else
							if ((vc=='E') || (vc=='4') )
								sp=sp+4
							else
								if ((vc=='F') || (vc=='5') )
									sp=sp+5
								else
									if ((vc=='G') || (vc=='6') )
										sp=sp+6
									else
										if ((vc=='H') || (vc=='7') )
											sp=sp+7
										else
											if ((vc=='I') || (vc=='8') )
												sp=sp+8
											else
												if ((vc=='J') || (vc=='9') )
													sp=sp+9
												else
													if( vc=='K' )
														sp=sp+10
													else
														if (vc=='L' )
															sp=sp+11
														else
															if (vc=='M' )
																sp=sp+12
															else
																if( vc=='N' )
																	sp=sp+13
																else
																	if (vc=='O' )
																		sp=sp+14
																	else
																		if( vc=='P' )
																			sp=sp+15
																		else
																			if( vc=='Q' )
																				sp=sp+16
																			else
																				if( vc=='R' )
																					sp=sp+17
																				else
																					if( vc=='S' )
																						sp=sp+18
																					else
																						if (vc=='T' )
																							sp=sp+19
																						else
																							if (vc=='U' )
																								sp=sp+20
																							else
																								if (vc=='V' )
																									sp=sp+21
																								else
																									if (vc=='W' )
																										sp=sp+22
																									else
																										if (vc=='X' )
																											sp=sp+23
																										else
																											if (vc=='Y' )
																												sp=sp+24
																											else
																												if (vc=='Z' )
																													sp=sp+25;		
		}
	}
	r=(sp % 26);
	//cognome+nome+anno+mese+gi||no e sesso+codice comune+carattere controllo
	switch (r)
	{
		case 0:rit='A';break;
		case 1:rit='B';break;
		case 2:rit='C';break;
		case 3:rit='D';break;
		case 4:rit='E';break;
		case 5:rit='F';break;
		case 6:rit='G';break;
		case 7:rit='H';break;
		case 8:rit='I';break;
		case 9:rit='J';break;
		case 10:rit='K';break;
		case 11:rit='L';break;
		case 12:rit='M';break;
		case 13:rit='N';break;
		case 14:rit='O';break;
		case 15:rit='P';break;
		case 16:rit='Q';break;
		case 17:rit='R';break;
		case 18:rit='S';break;
		case 19:rit='T';break;
		case 20:rit='U';break;
		case 21:rit='V';break;
		case 22:rit='W';break;
		case 23:rit='X';break;
		case 24:rit='Y';break;
		case 25:rit='Z';break;
	}
	var cmsg = document.getElementById(idsp);
	var msg = document.getElementById('tmsg');
	if (msg!=null)
	{
		cmsg.removeChild(msg);
	}

	if (rit!=carat)
	{
		msg = document.createElement('b');
		msg.setAttribute('id','tmsg');
    msg.style.color="red";
		var txt =document.createTextNode('Codice fiscale Errato!');
    msg.appendChild(txt);
		cmsg.appendChild(msg);
	}
	
		
}
function uppercase_string(str)
{
	str.value=str.value.toUpperCase();
}
function lowercase_string(str)
{
	str.value=str.value.toLowerCase();
}
