// Calques
function findObj(theObj, theDoc)
{
  var p, i, foundObj;  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);}
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-1); i+=2){
    if ((obj = findObj(args[i])) != null){
      visStr = args[i+1];
      if (obj.style){
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';}
      obj.visibility = visStr;}
  }
}
function showcalq(calque){ // avec une liste établie
	var i,visi,obj;
	for(i=0; i<calq.length; i++){
		visi=calq[i]==calque?'show':'hide';
	    if ((obj = findObj(calq[i])) != null){
	      	if (obj.style){
    	    	obj = obj.style;
				visi=calq[i]==calque?'visible':'hidden';}
			obj.visibility=visi;
		}
	}
}
function show1calq(calque){
	var obj;
	if ((obj = findObj(calque)) != null){
		if (obj.style){
    	  obj = obj.style;
				obj.visibility='visible';}
		else obj.visibility='show';
	}
}
function hide1calq(calque){
	var obj;
	if ((obj = findObj(calque)) != null){
		if (obj.style){
    	  obj = obj.style;
				obj.visibility='hidden';}
		else obj.visibility='hide';
	}
}
function setLayersHeight(){ 
	var i, obj, args = setLayersHeight.arguments;
	h=screen.height-60;
	if (h<800) h=800;
  for (i=0; i<(args.length); i++){
    if ((obj = findObj(args[i])) != null){
			if (obj.style) obj = obj.style;
			if (document.layers) obj.height=h;
			else obj.height = h+'px';
		}
	}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// fenetres pop-ups d'etiquette et de prix

var ff,ff2,ff3;
function WinPop(fname,titre,params) {
  if (ff3==null || ff3.closed)ff3=window.open(fname,titre,params);
  else ff3.focus();
}  
// sans scrollbars avec resize
function WinPopa(fname,w,h) {
  if (ffa==null || ffa.closed) ffa=window.open(fname,'HotelPLM','resizable=yes,scrollbars=no,width='+w+',height='+h);
  else {
 	ffa.focus();
	ffa.resizeTo(w+12,h+36);
	ffa.location.href=fname;
  }
}
// Generique 
function wPop(fname,larg,haut) {
  if (ff==null || ff.closed)ff=window.open(fname,"HotelPLM","scrollbars=yes,resizable=yes,width="+larg+",height="+haut);
  else{
   ff.focus();
   ff.location.href=fname;
  }
}
// Generique avec dimensions par défaut ("Bonjour c'est POP2") ;-)
function wPop2(fname) {
  if (ff==null || ff.closed)ff=window.open(fname,"HotelPLM","scrollbars=yes,resizable=yes,width=750,height=600");
  else{ff.focus();ff.location.href=fname;}
}
function wPop2x(fname) {
  if (ff==null || ff.closed)ff=window.open(fname,"HotelPLM","scrollbars=yes,resizable=yes,width=950,height=600");
  else{ff.focus();ff.location.href=fname;}
}
//Generique avec resize
function WinPopRs(fname,w,h) {
  if (ff3==null || ff3.closed) ff3=window.open(fname,'HotelPLM','resizable=yes,scrollbars=yes,width='+w+',height='+h);
  else {
 	ff3.focus();
	ff3.resizeTo(w+12,h+36);
	ff3.location.href=fname;
  }
}
function ferme_popup(){
   if(ff && !ff.closed) ff.close();
   ff=null;
   if(ff2 && !ff2.closed) ff2.close();
   ff2=null;
   if(ff3 && !ff3.closed) ff3.close();
   ff3=null;
}


var timerID = null;
var timerOn = false;
var timecount = 500;
var menudown =0;

function showMenu(nummenu){
	stopTim();
	closeMenu();
	menudown=nummenu;
	show1calq('smliens'+menudown);
}
function closeMenu(){
	if (menudown){hide1calq('smliens'+menudown);menudown=0;}
}
function startTim() {if (timerOn == false) {timerID=setTimeout( "closeMenu()" , timecount);timerOn = true;}}
function stopTim() {if (timerOn) {clearTimeout(timerID);timerID = null;timerOn = false;}}
var ffama;
function AmaLeg(fname){if (ffama==null || ffama.closed) ffama=window.open(fname,"","scrollbars=yes,resizable=yes,width=490,height=480");else{ffama.focus();ffama.location.href=fname;}}

function setprof()
{ 
if (navigator.appName == "Netscape" && eval(navigator.appVersion.substring(0,3) ) < 5) document.pge.document.mainpg.document.courrier.prof[1].checked=true;
else document.courrier.prof[1].checked=true;
}
/*
Code Avail Pro
 function init(){var d=new Date();var y=d.getFullYear();var lm=document.getElementById('AVP_list_months');var ld=document.getElementById('AVP_list_days');var ln=document.getElementById('AVP_list_nights');     for(i=0;i<12;i++){var m=(d.getMonth()+i)%12;if(m==0&&i!=0)y++;appendOption(lm,months[m]+' '+y,y+'-'+(m+1));}for(i=1;i<=31;i++){appendOption(ld,i,i);if(i<31)appendOption(ln,i,i);}ld.selectedIndex=d.getDate()-1;setDays();}
 function setDays(){var ld=document.getElementById('AVP_list_days');var lm=document.getElementById('AVP_list_months');var ym=lm.options[lm.selectedIndex].value;var y=eval(ym.substring(0,4));var m=eval(ym.substring(5,ym.length));var d=getDaysInMonth(y,m);if(d>ld.length){for(i=ld.length;i<d;i++)appendOption(ld,i+1,i+1);}if(d<ld.length){if(ld.selectedIndex>d-1)ld.selectedIndex=d-1;ld.length=d;}}
 function appendOption(l,t,v){var e=document.createElement('option');e.text=t;e.value=v;try{l.add(e,null);}catch(ex){l.add(e);}}
 function getDaysInMonth(y,m){var days=[31,28,31,30,31,30,31,31,30,31,30,31];var d=days[m-1];if(d==28){if(isLeapYear(y))d=29;}return d/1;}
 function isLeapYear(y){if(y%400==0||(y%4==0&&y%100!=0))return true;return false;}
 function validate(){var lm=document.getElementById('AVP_list_months');var ld=document.getElementById('AVP_list_days');var ym=lm.options[lm.selectedIndex].value;var y=eval(ym.substring(0,4));var m=eval(ym.substring(5,ym.length));var d=new Date();var t=new Date(d.getFullYear(),d.getMonth(),d.getDate());d=new Date(y,m-1,eval(ld.options[ld.selectedIndex].value));if(d<t){alert(message);return false;}var ln=document.getElementById('AVP_list_nights');document.getElementById('AVP_arrivalDate').value = lm.options[lm.selectedIndex].value+'-'+ld.options[ld.selectedIndex].value;document.getElementById('AVP_nights').value = ln.options[ln.selectedIndex].value;document.getElementById('AVP').submit();}
*/
