var t = true;var f = false;var d = document;var w = window;var n = null;
var isIe = !isNaN(parseFloat(navigator.appVersion.split("MSIE")[1])) ? t : f;
var isIe5 = parseFloat(navigator.appVersion.split("MSIE")[1]) == 5.5 ? t : f;
var isIe7 = parseFloat(navigator.appVersion.split("MSIE")[1]) == 7 ? t : f;
var bm = "childframe";
var minimise = "STD";
var maximise = "MAX";
var cache = "NO";
var widthBM = "340px";
var heightBM = "280px";
 
function debug() {

}
function _(obj) {
	return (typeof(obj)=='object' ? obj : d.getElementById(obj));
}
function _extend(obj, extension) {
	for(var property in extension) {
		if(extension.hasOwnProperty(property) && !obj[property]) {
			obj[property] = extension[property];
		}
	}
	return obj;
}
_extend(Array.prototype, {
	inArray: function(sValue){
		return this.getIndex(sValue)==-1 ? f : t;
	},
	getIndex: function(sValue){
		for(var i=0; i<this.length; i++) {
			if(this[i]==sValue) {
				return i;
			}
		}
		return -1;
	}
})

function bloc() {
	return f;
}
function addEvenement(obj, typeEvent, _function, bool) {
	try {
		obj.addEventListener(typeEvent , _function, bool?bool:f);
	} catch(error) {
		try {
			obj.attachEvent('on' + typeEvent , _function);
		} catch(error) {
	//		alert(error);
		}
	}
}
function initFrame() {
	if(_('parentframe') != n) {
		var page = getpageSize();
		_('parentframe').style.height = page.height + 'px';
		_('parentframe').style.width = page.width + 'px';
	}
}
function setModeAffichageBM(param) {
	var ref = _(bm).style;
	if(param == minimise) {
		ref.width = widthBM;
		ref.height = heightBM;
		ref.display = "block";
		ref.bottom = "200px";
		ref.right = "20px";
	} else if (param == cache) {
		ref.display = "none";
	} else if (param == maximise) {
		ref.width = getpageSize().width + "px";
		ref.height = getpageSize().height + "px";
		ref.bottom = "0px";
		ref.right = "0px";
	}
}
function showHide(obj) {
	var ref = _(obj).style;
	with (ref) {
		display = display == 'none' ? 'block' : 'none';
	}
}
// script pour faire apparaÃ®tre les info bulles de la carte
function show(obj) {
	var ref = _(obj).style;
	with (ref) {
		display = display == 'none' ? 'block' : 'block';
	}
}
// script pour faire disparaÃ®tre les info bulles de la carte
function hide(obj) {
	var ref = _(obj).style;
	with (ref) {
		display = display == 'block' ? 'none' : 'none';
	}
}
function getpageSize() {
	var x = y = 0;
	if(!isIe) {
		x = w.innerWidth;
		y = w.innerHeight;
	} else {
		if(d.documentElement.clientHeight != 0) {
			y = d.documentElement.clientHeight;
			x = d.documentElement.clientWidth;
		} else {
			y = d.body.clientHeight;
			x = d.body.clientWidth;
		}
	}
	return ({height:y, width:x});
}
function getPageSscroll() {
	var x = 0;
	var y = 0;
	var reference;
	if(!isIe){
		x = w.scrollX;
		y = w.scrollY;
	} else {
		reference = (d.documentElement && d.documentElement.clientWidth) ? d.documentElement : d.body;
		with (reference) {
			x = scrollLeft;
			y = scrollTop;
		}
	}
	return({top:y, left:x});
}
function cleanContent(o) {
	var p = _(o);
	if(p == n) {
		return;
	}
	while( p.firstChild ) {
		p.removeChild( p.firstChild );
	}
}

