/*-*-*-*-*-*-*-*-*-*-*-*-*-*-* AUTEUR: Matthieu Beunon    *-*-//-*-* SOCIETE : CYBER STUDIO            *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-* DATE DE CREATION: 02/11/00 *-*-//-*-* DERNIERE MISE A JOUR : 20/04/2000 version1.02 *-*-*-*-*-*-*-*-*-*/

/*******************************************************************************************************************/
/********************************************* FONCTIONS COMMUNES **************************************************/
/*******************************************************************************************************************/

/***********************************/
function addFavorite(){
	if(estce.ie)window.external.AddFavorite(''+window.location, 'jpc2002');
	else if(estce.ns)alert("appuyer sur Ctrl+D pour ajouter ce site à vos favoris");
}

/***********************************/
function precharge(iObj,iSrc) {
	if (document.images) {
		eval(iObj+' = new Image()');
		eval(iObj+'.src = "'+iSrc+'"');}
}
/***********************************/
function CCCalque(calque,cparent,contenu) {			
	if (document.layers)
	{
		var objet = (cparent)? eval('document.'+cparent+'.document.'+calque+'.document') : document.layers[calque].document;
		objet.open();
		objet.write(contenu);
		objet.close();
	}
	else if (document.all) document.all[calque].innerHTML = contenu;
}
/***********************************/
function roll(nom,calque,iObj) {
	if (document.images){
	   if (estce.ns4 && calque!=null) eval('document.layers["'+calque+'"].document.images["'+nom+'"].src = '+iObj+'.src'); 	 
	   else document.images[nom].src = eval(iObj+".src");
	}
}
/***********************************/
function longueur(calque){
	var yPos;
	if(estce.ns5)yPos = document.getElementById(calque).style.height;
	else if(estce.ns)yPos = document.layers[calque].document.height;
	else if(estce.ie)yPos = document.all[calque].offsetHeight;
	return yPos;
}
/***********************************/
function largeur(calque){
	var xPos;
	if(estce.ns5)xPos = document.getElementById(calque).style.width;
	else if(estce.ns)xPos = document.layers[calque].document.width;
	else if(estce.ie)xPos = document.all[calque].offsetWidth;
	return xPos;
}
/***********************************/
function cssDiv(nom,top,left,zindex){
	sty='#'+nom+'{position:absolute; top:'+top+'px; left:'+left+'px; z-index:'+zindex+'; visibility:hidden;}\n';
	return sty;
}
/***********************************/
function cssDiv1(nom,top,left,width,height,zindex){
	sty='#'+nom+'{position:absolute; top:'+top+'px; left:'+left+'px; width:'+width+'px; height:'+height+'px; z-index:'+zindex+'; visibility:hidden;}\n';
	return sty;
}
/***********************************/
function cssDiv2(nom,top,left,width,height,background,zindex){
	var CDM = "";
	var CDM2 = "";
	if(estce.ns){ 
		 CDM = "layer-";
		 CDM2 = ";layer-background-color:"+background;
	}
	sty='#'+nom+'{position:absolute; top:'+top+'px; left:'+left+'px; width:'+width+'px; height:'+height+'px; '+CDM+'background:'+background+CDM2+';z-index:'+zindex+'; visibility:hidden}\n';
	return sty;
}
/***********************************/
function openWindow(url,nom,large,haut)
{	
	var MinWin, winOpts="width="+large+",height="+haut+",scrollbars=1,left=150,top=100,menubar=0,toolbar=0";
	MinWin = window.open(url, nom, winOpts);
	if (navigator.appVersion.indexOf("(X11") != -1 || navigator.appVersion.indexOf("(Mac") != -1)
	   MinWin = window.open(url, nom, winOpts);
	if (navigator.appName == "Netscape" && (parseInt(navigator.appVersion) >=3 ))
	   MinWin.focus();
}
		   


/*******************************************************************************************************************/
/********************************************** CLASS CALQUE *******************************************************/
/*******************************************************************************************************************/
var ID_CALQUE = 0;

function Calque(nom,cparent) {																			   
	ID_CALQUE++;
	if(estce.ie)
	{
		 this.doc = document;
		 this.cal = document.all[nom]; 
		 this.css = this.cal.style;
 		 this.h = this.cal.offsetHeight;
		 this.w = this.cal.offsetWidth;
		 this.x = this.css.pixelLeft;
		 this.y = this.css.pixelTop;
	}
    else if(estce.ns)
	{
   		 if(estce.ns4)
		 {
		  	  if (!cparent)cparent='';
			  else cparent='document.'+cparent+'.';
		  	  this.css=eval(cparent+"document.layers." +nom);						
			  this.cal=this.css;
			  this.doc = this.css.document;
		 }
         else if(estce.ns5)
		 {
			  this.doc = this.document;
			  this.cal = document.getElementById(nom);
			  this.css = this.cal.style;
		 } 		 
		 this.x = parseInt(this.css.left);
		 this.y = parseInt(this.css.top);
	}
	this.z = this.css.zIndex;
	this.cparent = cparent;
	this.nom = nom;
	this.objet = nom + "Calque";
	this.nom = nom.substring(0,nom.length-3);
	this.div = nom;
	this.id = ID_CALQUE;
	eval (this.objet + "=this");
}

/** IMPLEMENTATION méthodes **/
function methode_bougerA(x,y) {this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y;}
function methode_bougerDe(x,y) {this.bougerA(this.x+x,this.y+y);}
function methode_montrer() {this.css.visibility = (estce.ns4)? "show" : "visible";}
function methode_cacher() {this.css.visibility = (estce.ns4)? "hide" : "hidden";}

/** PROTOTYPE métodes **/
Calque.prototype.montrer = methode_montrer;
Calque.prototype.cacher = methode_cacher;
Calque.prototype.bougerA = methode_bougerA;
Calque.prototype.bougerDe = methode_bougerDe;



/*******************************************************************************************************************/
/********************************************** GESTION EVENT ******************************************************/
/*******************************************************************************************************************/

/** CAPTURE EVENT **/
function DocEvent(){ document.onmousedown = mouseDown;document.onmousemove = mouseMove;document.onmouseup = mouseUp;if (estce.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);}

/** CAPTURE COORDONNEES **/
function getX(e) {X=(estce.ns)? e.pageX : event.x;return X;}
function getY(e) {Y=(estce.ns)? e.pageY : event.y;return Y;}
function getYdoc(e) {var Y=(estce.ns)? e.pageY : event.y+document.body.scrollTop;return Y;}
function getXdoc(e) {var X=(estce.ns)? e.pageX : event.x+document.body.scrollLeft;return X;}

/***********************************/
function getWidth(){
	if(estce.ns) return window.innerWidth;
	else if(estce.ie) return document.body.clientWidth;
}
/***********************************/
function getHeight(){
	if(estce.ns) return window.innerHeight;
	else if(estce.ie) return document.body.clientHeight;
}
