// JavaScript Document
var sezioneSelezionata="eCommerce";
var tempMenu="eCommerce";

 jQuery.fn.fadeToggle = function(speed, easing, callback) {
        return this.animate({opacity: 'toggle'}, speed, easing, callback);  
      };



/*
$(document).ready(function(){
	
	$('img.focusImg').jcaption({
		copyStyle: true,
		animate: false,
		show: {height: "show"},
		hide: {height: "hide"}
	});

});
*/
/*
$(document).ready(function(){
	
	  $('ul#slideAziendeHome').simpleSlider({height:'50px',titleStyle: { fontSize: '12px',height:'200px', paddingTop:'5px',fontFamily: 'Georgia' },timeOut:8000});
	  $('ul#slideProdottiHome').simpleSlider({height:'50px',titleStyle: { fontSize: '12px',height:'200px',paddingTop:'5px',fontFamily: 'Georgia'  },timeOut:8000});
	
	//$('img.imgCaption').footerCaption({ bgcolor: '#eee', color: '#000', text: 'Custom caption <a href="#">click here</a>' });
	//$('ul#slideAziendeHome').simpleSlider( {alpha: '0.5', titleStyle: { fontSize: '18px' } } );
});
*/



$(function() {
    $('select#sceltaRicerca').selectmenu({width: 150,height:10});
});


function getUrlVars()
{

var vars = [], hash;
var url=document.location.href.replace(/\&amp;/g,'&');

url=window.location.href.replace(/\&amp;/g,'&');

var hashes = window.location.href.slice(url.indexOf('?') + 1).split('&');

 

for(var i = 0; i < hashes.length; i++)

{

hash = hashes[i].split('=');

vars.push(hash[0]);

vars[hash[0]] = hash[1];

}

 

return vars;

}

$(document).ready(function(){
						   
$(".divPiuClicccatiCategoria").jCarouselLite({
        btnNext: ".cliccatiNext",
        btnPrev: ".cliccatiPrev",
		scroll:1,
		visible:5

    });

  $(".gareHome").jCarouselLite({
        btnNext: ".dxGare",
        btnPrev: ".sxGare",
		scroll:2,
		visible:2,
		auto:5000
    });
 $(".seminariHome").jCarouselLite({
        btnNext: ".dxSeminari",
        btnPrev: ".sxSeminari",
		scroll:2,
		visible:2,
		auto:5000
    });
						   });


function showChild(i)
{
			document.getElementById(tempMenu).style.display="none";
			$("#"+sezioneSelezionata).fadeOut("fast",function(){$("#"+i).fadeIn("fast");tempMenu=i;});

}

function setDefaultMenu()
{
	setTimeout(function(){if(tempMenu=="")$("#"+sezioneSelezionata).fadeIn("fast")},2000);
	//alert("ttt");
}


function nextLLPPHome()
{
	 $.post("/getNextNumero.php",null, function(xml) {document.getElementById("numeroHome").innerHTML=xml});

}
function prevLLPPHome()
{
	 $.post("/getPrevNumero.php",null, function(xml) {document.getElementById("numeroHome").innerHTML=xml});

}

function mostraCarrello()
{
	$(document).ready(function(){

	var pos = $("#superLogIn").offset(); 
	var heightBasket=$("#topBasket").height();
	var height = $("#superLogIn").height()+pos.top-10;

	
	
	$("#topBasket").css( { "left": (pos.left) + "px", "top":(height) + "px" } );
  	$("#topBasket").fadeToggle("slow");
	
	
							   });

}

var lightBox=false;
function viewLightBox()
{
	$(document).ready(function(){
	var height=$(document).height();
	var width=$(document).width();
	$("#lightBox").css({"height":height,"width":width});
	if(lightBox)
	{
		$("#lightBox").fadeOut("slow");
		lightBox=false;
	}
	else
	{
			$("#lightBox").fadeIn("fast");
			lightBox=true;
	}

							   });
}
var ajaxBox=false;

