function getXMLHttpRequest() {
	var xhr = null;
	
	if (window.XMLHttpRequest || window.ActiveXObject) {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
		} else {
			xhr = new XMLHttpRequest(); 
		}
	} else {
		alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
		return null;
	}
	
	return xhr;
}

function request(id, file) {
	var xhr = getXMLHttpRequest();
	xhr.onreadystatechange = function() {
		//load_data(id,"...chargement...");
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			//load_data(id,xhr.responseText);
			/*content = document.getElementById(id);
			alert(1);
			content.innerHTML = xhr.responseText ; // content c'est le div ou on veut afficher le résultat
			alert(2);*/
			jQuery('#content').html('<p>Chargement en cours...</p>').load(file);
			//self.location.hash="#ancre";
			//window.location.hash = '#ancre';
			//goTo("#content");
			// execution du js
			var AllScripts=content.getElementsByTagName("script")
			for (var i=0; i<AllScripts.length; i++) {
				var s=AllScripts[i];
				if (s.src && s.src!="") {
					alert(s.src);
					eval(getFileContent(s.src));
				}
				else {
					eval(s.innerHTML);
				}
			}
		}
	};

	xhr.open("GET", file, true);
	xhr.send(null);

	//load_data("test",xhr.responseText);
}

function load_data(id, content){
	//eval(content);
	//alert('test');
	//document.getElementById(id).innerHTML = content;
	/*var AllScripts=content.getElementsByTagName("script")
	for (var i=0; i<AllScripts.length; i++) {
		var s=AllScripts[i];
		if (s.src && s.src!="") {
			alert(s.src);
			eval(getFileContent(s.src));
		}
		else {
			eval(s.innerHTML);
		}
	} */
	//$('#gallery a').lightBox();
	//eval(content);
}

/*var scrolling = function(){
    var speed     = 1000;
    jQuery('a[href^="#"]').bind('click',function(){
        var id = jQuery(this).attr('href');
        if(id == '#')
            goTo('body');
        else
            goTo(id);
        return(false);
    });
    function goTo(ancre){
		jQuery('html,body').animate({scrollTop:jQuery(ancre).offset().top},speed,'swing',function(){
            if(ancre != 'body')
                window.location.hash = ancre;
            else
                window.location.hash = '#';
            jQuery(ancre).attr('tabindex','-1');
            jQuery(ancre).focus();
            jQuery(ancre).removeAttr('tabindex');
        });
    }
};*/
function goTo(ancre){
	jQuery('html,body').animate({scrollTop:jQuery(ancre).offset().top},speed,'swing',function(){
		if(ancre != 'body')
			window.location.hash = ancre;
		else
			window.location.hash = '#';
		jQuery(ancre).attr('tabindex','-1');
		jQuery(ancre).focus();
		jQuery(ancre).removeAttr('tabindex');
	});
}
