function deselect(e)
{return false;}
function select()
{return true;}
document.onselectstart=new Function("return false");
if (window.sidebar)
{
document.onmousedown=deselect;
document.onclick=select;
}

function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function refresh()
	{
	document.location.reload();
                return false;
	}
document.oncontextmenu = refresh;

function NoError()
	{
	return true;
	}
window.onerror=NoError;

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}



function carousel(params){
  if(!(params.width>0 && isFinite(params.width)))params.width=100;
  if(!(params.height>0 && isFinite(params.height)))params.height=100;
  if(!(params.sides>2 && isFinite(params.sides)))params.sides=4;
  if(!(params.steps>0 && params.steps<100 && isFinite(params.steps)))params.steps=20;
  if(!(params.speed>0 && isFinite(params.speed)))params.speed=8;
  if(!(params.image_border_width>=0 && isFinite(params.image_border_width)))params.image_border_width=0;
  if(isFinite(params.id)||!params.id)params.id='bad_id_given_'+Math.random();
  
  document.write("<div style='position:relative;overflow:hidden;' id='"+params.id.replace(/[\r\n\t ]+/g,'_')+"'></div>");
  var cdiv=document.getElementById(params.id.replace(/[\r\n\t ]+/g,'_'))
  cdiv.style.width=params.width+'px';
  cdiv.style.height=params.height+'px';
  cdiv.style.border=params.border;
  cdiv.style.position='relative';
  cdiv.style.overflow='hidden';
  cdiv.title=params.id;
    
  var counter=0,spinning=true,interval=Math.floor(60000/params.sides/params.steps/params.speed)-5;
  interval=isNaN(interval)?200:interval;
  var img_position=[],images=[],img_dimension=[];
  var img_index=params.images.length+1,img_index_cap=2*params.images.length;
  var faces=Math.ceil(params.sides/2), dimension, direction;

  function init(){
    if(params.direction=="left" || params.direction=="right"){
      direction=params.direction;
      dimension="width";
      }
    else if(params.direction=="top" || params.direction=="bottom"){
      direction=params.direction;
      dimension="height";
      }
    else {
      direction="left";
      dimension="width";
      }      
    cdiv.style[dimension]=params[dimension]/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)+'px';
    var img=new Image();
    img.style.position='absolute';
    img.style[direction]='10000px';
    img.style.width=params.width-2*params.image_border_width+'px';
    img.style.height=params.height-2*params.image_border_width+'px';

  
    for(var i=0;i<params.images.length;i++){
      images[i]=img.cloneNode(true);
      images[i].src=params.images[i];
      if(params.links && params.links[i] && params.links[i]!=''){
        images[i].onclick=new Function("window.location='"+params.links[i]+"'");
        images[i].style.cursor=document.all?'hand':'pointer';
        }
      if(params.titles && params.titles[i] && params.titles[i]!='')
        images[i].title=params.titles[i];
      images[i+params.images.length]=images[i];
      if(params.images.length==faces)
        images[i+2*params.images.length]=images[i];
      cdiv.appendChild(images[i]);
      }
  
    var face_size=params.size_mode=='image'?params[dimension]:params[dimension]*Math.sin(Math.PI/params.sides);
    var face_offset=params[dimension]*Math.cos(Math.PI/params.sides)/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)/2-.5;
    var pi_piece=2*Math.PI/params.steps/params.sides;
    for(i=0;i<=params.steps*faces;i++){
      img_dimension[i]=face_size*Math.sin(pi_piece*i);
      img_position[i]=(i<params.steps*params.sides/2)?Math.floor(params[dimension]/2/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)-face_offset*Math.cos(pi_piece*i)-img_dimension[i]/2)+'px':'10000px';
      img_dimension[i]=img_dimension[i]-2*params.image_border_width>1?Math.ceil(img_dimension[i])-2*params.image_border_width+'px':'1px';
      }
    }
  init();

  cdiv.rotate = function(){
    setTimeout('document.getElementById("'+cdiv.id+'").rotate()',interval);
    if(!spinning) return;
    if(++counter>=params.steps){
      counter=0;
      if(++img_index>=img_index_cap)
        img_index=params.images.length;
      }
    images[img_index-faces].style[direction]='20000px';
    for(var i=faces-1;i>=0;i--){
      images[img_index-i].style[direction]=img_position[counter+i*params.steps];
      images[img_index-i].style[dimension]=img_dimension[counter+i*params.steps];
      }
    }
  cdiv.onmouseover=function(){
    spinning=false;
    }
  cdiv.onmouseout=function(){
    spinning=true;
    }
  setTimeout('document.getElementById("'+cdiv.id+'").rotate()',200);
  }









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) { //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 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];}
}

function objet() {
this.length = objet.arguments.length
for (var i = 0; i < this.length; i++) this[i+1] = objet.arguments[i]
}
var nom = new objet ("pack_entreprise.gif", "pack_entreprise_plus.gif", "pack_antiquaire.jpg", "pack_commerce.jpg", "pack_immobilier.gif", "pack_catalogue.gif", "pack_documentaire.jpg", "pack_vehicule.jpg");
var numero = 1;
function changer() {
document.image.src = "images/"+nom[numero];
numero += 1;
if (numero == nom.length + 1) numero = 1;
setTimeout("changer()", 1500);
}

function popup(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=319,height=430,toolbar=true,scrollbars=1');	
}

function popup1(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=760,height=580,toolbar=true,scrollbars=1');	
}

function popup2(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=520,height=380,toolbar=true,scrollbars=1');	
}

