// Javascript pour Lichtenberg


/*   fonction d'affichage de popu
adresse= URL de la page
name = nom de la page
x, y = dimensions
top, left = emplacement
*/

var hautecran = screen.height - 100  // Notre variable équivaut à la résolution...


function popupmodulo(adresse, name, x, y, top, left){
	window.open(adresse,name,'location=no,toolbar=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=no,width='+x+',height='+y+',top='+top+',left='+left);
}


/* fonction d'agrandissement d'image
image = nom
vert = 0 si image horizontale
*/

function grandimg(image, vert) {
	if (vert==0) {
		eval('document.'+image+'.height=\"200\"');
		eval('document.'+image+'.width=\"300\"'); }
	else {
		eval('document.'+image+'.height=\"300\"');
		eval('document.'+image+'.width=\"200\"'); }
}

/* fonction de réduction d'image
image = nom
vert = 0 si image horizontale
*/

function petitimg(image, vert) {
	if (vert==0) {
		eval('document.'+image+'.height=\"100\"');
		eval('document.'+image+'.width=\"150\"'); }
	else {
		eval('document.'+image+'.height=\"150\"');
		eval('document.'+image+'.width=\"100\"'); }
}

/* change image principale */

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* vérification de formulaire */

function verifformu() {
	var rempli='true'
	//nom
	if (document.forms[0].nom.value=="") {
	window.alert('Champ NOM obligatoire');
	return;	
	}
	
	//prenom
	if (document.forms[0].prenom.value=='') {
	window.alert('Champ PRENOM obligatoire');
	return;	
	}
	
	//email téléphone adresse
	if ((document.forms[0].telep.value=='') && (document.forms[0].email.value=='') && (document.forms[0].adresse.value=='')) {
	window.alert('Un des 3 éléments est obligatoire : téléphone, email ou adresse');
	return;	
	}

	//contenu
	if (document.forms[0].comment.value=='') {
	window.alert('Vous ne pouvez envoyer un message vide');
	return;	
	}
	
	
	document.forms[0].submit();
}

/* vérification de formulaire */

function verifreserve() {
	var rempli='true'
	//nom
	if (document.forms[0].nom.value=="") {
	window.alert('Champ NOM obligatoire');
	return;	
	}
	
	//prenom
	if (document.forms[0].prenom.value=='') {
	window.alert('Champ PRENOM obligatoire');
	return;	
	}
	
	//email téléphone adresse
	if (document.forms[0].phone.value=='') {
	window.alert('Champ TELEPHONE obligatoire');
	return;	
	}
	
	var ok=0;
	for (var i=0; i<document.forms[0].repres.length;i++) 
		{
		if (document.forms[0].repres[i].checked) 
			{
			ok=1;
        	}
		}
		if (ok==0) 
		{
		window.alert('Choisir une date ');
		return;
		}

	if (document.forms[0].nbplaces.value==0) {
	window.alert('Choisir le nombre de places');
	return;
	}


//	window.alert(document.forms[0].repres.value);
	document.forms[0].submit();
}


function open_ext_link()
{
	var liens = document.getElementsByTagName('a');
	// On récupère tous les liens (<a>) du document dans une variable (un array), ici liens.
	// Une boucle qui parcourt le tableau (array) liens du début à la fin.
	for (var i = 0 ; i < liens.length ; ++i)  {
		// Si les liens ont un nom de class égal à lien_ext, alors on agit.
		if (liens[i].className == 'lien_ext')  {
			liens[i].title = 'S\'ouvre dans une nouvelle fenêtre';
			// Au clique de la souris.
			liens[i].onclick = function()  {
				window.open(this.href);
				return false; // On ouvre une nouvelle page ayant pour URL le href du lien cliqué et on inhibe le lien réel.
			};
		}
	}
}

/*
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

*/

function nouvphoto(ind) {
	numero = parseInt(document.formu.numfile.value);
	total = parseInt(document.formu.nbfiles.value);
	switch(ind) {
		case 1 :
			window.location.href='photos.php?numfile=1';
			break;
		case 2 :
			if (numero > 1) numero--;
			window.location.href='photos.php?numfile=' + numero;
			break;
		case 3 :
			if (numero < total) numero++;
			window.location.href='photos.php?numfile=' + numero;
			break;
		case 4 :
			window.location.href='photos.php?numfile=' + total;
			break;			
	}
}
