Array.prototype.in_array_index = function(p_val) {
    for(var i = 0, l = this.length; i < l; i++) {
        if(this[i] == p_val) {
            return i;
        }
    }
}
function addLoadEvent(event){// permet d'ajouter 
	new SuperClass().addEvent(window,"load",event);
}
function createDomElement(parent,type){// raccourci pour creer un element
	var d = document.createElement(type);
	 return parent.appendChild(d);
}

function getCssStyleValue (element /*element html*/, style/*style recherché*/){
  if(element.currentStyle){
    return element.currentStyle[style];
  }
  else{
    return window.getComputedStyle(element,null).getPropertyValue(style);
  }
}
///////////////////////
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=650,width=650');
}

function pop_up2(){	
fenetre2=window.open('','popup2','toolbar=0, location=0, directories=0, status=0,  resizable=1, scrollbars=1, height=650,width=650');
}
//////////////////////////////////////////////////////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;
}
//Pop up
function deletePopup_f(){
	if(document.getElementById('scontenu__js__pop__'))document.body.removeChild(document.getElementById('contenu__js__pop__'));
}
function fausse_popup(content) {
	var pop=new JsPop();
	pop.openPop(508, "auto","<div id=\"popup\"><a href=\"#\" onclick=\"deletePopup_f();return false;\" id=\"imgclosepopPetition\"></a><div id=\"scontenu__js__pop__\">"+content+"</div></div>");
}
