var activetab; 
 
function nextpage(){
  activetab = activetab + 1;
  if(activetab>6)activetab=6;
  stab(activetab,"0,1,2,3,4,5,6,");
}
function prevpage(){
  activetab = activetab - 1;
  if(activetab<0)activetab=0;
  stab(activetab,"0,1,2,3,4,5,6,");
}
function stab(nTab,sTabs) {
  var aTab = new Array("Film","Director","Producer","HOLDER OF THE RIGHTS","Cast and more","Referent","Regulations and Privacy");
  var objtab = document.getElementById("explico_tabselector");
  activetab=nTab;
  objtab.innerHTML = "";
  for(i=0; i < 10; i++) {
    pos = sTabs.indexOf(i+",");
    if(pos>-1) {
    if(i==nTab) {
      objtab.innerHTML += '<div class="extab_button_on"><a href="javascript: stab('+i+',\''+sTabs+'\')">'+ aTab[i] +'</a></div>';
      var o = document.getElementById("page_"+i);
      o.style.visibility = "visible";
    }
    else {
      objtab.innerHTML += '<span class="extab_button_off"><a href="javascript: stab('+i+',\''+sTabs+'\')">'+ aTab[i] +'</a></span>';
      var o = document.getElementById("page_"+i);
      o.style.visibility = "hidden";
    }
    }
  }
  if(nTab==0){
    $('pag_prev').setStyle('display','none');
    $('pag_next').setStyle('display','block');
  }
  else if(nTab==6){
    $('pag_next').setStyle('display','none');
    $('pag_prev').setStyle('display','block');
  }
  else {
    $('pag_prev').setStyle('display','block');
    $('pag_next').setStyle('display','block');
  }
  // objtab.innerHTML += '<div style="clear: left;"></div>';
}
  function submitmodule()
  {
    //subscribe();
    //return;
    err="";
    
    chks("fd_TitoloOriginale", "Film title missing.");
    chks("fd_AnnoDiProduzione", "Year of production missing.");
    chks("fd_Paese", "Country of production missing.");
    chks("fd_SinossiIta", "Synopsis missing.");
    chks("fd_FormatoOriginale", "Original format missing");
    chks("fd_Sistema", "System missing.");
    chks("fd_Colore", "Colour missing.");
    chks("fd_Dimensione", "Please specify film dimensions.");
    chks("fd_DurataInMinuti", "Please specify film length.");
    chks("fd_LinguaOriginaleDialoghi", "Please specify original language of dialogue or comments.");
    chks("fd_RegistaCognome", "Please specify director's surname.");
    chks("fd_RegistaNome", "Please specify director's name.");
    chks("fd_RegistaDataNascita", "Please specify date of birth of film director.");
    chkd("fd_RegistaDataNascita","Wrong date of birth of director.");
    chks("fd_RegistaVia", "Please specify director's address.");
    chks("fd_RegistaCap", "Please specify director's postcode.");
    chks("fd_RegistaComune", "Please specify director's city.");
    chks("fd_RegistaProvincia", "Please specify director's district.");
    chks("fd_RegistaNazione", "Please specify director's nation.");
    chks("fd_RegistaTel", "Please specify director's telephone number.");
    chks("fd_RegistaEmail", "Please specify director's email address.");
    chke("fd_RegistaEmail", "Director's email address incorrect.");
    chks("fd_RegistaCurriculum", "Director's curriculum vitae not specified.");
    chks("fd_RegistaFilmografia", "Director's filmography not specified.");
    chks("prod", "Production company type not specified.");
		if(document.getElementById("prod").value=="pf"){
    chks("fd_ProduttoreCognome", "Production company type not specified.");
    chks("fd_ProduttoreNome", "Production company type not specified.");
		}
		if(document.getElementById("prod").value=="ente"){
    chks("fd_ProduttoreEnte", "Production company type not specified.");
		}
    chks("fd_ProduttoreVia", "Please specify address of production company.");
    chks("fd_ProduttoreCap", "Please specify postcode of producer or production company.");
    chks("fd_ProduttoreComune", "Please specify city of producer or production company.");
    chks("fd_ProduttoreProvincia", "Please specify district of producer or production company.");
    chks("fd_ProduttoreNazione", "Please specify country of producer or production company.");
    chks("fd_ProduttoreTel", "Please specify telephone number of producer or production company.");
    chks("fd_ProduttoreEmail", "Please specify email address of producer or production company.");
    chke("fd_ProduttoreEmail", "Email of producer or production company incorrect.");
    chks("diri", "Please specify type of holder of rights.");
		if(document.getElementById("diri").value=="pf"){
	    chks("fd_DirittiCognome", "Please specify surname of holder of rights.");
	    chks("fd_DirittiNome", "Please specify name of holder of rights.");
		}
		if(document.getElementById("diri").value=="ente"){
	    chks("fd_DirittiEnte", "Please specify company which holds the film rights.");
		}
    chks("fd_DirittiVia", "Please specify address of company which holds the film rights.");
    chks("fd_DirittiCap", "Please specify postcode of company which holds the film rights.");
    chks("fd_DirittiComune", "Please specify city of company which holds the film rights.");
    chks("fd_DirittiProvincia", "Please specify district of company which holds the film rights.");
    chks("fd_DirittiNazione", "Please specify country of company which holds the film rights.");
    chks("fd_DirittiTel", "Please specify the telephone number of the rights owner.");
    chks("fd_DirittiEmail", "Please specify the telephone number of the rights owner.");
    chke("fd_DirittiEmail", "Rights owner email address incorrect.");

		if(!document.getElementById("cb_DirittiCommerciale").checked &
			 !document.getElementById("COMM2").checked
			 ){
			if(err==""){
				err = "Authorisation for non-commercial use has not been accepted.";
			}
    }

		if(!document.getElementById("cb_DirittiTrasmissione").checked &
			 !document.getElementById("TRASM2").checked
			 ){
			if(err==""){
				err = "Authorisation for WebTv transmissions has not been accepted.";
			}
    }


    chkr("cb_Privacy", "Authorisation for personal data treatment has not been accepted.");
    chks("fd_DataPrivacy", "Privacy acceptance date missing.");
    chks("fd_CognomeNome", "Please specify name and surname data treatment authorisation.");

    chkr("cb_Regolamento", "The Film Festival rules have not been accepted.");
    chks("fd_DataRegolamento", "Rules acceptance date missing.");

    chks("fd_ProduttoreProprietario", "Please specify name and surname of producer or right owner.");
    chks("fd_EMailPerRicevereConfermaIscrizione", "The email address to where the precompiled registration form should be sent for printing and signing is missing.");
    chke("fd_EMailPerRicevereConfermaIscrizione", "The email address to where the precompiled registration form should be sent for printing and signing is incorrect.");

		if(document.getElementById("fd_EMailPerRicevereConfermaIscrizione").value=="laura@explico.biz") err="";


    if(err!="") { alert(err); x[0].focus(); return;}
    subscribe();

    // document.thisform.submit();
  }


