// JavaScript Document version 1.05
function showSmenu(){
document.getElementById('smensous').style.display = 'block';	
}
function hideSmenu(){
document.getElementById('smensous').style.display = 'none';	
}

function showSmenu1(){
document.getElementById('subMenu1').style.display = 'block';	
}
function hideSmenu1(){
document.getElementById('subMenu1').style.display = 'none';	
}

function showSmenu2(){
document.getElementById('subMenu2').style.display = 'block';	
}
function hideSmenu2(){
document.getElementById('subMenu2').style.display = 'none';	
}
function showSmenu3(){
document.getElementById('subMenu3').style.display = 'block';	
}
function hideSmenu3(){
document.getElementById('subMenu3').style.display = 'none';	
}
function showSmenu1b(){
document.getElementById('subMenu1b').style.display = 'block';	
}
function hideSmenu1b(){
document.getElementById('subMenu1b').style.display = 'none';	
}

function showSmenu2b(){
document.getElementById('subMenu2b').style.display = 'block';	
}
function hideSmenu2b(){
document.getElementById('subMenu2b').style.display = 'none';	
}


function showSmenu3b(){
document.getElementById('subMenu3b').style.display = 'block';	
}
function hideSmenu3b(){
document.getElementById('subMenu3b').style.display = 'none';	
}
////////////////////////////////////////
function centerPopUp (file,w,h,scrollbar,name){
var cx = Math.round ((screen.availWidth / 2) - (w / 2));
var cy = Math.round ((screen.availHeight / 2) - (h / 2));
scrollbar=(scrollbar == "undefined")?'no':scrollbar;
name=(name == "undefined")?'popUp':name;
window.open(file, name, 'height='+ h +', width='+ w +', top='+ cy +', left='+ cx +', toolbar=no, menubar=yes, location=no, toolbar = no,resizable=yes, scrollbars='+scrollbar+', status=no');
}
function openPop (file,w,h,scrollbar,name){
scrollbar=(scrollbar == "undefined")?'no':scrollbar;
name=(name == "undefined")?'popUp':name;
window.open(file, name, 'height='+ h +', width='+ w +', top=0, left=0, toolbar=no, menubar=yes, location=no, toolbar = no,resizable=yes, scrollbars='+scrollbar+', status=no');
}
////////////////////////////// messages d'alertes simple
function simpleAlert(msg){
	var al = new Alert_window();
	//al.setCloseButton("X","Fermer");
	al.create(msg);
}


function pop_up(){	
fenetre=window.open('','popup','toolbar=0, location=0, directories=0, status=0,  resizable=1, scrollbars=1, height=570,width=790');
}

function pop_up2(){	
fenetre2=window.open('','popup2','toolbar=0, location=0, directories=0, status=0,  resizable=1, scrollbars=1, height=650,width=650');
}

function pop_up3(){	
fenetre3=window.open('','popup3','toolbar=0, location=0, directories=0, status=0,  resizable=1, scrollbars=1, height=900,width=790');
}

//////////////////////////////////////////////////////popup centrage et redim
function pop_redim(nx,ny) {
	xall = (screen.availWidth / 2);
	yall = (screen.availHeight / 2);
	window.resizeTo(nx,ny);
	self.moveTo(xall - (nx / 2), yall - (ny / 2));
	self.focus();
}

///////////////////////////////////fermer pop ou fenetre
function pop_fermer() { 
	opener=self; 
	self.close(); 
} 

function ouvre_ferme_inline(id) {
	var d = document.getElementById(id);
	
	if(d){
		if (d.style.display=='inline') d.style.display='none'; 			
		else d.style.display='inline';
	}
			
}

function ouvre_ferme_block(id) {
	var d = document.getElementById(id);
	if(d){
		if (d.style.display=='block') d.style.display='none'; 			
		else d.style.display='block';
	}
}

function setStyle(identifiant, style, value){
var id=identifiant;
var styl=style;
var val=value;
if (document.all) { /// si IE
	document.getElementById(id).style.setAttribute(styl,val,"false");
}
else document.getElementById(id).setAttribute("style",style+":"+value+";");
}

function getSrc(img){
var	src=document.getElementById(img).src;
return src;
}

function setSrc(img, src){
document.getElementById(img).src=src;
}

function changeImg(id, name_img1, name_img2, dir_img){
var nameImg=getSrc(id);
nameImg=nameImg.split(dir_img);

if(name_img1==nameImg[1]){
	setSrc(id,dir_img+name_img2);
}
else setSrc(id,dir_img+name_img1);
	
}

var global_onclick = new Array();
function disableDoubleClick(id){
	if(document.getElementById(id)){
		global_onclick[id]=document.getElementById(id).onclick;	
		document.getElementById(id).onclick='';
		return true;
	}
	else return false;
}

function enableDoubleClick(id){
	if(document.getElementById(id)){
		document.getElementById(id).onclick=global_onclick[id];	
		//alert(global_onclick[id]);
		global_onclick[id]='';
		return true;
	}
	else return false;
}

