function chk_contacts(lang_id){
	
	with(document.contacts){
		
		if(
         chk_txt1(nome,		nome.alt ) &&
		 chk_email(email,	email.alt ) &&
		 //chk_telefono(telefono,telefono.alt) &&
		 //chk_txt(citta,		citta.alt ) &&
		 //chk_txt(messaggio,	'Inserisci il Messaggio') &&
		 chk_aut2(lang_id, autorizzazione.alt) ){
			return true;
		}
		return false;
		
	}
}

function refresh(){
	document.captcha.src = "captcha.php" + '?' + (new Date()).getTime();
}


function chk_request(lang_id){
	
	with(document.request){
		if(
         chk_txt1(nome,		nome.alt ) &&
		 chk_email(email,	email.alt ) &&
		 chk_txt(messaggio,	'Insert your Messagge')&&
		 chk_codfis(codice, codice.alt)){
			return true;
		}else{
			return false;
		}
	}
}



function chk_form_iscrizione(){
	with(document.iscrizione){
		if(
		 chk_txt1(nome,		nome.alt ) &&
		 chk_txt1(cognome,	cognome.alt ) &&
         chk_email(email,	email.alt ) &&
		 chk_txt(indirizzo,	indirizzo.alt ) &&
		 chk_txt(citta,		citta.alt ) &&
		 chk_num(cap,		cap.alt ) &&
		 chk_txt1(prov,		prov.alt ) &&
		 chk_txt1(stato,		stato.alt ) &&
		 chk_telefono(telefono,	telefono.alt) &&
		 chk_info(informazione.alt)  &&
		 chk_radio(autorizzazione[0].alt)
		){
		
		return true;
		}
		return false;
	}
}	


function control_login(){
	with(document.login){
		if((user.value=="")&&(pswd.value=="")){
			return false;
		}
		return true;
	}
}


function PrintThisPage() 
{ 
   var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
       sOption+="scrollbars=yes,width=800,height=650,left=100,top=25"; 

   var sWinHTML = document.getElementById('contentstart').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><LINK href=print.css rel=Stylesheet><body onload="window.print();window.close();">'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
}



function GetPrintContent()
{
	var PrintDiv =  document.getElementById('printcontent');
	var ContentDiv =  window.opener.document.getElementById('contentstart');
	PrintDiv.innerHTML = ContentDiv.innerHTML;
}



function changemenu(menusel,menustampsel)
{
	document.getElementById('menu0').className = 'campo_scelta_menu_normale';
	document.getElementById('menu1').className = 'campo_scelta_menu_normale';
	document.getElementById('menu2').className = 'campo_scelta_menu_normale';
	document.getElementById('menu3').className = 'campo_scelta_menu_normale';
	
	document.getElementById(menusel).className = 'campo_scelta_menu_sel';
	
	document.getElementById('menustamp0').style.display = 'none';
	document.getElementById('menustamp1').style.display = 'none';
	document.getElementById('menustamp2').style.display = 'none';
	document.getElementById('menustamp3').style.display = 'none';
	
	document.getElementById('menustamp0').style.visibility = 'hidden';
	document.getElementById('menustamp1').style.visibility = 'hidden';
	document.getElementById('menustamp2').style.visibility = 'hidden';
	document.getElementById('menustamp3').style.visibility = 'hidden';
	
	document.getElementById(menustampsel).style.display = "block";
	document.getElementById(menustampsel).style.visibility = "visible";
}

function chk_ordine(count, pagamento0, pagamento1, pagamento2){
	
	//document.carrello2.codicesconto.value = document.carrello.codicesconto.value;
	
	var pagamento = '';
	var checked = '';
	
	if(pagamento0 == true) checked = 0;
	else if(pagamento1 == true) checked = 1;
	else if(pagamento2 == true) checked = 2;
	
	if(checked !== '') pagamento = document.carrello.pagamento[checked].value;
	else pagamento = '';
	
	//alert(pagamento);
	
	document.carrello2.pagamento.value = pagamento;
	
	var ordine = parseInt(count);
	if(ordine > 0 && pagamento !== '') return true;
	else if(!ordine) alert("Impossibile inviare l'ordine: il carrello è vuoto");
	else alert("attenzione, devi scegliere un metodo di pagamento");
	
	return false;
	
}


function check_ordina(prodo){
	if (prodo==false){
		alert('Carrello vuoto impossibile inoltrare l\'ordine');
		return false;
	}
	else{
		return window.confirm('Stai per inviare l\' ordine a Prontolatte. Sei sicuro?');
	}
	}

function check_carrello(prodo){
	if (prodo==0){
		alert('Carrello vuoto impossibile inoltrare l\'ordine');
		return false;
	}
	else{
		return true;
	}
}

/*function CheckKeyCode(){
	if(event.keyCode){
		code  =  event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	}
  	
	if( (code == 189 || code == 109) ||
    	(code >= 48 && code <= 57) || 
		(code >= 96 && code <= 105) || (code==8) || (code==46) ) {
		return true; 
	}else {
		return false;
	}
}*/

function controlla_qta(){
	var code = parseInt(event.keyCode);
	if(code == 46 || (code > 47 && code < 58)) return true;
	alert('Attenzione\nNon è permesso inserire spazi o caratteri alfabetici come quantità: inserire un punto come carattere virgola, sono previsti fino a due decimali (per esempio digitare 0,25 per richiedere 250 grammi)');
	return false;
}

function controlla_qta2(){
	var code = parseInt(event.keyCode);
	if(code > 47 && code < 58) return true;
	alert('Attenzione\nNon è permesso inserire spazi o caratteri alfabetici come quantità)');
	return false;	
}


function Stampa() {
	document.getElementById('header').style.display = "none";
	document.getElementById('campo_menu').style.display = "none";
	document.getElementById('offerte').style.display = "none";
	document.getElementById('footer').style.display = "none";
	
	//Lancia la funzione di stampa
	window.print();
}