function popup3(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=600,height=500,toolbar=true,scrollbars=1');	
}

function popup6(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=760,height=350,toolbar=true,scrollbars=0');	
}


function popup7(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=630,height=580,toolbar=true,scrollbars=1');	
}

function popup11(page) {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width=700,height=500,toolbar=true,scrollbars=1');	
}

function spop( fichier, nom, largeur, hauteur, options )
{
var id = Math.round( Math.random() * 100 );
var gauche = ( screen.width - largeur ) / 2;
var haut = ( screen.height - hauteur ) / 2;
if ( options )
{
options = 'width=' + largeur + 'px, height=' + hauteur + 'px,  top=' + haut + ', left=' + gauche + ', ' + options;
	}
else
{
options = 'width=' + largeur + 'px, height=' + hauteur + 'px,  top=' + haut + ', left=' + gauche;
	}
document.open( fichier, nom + id, options );
	}
	
function showdetails(person)
{
x = details.x;
y = details.y;
h = details.h;
w = details.w;
ct = details.ct;
cb = details.cb;
cl = details.cl;
cr = details.cr;
css = details.css;
if(who!=''){who.clipIt(0,0,0,0,20);who.nodragdrop();}
person.moveIt(x,y);person.showIt(); 
person.clipIt(ct,500,270,cl,20); // 510*270 étant les dimensions des fiches contacts
person.dragdrop();
who = person;
}

var who='';
function init_em()
{
details = new lib_obj('detailsDIV');
instantm = new lib_obj('instantmDIV');
coord = new lib_obj('coordDIV');
mmails = new lib_obj('mmailsDIV');
// Cacher les fiches des contacts
instantm.h=0;instantm.w=0;
coord.h=0;coord.w=0;
mmails.h=0;mmails.w=0;
instantm.hideIt();
details.showIt();
details.nodragdrop();
// Positionner les contacts sur la zone
x = details.x;
y = details.y;
instantm.moveIt(x,y);instantm.clipIt(0,0,0,0,740);
coord.moveIt(x,y);coord.clipIt(0,0,0,0,740);
mmails.moveIt(x,y);mmails.clipIt(0,0,0,0,740);
// details.centerIt();
//bloc.dragdrop();
}

function hide_wait()
{
// Cacher le div du téléchargement en cours
var nava = (document.layers);
var dom = (document.getElementById);
var iex = (document.all);
if (nava) { waitDIVobj = document.waitDIV }
else if (dom) { waitDIVobj = document.getElementById("waitDIV").style }
else if (iex) { waitDIVobj = waitDIV.style }
waitDIVobj.visibility = "hidden";
//et affichet le div pricipal de la page
if (nava) { mainDIVobj = document.mainDIV }
else if (dom) { mainDIVobj = document.getElementById("mainDIV").style }
else if (iex) { mainDIVobj = mainDIV.style }
mainDIVobj.visibility = "visible";
}

function emailCheck(txt) {
  if (txt.indexOf("@")<3)return false;
  return true;
 }
 //###################################################################
 // Pour envoyer les données au module de contacts dans une chromless
 //###################################################################
 function Send_This()
 { 
    window.name="origine";
	nom = document.forms['contacts']['nom'].value;
	email = document.forms['contacts']['email'].value;
	tel = document.forms['contacts']['tel'].value;
	sujet = document.forms['contacts']['sujet'].value;
	message = document.forms['contacts']['message'].value;
    theURL="contacts/rcontact19d1.html?nom="+nom+"&email="+email+"&tel="+tel+"&sujet="+sujet+"&message="+message;
	//theURL = "index.php";
	//document.model_form.form_sresultcontent.value = theURL;
	// Paramètres de la Chromeless Window
	wname ="MODEL_TESTER";
	W=510;
	H=270;
	windowCERRARa 		= "scripts/chromeless/img/close_a.gif";
	windowCERRARd 		= "scripts/chromeless/img/close_d.gif";
	windowCERRARo 		= "scripts/chromeless/img/close_o.gif";
	windowNONEgrf 		= "scripts/chromeless/img/none.gif";
	windowCLOCK		    = "scripts/chromeless/img/clock.gif";
	windowREALtit		= " Test du modèle de résultats ..."
	windowTIT 	    	= "<font face=verdana size=1 color='#ff3300'><b>&nbsp;  Veuillez patienter quelques instant...</b></font>";
	windowBORDERCOLOR   	= "#000000";
	windowBORDERCOLORsel	= "#000000";
	windowTITBGCOLOR    	= "#FFEFA1";
	windowTITBGCOLORsel 	= "#FFCC00";
	z=openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel);
   //if (z.opener == null) {z.opener = self;}
} 
// Vérifier que tous les champs ont été bien remplis
function validateform()
{
var mess =new String();
if (document.forms['contacts']['nom'].value =="")mess= "Vous devez saisir votre nom";
if (!emailCheck(document.forms['contacts']['email'].value))mess+= "\n Votre adresse email semble erronée. veuillez reverifier";
if (document.forms['contacts']['sujet'].value=="")mess+= "\n Vous devez saisir un sujet pour votre message";
if (document.forms['contacts']['message'].value=="")mess+= "\n Vous devez saisir votre message";
if(mess!="") alert(mess);
else {Send_This();}
}
// Et pour pouvoir sélectionner dans le div
function ResetEvents()
{
 document.onmousemove="";
 document.onmousedown="";
 document.onmouseup="";
}

function gotourl(url)
{
location=url;
}
