<!--

function clearValue(object) {
	if (object.value == object.defaultValue) {
		object.value = '';
	}
}

function restoreValue(object) {
	if (object.value == '') {
		object.value = object.defaultValue; 
	}
}

function scrollContent(direction, el) {
	var content = document.getElementById(el);
	if (direction == 2) {
		content.scrollTop += 1;
		scrolldelay = setTimeout("scrollContent(2, '"+ el +"')", 1);
	}
	if (direction == 1) {
		content.scrollTop -= 1;
		scrolldelay = setTimeout("scrollContent(1, '"+ el +"')", 1);
	}
	return false;
}

function stopScrollContent() {
	clearTimeout(scrolldelay);
}

function handle(delta) {
	var contenu = document.getElementById('sidebar_content_scroll');
	if (delta < 0)
		contenu.scrollTop += 7;
	else
		contenu.scrollTop -= 7;
}

function wheel(event){
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	} else if (event.detail) {
		delta = -event.detail/3;
	}
	if (delta)
		handle(delta);
}

function efface_champs(field) {
	if (field.defaultValue == field.value) {
		field.value = "";
	}
}

function displayOverlay(url, type, width, height) {
	if ($('overlay').getStyle('display') == 'block') {
		new Effect.Fade('overlay');
		new Effect.Fade('overlay_content', { duration: 0.1, afterFinish: function() { $('overlay_content').update('') } });
	} else {
		if (width != '') $('overlay_content').setStyle({ 'width': width +'px', 'margin-left': '-'+ width/2 +'px' });
		if (height != '') $('overlay_content').setStyle({ 'height': height +'px' });
		
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var boxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		$('overlay').setStyle({ height: arrayPageSize[2] +'px' });
		$('overlay_content').setStyle({ top: boxTop +'px' });
		
		new Effect.Appear('overlay', { duration: 0.1, from: 0.0, to: 0.6 });
		new Effect.Appear('overlay_content');
		if (type == 'ajax') {
			new Ajax.Updater('overlay_content', url, { evalScripts: true });
		} else {
			if (width == '') width = '100%';
			if (height == '') height = 480;
			/*var iframe = document.createElement('iframe');
			iframe.setAttribute('width', width-10);
			iframe.setAttribute('height', height-10);
			iframe.setAttribute('frameborder', '0');
			iframe.setAttribute('src', url);
			iframe.setAttribute('id', 'iframe');
			$('overlay_content').appendChild(iframe);*/
			$('overlay_content').innerHTML = '<iframe width="' + eval(width-10) + '" height="' + eval(height-10) + '" frameborder="0" src="' + url + '" id="iframe"></iframe>'
			$('iframe').src = url;
		}
	}
}

function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/* -----------------------------------*/
/* --->>> onDOMReady Extension <<<----*/
/* -----------------------------------*/

Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);
    
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
      
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
        
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
        
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
        
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});

-->
