function useAjax(id_string,select,sesion_id){
	var object = document.getElementById(id_string+select);
	var file = "index_ajax.php?"+"contentIndex="+select+"&session_idUser="+sesion_id+"&ajax=1";
	if (object.innerHTML == ''){
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox
				xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
				xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else { // XMLHttpRequest non supporté par le navigateur
				alert("Problem of navigator, contact SUPPORT");
		}
			
		xhr_object.open("GET", file, true);

		xhr_object.onreadystatechange = function(){
				if ( xhr_object.readyState == 4 ){
						for(i=0;i<5;i++){
							document.getElementById(id_string+i).style.display='none';
						}
						object.innerHTML = xhr_object.responseText;
						menu_showBlock(select);
						object.style.display = 'block';
						
				}
		}

		xhr_object.send(null);
	} else {
		for(i=0;i<5;i++){
			document.getElementById(id_string+i).style.display = 'none';
		}
		menu_showBlock(select);
		object.style.display = 'block';
		
	}
	return false;
}
// MENU IN index_content.php
function menu_showBlock(idBlock){
	for (i=0; i<=4; i++){
		document.getElementById('menu'+i).className = 'optionMenu';
		document.getElementById('arrow_menu'+i).style.backgroundImage='';
	}
	document.getElementById('menu'+idBlock).className = 'optionMenuSelected';
	document.getElementById('arrow_menu'+idBlock).style.background='url("img/index_content/arrow.png") no-repeat';
}

function changeStyle(idBlock,number,newName){
	var className = document.getElementById(idBlock);
	var blockPrice = document.getElementById('displayPrice'+number);
	var pName = document.getElementById('displayText'+number);

	if(className.getAttribute('class')=='service'){
		className.setAttribute('class', newName);
		blockPrice.style.display = 'block';
		pName.style.display = 'none';
		if (navigator.appName == "Microsoft Internet Explorer"){
			 className.style.backgroundColor= "#666666";
		}
	}else{
		className.setAttribute('class', newName);
		blockPrice.style.display = 'none';
		pName.style.display = 'block';
		if (navigator.appName == "Microsoft Internet Explorer"){
			 className.style.backgroundColor= "#EAEAEA";
		}
	}
	return false;
}

//CONTENT INDEX PROMO FROM index_ajax
function showPromo(select, limitItem){
	// ADDING CONTENT FROM FILE IN INNER.HTML AND HIDDING EXISTING CONTENT
	var file = "lib/data_promo.php?"+"contentPromo="+select;
	var blockNameId = "promoContent";
		
	var object = document.getElementById(blockNameId+select);
	var blockSup = document.getElementById('blockSup'+select);
	
	if (object.innerHTML == ''){
		var xhr_object = null;
		if(window.XMLHttpRequest) // Firefox
				xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
				xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else { // XMLHttpRequest non supporté par le navigateur
				alert("Problem of navigator, contact SUPPORT");
		}
			
		xhr_object.open("GET", file, true);

		xhr_object.onreadystatechange = function(){
			if ( xhr_object.readyState == 4 ){
				for(i=0;i<9;i++){
					document.getElementById(blockNameId+i).style.display='none';
				}
				object.innerHTML = xhr_object.responseText;
				object.style.display = 'block';
			}
		}

		xhr_object.send(null);
		
		} else {
			for(i=0;i<9;i++){
				document.getElementById(blockNameId+i).style.display = 'none';
			}
			object.style.display = 'block';
		}
		
		//SHOW SELECTED PRODUCT
		for (i=0;i<limitItem;i++){
			document.getElementById("arrowUp"+i).innerHTML = '';
		}			
		document.getElementById("arrowUp"+select).innerHTML = '<img src="img/index_content/arrow_img_selected.jpg"/>';
		
		for (i=0;i<limitItem;i++){
			document.getElementById("blockSup"+i).style.border  = '';
		}			
		document.getElementById("blockSup"+select).style.border = 'solid 4px #83BD49';
		
		return false;
}

var t;
var timer_is_on=0;
var end = 0;

function timedCount(option){
	var object = document.getElementById('allImgScroll');
	var margin=object.style.marginLeft;
	
	if (!option){
		if (parseInt(margin) >= 0){
				clearTimeout(t);
		} else {
				object.style.marginLeft = parseInt(margin) + 10 + 'px';
				t=setTimeout("timedCount("+option+")",100);
		}
		
	} else {
		if (end){
			if (parseInt(margin) >= 0){
				end = 0;
			} else {
				object.style.marginLeft = parseInt(margin) + 5 + 'px';
				t=setTimeout("timedCount("+option+")",10);
			}
		} else {
			if (parseInt(margin) <= -561){
				end = 1;
				t=setTimeout("timedCount("+option+")",50);
			} else {
				object.style.marginLeft = parseInt(margin) - 5 + 'px';
				t=setTimeout("timedCount("+option+")",50);
			}
		}
	}
}

function moveBlock(option){
	if (!timer_is_on){
	  timedCount(option);
	}
}
function stopBlock(){
	clearTimeout(t);
	end = 0;
}

function changeStyleScrool(numberId,state){
	
	var object = document.getElementById('arrowUp'+numberId);
	var blockSup = document.getElementById('blockSup'+numberId);
	
	if(state==1){
		object.style.backgroundColor='#D6D6D6';
		object.innerHTML ='<img src="img/index_content/arrow_img_selected.jpg" />';
		blockSup.style.border =	'solid 4px #83BD49';
	}else{
		object.innerHTML = '';
		blockSup.style.border =	'';
	}
	
	return false;
}

function showPromoBottom(select){
	
	var file = "lib/data_promo_bottom.php?"+"contentPromoMonth="+select;
	var blockNameId = "promoMonth";
	
	var object = document.getElementById(blockNameId+select);
	for(i=0;i<5;i++){
		document.getElementById('rond'+i).src = "img/index_content/rond_selected.jpg";
	}
	document.getElementById('rond'+select).src = "img/index_content/rond_selected_green.jpg";
		
		if (object.innerHTML == ''){
			var xhr_object = null;
			if(window.XMLHttpRequest) // Firefox
					xhr_object = new XMLHttpRequest();
			else if(window.ActiveXObject) // Internet Explorer
					xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
			else { // XMLHttpRequest non supporté par le navigateur
					alert("Problem of navigator, contact SUPPORT");
			}
				
			xhr_object.open("GET", file, true);
	
			xhr_object.onreadystatechange = function(){
				if ( xhr_object.readyState == 4 ){
					for(i=0;i<=4;i++){
						document.getElementById(blockNameId+i).style.display='none';
					}
					object.innerHTML = xhr_object.responseText;
					object.style.display = 'block';
				}
			}
	
			xhr_object.send(null);
		
		} else {
			for(i=0;i<=4;i++){
				document.getElementById(blockNameId+i).style.display = 'none';
			}
			object.style.display = 'block';
		}
		return false;
}

