//-----------------------------------------------------------------------------------------
//MACROMEDIA SCRIPTS
//-----------------------------------------------------------------------------------------
function MM_showHideLayers() 
{ //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  	if ((obj=MM_findObj(args[i]))!=null)
	{
		v=args[i+2];
    	if (obj.style)
		{
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
		}
    	obj.visibility=v; 
	}
}
//-----------------------------------------------------------------------------------------
function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	if (restore) 
  		selObj.selectedIndex=0;
}

//-----------------------------------------------------------------------------------------
function MM_swapImgRestore()
{ //v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
		x.src=x.oSrc;
}

//-----------------------------------------------------------------------------------------
function MM_preloadImages() 
{ //v3.0
	var d=document;
	if(d.images)
	{ 
		if(!d.MM_p) d.MM_p=new Array();
    		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    		for(i=0; i<a.length; i++)
    		if (a[i].indexOf("#")!=0)
    		{
    			d.MM_p[j]=new Image;
    			d.MM_p[j++].src=a[i];
    		}
    	}
}

//-----------------------------------------------------------------------------------------
function MM_findObj(n, d)
{ //v3.0
	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); 
  	return x;
}

//-----------------------------------------------------------------------------------------
function MM_swapImage()
{ //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
   		if ((x=MM_findObj(a[i]))!=null)
   		{
   			document.MM_sr[j++]=x;
   			if(!x.oSrc)
   				x.oSrc=x.src;
   			x.src=a[i+2];
   		}
}
//-----------------------------------------------------------------------------------------
// ARACHNE SCRIPTS
//-----------------------------------------------------------------------------------------
function AraSearch()
{
	for(i=0;i<document.mapform.elements.length;i++)
	{
		document.searchform.elements[i].value=document.mapform.elements[i].value;
	}
	document.searchform.submit();	
}
//-----------------------------------------------------------------------------------------
function makeUrl(fiche,rep)
{
	TheUrl = '/fiches/'+rep+'/'+fiche.options[fiche.selectedIndex].value;
	window.open(TheUrl,'_self');
}
//-----------------------------------------------------------------------------------------
function AraMap(Cmd)
{
	document.mapform.elements[document.mapform.elements.length-1].value = Cmd;
	document.mapform.submit();
}
//-----------------------------------------------------------------------------------------
function navCheck()
{
	var path="http://localhost/guide4x4/";
	var nav2=navigator.appName;
	var version=navigator.appVersion;
	var nav3=version.substring(0,3);
	var nav3n=Number(nav3);
	var verif=false;
	var navigateur=nav2+' '+version.substring(0,4);
	var sort='nonav.htm';
	if ((nav2=='Netscape' || nav2=='Microsoft Internet Explorer') && nav3n>=4)
	{
		top.status='Vous utilisez '+navigateur;
		verif=true;
	}
	else
	{ 
		verif=confirm('Votre navigateur, '+navigateur+' est trop ancien, ou non reconnu.\n Vous risquez d\'avoir des problèmes pour accéder aux pages du site.\n Souhaitez - vous tout de même entrer ?\n(Ok pour entrer)');
	}
	if (verif)
	{
		if(nav2=='Microsoft Internet Explorer') document.navform.NAV.value='IE';
		else document.navform.NAV.value='NS';
		document.navform.submit();
	}
	else window.open(sort,'','resizable=yes,width=360,height=200');
	return true;
}

//-----------------------------------------------------------------------------------------
function EndGuide()
{
	window.open('close.htm','_blank','status=0,titlebar=0,toolbar=0,location=0,left=0,top=0,scrollbars=0,,width=200,height=200');
}

