// -------------------------------------------------------
// 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
//-------------------------------------------------------

//-------------------------------------------------------------------//
//-------------------------------------------------------------------//
//<a id="id_prodotto" class="attivo" onclick="javascript: switch_multimedia(this);" >Focus</a>
//<a id="id_thechnical_data"  onclick="javascript: switch_multimedia(this);">Technical data</a>
//<a id="id_foto_gallery" onclick="javascript: switch_multimedia(this);" >Fotogallery</a>
//<a id="id_video_gallery"  onclick="javascript: switch_multimedia(this);">Video</a>
//------------------------------------------------------------------//
//-------------------------------------------------------------------//
//<div id="box_desc_prodotto">
//<div id="gallery_prodotto">
//<div id="video_prodotto">
//<div id="box_data">

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

			
			var id_foto_gallery = document.getElementById('id_foto_gallery');
			if(id_foto_gallery !== null)
				id_foto_gallery.className="noattivo"
			
		
			var id_video_gallery = document.getElementById('id_video_gallery');
			if(id_video_gallery !== null)
				id_video_gallery.className="noattivo";

			/* display */
	
			var corpoFoto = document.getElementById('gallery_prodotto'); 
			if(corpoFoto !== null)
				corpoFoto.style.display="none";
			
			
			var corpoVideo = document.getElementById('video_prodotto'); 
			if(corpoVideo !== null)
				corpoVideo.style.display="none";	
				
			var ContenitoreAllegati = document.getElementById('contenitore_allegati'); 
			if(ContenitoreAllegati !== null)
				ContenitoreAllegati.style.display="block";		
										
			}		
			
		
		if(e.id== 'id_video_gallery'){
		
			document.getElementById('video_prodotto').style.display="block";
			document.getElementById('box_desc_prodotto').style.display="none";
			document.getElementById('id_video_gallery').className="attivo";
						
			/* link */
			
			var id_prodotto = document.getElementById('id_prodotto');
			if(id_prodotto !== null)
				id_prodotto.className="noattivo"
					
			var id_foto_gallery = document.getElementById('id_foto_gallery');
			if(id_foto_gallery !== null)
				id_foto_gallery.className="noattivo"
			
		
			/* display */
	
			var corpoFoto = document.getElementById('gallery_prodotto'); 
			if(corpoFoto !== null)
				corpoFoto.style.display="none";
				
			var ContenitoreAllegati = document.getElementById('contenitore_allegati'); 
			if(ContenitoreAllegati !== null)
				ContenitoreAllegati.style.display="none";			
					

			}		
					
			
				
	if(e.id== 'id_foto_gallery'){
		
			document.getElementById('gallery_prodotto').style.display="block";
			document.getElementById('box_desc_prodotto').style.display="none";
			document.getElementById('contenitore_allegati').style.display="none";
			document.getElementById('id_foto_gallery').className="attivo";
						
			/* link */
			
			var id_prodotto = document.getElementById('id_prodotto');
			if(id_prodotto !== null)
				id_prodotto.className="noattivo"
					
			var id_video_gallery = document.getElementById('id_video_gallery');
			if(id_video_gallery !== null)
				id_video_gallery.className="noattivo"
			
		
			/* display */
	
			var corpoVideo = document.getElementById('video_prodotto'); 
			if(corpoVideo !== null)
				corpoVideo.style.display="none";
				
			var ContenitoreAllegati = document.getElementById('contenitore_allegati'); 
			if(ContenitoreAllegati !== null)
				ContenitoreAllegati.style.display="none";		

		
			}	
			
			
			setFooter();
		
}