function getElementsByClassName(clsName,htmltag){ 
	var arr = new Array(); 
	var elems = document.getElementsByTagName(htmltag);
	for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
		if ( elem.className == clsName ){
			arr[arr.length] = elem;
		}
	}
	return arr;
}

/**
	Ajax Extensible Page - (c) 2007 Denis Sureau
	http://ajax.xul.fr
	Version 1.2.
*/


/**
	A framework to make web pages that are expanded at users request,
	from data hidden in the same page or taken from external files.
	Free and open source under the GNU GPL 2.0 licence.
	
	Usage: 
	Include this JavaScript file into the head section of your page. Read the manual for details.
	You can shorten this code by removing the comments but the copyright notive above.
*/	


function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
				try {
				request = new XMLHttpRequest();
				}
				catch (err1) 
				{
					request = false;
				}
            }
        }
    return request;
}

function read(url, fun, element)
{ 
	var xhr=createXHR();

	xhr.open("GET", url, true);
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			var content = xhr.responseText;	
			fun(content, element);
		} 
	}; 

	xhr.send(null); 

} 


// Expand / Collapse a single object

function fileCallback(source, element)
{
	element.innerHTML = source;	// set the new content or cross
}

/**
	This function swaps the hidden text with the displayed one.
*/

function quietVerbose(element)
{
	var container = element.getAttribute("name");

	if(container == null || container.length == 0)
	{
		container = element.getAttribute("title");

		if(container == null || container.length == 0) 
		{
			container = element.getAttribute("src");
			if(container == null || container.length == 0) return;
			element.setAttribute("title", element.innerHTML);	// save content into title
			// loading an external text file and assign content into current element
			read(container, fileCallback, element);		// call Ajax to retrieve the file.
			return;
		}	
		
		var y = element.innerHTML;	// get shown text
		element.innerHTML = container;		// show hidden text
		element.setAttribute("title", y);	// save previously displayed text

	}

	var x = document.getElementById(container).innerHTML;	// get hidden text
	var y = element.innerHTML;	// get shown text

	element.innerHTML = x;		// show hidden text
	document.getElementById(container).innerHTML = y;	// save previously displayed text
}


/**
	Summarize a single element
*/	


function doQuiet(element)	// target is large, small is hidden
{
	var small = element.getAttribute('name');	// collapsed is hidden
	if(small == null || small.length == 0) 
	{
		container = element.getAttribute("title");	
		if(container == null || container.length == 0) return;
		var y = element.innerHTML;	// get shown text
		if(container.length > y.length) return; 
		element.innerHTML = container;		// show hidden text
		element.setAttribute("title", y);	// save previously displayed text
		return;
	}	

	var largeText = element.innerHTML;	// get large text displayed
	var smallText = document.getElementById(small).innerHTML;	// get small text hidden

	if(smallText.length > largeText.length) return;	// hidden text must be smaller than displayed

	document.getElementById(small).innerHTML = largeText;	// hide
	element.innerHTML = smallText;	// display

}


/**
	Develop a single element
*/	

function doVerbose(element)
{
	var largeID = element.getAttribute('name');	// the hidden larger text to display

	if(largeID == null || largeID.length == 0)
	{
		var content = element.getAttribute('title');
		if(content != null && content.length != 0)
		{
			// already loaded
			var x = element.innerHTML;	// get current content
			if(x.length > content.length) return; // current must be smaller
			element.innerHTML = content;
			element.setAttribute("title", x);
			return;
		}
		
		// Loading a file, saving current content into an attribute and replacing it by the content of the file
		var url = element.getAttribute('src');
		if(url == null || url.length == 0) return;
		element.setAttribute("title", element.innerHTML);	// save content into title
		// loading an external text file and assign content into current element
		read(url, fileCallback, element);		// call Ajax to retrieve the file.
		return;
	}	

	var smaller = element.innerHTML;	// currently displayed
	var larger = document.getElementById(largeID).innerHTML;	// is hidden and must be displayed

	if(smaller.length > larger.length) return;	// already developed, ignore

	element.innerHTML = larger;	// display big text
	document.getElementById(largeID).innerHTML = smaller;		// hide small text
}

/**
	Develop the whole page
*/	

function develop()
{
	var content;
	var list = document.getElementsByTagName("span");

	for(i = 0;  i < list.length;  i++)
	{
		var element = list.item(i);
		var id = element.getAttribute("id");		// not all span tags are processed
		if(id != null && id.length > 0) 
		{
			doVerbose(element);
		}	
	}
}


/**
	Summarize the whole page
*/	

function summarize()
{
	var content;
	var list = document.getElementsByTagName("span");

	for(i = 0;  i < list.length;  i++)
	{
		var element = list.item(i);
		var id = element.getAttribute('id');
		if(id != null && id.length > 0) 
		{
			doQuiet(element);
		}	
	}
}