//-----------------------------------------------------------------------------------------
function OpenMain()
{
	var wh=screen.height-70;
	var ww=screen.width-10;
	var chaine='status=0,titlebar=0,toolbar=1,location=0,left=0,top=0,scrollbars=1,,width='+ww+',height=';
	if(navigator.appName=='Netscape') wh-=50;
	chaine+=wh;
	mainWindow=window.open('navcheck.htm','_blank',chaine);
	mainWindow.focus();
}
//-----------------------------------------------------------------------------------------
function AWDError()
{
	alert("Une erreur est survenue, vous allez être redirigé vers la page d'accueil.\n Si le problème persiste, envoyez un mail au WebMaster.");		
	window.open('http://localhost/guide4x4/index.htm','_top');
}
//-----------------------------------------------------------------------------------------
function SearchSub(F)
{
	F.submit();
}
//-----------------------------------------------------------------------------------------
function nextBack(F,neba)
{
	if(neba=="next")
	{
		F.recStart.value=Number(F.recStart.value)+Number(F.recMax.value);
	}
	if(neba=="back")
	{
		F.recStart.value=Number(F.recStart.value)-Number(F.recMax.value);
	}
	F.submit();
}
//-----------------------------------------------------------------------------------------
function AddFunc(F)
{
	var chaine="Avez-vous pense a verifier votre fiche ?\n";
	if((document.addform.elements[1].name=="charte")&&(!document.addform.charte.checked))
	{
		alert ("vous devez accepter la charte du clan 4x4 avant de pouvoir enregistrer votre établissement")
	}
	else
	{
		if(confirm(chaine))	F.submit();
	}
}
//-----------------------------------------------------------------------------------------
function SelectVal(elemen)
{
	var valeur="";
	valeur=elemen.options[elemen.selectedIndex].value;
	return valeur;
}
//-----------------------------------------------------------------------------------------
function GetIndex(F,name)
{
	var i=0;
	while(F.elements[i].name!=name) i++;
	return i;
}
//-----------------------------------------------------------------------------------------
function SetDate(DateElem)
{
	var start=GetIndex(DateElem.form,DateElem.name);
	if(DateElem.name.charAt(4)=="M") start--;
	if(DateElem.name.charAt(4)=="A") start-=2;
	var theDate=SelectVal(DateElem.form.elements[start+1])+"/"+SelectVal(DateElem.form.elements[start])+"/"+SelectVal(DateElem.form.elements[start+2]);
	DateElem.form.elements[start+3].value=theDate;
	alert(DateElem.form.elements[start+3].value);
}
//-----------------------------------------------------------------------------------------
function OpenCharte()
{
	var wh=100;
	var ww=100;
	var chaine='status=0,titlebar=0,toolbar=0,location=0,left='+ww+',top='+wh+',scrollbars=1,,width=600,height=400';
	window.open('/library/charte.htm','Charte',chaine);	
}
//-----------------------------------------------------------------------------------------
function OpenCharteReserv()
{
	var wh=100;
	var ww=100;
	var chaine='status=0,titlebar=0,toolbar=0,location=0,left='+ww+',top='+wh+',scrollbars=1,,width=600,height=400';
	window.open('/library/charteReservation.asp','Charte',chaine);	
}
//-----------------------------------------------------------------------------------------
function AraForumDisp(msgId,chid)//Used for normal messages
{
	var wh=screen.height-400;
	var ww=screen.width-400;
	var chaine='status=0,titlebar=0,toolbar=0,location=0,left='+ww+',top='+wh+',scrollbars=1,,width=360,height=210';
	MsgPopUp=window.open('/forums/msg_det_nt.asp?chid='+chid+'&msg_id='+msgId,'MsgPopUp',chaine);
	MsgPopUp.focus();
}
//-----------------------------------------------------------------------------------------
function AraForumDispBis(msgId,chid)//Used for messages at last level
{
	var wh=screen.height-400;
	var ww=screen.width-400;
	var chaine='status=0,titlebar=0,toolbar=0,location=0,left='+ww+',top='+wh+',scrollbars=1,,width=350,height=210';
	MsgPopUp=window.open('/forums/msg_det_norep.asp?chid='+chid+'&msg_id='+msgId,'MsgPopUp',chaine);
	MsgPopUp.focus();
}
//-----------------------------------------------------------------------------------------
function AraForumDispTer(msgId,chid)//Used for initial message list
{
	var wh=screen.height-400;
	var ww=screen.width-400;
	var chaine='status=0,titlebar=0,toolbar=0,location=0,left='+ww+',top='+wh+',scrollbars=1,,width=360,height=210';
	MsgPopUp=window.open('/forums/msg_det.asp?chid='+chid+'&msg_id='+msgId,'MsgPopUp',chaine);
	MsgPopUp.focus();
}
//-----------------------------------------------------------------------------------------
// BRATTA SCRIPTS
//-----------------------------------------------------------------------------------------
function checkBrowser(){
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this;
}

