// -------------------------------------------------------
// galleria generale: selezione di una categoria di immagini
// -------------------------------------------------------
function SelectCategory(myvalue,url2prepend)
{
	var interfaceLanguage=document.getElementById('selectCategory').lang.value;
	document.location.href = url2prepend+"&categoria="+myvalue+"&lang="+interfaceLanguage;
}



// -------------------------------------------------------
// validazione registrazione
// -------------------------------------------------------
function validateRegistrazione()
{
 
  var nome    = document.getElementById('newsletterForm').registrazione_nome.value;
  var cogn    = document.getElementById('newsletterForm').registrazione_cognome.value;
  var mail    = document.getElementById('newsletterForm').registrazione_mail.value;
  var captcha = document.getElementById('newsletterForm').registrazione_captcha.value;
  
  
  if (nome && mail && cogn && captcha )
  {
    
    	if (mail.indexOf('@',0) != -1 && mail.indexOf('.',0) != -1)
         return true;
      else
      {
        alert('inserire un indirizzo di mail corretto.');
        return false;
      }
   
  }
  else
  {
     alert('compilare tutti i campi obbligatori.');
     return false;
  }
}

function validateUnRegistrazione()
{
 
  var mail    = document.getElementById('newsletterFormUn').registrazione_mail.value;
  
  
  if (mail)
  {
    
    	if (mail.indexOf('@',0) != -1 && mail.indexOf('.',0) != -1)
         return true;
      else
      {
        alert('inserire un indirizzo di mail corretto.');
        return false;
      }
   
  }
  else
  {
     alert('compilare tutti i campi obbligatori.');
     return false;
  }
}



// -------------------------------------------------------
// apertura pagina di edit delle schede
// -------------------------------------------------------
function EditSk(page)
{
  var wnd = window.opener;
  
  if ( (wnd != null) && (!wnd.closed) )
  {
    wnd.focus();
    wnd.location.href = page;
  }  
  else
    OpenWindow(page, 'EditSk', 700, 500);
}


// -------------------------------------------------------
// messaggio di conferma
// -------------------------------------------------------
function ConfirmDelete(msg)
{
  return confirm(msg);
}

// -------------------------------------------------------
// permette di digitare solo numeri
// -------------------------------------------------------
function numbersonly(myfield, e, dec)
{
  var key;
  var keychar;
  
  if (window.event)
     key = window.event.keyCode;
  else if (e)
     key = e.which;
  else
     return true;
  keychar = String.fromCharCode(key);
  
  // control keys
  if ((key==null) || (key==0) || (key==8) || 
      (key==9) || (key==13) || (key==27) )
     return true;
  
  // numbers
  else if ((("0123456789").indexOf(keychar) > -1))
     return true;
  
  // decimal point jump
  else if (dec && (keychar == "."))
     {
     myfield.form.elements[dec].focus();
     return false;
     }
  else
     return false;
}

// -------------------------------------------------------
// permette di digitare solo numeri e lettere
// -------------------------------------------------------
function letternumber(e)
{
  var key;
  var keychar;
  
  if (window.event)
     key = window.event.keyCode;
  else if (e)
     key = e.which;
  else
     return true;
  keychar = String.fromCharCode(key);
  keychar = keychar.toLowerCase();
  
  // control keys
  if ((key==null) || (key==0) || (key==8) || 
      (key==9) || (key==13) || (key==27) )
     return true;
  
  // alphas and numbers
  else if (((" '.-abcdefghijklmnopqrstuvwxyz0123456789àèìòù?_,éç&âäèêëöüçß&()").indexOf(keychar) > -1))
     return true;
  else
     return false;
}

// -------------------------------------------------------
// classica openWindow
// -------------------------------------------------------
function OpenWindow(url, windowName, w, h)
{
   var wf = "";
   wf = wf + "width=" + w;
   wf = wf + ",height=" + h;
   wf = wf + ",resizable=yes";
   wf = wf + ",scrollbars=yes";
   wf = wf + ",menubar=no";
   wf = wf + ",toolbar=yes";
   wf = wf + ",directories=no";
   wf = wf + ",location=no";
   wf = wf + ",status=yes";
   var wnd = window.open(url,windowName,wf);
   wnd.focus();
}


// -------------------------------------------------------
// si muove tra le pagine del navigatore
// -------------------------------------------------------
function ChangeOffset(NewOffset) {
	if (document.getElementById('mainForm')) {
		var navigator_form=document.getElementById('mainForm');
		navigator_form.last_record.value=NewOffset;
		navigator_form.submit();
	} else {
		document.mainForm.last_record.value = NewOffset;
		document.mainForm.submit();
	}
}