function getElementsByClassName(classname)	{
	var obj = getElementsByClassName.arguments.length == 2 ? _(getElementsByClassName.arguments[1]) : d;
	var listTags = obj.getElementsByTagName('*');
	var listId = new Array();
	for(var i=0; i < listTags.length; i++) {
		if(listTags[i].className == classname) {
			!listTags[i].getAttribute('id') ? listTags[i].id = classname+"-"+i : f;
			listId[listId.length] = listTags[i].id ;
		}
	}
	return listId;
}
// coordonnÃ©es (x,y) d'un Ã©lement dans la page
function getOffset(o) {
	var PosX = PosY = 0;
	var Obj = _(o);
	if(Obj){
		PosX = Obj.offsetLeft;
		PosY = Obj.offsetTop;
		if(Obj.offsetParent){
			while (Obj = Obj.offsetParent) {
				if (Obj.offsetParent) {
					PosX += Obj.offsetLeft;
					PosY += Obj.offsetTop;
				}
			}
		}
	}
	return({left:PosX, top:PosY});
}
// fonction pour customiser les boutons
function customizeButtons() {
	var buttons = document.getElementsByTagName('BUTTON');
	if(buttons.length == 0) {
		return;
	}
	var strBegin = /^\s+/;
	var strEnd = /\s+$/;
	for(var i=0; i < buttons.length; i++) {
		if(buttons[i].childNodes[0].nodeName == '#text') {
			var texte = '';
			for( var j=0; j < buttons[i].childNodes.length; j++) {
				texte += buttons[i].childNodes[j].nodeValue;
			}
			buttons[i].getAttribute('TYPE') == null ? buttons[i].setAttribute('type','button') : false;
			buttons[i].className.length == 0 ? buttons[i].className = 'button' + buttons[i].getAttribute('TYPE').toLowerCase() : false ;
			while(buttons[i].childNodes.length != 0) {
				buttons[i].removeChild(buttons[i].lastChild);
			}
			var table = document.createElement('TABLE');
			var tr = table.insertRow(-1);
			var td_1 = tr.insertCell(-1);
			td_1.className = 'buttonLeft';
			var td_2 = tr.insertCell(-1);
			td_2.className = 'buttonRight';
			td_2.appendChild(document.createTextNode(texte.replace(strBegin,'').replace(strEnd,'')));
            buttons[i].appendChild(table);

		}
	}
}

function openPopup(url) {
	w.open(url,"impression","scrollbars=yes, toolbar=yes, location=0, resizable=no, fullscreen=no, dialog=no, width=640, height=480, top=0, left=0",false);
}

function closePopup() {
	w.close();
}

// apparition/disparition du champ input text et de son calendrier dans la maquette B_news.html
// "eventObj" = "select" ou "input", etc... dan la page souvent remplacÃ© par "this"
// "viewElement" = nom du id de la balise concernÃ©e 
function showHideOnChange(eventObj, viewElement) {
	document.getElementById(viewElement).style.display = (eventObj.options.selectedIndex == 0 || eventObj.options.selectedIndex == 1) ? "block" : "none";
	var showCalend = false;
	if(eventObj.options.selectedIndex == 0 || eventObj.options.selectedIndex == 1)
	  showCalend = true;
	showCalend == true ? "block" : document.location=eventObj.options[eventObj.options.selectedIndex].value;
}

//si la liste déroulante est positionnée sur le premier ou le 2ème item, alors on affiche le calendrier
function initializeCalendar(onElement, viewElement) {
  var selected = false;
  if(document.getElementById(onElement).options[0].selected || document.getElementById(onElement).options[1].selected)
    selected = true;
	selected ? document.getElementById(viewElement).style.display = 'block' : false;
}
// end

function forSelect(that) {
	var listSelect = document.getElementsByTagName('SELECT');
	for (var i=0; i<listSelect.length ; i++) {
		listSelect[i].blur();
		if (listSelect[i].id == that.id) {
			var j = ++i;
		}
	}
	if (j<listSelect.length) {
		listSelect[j].focus();
	}
}

// empÃªcher l'apparition des title et/ou alt sous IE voire sous les autres navigateurs
function supprInfoBulle() {
	var areas = document.getElementsByTagName("area");
	for (var i=0; i<areas.length; i++) {
		areas[i].setAttribute("alt", "");
		areas[i].setAttribute("title", "");
	}
}
//Supprime et remplace le paramï¿½tre d'url "orderby"
function trier(id, colonne, ordre){
	var queryString = window.location.href.substring(window.location.href.indexOf("?")+1, window.location.href.length);
	var queryArgs = queryString.split("&");
	var newQueryArgs = new Array();
	for(var i = 0 ; i < queryArgs.length ; i++) {
		if((queryArgs[i].indexOf("orderby") < 0) && (queryArgs[i].indexOf("idfile") < 0) && (queryArgs[i].indexOf("action") < 0)) {
			newQueryArgs.push(queryArgs[i]); 
		}
	}
	var orderBy = ((newQueryArgs.length <= 0)?"?":"&") + "orderby=" + colonne + "%20" + ordre;
	var newQueryString = newQueryArgs.join("&") + orderBy;
	var newHref = window.location.href.substring(0, window.location.href.indexOf("?")) + "?" + newQueryString;
	document.getElementById(id).action = newHref;
	document.getElementById(id).submit();
}
// LOAD EVENTS
addEvenement( window, 'load', customizeButtons);
addEvenement( window, 'load', supprInfoBulle);