function focusBandoLavoro()
{
	var i=getUrlVars();
	
	$.post("/getFocusBandoLavoro.php",{i:i['idBando']},
		   function(result){
			   document.getElementById("resultAjax").innerHTML=result;
			   });
}
function focusBandoProgettazione()
{
	var i=getUrlVars();
	
	$.post("/getFocusBandoProgettazione.php",{i:i['idBando']},
		   function(result){
			   document.getElementById("resultAjax").innerHTML=result;
			   });
}

function startAjaxLogIn()
{
	viewLightBox();
	
	
	
	$.post("/getLog.php",{a:2},function(re){
									    document.body.innerHTML+=re
									    var box= $("#ajaxRedLogIn");
	 box.css("position","absolute");
	
	 
     box.css("top", ( $(window).height() - box.height() ) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  })

}

function stopAjaxLogIn()
{
	viewLightBox();
	var div = document.getElementById("ajaxRedLogIn");
	document.body.removeChild(div);
	
}

function viewAjaxBasket()
{
	viewLightBox();

	$(document).ready(function(){
	var pos = $("#superLogIn").offset(); 
	var left=pos.left+2;
	var top=pos.top+5;

	$("#ajaxBasket2").css( { "left": (left) + "px", "top":(top) + "px" } );
	if(ajaxBox)
	{
		$("#ajaxBasket2").fadeOut("slow");
		ajaxBox=false;
		
	}
	else
	{
		$("#ajaxBasket2").show();
		ajaxBox=true;
	//	alert("top: "+top+" left: "+left);
	}
							   });
}

function addToBasketAjax(c)
{
	c=c==""?"":c;
	 $.post("/addToBasket.php",{codice:c}, function(xml) {
												   var b=xml.split('|');
												    document.getElementById("ajaxBasket2").innerHTML=b[0];
												 //   $("#ajaxBasket2").html(b[0]);
												 viewAjaxBasket();
												   $("#ajaxBasket2Count").html("("+b[1]+")");
												
												   $("#topLogBasket").html("Prodotti nel carrello ("+b[1]+")");
												   $("#topBasketTitle").html("Prodotti nel carrello ("+b[1]+")");
												//   vaiAllaCassaCheck();
												   });
}
function removeItemBasketAjax(c)
{
	c=c==""?"":c;
	 $.post("/removeItemBasket.php",{codice:c}, function(xml) {
												   var b=xml.split('|');
												     document.getElementById("ajaxBasket2").innerHTML=b[0];
													
												
												   $("#ajaxBasket2Count").html("("+b[1]+")");
												   $("#topLogBasket").html("Prodotti nel carrello ("+b[1]+")");
												   $("#topBasketTitle").html("Prodotti nel carrello ("+b[1]+")");
												      vaiAllaCassaCheck();
												   });
}

function addToBasket(c)
{
	
	setTimeout(function(){
	 $.post("/addToBasket.php",{codice:c}, function(xml) {
												   var b=xml.split('|');
												   $("#topBasketContent").html(b[0]);
												   $("#topLogBasket").html("Prodotti nel carrello ("+b[1]+")");
												   $("#topBasketTitle").html("Prodotti nel carrello ("+b[1]+")");
												      mostraAvvisoBasket();
													  mostraCarrello();
													vaiAllaCassaCheck();
												   setTimeout(function(){mostraCarrello()},5000);
												   });
						},900);
	
												  
}
function vaiAllaCassaCheck()
{
	 $.post("/isBasketEmpty.php",{a:0}, function(xml) {
											
												 if(xml=="0")
												 {
													 $("#concludiAcquisto").fadeOut("fast");
												 }
												 else
											  	{
													 $("#concludiAcquisto").fadeIn("fast");
											  	}
												  
											
											  });
}
function initToBasket()
{
	 $.post("/addToBasket.php",null, function(xml) {
												   var b=xml.split('|');
												   $("#topBasketContent").html(b[0]);
												   $("#topLogBasket").html("Prodotti nel carrello ("+b[1]+")");
												   $("#topBasketTitle").html("Prodotti nel carrello ("+b[1]+")");
												
												   });
												  
}

function mostraAvvisoBasket()
{
	var pos = $("#superLogIn").offset();
	var x=pos.left-435;
	var y=pos.top+80;
	
	$("#alertProdottoInserito").css( { "left": (x) + "px", "top":(y) + "px" } );
	$("#alertProdottoInserito").fadeIn("slow");
	setTimeout(function(){$("#alertProdottoInserito").fadeOut("slow");},5000);
}

var sizeNotizia=12;
function ingrandisciTestoNotizia()
{
	
	var maxPx=18;
	var incremento=2;
	
	if((sizeNotizia+incremento)<=maxPx)
	{
		var size=sizeNotizia+incremento;
	}
	else
	{
		var size=sizeNotizia;
	}
	sizeNotizia=size;
	$(".testoNotizia").css({ "font-size": size});

	
}
function diminuisciTestoNotizia()
{
	
	var minPx=12;
	var decremento=2;
	
	if((sizeNotizia-decremento)>=minPx)
	{
		var size=sizeNotizia-decremento;
	}
	else
	{
		var size=sizeNotizia;
	}
	sizeNotizia=size;
	$(".testoNotizia").css({ "font-size": size});

	
}


function checkEmail(mail)
{
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (!email_reg_exp.test(mail) || (mail == "") || (mail == "undefined")) 
	{
		return false;
	}
	else
	{
		return true;
	}

}


function controllaEmailSegnalaNotizia(t)
{
	if(checkEmail(t.value))
	{
		$("#segnalaNotiziaCheckEmail").show();
	}
	else
	{
		$("#segnalaNotiziaCheckEmail").hide();
	}
}

function postCommentoNotizia()
{
	var titolo=document.formCommentoNotizia.titoloCommento.value;
	var nominativo=document.formCommentoNotizia.nomeCommento.value;
	var testo=document.formCommentoNotizia.testoCommento.value;
	var email=document.formCommentoNotizia.emailCommento.value;
	var i=document.formCommentoNotizia.idNews.value;
	
	$.post("/newCommentoNotizia.php",{n:nominativo,te:testo,ti:titolo,i:i,e:email},function(r){
																																				  
																	  if(r=="1")
																	  {
																		  alert("Commento inviato correttamente.\nGrazie del prezioso contributo.\n\n\n\nLavoriPubblici.it, il portale dell'informazione tecnica");
																		//  alert(window.location);
																		  var self= window.location.toString();
																		  var u=self.split("#");
																		 window.location=u[0];
																	  }
																	  })

}

function checkUser(u)
{
	var u=u.value;
	
	if(u.length>=6)
	{
		$.post("/checkU.php",{u:u},function(r){
										  if(r=="1")
										  {
											  $("#registrazioneUtenteFormBoxVerificaUser").css({ "background-image":"url(img/registrazioneUserOk.png)"});
											  document.registrazioneUtenteForm.u.value=1;
										  }
										 else
										  {
											  $("#registrazioneUtenteFormBoxVerificaUser").css({ "background-image":"url(img/registrazioneUserBad.png)"});
											  document.registrazioneUtenteForm.u.value=0;
										  }
										  });
	}
	else
	{
		 $("#registrazioneUtenteFormBoxVerificaUser").css({ "background-image":"url(img/registrazioneUser.png)"});
		 document.registrazioneUtenteForm.u.value=0;
	}
}

function regIsValidEmail(t)
{
	if(t.value.length>3)
	{
		if(checkEmail(t.value))
		{
			  $("#registrazioneUtenteFormBoxVerificaEmail").css({ "background-image":"url(img/registrazioneEmailOk.png)"});
			   document.registrazioneUtenteForm.e.value=1;
			  
		}
		else
		{
			 $("#registrazioneUtenteFormBoxVerificaEmail").css({ "background-image":"url(img/registrazioneEmailBad.png)"});
			  document.registrazioneUtenteForm.e.value=0;
		}
	}
	else
	{
		 document.registrazioneUtenteForm.e.value=0;
	}
}
function modIsValidEmail(t)
{
	if(t.value.length>3)
	{
		if(checkEmail(t.value))
		{
			  $("#modificaUtenteFormBoxVerificaEmail").css({ "background-image":"url(img/registrazioneEmailOk.png)"});
			   document.modificaUtenteForm.e.value=1;
			  
		}
		else
		{
			 $("#modificaUtenteFormBoxVerificaEmail").css({ "background-image":"url(img/registrazioneEmailBad.png)"});
			  document.modificaUtenteForm.e.value=0;
		}
	}
	else
	{
		 document.modificaUtenteForm.e.value=0;
	}
}

function checkReg()
{
	var error=false;
	var mexError="ATTENZIONE\n\n";
	var nome=document.registrazioneUtenteForm.nomeRegistrazione.value;
	var cognome=document.registrazioneUtenteForm.cognomeRegistrazione.value;
	var professione=document.registrazioneUtenteForm.professioneRegistrazione.value;
	var codiceFiscale=document.registrazioneUtenteForm.cfRegistrazione.value;
	var indirizzo=document.registrazioneUtenteForm.indirizzoRegistrazione.value;
	var nCivico=document.registrazioneUtenteForm.ncivicoRegistrazione.value;
	var citta=document.registrazioneUtenteForm.cittaRegistrazione.value;
	var cap=document.registrazioneUtenteForm.capRegistrazione.value;
	var provincia=document.registrazioneUtenteForm.provinciaRegistrazione.value;
	var telefono=document.registrazioneUtenteForm.telefonoRegistrazione.value;
	var email=document.registrazioneUtenteForm.emailRegistrazione.value;
	var e=document.registrazioneUtenteForm.e.value;
	var confermaEmail=document.registrazioneUtenteForm.confermaEmailRegistrazione.value;
	var u=document.registrazioneUtenteForm.u.value;
	var password=document.registrazioneUtenteForm.passwordRegistrazione.value;
	var passwordConferma=document.registrazioneUtenteForm.confermaPasswordRegistrazione.value;
	var pagamento=document.registrazioneUtenteForm.pagamentoRegistrazione;
	var spedizione=document.registrazioneUtenteForm.spedizioneRegistrazione;
	var privacy=document.registrazioneUtenteForm.consentoRegistrazione;
	
	if(nome=="" || nome=="undefined" || nome.length<3)
	{
		error=true;
		mexError+="- Il Nome inserito non e' valido(min 3 caratteri)\n";
	}
	if(cognome=="" || cognome=="undefined" || cognome.length<3)
	{
		error=true;
		mexError+="- Il Cognome inserito non e' valido(min 3 caratteri)\n";
	}
	if(professione=="--")
	{
		error=true;
		mexError+="- Non hai scelto la professione\n";
	}
	if(indirizzo=="" || indirizzo=="undefined")
	{
		error=true;
		mexError+="- Non e' stato inserito un indirizzo valido\n";
	}
	if(cap=="" || cap=="undefined")
	{
		error=true;
		mexError+="- Non e' stato inserito un cap valido\n";
	}
	if(citta=="" || citta=="undefined")
	{
		error=true;
		mexError+="- Non e' stata inserita una citta' valida\n";
	}
	if(provincia=="--")
	{
		error=true;
		mexError+="- Non e' stata scelta la provincia\n";
	}
	if(codiceFiscale=="")
	{
		error=true;
		mexError+="-Non e' stato inserito un codice fiscale valido\n";
	}
	if(telefono=="" || telefono=="undefined")
	{
		error=true;
		mexError+="- Non e' stato inserito un numero di telefono valido, se non possiedi un numero fisso puoi inserire il cellulare nel campo TELEFONO\n";
	}
	
	if(e==1)
	{
		if(email!=confermaEmail)
		{
			error=true;
			mexError+="- Email e conferma email non coincidono\n";
		}
			
	}
	else
	{
		error=true;
		mexError+="- Email inserita non valida!\n";
	}
	
	
	if(u==0)
	{
		error=true;
		mexError+="- Username inserito non valido(min 6 caratteri)!\n";
	}
	
	if(password.length<6 )
	{
		error=true;
		mexError+="- La password deve essere min 6 caratteri \n";
	}
	else
	{
		if(password!=passwordConferma)
		{
			error=true;
			mexError+="- Password e conferma password non coincidono\n";
		}
	}
	
	if(pagamento.selectedIndex == 3)
	{
		if(spedizione.selectedIndex==1)
		{
			error=true;
			mexError+="- Il tipo di pagamento non e' compatibile con il tipo di spedizione\n";
		}
	}
	if(!privacy.checked)
	{
		error=true;
			mexError+="- Non esprimendo il consenso al trattamento dei dati personali, non e' possibile completare la registrazione\n";
	}
	
	
	if(error)
	{
		alert(mexError);
		return false;
	}
	else
	{
		alert("Si procedera' ora alla registrazione dell'account.\n Le sara' inviata una email all'indirizzo indicato per la sua attivazione.\n");
	}
	
	
}

function checkModifica()
{
	var error=false;
	var mexError="ATTENZIONE\n\n";
	var nome=document.modificaUtenteForm.nomeModifica.value;
	var cognome=document.modificaUtenteForm.cognomeModifica.value;
	var professione=document.modificaUtenteForm.professioneModifica.value;
	var codiceFiscale=document.modificaUtenteForm.cfModifica.value;
	var indirizzo=document.modificaUtenteForm.indirizzoModifica.value;
	var nCivico=document.modificaUtenteForm.ncivicoModifica.value;
	var citta=document.modificaUtenteForm.cittaModifica.value;
	var cap=document.modificaUtenteForm.capModifica.value;
	var provincia=document.modificaUtenteForm.provinciaModifica.value;
	var telefono=document.modificaUtenteForm.telefonoModifica.value;
	var email=document.modificaUtenteForm.emailModifica.value;
	var e=document.modificaUtenteForm.e.value;
	var confermaEmail=document.modificaUtenteForm.confermaEmailModifica.value;
	var u=document.modificaUtenteForm.u.value;
	var password=document.modificaUtenteForm.passwordModifica.value;
	var passwordConferma=document.modificaUtenteForm.confermaPasswordModifica.value;
	var pagamento=document.modificaUtenteForm.pagamentoModifica;
	var spedizione=document.modificaUtenteForm.spedizioneModifica;
	
	
	if(nome=="" || nome=="undefined" || nome.length<3)
	{
		error=true;
		mexError+="- Il Nome inserito non e' valido(min 3 caratteri)\n";
	}
	if(cognome=="" || cognome=="undefined" || cognome.length<3)
	{
		error=true;
		mexError+="- Il Cognome inserito non e' valido(min 3 caratteri)\n";
	}
	if(professione=="--")
	{
		error=true;
		mexError+="- Non hai scelto la professione\n";
	}
	if(indirizzo=="" || indirizzo=="undefined")
	{
		error=true;
		mexError+="- Non e' stato inserito un indirizzo valido\n";
	}
	if(cap=="" || cap=="undefined")
	{
		error=true;
		mexError+="- Non e' stato inserito un cap valido\n";
	}
	if(citta=="" || citta=="undefined")
	{
		error=true;
		mexError+="- Non e' stata inserita una citta' valida\n";
	}
	if(codiceFiscale=="")
	{
		error=true;
		mexError+="-Non e' stato inserito un codice fiscale valido\n";
	}
	if(provincia=="--")
	{
		error=true;
		mexError+="- Non e' stata scelta la provincia\n";
	}
	if(telefono=="" || telefono=="undefined")
	{
		error=true;
		mexError+="- Non e' stato inserito un numero di telefono valido, se non possiedi un numero fisso puoi inserire il cellulare nel campo TELEFONO\n";
	}
	
	if(e==1)
	{
		if(email!=confermaEmail)
		{
			error=true;
			mexError+="- Email e conferma email non coincidono\n";
		}
			
	}
	else
	{
		error=true;
		mexError+="- Email inserita non valida!\n";
	}
	
	
	if(u==0)
	{
		error=true;
		mexError+="- Username inserito non valido(min 6 )!\n";
	}
	
	if(password.length<6)
	{
		error=true;
		mexError+="- La password deve essere min 6 caratteri \n";
	}
	else
	{
		if(password!=passwordConferma)
		{
			error=true;
			mexError+="- Password e conferma password non coincidono\n";
		}
	}
	
	if(pagamento.selectedIndex == 3)
	{
		if(spedizione.selectedIndex==1)
		{
			error=true;
			mexError+="- Il tipo di pagamento non e' compatibile con il tipo di spedizione\n";
		}
	}
	
	
	if(error)
	{
		alert(mexError);
		return false;
	}
	else
	{
		alert("Si procedera' ora alla Modifica dell'account.\n\n");
	}
	
	
}


function nuovoIndirizzo()
{
	$("#eCommerceNuovoIndirizzo").fadeToggle("slow");
}

function aziendeVediSottocategoria(t)
{
	window.location='aziendeLLPPCategoria.php?cat='+t+'#r';
}
function prodottiVediSottocategoria(t)
{
	window.location='prodottiLLPPCategoria.php?cat='+t+'#r';
}
function checkFormInfo()
{
	var error=false;
	var nome=document.formRichiestaInfoAzienda.nomeRichiestaInfo.value;
	var cognome=document.formRichiestaInfoAzienda.cognomeRichiestaInfo.value;
	var indirizzo=document.formRichiestaInfoAzienda.indirizzoRichiestaInfo.value;
	var cap=document.formRichiestaInfoAzienda.capRichiestaInfo.value;
	var comune=document.formRichiestaInfoAzienda.comuneRichiestaInfo.value;
	var provincia=document.formRichiestaInfoAzienda.provinciaRichiestaInfo.value;
	var professione=document.formRichiestaInfoAzienda.professioneRichiestaInfo.value;
	var azienda=document.formRichiestaInfoAzienda.aziendaRichiestaInfo.value;
	var telefono=document.formRichiestaInfoAzienda.telefonoRichiestaInfo.value;
	var email=document.formRichiestaInfoAzienda.emailRichiestaInfo.value;
	var richiesta=document.formRichiestaInfoAzienda.testoRichiestaInfo.value;
	var accetta=document.formRichiestaInfoAzienda.accetta;
	var mex="";
	
	
	if(nome=="")
	{
		error=true;
		mex+="- Nome campo obbligatorio\n";
		
	}
	if(cognome=="")
	{
		error=true;
		mex+="- Cognome campo obbligatorio\n";
		
	}
	if(indirizzo=="")
	{
		error=true;
		mex+="- Indirizzo campo obbligatorio\n";
		
	}
	if(cap=="")
	{
		error=true;
		mex+="- CAP campo obbligatorio\n";
		
	}
	if(comune=="")
	{
		error=true;
		mex+="- Comune campo obbligatorio\n";
		
	}
	if(provincia=="" || provincia =="--")
	{
		error=true;
		mex+="- Provincia campo obbligatorio\n";
		
	}
	if(professione=="" || professione=="--")
	{
		error=true;
		mex+="- Professione campo obbligatorio\n";
		
	}
	
	if(richiesta=="")
	{
		error=true;
		mex+="- Testo richiesta campo obbligatorio\n";
		
	}
	
	if(!accetta.checked)
	{
		error=true;
		mex+="- Accetta l'informativa sulla privacy per continuare\n";
	}
	if(!checkEmail(email))
	{
		error=true;
		mex+="- L'email inserita non e' valida\n";
	}
	
	if(error)
	{
		alert(mex);
		return false;
	}
	else
	{
		return true;
	}
	
}

function archivioNewsData(n)
{
	if(n==0)
	{
		document.formRicercaArchivioNews.archivioNewsDataDal.disabled=false;
		document.formRicercaArchivioNews.archivioNewsDataAl.disabled=false;
		
		document.formRicercaArchivioNews.archivioNewsAnno.disabled=true;
	}
	else
	{
		document.formRicercaArchivioNews.archivioNewsDataDal.disabled=true;
		document.formRicercaArchivioNews.archivioNewsDataAl.disabled=true;
		
		document.formRicercaArchivioNews.archivioNewsAnno.disabled=false;
	}
}
function getArchivioNews(p,c)
{
	$.post("/getArchivioNews.php",{p:p,c:c},function(r){
												var res=r.split("#");
												document.getElementById("risultatiRicercaArchivioNews").innerHTML=res[0];
											
												if(res.length==2)
												{
												document.getElementById("pageArchivioNews").innerHTML=res[1];
												}
									   
									   });
}

function getFormVotaCommenta(t,i)
{
	viewLightBox();
	
	
	
	$.post("/getVotaCommentaSondaggio.php",{t:t,i:i},function(r){
									    document.body.innerHTML+=r;
										
									    var box= $("#focusSondaggioVotaCommentaPack");
	 box.css("position","absolute");
	
	 
     box.css("top", ( $(window).height() - box.height() ) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  box.show();
									  })
	
	
	
}
function stopCommentaSondaggio()
{
	viewLightBox();
	var div = document.getElementById("focusSondaggioVotaCommentaPack");
	$("#focusSondaggioVotaCommentaPack").remove();
	
	//document.body.removeChild(div);
}
function checkCommento()
{/*
	var titolo=document.getElementById("titolo").value;
	var testo=document.focusSondaggioVotaCommentaForm.testo.value;
	var nominativo=document.focusSondaggioVotaCommentaForm.nominativo.value;
	var error=false;
	var messaggio="Attenzione:\n\n";
	
	if(titolo=="")
	{
		messaggio+"- Titolo campo obbligatorio\n";
		error=true
	}
	if(testo=="")
	{
		messaggio+="- Testo campo obbligatorio\n";
		error=true;
	}
	if(nominativo=="")
	{
		messaggio+="- Nominativo campo obbligatorio\n";
		error=true
	}
	if(error)
	{
		alert(messaggio);
		return false
	}
	else
	{
		return true;
	}*/
	return true;
}

function startIscrizioneNewsletter()
{
	viewLightBox();
	var e=document.formHeaderNewsletter.headerNewsletterKey.value;
	
	
	$.post("/getIscrizioneNewsletter.php",{e:e},function(re){
									    document.body.innerHTML+=re
									    var box= $("#iscrivitiNewsletter");
	 box.css("position","absolute");
	
	 
     box.css("top", ( $(window).height() - box.height() ) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  })
	return false;
}


function startIstruzioniEcommerce()
{
	viewLightBox();

	
	
	$.post("/getIstruzioniEcommerce.php",{a:1},function(re){
									    document.body.innerHTML+=re
									    var box= $("#istruzioniEcommerce");
	 box.css("position","absolute");
	

	 
     box.css("top", ( $(window).height()-box.height()) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  })
}

function stopIstruzioniEcommerce()
{
	viewLightBox();
	var div = document.getElementById("istruzioniEcommerce");
	$("#istruzioniEcommerce").remove();
}

function startIstruzioniEcommerce()
{
	viewLightBox();

	
	
	$.post("/getIstruzioniEcommerce.php",{a:1},function(re){
									    document.body.innerHTML+=re
									    var box= $("#istruzioniEcommerce");
	 box.css("position","absolute");
	

	 
     box.css("top", ( $(window).height()-box.height()) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  })
}

function stopInformativaPrivacy()
{
	viewLightBox();
	var div = document.getElementById("informativaPrivacy");
	$("#informativaPrivacy").remove();
}



function startInformativaPrivacy()
{
	viewLightBox();

	
	
	$.post("/getInformativaPrivacy.php",{a:1},function(re){
									    document.body.innerHTML+=re
									    var box= $("#informativaPrivacy");
	 box.css("position","absolute");
	

	 
     box.css("top", ( $(window).height()-box.height()) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  })
}

function stopInformativaPrivacy()
{
	viewLightBox();
	var div = document.getElementById("informativaPrivacy");
	$("#informativaPrivacy").remove();
}



function startContatti()
{
	viewLightBox();

	
	
	$.post("/getContatti.php",{a:1},function(re){
									    document.body.innerHTML+=re
									    var box= $("#contattiLLPP");
	 box.css("position","absolute");
	

	 
     box.css("top", ( $(window).height()-box.height()) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  })
}

function stopContatti()
{
	viewLightBox();
	var div = document.getElementById("contattiLLPP");
	$("#contattiLLPP").remove();
}



function stopIscrizioneNewsletter()
{
	viewLightBox();
	var div = document.getElementById("iscrivitiNewsletter");
	$("#iscrivitiNewsletter").remove();
}

function setApprezzaItem(i)
{
	$.post("/setApprezzaItem.php",{i:i},function(r){
											  document.getElementById("apprezzamentoItem").innerHTML=r;
											  });
	
}
function setApprezzaNews(i)
{
	$.post("/setApprezzaNews.php",{i:i},function(r){
											  document.getElementById("apprezzamentoNews").innerHTML="";
											  document.getElementById("resumeApprezzoNews").innerHTML=" - "+r;
											  });
	
}
var sizeItem=12;
function ingrandisciTestoItem()
{
	
	var maxPx=18;
	var incremento=2;
	
	if((sizeItem+incremento)<=maxPx)
	{
		var size=sizeItem+incremento;
	}
	else
	{
		var size=sizeItem;
	}
	sizeItem=size;

	$(".testoItem").css({ "font-size": size});

	
}
function diminuisciTestoItem()
{
	
	var minPx=12;
	var decremento=2;
	
	if((sizeItem-decremento)>=minPx)
	{
		var size=sizeItem-decremento;
	}
	else
	{
		var size=sizeItem;
	}
	sizeItem=size;
	$(".testoItem").css({ "font-size": size});

	
}

function stopSegnalaLink()
{
	viewLightBox();
	var div = document.getElementById("segnalaLink");
	$("#segnalaLink").remove();
}
function segnalaLink(l)
{
	
	viewLightBox();
	
	
	
	$.post("/getSegnalaLink.php",{l:l},function(r){
									    document.body.innerHTML+=r;
										
									    var box= $("#segnalaLink");
	 box.css("position","absolute");
	
	 
     box.css("top", ( $(window).height() - box.height() ) / 2+$(window).scrollTop() + "px");
     box.css("left", ( $(window).width() - box.width() ) / 2+$(window).scrollLeft() + "px");
									   
									  box.show();
									  })
	
	

}

function aggiungiDestinatario()
{
	var html="<label for=\"segnalaLinkNomeDestinatario[]\">Nome destinatario </label><br /><input type=\"text\" class=\"formGrigio224x25\" id=\"segnalaLinkNomeDestinatario[]\" name=\"segnalaLinkNomeDestinatario[]\" /><br /><label for=\"segnalaLinkEmailDestinatario[]\">Email destinatario </label><br /><input type=\"text\" class=\"formGrigio224x25\" id=\"segnalaLinkEmailDestinatario[]\" name=\"segnalaLinkEmailDestinatario[]\" /><br /><br /> ";
				document.getElementById("segnalaLinkDestinatari").innerHTML+=html;
	
}
