
var curr_smenu_id=-1 ;
//var page_pour_carnet="";

function visibilite(thingId)
{
    var i;
    var targetElement;
    var max_menu_items = 6;
    for(i=1; i <= max_menu_items; i++){
        targetElement = document.getElementById("divid" + i) ;
        targetElement.className="dividxxN";
        targetElement = document.getElementById("lienmenu" + i) ;
        targetElement.className = "menu-fiche" ;
        if(document.getElementById("menu" + i)==null)
            document.getElementById("current").id="menu"+i;
    }
    targetElement = document.getElementById("divid" + thingId) ;
	//alert(targetElement.className);
    targetElement.className="dividxxV"; ;
    targetElement = document.getElementById("lienmenu" + thingId) ;
    targetElement.className = "menu-fiche-over" ;
    document.getElementById("menu"+thingId).id="current";
}

function fwin(theURL) { //v2.0
  pw2=window.open(theURL,'fpack','scrollbars=YES,resizable=YES,width=748,height=510');
  pw2.window.focus();
}

//window.onload=montre;

function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=30; i++) {
		if (document.getElementById('smenu'+i) && i!=curr_smenu_id) {
			document.getElementById('smenu'+i).style.display='none';
		}
	}
	if (d) {d.style.display='block';}
	//if (page_pour_carnet == "" ) { document.getElementById('imgCARNET').style.display='none'; }
}
//window.onload=liste;
function liste(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('liste'+i)) {document.getElementById('liste'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

function ImageMax(chemin,nom,ref)
   {
   i1 = new Image;
   i1.src = chemin;
   html = '<html><head><title>'+nom+' - Réf : ' +ref+'</title></head><body scroll="no" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" onBlur="top.close()"><IMG src="'+chemin+'" BORDER=0 NAME=ImageMax onLoad="window.resizeTo(document.ImageMax.width+10,document.ImageMax.height+30)"></body></html>';
   popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close()
   };


function inscription()
{
  le_mail = nlh2.mail.value;
  if (le_mail !='') {
  //	alert(le_mail);
	if (MM_validateForm('mail','','isEmail')){ 
	  //alert(le_mail);
      //url_str = 'newsletter.asp?lan=fr&action=abo&serv=aggloperp&langue=fr&mail=' + le_mail;
	  url_str = 'newsletter.asp?action=abo&serv=<%=site_code%>&mail=' + le_mail;
	  //alert(url_str);
      popup =window.open(url_str,'nlhome2','scrollbars=no,status=no,width=400,height=160');
	  popup.window.focus();
	}
  } else { 
    alert('Vous devez préciser un email...'); 
    return;
  }

}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
  	test=args[i+2]; 
	val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- l\'adresse e-mail n\'est pas valide.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' doit contenir un chifres.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' doit contenir chifres antre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') erreurss += '- '+nm+' est obligatoire.\n'; }
  } 
  if (errors) alert('Erreur:\n'+errors); 
  return (errors == '');
}
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;
}

function visu_galeries(le_type,le_theme,gale_type)
{
	if ( le_type == 'galerie' )
	{
		le_link = "gal_visu.asp?site=<%=site_code%>&le_type=diapo&theme="+le_theme+"&galerie_type="+gale_type ;
		pw2=window.open(le_link,'gfpack','scrollbars=NO,resizable=NO,width=600,height=490,top=1,left=1');
  		pw2.window.focus();
	}
	if ( le_type == 'diapo' )
	{
		le_link = "diapo_visu.asp?site=raho&le_type=diapo&theme="+le_theme ;
		pw3=window.open(le_link,'dfpack','scrollbars=NO,resizable=NO,width=270,height=330,top=1,left=1');
  		pw3.window.focus();
	}
}


function impression(id) { //v2.0
  wprn=window.open('articles.asp?id='+id+'&popup=1&noclose=1','imprimer','top=0,left=0,toolbar=yes,scrollbars=yes,status=no,resizable=YES,width=675,height=510');
  wprn.window.focus();
}

function popup(url, longeur, hauteur)
{

var properties=  "width=" + longeur + ",height=" + hauteur +" scrollbars=1;"
var fenetrebis = window.open(url, "", properties);
}


function pwin(theURL) { //v2.0 
  if (theURL.indexOf('?') == -1 ) {
  	theURL = theURL.split('&')[0];
	//alert(theURL.split('&').length);
  }
  pw=window.open(theURL,'ppop','scrollbars=YES,resizable=YES,width=760,height=500');
  pw.window.focus();
}

function fwin2(theURL,haut,larg) { //v2.0  
  w_screen =screen.width;
  h_screen =  screen.height;
  if (larg > (w_screen-20) ) {
  	larg = w_screen-20;
	haut = haut +15;
	scr_bars = 'YES';
  } else {
  	haut = haut -2;
	larg = larg -2;
	scr_bars = 'NO';
  }
  pw2=window.open('pop_up_img.asp?photo='+theURL,'fpack22','left=1,top=1,scrollbars='+scr_bars+',resizable=YES,width='+larg+',height='+haut);
  pw2.window.focus();
}
function fwinZoom(theURL,haut,larg) { //v2.0  
  w_screen =screen.width;
  h_screen =  screen.height;

	scr_bars = 'NO';

  pw2=window.open('zoom_img.php?photo='+theURL,'fpack22','left=1,top=1,scrollbars='+scr_bars+',resizable=YES,width='+larg+',height='+haut);
  pw2.window.focus();
}
function winsndart(theID) { //v2.0
  pw32=window.open('envoyez-article.asp?id='+theID,'fp2ack','scrollbars=NO,resizable=YES,width=448,height=510');
  pw32.window.focus();
}

// activation du menu
   function init_menus() 
  {
	var uls = document.getElementsByTagName('ul');
	for (i=0; i<uls.length;i++)
	{
		if (uls[i].id.match(/slidedown.+/))
		{
			var id = uls[i].id.replace(/[^0-9]/gi, '');
			$(uls[i].id).observe('click', function (event) {
				if (! event.currentTarget)
					var t = event.target.parentNode.parentNode;
				else
					var t = event.currentTarget;
				
				var id = t.id.replace(/[^0-9]/gi, '');
				var listItems = $('slidedown'+id).select('li');
				Effect.multiple(listItems, Effect.Fade);
			});
			$('reset_link'+id).observe('click', function (event) {
				if (! event.currentTarget)
					var t = event.target.parentNode;
				else
					var t = event.currentTarget;
				event.stop(); 
				var id = t.id.replace(/[^0-9]/gi, '');
				var listItems = $('slidedown'+id).select('li');
				Effect.multiple(listItems, Effect.Appear);
			});
		}
	}
  }
  
  
  function toto(id_open) {
	var id=id_open;
	var listItems = $('slidedown'+id).select('li');
	Effect.multiple(listItems, Effect.Appear);

}