
//accordion
$(document).ready(function() {
	$(".content").hrzAccordion({
			openOnLoad    	   : "1",
			handlePosition     : "left",
			containerClass     : "container",
			listItemClass      : "listItem",					
			
			contentWrapper     : "contentWrapper",
			contentInnerWrapper: "contentInnerWrapper",
			handleClass        : "handle",
			handleClassOver    : "handleOver",
			handleClassSelected: "handleSelected",
			cycle			   : true, // not integrated yet, will allow to cycle through tabs by interval
			cycleInterval	   : 5000
							  });
 });

//colorbox
$(document).ready(function(){
	$(".video").colorbox({width:885, height:514, iframe:true});
});

//newsletter
function check_fields_newsletter(){
	firstName=document.subscribe.firstName.value
	lastName=document.subscribe.lastName.value
	email=document.subscribe.email.value
	
	if(firstName == "" || firstName == "Nome" || firstName == null || !isNaN(firstName) || firstName.charAt(0) == ' ') {
	    alert('Nome obbligatorio');
		return false;
	}
	else if(lastName == "" || lastName == "Cognome" || lastName == null || !isNaN(lastName) || lastName.charAt(0) == ' '){
		alert('Cognome obbligatorio');
		return false;
	}
	else if(!indirizzoEmailValido(email)){
		alert('Indirizzo email non valido');
		return false;
	}
	else if(document.subscribe.privacy.checked==false){
		alert('Per procedere con l\'invio del modulo e\' necessario accettare le condizioni presenti nell\'informativa.');
		return false;
	}
	else{
		return true;
	}
}
function indirizzoEmailValido(indirizzo) {
  if (window.RegExp) {
    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(nonvalido);
    var regv = new RegExp(valido);
    if (!regnv.test(indirizzo) && regv.test(indirizzo))
      return true;
    return false;
	}
  else {
    if(indirizzo.indexOf("@") >= 0)
      return true;
    return false;
  	}
};