function mLeft(){
	if(!noScroll && oMenu.x<sArrowwidth){
		oMenu.moveBy(sScrollPx,0)
		tim=setTimeout("mLeft()",sScrollspeed)
	}
}
function mRight(){
	if(!noScroll && oMenu.x>-(oMenu.scrollWidth-(pageWidth))-sArrowwidth){
		oMenu.moveBy(-sScrollPx,0)
		tim=setTimeout("mRight()",sScrollspeed)
	}
}
function noMove(){clearTimeout(tim); noScroll=true}
function makeObj(obj,nest,menu){
	nest=(!nest) ? '':'document.'+nest+'.'										
   	this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;		
	this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;		
	this.scrollWidth=bw.ns4?this.css.document.width:this.evnt.offsetWidth
	this.x=(bw.ns4 || bw.ns5)? this.css.left:this.css.pixelLeft;
	this.y=(bw.ns4 || bw.ns5)? this.css.top:this.css.pixelTop;		
	this.moveBy=b_moveBy; this.moveIt=b_moveIt;	this.showIt=b_showIt;this.clipTo=b_clipTo;
	return this
}
function b_moveBy(x,y){this.x=this.x+x; this.y=this.y+y; this.css.left=this.x; this.css.top=this.y}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
function b_clipTo(t,r,b,l){
	if(bw.ns4){this.css.clip.top=t; this.css.clip.right=r; this.css.clip.bottom=b; this.css.clip.left=l
	}else this.css.clip="rect("+t+","+r+","+b+","+l+")";
}
function b_showIt(){this.css.visibility="visible"}

function sideInit(){
	pageWidth=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth-20;
	
	oBg=new makeObj('divBg')
	oMenu=new makeObj('divMenu','divBg',1)
	oArrowRight=new makeObj('divArrowRight','divBg')
	//Placement
	oBg.moveIt(sLeft,sTop) //Main div, holds all the other divs.
	oMenu.moveIt(sArrowwidth,6)
	oArrowRight.moveIt(pageWidth-sArrowwidth,9)
	//setting the width and the visible area of the links.
	if(bw.dom || bw.ie4){ oBg.css.width=pageWidth; oBg.css.overflow="hidden" }
	oBg.clipTo(0,pageWidth,sMenuheight,0)
	//LeftMenu
/*	lMenu=new Array()
	lMenu[0]=new makeMenu('divLogin','',lShow,lMove,lSpeed) 
	scrolled=bw.ns4?"window.pageYOffset":"document.body.scrollTop"
	for(i=0;i<lMenu.length;i++){
		lMenu[i].moveIt(-lMenu[i].width+lMenu[i].show,lMenu[i].y)
		lMenu[i].css.visibility='visible'
	}
	if(lMoveOnScroll) bw.ns4?checkScrolled():window.onscroll=checkScrolled;*/
	//LeftMenuInit
}


//FOR LEFT MENU
/*
function makeMenu(obj,nest,show,move,speed)
{
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;		
	this.x=(bw.ns4 || bw.ns5)? this.css.left:this.el.offsetLeft;
	this.y=(bw.ns4 || bw.ns5)? this.css.top:this.el.offsetTop;		
	this.state=1; this.go=0; this.min=b_min; this.show=show
	this.top=this.y; this.mout=b_mout; 
	this.width=bw.ns4?this.css.document.width:this.el.offsetWidth
	this.moveIt=b_moveIt; this.move=move; this.speed=speed
    this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}
*/

function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
function b_min(){
	if(this.x>-this.width+this.show){
		this.go=1; 
		this.moveIt(this.x-this.move,this.y);
		setTimeout(this.obj+".min()",this.speed);
	}else{this.go=0; this.state=1};
}
function b_mout(){
	if(this.x<0){
		this.go=1; this.moveIt(this.x+this.move,this.y)
		setTimeout(this.obj+".mout()",this.speed)
	}else{this.go=0; this.state=0}	
}
function moveLeftMenu(num){
	if(!lMenu[num].go){
		if(!lMenu[num].state)lMenu[num].min()	
		else lMenu[num].mout()
	}
}
function checkScrolled(){
	for(i=0;i<lMenu.length;i++){
		if(!lMenu[i].go) lMenu[i].moveIt(lMenu[i].x,eval(scrolled)+lMenu[i].top)
	}
	if(bw.ns4) setTimeout('checkScrolled()',40)
}