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;
}

function alertDiv(msg,taille){
	var pop=new JsPop();
	taille = parseInt(taille) + 60;
	if(taille == '60') taille = 540;
	pop.openPop(750, taille, "<div id=\"simplePop\"><img src='inc/php/image.php?image="+msg+"&L=700&H=700' alt=' ' /></div>");
	pop.setTextFermer("Fermer");
	pop.addBoutonFermer();
	pop.globalDiv.onclick=function(){pop.closePop();}
	pop.func=pop.closePop;
	pop.closePop=function(){
		pop.contenuDiv.style.display="none";
		pop.func();
	}
}

function faussepopupURL(url,lang) {

	page = "envoi.php";
	var mail = " class='margepop'";
	taillew = 440;
	tailleh = 327;	
	
	var reqfauxpop = new HTTP_request(page,
				function(){
					if(reqfauxpop.isSuccess()){
							var content = reqfauxpop.getText();
							var pop=new JsPop();
	pop.openPop(taillew, tailleh,"<div"+mail+"><div id=\"scontenu__js__pop__\">"+content+"</div><br /><a href=\"#\" onclick=\"deletePopup_f();return false;\" id=\"imgclosepopPetition\"><img src='medias/fermer.gif' alt='fermer' /></a></div>");
							if(page == "mentions.php" && taille_fen[1]<670) {
								document.getElementById("mention").style.overflow = "auto";
								document.getElementById("mention").style.height = (tailleh-100)+"px";
							}
					}
			}
			,'get');// nouvelle requete
			reqfauxpop.sendRequest('url='+url+"&langue="+lang);
	
}

function deletePopup_f(){
	if(document.getElementById('global__js__pop__'))document.body.removeChild(document.getElementById('global__js__pop__'));
	if(document.getElementById('contenu__js__pop__'))document.body.removeChild(document.getElementById('contenu__js__pop__'));
}

function envoi_message(lang,url) {
	adresse = document.getElementById("adresse").value;
	adresseexp = document.getElementById("adresseexp").value;
	nom = document.getElementById("nom").value;
	message = document.getElementById("message").value;
	var reqfauxpop = new HTTP_request("envoi.php?friend_send=1&langue="+lang+"&url="+url+"",
	function(){
			if(reqfauxpop.isSuccess()){
					var content = reqfauxpop.getText();
					var pop=new JsPop();
					pop.openPop("300", "100","<div><div id=\"scontenu__js__pop__\">Votre mail à bien été envoyé</div><br /><a href=\"#\" onclick=\"deletePopup_f();return false;\" id=\"imgclosepopPetition\"><img src='medias/fermer.gif' alt='fermer' /></a></div>");
			}		
			},'POST');// nouvelle requete
	
		reqfauxpop.sendRequest('adresse='+adresse+"&nom="+nom+"&adresseexp="+adresseexp+"&message="+message);
}
