var activetab; 
 
function nextpage(){
  activetab = activetab + 1;
  if(activetab>2)activetab=2;
  stab(activetab,"0,1,2,");
}
function prevpage(){
  activetab = activetab - 1;
  if(activetab<0)activetab=0;
  stab(activetab,"0,1,2,");
}
function stab(nTab,sTabs) {
  var aTab = new Array("BOOK DETAILS","Author","EDITOR");
  var objtab = document.getElementById("explico_tabselector");
  activetab=nTab;
  objtab.innerHTML = "";
  for(i=0; i < 3; 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";
      //o.style.zIndex = 20;
    }
    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";
      // o.style.zIndex = i;
    }
    }
  }

  if(nTab==0){
    $('pag_prev').setStyle('display','none');
    $('pag_next').setStyle('display','block');
  }
  else if(nTab==2){
    $('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_Titolo", "Book title missing.");
    chks("fd_AnnoPubblicazione", "Year of publication missing.");
    chks("fd_Prezzo", "Price missing.");
    chks("fd_SinossiIng", "Synopsis missing.");
    chks("fd_Categoria", "Category missing.");
    chks("fd_NumeroPagine", "Number of pages missing.");
    chks("fd_Dimensioni", "Book dimensions missing.");

		if(!document.getElementById("cb_Coeditore").checked &
			 !document.getElementById("COED2").checked
			 ){
			if(err==""){
				err = "You have not specified if there is a co-editor.";
			}
    }

		if(document.getElementById("cb_Coeditore").checked){
			chks("fd_NoteCoeditore", "Co-editor details missing.");
    }

		if(trim(document.getElementById('cast_details').innerHTML)==""){
			if(err==""){err="Author missing.";}
		}

    chks("fd_RagioneSociale", "Publishing house missing.");
    chks("fd_Citta", "Manca la città dell'editore.");
    chks("fd_Indirizzo", "Address of publishing house missing.");
    chks("fd_Cap", "Post code of publishing house missing.");
    chks("fd_Prov", "Province of publishing house missing.");
    chks("fd_Nazione", "Nation of publishing house missing.");
    chks("fd_Telefono", "Telephone number of publishing house missing.");
    chks("fd_Email", "Email of publishing house missing.");
    chke("fd_Email", "Wrong email of publishing house.");
		
    chkr("cb_Privacy", "Please accept the treatment of private data.");
    chks("fd_DataPrivacy", "Date missing for acceptance of privacy.");
    chkd("fd_DataPrivacy","Data di accettazione della privacy errata.");
    chks("fd_CognomeNome", "Name and surname missing for agreement of data treatment.");
    chks("fd_EMailPerRicevereConfermaIscrizione", "Please specify email for the pre-filled form which must be printed and signed.");
    chke("fd_EMailPerRicevereConfermaIscrizione", "Wrong email for pre-filled form.");


    if(err!="") { alert(err); x[0].focus(); return;}
    subscribe();
  }

function validateDetail(){
    err="";
    chks("fdd_cognome", "Surname missing.");
    chks("fdd_nome", "Name missing.");
    return err;
}
function submitMessage(){
  document.getElementById('sch').innerHTML='<div style="height:500px;background-color:#000;text-align:center;"><h2 style="padding-top:100px;">Form sent correctly.</h2><h2>To submit another book by the same publisher, click <a href="' + location.pathname + '?book=next">here</a></h2></div>';
}

   function scanLinks() {
            $$('a.moobox-link').each(function(element){
              Moodal = new MoodalWindow( element, {
                height	: 300,
        				width	: 420,
								language : 'en'
              });
            });
            $$('a.moobox-linkedit').each(function(element){
              Moodal = new MoodalWindow( element, {
                height	: 300,
        				width	: 420,
								title : 'Edit',
								language : 'en'
              });
            });
            $$('a.moobox-linkdel').each(function(element){
              MoodalDel = new MoodalWindow( element, {
                height	: 250,
        				width	: 350,
								title : 'Delete',
								language : 'en'
              });
            });
   }


