 /*	==========================================================
	Filename		: core.js
	Created			: mercredi 8 octobre 2003 16:47:41
	Last Updated	: mercredi 8 octobre 2003 16:47:41
	Comments		: 
	
	DOM API - mainly from http://timmorgan.info/1k/
	bibliothèque de base.
	
	==========================================================*/

var d=document;
var ua = navigator.userAgent;
var ns4=(d.layers)?1:0;
var op = /opera [56789]|opera\/[56789]/i.test(ua); // opera version 5+
var ie = !op && /MSIE/.test(ua);
var dom=d.getElementById;
var ns6=(dom&&!ie)?1:0;
var mac=(ua.indexOf("Mac")!=-1);
var macie5 = ie && mac && /MSIE 5/i.test(ua); // IE mac 5
// no support for ns4 !
if (ns4) alert ("le support de Netscape 4 n'est pas assuré.");
// 1K dom original
function gE(e){return d.getElementById(e)};
function cE(t){return d.createElement(t||'div')};
function aC(e,p){return (p||d.body).appendChild(e)};
function sE(e){e.style.visibility='visible'};
function hE(e){e.style.visibility='hidden'};
function sZ(e,z){e.style.zIndex=z};
function sX(e,x){e.style.left=px(x)};
function sY(e,y){e.style.top=px(y)};
function sW(e,w){e.style.width=px(w)};
function sH(e,h){e.style.height=px(h)};
function sC(e,t,r,b,l){e.style.clip='rect('+t+' '+r+' '+b+' '+l+')'};
function wH(e,h){e.innerHTML=h};
function sB(e,b){e.style.background=b};
function sign(x,y){return(x<y)?1:-1};
function px(n){return n+'px'};

// additions
function moveto(e,p){sX(e,p.x);sY(e,p.y)}
function gW(e){return(op)?e.style.pixelWidth:parseInt(e.style.width);}
function gH(e){return(op)?e.style.pixelHeight:parseInt(e.style.height);}
function gX(e){return(op)?e.style.pixelLeft:e.style.left;}
function gY(e){return(op)?e.style.pixelTop:e.style.top;}

function pt(x,y){this.x=x;this.y=y;}
function gPT(e){return new pt(gX(e),gY(e));}
// retourne la position absolue d'un objet dans la page (testé : win : Mozilla 1.5, NS6.2, IE5.0 et Mac : IE5.1)
function eltPos(o){
	var x=0,y=0;
	if (macie5){  // macie5
		var lastOffset=0;
		while(o){
			if(o.leftMargin){x+=parseInt(o.leftMargin);y+=parseInt(o.topMargin);}
			if((o.offsetLeft != lastOffset) && o.offsetLeft){x+=parseInt(o.offsetLeft);y+=parseInt(o.offsetTop);}
			if(o.offsetLeft!=0) lastOffset = o.offsetLeft;
			o=o.parentElement;
		}
	}else{ // other os
		if(o.x){x=o.x;y=o.y}
		else{while(o.offsetParent){x+=o.offsetLeft;y+=o.offsetTop;o=o.offsetParent;}}
	}
	return new pt(x,y);
}
// retourne le rectangle contenant d'un objet
function eltRect(e) {
	var c=eltPos(e);return{left:c.x,top:c.y,bottom:c.y+e.offsetHeight,right:c.x+e.offsetWidth};
}
// retourne les dimensions intérieures de la fenêtre du navigateur
function winSize() {
	var w=0,h=0;
  if(op){w=window.innerWidth;h=window.innerHeight;}
  else if(d.documentElement && d.documentElement.clientWidth){w=d.documentElement.clientWidth;h=document.documentElement.clientHeight;}
  else if(d.body && d.body.clientWidth){w=d.body.clientWidth;h=document.body.clientHeight;}
  else if(xDef(window.innerWidth,window.innerHeight,d.height)){
    w=window.innerWidth;h=window.innerHeight;
    if(d.height>window.innerHeight) w-=16;if(d.width>window.innerWidth) h-=16;
  }
  return {'w':w,'h':h};
}
function xDef() {
  for(var i=0;i<arguments.length;++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
// renvoie les valeurs de scroll top et left dans un objet point.
function wscroll(){
	var w,h;if(ie){h=d.body.scrollTop;w=d.body.scrollLeft;}else{h=window.pageYOffset;h=window.pageXOffset;}
	return new pt(w,h);
}
// events (DOM only)
function addEvt(e,ev,f){if(ie)e.attachEvent("on"+ev,f);else e.addEventListener(ev,f,true);}
function remEvt(e,ev,f){if(ie)e.detachEvent("on"+ev,f);else e.removeEventListener(ev,f,true);}
function stopEvt(ev){
if(ie){window.event.cancelBubble=true;window.event.returnValue=false;}
else{ev.preventDefault();ev.stopPropagation();}}
function getElement(ev){return(ie)?window.event.srcElement:ev.currentTarget;}
function getTargetElement(ev){return(ie)?window.event.srcElement:ev.target;}
// ---------- END DOM API
