if(OZ === undefined) {
	var OZ = {};
}

if(typeof XMLHttpRequest == 'undefined' && window.ActiveXObject) {
	XMLHttpRequest = function() {
		var xml = false;
		try {
			xml = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				xml = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xml = false;
			}
		}
		return xml;
	};
}

OZ.ajax = function(options) {
	options = {
		type: options.type || "POST",
		url: options.url || "",
		timeout: options.timeout || 5000,
		onComplete: options.onComplete || function(){},
		onError: options.onError || function(){},
		onSuccess: options.onSuccess || function(){},
		onSuccessDatas: options.onSuccessDatas || null,
		data: options.data || null
	};
	
	var xml = new XMLHttpRequest();
	
	xml.open(options.type, options.url, true);
	if(options.type == 'POST') {
		xml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	}
	
	var timeoutLength = options.timeout;
	
	var requestDone = false;
	
	setTimeout(function(){
		requestDone = true;
	}, timeoutLength);
	
	xml.onreadystatechange = function(){
		if(xml.readyState == 4 && !requestDone) {
			if(httpSuccess(xml)) {
				options.onSuccess(httpData(xml, options.type), options.onSuccessDatas);
			} else {
				options.onError();
			}
			options.onComplete();
			xml = null;
		}
	};
	
	xml.send(options.data);
	
	function httpSuccess(r) {
		try {
			return !r.status && location.protocol == "file:" ||
			(r.status >= 200 && r.status < 300) ||
			r.status == 304 ||
			navigator.userAgent.indexOf("Safari") >= 0 && typeof r.status == "undefined";
		} catch(e) {}
		return false;
	}
	
	function httpData(r, type) {
		var ct = r.getResponseHeader("content-type");
		var data = null;
		data = ct.indexOf("xml") > -1 ? r.responseXML : r.responseText;
		if(ct.indexOf("script") > -1) {console.log('aa');eval.call(window, data);}
		return data;
	}
};

addEvent(window,'load', function() {
	var ul = document.getElementById('changing_menu');
	var div = document.getElementById('changing_core');
	if(!ul || !div) {return;}
	
	var lastActive = ul.getElementsByTagName('li')[0];
	if(!lastActive) {return;}
	
	var processDatas = function(datas) {
		div.innerHTML = datas;
	};
	
	var activateItem = function(item) {
		item.className = 'on';
	};
	
	var desactivateItem = function(item) {
		item.className = '';
	};
	
	ul.onclick = function(e) {
		var t = e.target || e.srcElement;
		if(t.nodeType != 1) {t = t.parentNode;}
		if(t.nodeName == 'A') {
			OZ.ajax({
				url: t.href,
				type: 'GET',
				onSuccess: processDatas
			});
			if(lastActive) {
				desactivateItem(lastActive);
			}
			lastActive = t.parentNode;
			activateItem(lastActive);
			return false;
		}
	};
}
);

// GETELEMENTSBYCLASSNAME
                function getElementsByClassName(oElm, strTagName, strClassName){
                    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
                    var arrReturnElements = new Array();
                    strClassName = strClassName.replace(/\-/g, "\\-");
                    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
                    var oElement;
                    for(var i=0; i<arrElements.length; i++){
                        oElement = arrElements[i];
                        if(oRegExp.test(oElement.className)){
                            arrReturnElements.push(oElement);
                        }
                    }
                    return (arrReturnElements)
                }

// FIN GETELEMENTSBYCLASSNAME
function show_detail_perfume() {

	if( document.getElementById( "changing_menu" ) ) {
	
	    var elementList = document.getElementById( "changing_menu" ).getElementsByTagName( "li" );
	
	    var index = 0;
	    var nbElement = elementList.length;
	
	    while( index < nbElement ) {
	
	        var currentElement = elementList[index];
	
	        if( currentElement.className == "on" ) {
	
	            currentElementDetail = document.getElementById( "bloc_" +currentElement.id );
	
	            currentElementDetail.style.visibility = 'visible';
	            currentElementDetail.style.zIndex = '+1';
	            currentElementDetail.style.display = 'block';
	
	        }
	
	        currentElement.onclick = function() { this.className = 'on';
	                                                show_over( this );
	                                 }
	
	        index++;
	
	    }
	 }

}
function show_over(d){

    var bloc_detail = getElementsByClassName(document, "div", "bloc_detail");
    var bloc_details = document.getElementById("bloc_"+d.id);

    for (i=0; i< bloc_detail.length ; i++ )
    {
         var list_li = bloc_detail[i].getElementsByTagName('li');
         for (j=0; j< list_li.length; j++)
         {
             if(list_li[j].id == d.id){list_li[j].className = 'on';affiche_bloch(bloc_details);}
             else {list_li[j].className = ' ';}
         }
    }

}
function affiche_bloch(bloc) {

    var detail_show = getElementsByClassName(document, "div", "changing_core");
    for (i=0;i<detail_show.length ;i++ )
    {
        if(detail_show[i].id == bloc.id){detail_show[i].style.visibility = 'visible';detail_show[i].style.zIndex = '+1';detail_show[i].style.display = 'block';}
        else {detail_show[i].style.visibility = 'hidden';detail_show[i].style.display = 'none';}
    }

}