// -------------------------------------------------------
// posiziona un'immagine secondaria come principale
// -------------------------------------------------------
/*
echo '<img id="placeholder" src="immagini/nrm/'.$main_image_name.'.jpg" alt="'.$main_image_alt.'" title="'.$main_image_alt.'"';

$photogallery=PrintSkGallery(
	//ID scheda corrente
	$id,
	//ruolo link
	LINKS_ROLE_GALLERY,
	//mostro il link x zoom immagine?
	false,
	//URL da sostituire
	'',//'index.php?page=zoom&amp;image_id=#IMG_ID#&amp;lang='.$lang,
	//il nome del file nel DB contiene l'estensione?
	false,
	//testo da stampare prima del record
	'<a onclick="return showPic(this,\'div_id\');" href="immagini/nrm/#IMG_FILE_NAME_TAG#.jpg">',
	//testo da stampare dopo del record
	'<img src="immagini/prw/#IMG_FILE_NAME_TAG#.jpg" alt="#IMG_DIDA#" title="#IMG_DIDA#" /></a>',
	//SQL x ordinamento
	'',
	//stampo il tag "<img>"?
	false,
	//tipologia della tabella master
	LINKS_SK_TYPE
);
*/

// -------------------------------------------------------
// switch etichette per allegati e photogalleryy
// -------------------------------------------------------


function switch_multimedia (e) {
		
	if(e.id== 'id_allegato'){
		
		
		document.getElementById('corpo_allegato').style.display="block";
			
			/* link */
			
			var id_allegato = document.getElementById('id_allegato');
			if(id_allegato !== null)
				id_allegato.className="attivo"

			
			var id_link = document.getElementById('id_link');
			if(id_link !== null)
				id_link.className="noattivo"
			
		
			var id_video = document.getElementById('id_video');
			if(id_video !== null)
				id_video.className="noattivo";
				
			var id_foto = document.getElementById('id_foto');
			if(id_foto !== null)
				id_foto.className="noattivo";	

			/* display */
	
			var corpoFoto = document.getElementById('corpo_foto'); 
			if(corpoFoto !== null)
				corpoFoto.style.display="none";
			
			
			var corpoLink = document.getElementById('corpo_link'); 
			if(corpoLink !== null)
				corpoLink.style.display="none";	
				
			var corpoVideo = document.getElementById('corpo_video'); 
			if(corpoVideo !== null)
				corpoVideo.style.display="none";		
		

			}
			
			
		
	if(e.id== 'id_link'){
		
		
		document.getElementById('corpo_link').style.display="block";
			
			/* link */
			
			var id_allegato = document.getElementById('id_allegato');
			if(id_allegato !== null)
				id_allegato.className="noattivo"

			
			var id_link = document.getElementById('id_link');
			if(id_link !== null)
				id_link.className="attivo"
			
		
			var id_video = document.getElementById('id_video');
			if(id_video !== null)
				id_video.className="noattivo";
				
			var id_foto = document.getElementById('id_foto');
			if(id_foto !== null)
				id_foto.className="noattivo";	

			/* display */
	
			var corpoFoto = document.getElementById('corpo_foto'); 
			if(corpoFoto !== null)
				corpoFoto.style.display="none";
			
			
			var corpoAllegato = document.getElementById('corpo_allegato'); 
			if(corpoAllegato !== null)
				corpoAllegato.style.display="none";	
				
			var corpoVideo = document.getElementById('corpo_video'); 
			if(corpoVideo !== null)
				corpoVideo.style.display="none";		
		
				
		
	
	}
	
	if(e.id== 'id_video'){
		
		document.getElementById('corpo_video').style.display="block";
			
			/* link */
			
			var id_allegato = document.getElementById('id_allegato');
			if(id_allegato !== null)
				id_allegato.className="noattivo"

			
			var id_link = document.getElementById('id_link');
			if(id_link !== null)
				id_link.className="noattivo"
			
		
			var id_video = document.getElementById('id_video');
			if(id_video !== null)
				id_video.className="attivo";
				
			var id_foto = document.getElementById('id_foto');
			if(id_foto !== null)
				id_foto.className="noattivo";	

			/* display */
	
			var corpoFoto = document.getElementById('corpo_foto'); 
			if(corpoFoto !== null)
				corpoFoto.style.display="none";
			
			
			var corpoAllegato = document.getElementById('corpo_allegato'); 
			if(corpoAllegato !== null)
				corpoAllegato.style.display="none";	
				
			var corpoLink = document.getElementById('corpo_link'); 
			if(corpoLink !== null)
				corpoLink.style.display="none";		
	}
	
	if(e.id== 'id_foto'){
		
		document.getElementById('corpo_foto').style.display="block";
			
			/* link */
			
			var id_allegato = document.getElementById('id_allegato');
			if(id_allegato !== null)
				id_allegato.className="noattivo"

			
			var id_link = document.getElementById('id_link');
			if(id_link !== null)
				id_link.className="noattivo"
			
		
			var id_video = document.getElementById('id_video');
			if(id_video !== null)
				id_video.className="noattivo";
				
			var id_foto = document.getElementById('id_foto');
			if(id_foto !== null)
				id_foto.className="attivo";	

			/* display */
	
			var corpoVideo = document.getElementById('corpo_video'); 
			if(corpoVideo !== null)
				corpoVideo.style.display="none";
			
			
			var corpoAllegato = document.getElementById('corpo_allegato'); 
			if(corpoAllegato !== null)
				corpoAllegato.style.display="none";	
				
			var corpoLink = document.getElementById('corpo_link'); 
			if(corpoLink !== null)
				corpoLink.style.display="none";	
						}
	setFooter();
		
}