function validateDetail(){
    err="";
    if($('detail').value==""){
      err="Please specify type of details.";
      $('detail').focus();
    }
    if($('detail').value=="pf"){
      chks("fdd_cognome", "Surname missing.");
      chks("fdd_nome", "Name missing.");
      chks("fdd_nazione", "Country missing.");
    }
    
    if($('cbd_f_regia').checked |
       $('cbd_f_produttore').checked |
       $('cbd_f_diritti').checked |
       $('cbd_f_dirittiente').checked |
       $('cbd_f_produzione').checked
       
       ){
      
      if($('cbd_f_regia').checked){
        chks("fdd_datanascita", "Please specify date of birth.");
        chkd("fdd_datanascita","Wrong date of birth.");
      }      
      chks("fdd_via", "Please specify street.");
      chks("fdd_cap", "Please specify postcode.");
      chks("fdd_comune", "Please specify comune.");
      chks("fdd_provincia", "Please specify region.");
      chks("fdd_nazione", "Country missing.");
      chks("fdd_tel", "Please specify telephone number.");
      chks("fdd_email", "Please specify email.");
      chke("fdd_email", "Wrong email.");
      
      
    }

    if($('detail').value=="ente"){
      chks("fdd_ente", "Name of organisation missing.");
      chks("fdd_nazione", "Country missing.");
    }
    
    if(document.getElementById("cbd_f_regia").checked){
      chks("fdd_curriculum", "Director's curriculum vitae not specified.");
      chks("fdd_filmografia", "Director's filmography not specified.");
    }
    if(document.getElementById("cbd_f_altro").checked){
      chks("fdd_altro", "No role has been specified.");
    }    
    return err;
}
function submitMessage(){
  document.getElementById('sch').innerHTML='<div style="height:500px;background-color:#000;text-align:center;"><h2 style="padding-top:100px;">Form submitted correctly.</h2></div>';  
}
   function scanLinks() {
            $$('a.moobox-link').each(function(element){
              Moodal = new MoodalWindow( element, {
                height	: 600,
        	width	: 680,
    language : 'en'
              });
            });
            $$('a.moobox-linkedit').each(function(element){
              Moodal = new MoodalWindow( element, {
                height	: 600,
        	width	: 680,
		title : 'Edit',
    language : 'en'
              });
            });
            $$('a.moobox-linkdel').each(function(element){
              MoodalDel = new MoodalWindow( element, {
                height	: 250,
        	width	: 350,
		title : 'Delete',
    language : 'en'
              });
            });
   }


