<!--

//SHOW HIDE ELEMENT
function ShowHide(shID) {
var obj = document.getElementById(shID);
	if (obj.style.display != 'none') {
		obj.style.display = 'none';
	}
	else {
		obj.style.display = 'block';
	}
}
//REPLACE TEXT BY SOMETHING ELSE
function text_replace(id,text,status){
	if(status == 0){
		if (document.getElementById(id).value == ''){
			document.getElementById(id).value = text;
		}
	}
	else if(status == 1){
		if (document.getElementById(id).value == text){
			document.getElementById(id).value = '';
		}
	}
}

//OPEN THE LIGHTBOX
function lightbox_open() {
	//LOADING MSG
	lightbox_load();
	
	var box = document.getElementById('light');
	
	//CHECK WHERE THEY ARE IN THE PAGE
	var scroll = document.body.scrollTop;

	if (scroll == 0) {
		if (window.pageYOffset){
			scroll = window.pageYOffset;
		}
		else {
			scroll = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
	}
	
	width =	getWidth(box);
	height = getHeight(box);
	box.style.left = ((document.documentElement.clientWidth/2) - (width/2))+"px";
	box.style.top = scroll+((document.documentElement.clientHeight/2) - (height/2))+"px";
	
	box.style.display='block';
	
	var fade = document.getElementById('fade');
	
	//PUT THE FADE ON THE WHOLE SCREEN
	fade.style.height = (document.body.clientHeight) + "px";
	fade.style.display='block';
	
}
//RESIZE THE LIGHTBOX DEPENDING ON THE CONTENT
function lightbox_resize() {
	var box = document.getElementById('light');
	
	//CHECK WHERE THEY ARE IN THE PAGE
	var scroll = document.body.scrollTop;

	if (scroll == 0) {
		if (window.pageYOffset){
			scroll = window.pageYOffset;
		}
		else {
			scroll = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}
	}
	
	width =	getWidth(box);
	height = getHeight(box);
	box.style.left = ((document.documentElement.clientWidth/2) - (width/2))+"px";
	box.style.top = scroll+((document.documentElement.clientHeight/2) - (height/2))+"px";
}

function lightbox_load() {
	document.getElementById('lightbox_content').innerHTML = 'Chargement...<br /><br /><img src="/images/site/loading-arrows.gif" style="margin:100px 150px" alt="Chargement" />';
}

//CLOSE THE LIGHBOX
function lightbox_close() {
	document.getElementById('light').style.display='none';
	document.getElementById('fade').style.display='none';
	//CLEAR CONTENT
	document.getElementById('lightbox_content').innerHTML = '';
}

//GET ELEMENT HEIGHT
function getHeight(el) {
	var s = el.style;
	var v = s.visibility;
	var p = s.position;
	var d = s.display;
	sh = s.height;
	elh = el.height;
	elw = el.width;
	el.width = el.offsetWidth;
	s.visibility = "hidden";
	s.position = "absolute";
	s.display = "block";
	s.height = "auto";
	el.height = "auto";
	var h = (parseInt(s.height)>0)? s.height: el.offsetHeight;
	el.width = elw;
	s.display = d;
	s.position = p;
	s.visibility = v;
	s.height = sh;
	el.height = elh;
	return h;
}

//GET ELEMENT WIDTH
function getWidth(el) {
	var s = el.style;
	var v = s.visibility;
	var p = s.position;
	var d = s.display;
	sh = s.height;
	elh = el.height;
	elw = el.width;
	el.width = el.offsetWidth;
	s.visibility = "hidden";
	s.position = "absolute";
	s.display = "block";
	s.height = "auto";
	s.width = "auto";
	el.height = "auto";
	var w = (parseInt(s.width)>0)? s.width: el.offsetWidth;
	el.width = elw;
	s.display = d;
	s.position = p;
	s.visibility = v;
	s.height = sh;
	el.height = elh;
	return w;
}

/** AJAX OPEN LIGHTBOX **/
function open_lightbox(name,params) {
	//BOX OPEN
	lightbox_open();

	//IF NOT JUST A LOADING BOX
	if(name != 'loading') {
		
		// We have the id of the album we are editing, we take the value
		var lightbox_content = document.getElementById('lightbox_content');
		
		//Object creation & XMLHttpRequest
		var xhr = getXMLHttpRequest();
			
		//Response analysis
		if(xhr && xhr.readyState != 0) {
			 xhr.abort(); 
		}

		xhr.onreadystatechange = function() {
		//If everything's fine, let's go		
			if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
				//Display that album was edited
				lightbox_content.innerHTML = xhr.responseText;	
				lightbox_resize();
			}
		}
		// Sending the request to the server
		xhr.open("POST", "http://www.aidoweb.com/libs/ajax/lightbox.php", true); // selection de la page interroger
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		
		if(params) { params = 'type='+name+'&'+params; }
		else { var params = 'type='+name; }

		xhr.send(params);
	}
}

/** AJAX XMLHTTPREQUEST **/
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 XMLHTTPRequest...");
                return null;
        }
        return xhr;
}
/** End AJAX XMLHTTPREQUEST **/

//AJAX REQUEST
function simple_query(name,params,element_id) {
	//Loading icon
	if(element_id != 'none') {
		document.getElementById(element_id).innerHTML = '<img src="http://www.aidoweb.com/images/site/loading-arrows.gif" />';	
		document.getElementById(element_id).style.display = 'block';
	}
	
	//Object creation & XMLHttpRequest
	var xhr = getXMLHttpRequest();
		
	//Response analysis
	if(xhr && xhr.readyState != 0) {
		 xhr.abort(); 
	}

	xhr.onreadystatechange = function() {
   //If everything's fine, let's go
		if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			//IT WORKED
			if(element_id != 'none') {
				// PUT RESPONSETEXT IN THE ID
				if(xhr.responseText != '') {
					document.getElementById(element_id).innerHTML = xhr.responseText;	
				}
				else {
					document.getElementById(element_id).style.display = 'none';
				}
			}
		}
   }
	// Sending the request to the server
	xhr.open("POST", "http://www.aidoweb.com/libs/ajax/simple_query.php", true); // selection de la page interroger
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	if(params) { params = 'type='+name+'&'+params; }
	else { params = 'type='+name; }

	xhr.send(params);
}

//PUT THE DESIGN TO A FIXED WIDTH
function fixed_width() {
	var tout = document.getElementById('tout');
	var choice = document.getElementById('width_choice');
	
	if(choice.className == 'expand') {
		tout.style.width='';
		tout.style.margin='0 20px';
		choice.className='fixed';
		var new_width = 'expanded';
	}
	else {
		tout.style.width='1000px';
		tout.style.margin='0 auto';
		choice.className='expand';
		var new_width = 'fixed';
	}
	//SAVE IT
	simple_query('site_width','choice='+new_width,'none');
}



//--> 