
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function popup_window( url, id, width, height )
{
	var url2;
	url2 = replace(url," ","") ;
	//url2 = replace(url2,"www.veolia-proprete.fr","83.169.72.11") ;
	
	popup = window.open(url2, id, 'toolbar=yes, scrollbars=yes, location=yes, statusbar=yes, menubar=yes, resizable=yes, width=' + width + ', height=' + height + '' );
	if (
		popup!=null){popup.focus();
	}
}


var vp_boites_accordion;

window.addEvent('load', function() {
	
	var hs = $$('.vp_boite_hideshow');
	var c = $$('.vp_boite_content');
	
	if(hs && hs.length>0 && c && c.length>0) {
		vp_boites_accordion = new Fx.Accordion(hs, c, { display: false, alwaysHide: true, opacity: false
			, onBackground: function(tog, i) {
				tog.className = 'vp_boite_hideshow';
				vp_boites_onClose(tog, i)
			}
			, onActive: function(tog, i) {
				tog.className = 'vp_boite_hideshow active';
				this.completed = i;
				this.currentTog = tog;
				this.currentI = i;
			}
			, onComplete: function() {
				if(this.completed != null) {
					vp_boites_onOpen(this.currentTog, this.currentI)
					this.completed = null;
				}
			}
		});
	}

});


function vp_boites_onOpen(tog, i) {
}
function vp_boites_onClose(tog, i) {
}


function showdiv(args) {
	
	var ceTexte = 'texte0' +  args;
	
	//alert(ceTexte);
	activateText(document.getElementById(ceTexte));
	
}
function activateText(cetId){
	etat_active = cetId.id;
	
	var TousLi = $ES('.gallery_child');
	//console.log(TousLi);
	for (var i=0; i<TousLi.length; i++) {
		//alert(TousLi[i].id);
		//console.log(i);
		//console.log(TousLi[i].id);
		if (TousLi[i].id != etat_active){
			TousLi[i].style.display="none";
		}else{
			TousLi[i].style.display="block";
		}
	}
}


