
function showdiv(ID) {
	var DIV = document.getElementById(ID);
	var display = DIV.style.display;
	DIV.style.display = (display == "block") ? "none" : "block";	
}

function GID(id){
	return document.getElementById(id);
}

function CustomPopup(link,w,h){

	/*GID('popup').style.zIndex=1000000;*/
	GID('popup').innerHTML='';
	if( GID('loghi') )
		hide('loghi');
	h=h-25;
	GID('popup').style.width=w+"px";
	GID('popup').style.height=h+"px";
	GID('popup').style.top="400px";
	GID('popup').style.left=(screen.width/2-w/2)+"px";
	GID('popup').style.display="block";
	getURL(link,"popup");
}

function CloseCustomPopup(){
	GID('popup').style.display="none";
}

function FormLogin(){

   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   if ( ! Filtro.test(document.login.username.value) ) {
      alert('Controlla indirizzo Email!');
      return false;
   }

   var password = document.login.password.value;
   if ( password.length < 6 ) {
      alert('inserire password - minimo 6 caratteri!');
      return false;
   }

   return true;
}

function IsPhoneNumber(Expression){
    Expression = Expression.toLowerCase();
    RefString = "0123456789";
    
    if (Expression.length == 0) return (false);
    
    for (var i = 0; i < Expression.length; i++) 
    {
        var ch = Expression.substr(i, 1);
        var a = RefString.indexOf(ch, 0);
        if (a == -1)
            return (false);
    }
    return(true);
}

function Max2check(){
	var count = 0;
	if( document.frmcontatto.sw_civil.checked==true ) count++;
	if( document.frmcontatto.sw_gen1.checked==true ) count++;
	if( document.frmcontatto.sw_gen2.checked==true ) count++;
	if( document.frmcontatto.sw_gts1.checked==true ) count++;
	if( document.frmcontatto.sw_gts2.checked==true ) count++;
	if( document.frmcontatto.sw_geo5.checked==true ) count++;
	return count;			
}

function Testform(){

   if ( Max2check()>2 ) {
      alert('Puoi selezionare al massimo 2 tematiche di interesse!');
      return false;
   }

  if(document.frmcontatto.nome_cognome.value == ''){
  	alert('Il campo Cognome Nome è obbligatorio!');
  	document.frmcontatto.nome_cognome.focus();
  	return false;
  }


   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

   if ( ! Filtro.test(document.frmcontatto.email.value) ) {
      alert('Controlla l\'indirizzo Email inserito!');
      document.frmcontatto.email.focus();
      return false;
   }

   var inputPWD = document.getElementById("password");
   if ( inputPWD != null ){
	if(document.frmcontatto.password.value == '' || document.frmcontatto.password.value.length<6 ){
		alert('Il campo Password è obbligatorio e deve essere almeno di 6 caratteri alfanumerici!');
		document.frmcontatto.password.focus();
		return false;
	}      
   }

   if (IsPhoneNumber(document.frmcontatto.telefono.value)==false) {
      alert('Il campo Telefono è obbligatorio! Inserire solo numeri!');
      document.frmcontatto.telefono.focus();
      return false;
   }

   if (IsPhoneNumber(document.frmcontatto.cap.value)==false) {
      alert('Il campo CAP è obbligatorio! Inserire solo numeri!');
      document.frmcontatto.cap.focus();
      return false;
   }
   
  if(document.frmcontatto.citta.value == '') {
  	alert('Il campo Città è obbligatorio!');
  	document.frmcontatto.citta.focus();
  	return false;
  }

  if(document.frmcontatto.provincia.value == '') {
  	alert('Il campo Provincia è obbligatorio!');
  	document.frmcontatto.provincia.focus();
  	return false;
  }
  
  if(document.frmcontatto.indirizzo.value == '') {
  	alert('Il campo Indirizzo è obbligatorio!');
  	document.frmcontatto.indirizzo.focus();
  	return false;
  }

   if (document.frmcontatto.privacy.checked==false) {
      alert('Devi accettare l\'informativa sulla privacy per inviare i tuoi dati!');
      document.frmcontatto.privacy.focus();
      return false;
   }
     
  return true;

}

/*************************************JQuery****************************************************/

	$(window).load(function() {
	
		$('#slider').nivoSlider();
		
		if(!NiftyCheck()) return;
		Rounded("div#nifty","all","#FFF","#dadada","smooth");
		Rounded("div.nifty","all","#E1E324","#fff","smooth"); // per eventi.php
		Rounded("div#nifty_green","all","#fff","#19603B","smooth"); // per fine_geo5.php


		$().piroBox({
				my_speed: 600, //animation speed
				bg_alpha: 0.6, //background opacity
				radius: 4, //caption rounded corner
				scrollImage : false, // true == image follows the page, false == image remains in the same open position
				pirobox_next : 'piro_next', // Nav buttons -> piro_next == inside piroBox , piro_next_out == outside piroBox
				pirobox_prev : 'piro_prev',// Nav buttons -> piro_prev == inside piroBox , piro_prev_out == outside piroBox
				close_all : '.piro_close',// add class .piro_overlay(with comma)if you want overlay click close piroBox
				slideShow : 'slideshow', // just delete slideshow between '' if you don't want it.
				slideSpeed : 4 //slideshow duration in seconds(3 to 6 Recommended)
		});


		
	        $("div#controller").jFlow({
			slides: "#slides",
			controller: ".jFlowControl", // must be class, use . sign
			slideWrapper : "#jFlowSlide", // must be id, use # sign
			selectedWrapper: "jFlowSelected",  // just pure text, no sign
			auto: true,		//auto change slide, default true
			width: "700px",
			height: "130px",
			duration: 2500,
			prev: ".jFlowPrev", // must be class, use . sign
			next: ".jFlowNext" // must be class, use . sign
	        });

    
		$("#pagina-supporto").organicTabs();
		
	});


function mostraDivScorrevole(){	$("#divScorrevole").animate({"height": "toggle"}, { duration: 1000 }); }
function mostraDivScorrevole2(){ $("#divScorrevole2").animate({"height": "toggle"}, { duration: 1000 }); }
function mostraDivScorrevole3(){ $("#divScorrevole3").animate({"height": "toggle"}, { duration: 1000 }); }

function mostraDivScorrevole_prodotto(){ $("#divScorrevoleRelease").animate({"height": "toggle"}, { duration: 1000 }); }	

function mostraDivScorrevole_testo_gts(){ $("#divScorrevoleGTS").animate({"height": "toggle"}, { duration: 1000 }); }

function openThickbox(title,url){ tb_show(title, url); }


