
/***************************************************************************
 *				classes.js
 *				----------
 *	Cree le		: 7 Fevrier 2007
 *	Derniere modif.	: 15 Fevrier 2007
 *	Auteur		: Asselin Benoit Developpement
 *	Email		: contact(a)ab-d.fr
 *
 ***************************************************************************/



Doc = {
	id : function(id) {
		return document.getElementById(id) || false;
	}
}



function ClassAJAX(v_method) {
	this.method = (v_method) ? (v_method) : 'POST';
	this.connexion = false;
	
	this.text = '';
	this.xml = '';
	
	this.setConnexion();
}

ClassAJAX.prototype = {
	setConnexion : function() {
		if (window.XMLHttpRequest) {
			this.connexion = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			try {
				this.connexion = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e) {
				this.connexion = new ActiveXObject('Microsoft.XMLHTTP');
			}
		} else {
/*			alert('Votre navigateur ne supporte pas le XMLHttpRequest. Merci de charger la derni\xE8re version de Mozilla Firefox.');	*/
		}
	},
	send : function(v_openFile, f_state, v_send) {
		if (this.connexion) {
			if (this.method == 'GET') {
				this.connexion.open('GET', v_openFile +'?'+ v_send, true);
				this.connexion.onreadystatechange = f_state;
				this.connexion.send(null);
			} else {
				this.connexion.open('POST', v_openFile, true);
				this.connexion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				this.connexion.onreadystatechange = f_state;
				this.connexion.send(v_send);
			}
		}
	},
	sendReturn : function() {
		if (this.connexion.readyState == 4 && this.connexion.status == 200) {
			this.text = this.connexion.responseText;
			this.xml = this.connexion.responseXML;
			return true;
		} else {
			return false;
		}
	}
}



var v_fixDblKey = 0;
function fixDblKey() { /* fix.safari */
	if (v_fixDblKey != 0) {
		return true;
	} else {
		v_fixDblKey = setTimeout('v_fixDblKey = 0;', 10);
		return false;
	}
}



/* prototype.conio.net */
var $A = Array.from = function(iterable) {
	if (!iterable) return [];
	if (iterable.toArray) {
		return iterable.toArray();
	} else {
		var results = [];
		for (var i = 0; i < iterable.length; i++) {
			results.push(iterable[i]);
		}
		return results;
	}
}

Function.prototype._bind = function() {
	var __method = this, args = $A(arguments), object = args.shift();
	return function() {
		return __method.apply(object, args.concat($A(arguments)));
	}
}

Function.prototype._bindEvent = function(object) {
	var __method = this;
	return function(event) {
		return __method.call(object, event || window.event); /* fix.ie */
	}
}

FixEvent = {
	element : function(e) {
		return e.target || e.srcElement;
	},
	isLeftClick : function(e) {
		return	( (e.which) && (e.which == 1) )	||
			((e.button) && (e.button == 1))	;
	},
	pointerX : function(e) {
		return e.pageX || ( e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) );
	},
	pointerY : function(e) {
		return e.pageY || ( e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) );
	},
	stop : function(e) {
		if (e.preventDefault) {
			e.preventDefault();
			e.stopPropagation();
		} else {
			e.returnValue = false;
			e.cancelBubble = true;
		}
	}
}



