function loading() {
  xajax.callback.global.onRequest = function() {xajax.$('loading').style.display = 'block';}
  xajax.callback.global.beforeResponseProcessing = function() {xajax.$('loading').style.display='none';}
}

function modifPageColor(color) {
 	var div = document.getElementById("page")
	div.setAttribute("style", color)
}

function modifBodyBg() {
 	var div = document.getElementById("body");

	div.setAttribute("style", "background: url('');background-color:#f4f3f3;");

	//Remplace setAttribute pour IE
	div.style.cssText = "background: url('');background-color:#f4f3f3;";
}

function afficheLogo() {
 	var div = document.getElementById("logo_intro");
	
	div.setAttribute("style", "display:block;position:absolute; height:auto; margin-top:450px; margin-left:650px; z-index:102;");
	//Remplace setAttribute pour IE
	div.style.cssText = "display:block;position:absolute; height:auto; margin-top:450px; margin-left:650px; z-index:102;";
}

function afficheLang(rub) {

	if (rub == 99) { 
		
 		var div = document.getElementById("lang")
		div.setAttribute("style", "display:none;")
		//Remplace setAttribute pour IE
		div.style.cssText = "display:none;";

	} else {

 		var div = document.getElementById("lang")
		div.setAttribute("style", "display:block;")
		//Remplace setAttribute pour IE
		div.style.cssText = "display:block;";
	}
}
/*
|--------------------------------------------------------------------------
| Fonctions Caddie
|--------------------------------------------------------------------------
|
*/
function subtractQty(id){
	if(document.getElementById("quantity"+id).value - 1 < 0)
		return;
	else
		 document.getElementById("quantity"+id).value--;
}

function afficheStock() {
 	var div = document.getElementById("stock");
	div.setAttribute("style", "display:block;color:red;");

	//Remplace setAttribute pour IE
	div.style.cssText = "display:block;color:red;";
}

function affiche(id) {
 	var div = document.getElementById(id);
	div.setAttribute("style", "display:block;");

	//Remplace setAttribute pour IE
	div.style.cssText = "display:block;";
}

function mask(id) {
 	var div = document.getElementById(id);
	div.setAttribute("style", "display:none;");

	//Remplace setAttribute pour IE
	div.style.cssText = "display:none;";
}
/*
|--------------------------------------------------------------------------
| Fonctions diverses
|--------------------------------------------------------------------------
|
*/

function moveFooter(rub) {

	if (rub == 4) { 
		
 		var div = document.getElementById("footer")
		div.setAttribute("style", "margin-top:730px;")
		//Remplace setAttribute pour IE
		div.style.cssText = "margin-top:730px;";

	} else if (rub == 6) { 
		
 		var div = document.getElementById("footer")
		div.setAttribute("style", "margin-top:650px;")
		//Remplace setAttribute pour IE
		div.style.cssText = "margin-top:650px;";

	} else if (rub == 7) { 
		
 		var div = document.getElementById("footer")
		div.setAttribute("style", "margin-top:650px;")
		//Remplace setAttribute pour IE
		div.style.cssText = "margin-top:650px;";

	} else if (rub == 8) { 
		
 		var div = document.getElementById("footer")
		div.setAttribute("style", "margin-top:700px;")
		//Remplace setAttribute pour IE
		div.style.cssText = "margin-top:700px;";

  	} else {

 		var div = document.getElementById("footer")
		div.setAttribute("style", "margin-top:auto;")
		//Remplace setAttribute pour IE
		div.style.cssText = "margin-top:auto;";
	}
}



/*
|--------------------------------------------------------------------------
| Fonctions diverses
|--------------------------------------------------------------------------
|
*/

function modifierStyle() {

	new Effect.SlideUp('erreur');
}

function modifierHauteur(rub) {

	if (rub == 1) { 
		
		var div = document.getElementById("enter")
		div.setAttribute("style", "height:600px;")
		//Remplace setAttribute pour IE
		div.style.cssText = "height:600px;";

  	} else {

		var div = document.getElementById("enter")
		div.setAttribute("style", "height:350px;")		
		//Remplace setAttribute pour IE
		div.style.cssText = "height:350px;";
	}
}


function modifierBodyBackground() {
	var body = document.getElementById("body")
	body.setAttribute("style", "background-color:#000;")
	//Remplace setAttribute pour IE
	div.style.cssText = "background-color:#000;";

}


function fermerOutilWindow() {

	new Effect.SlideUp('outilWindow');
}

function ouvrirOutilWindow() {

 	var div = document.getElementById("outilWindow")
	div.setAttribute("style", "display:block;")
	new Effect.SlideDown('outilWindow');
}

/*
|--------------------------------------------------------------------------
| Fonctions diverses
|--------------------------------------------------------------------------
|
*/
function fermerWindow() {

	new Effect.SlideUp('searchResultDiv');
	new Effect.Fade('closeSearchResultDiv');
}

function ouvrirWindow() {

	var div = document.getElementById("closeSearchResultDiv")
	var div2 = document.getElementById("searchResultDiv")

	//div.setAttribute("style", "display:block;");
	//div2.setAttribute("style", "display:block;");

	div.setAttribute("style", "position:absolute;background-color:#c89560;width:350px;height:20px;font-family:'Trebuchet MS', helvetica, sans-serif ;font-size:10px;text-align:center;padding:5px;z-index:100;");
	div2.setAttribute("style", "position:absolute;background-color:#000;width:350px;height:auto;filter:alpha(opacity=50);opacity: 0.8;margin-top:25px;padding:5px;z-index:99;");

	//new Effect.SlideDown('searchResultDiv');
}

/*
|--------------------------------------------------------------------------
| Fonctions relatives au LiveSearch des villes -> cp
|--------------------------------------------------------------------------
|
*/

function livesearch (ville, livestop, olds) {
    if (ville.length >= 5 && ville != olds && livestop == 'live') {

 		var div = document.getElementById("searchResultDiv")
 		var div2 = document.getElementById("closeSearchResultDiv")

		div.setAttribute("style", "position:absolute;background-color:#dedede;width:350px;height:auto;filter:alpha(opacity=50);opacity: 0.8;margin-top:25px;z-index:99;");
		div2.setAttribute("style", "position:absolute;background-color:#666;width:350px;height:20px;font-family:'Trebuchet MS', helvetica, sans-serif ;font-size:10px;text-align:center;padding-top:5px;padding-bottom:0px;z-index:100;");
    
        document.getElementById('myForm').old_s.value = ville;
        xajax_liveSearch(ville, '');
    }
    if (livestop == 'live') {
        setTimeout("livesearch(document.getElementById('myForm').ville.value, document.getElementById('myForm').livestop.value, document.getElementById('myForm').old_s.value)", 500);
    }
}

function fillVille (ville, cp) {
	if (cp == '1') {
        document.getElementById('myForm').villeInteret1.value = ville;
	}else if(cp == '2'){
        document.getElementById('myForm').villeInteret2.value = ville;
    }else if(cp == '3'){
        document.getElementById('myForm').villeInteret3.value = ville;
    }else if(cp == '4'){
        document.getElementById('myForm').ville_bien.value = ville;
    }else{
        document.getElementById('myForm').ville.value = ville;
        document.getElementById('myForm').cp.value = cp;
    }

}

function fermerliveSearch() {

 	//var div = document.getElementById("outilWindow")
	//div.setAttribute("style", "position:absolute; width:100%; text-align:center;opacity : 0.8;filter : alpha(opacity=50);display:none;")
	new Effect.SlideUp('searchResultDiv');
	new Effect.Fade('closeSearchResultDiv');
}


/*
|--------------------------------------------------------------------------
| Fonction diaporama
|--------------------------------------------------------------------------
|
*/

var effect = 1;
var time = 5000;

var current_image = 0;
var next_image = 1;
var image = new Array();

function init() {
	if(document.getElementsByClassName("image")) {
		image = document.getElementsByClassName("image");
		for(i=1; i < image.length; i++) {
			image[i].style.display = "none";
		}
	}
	
	if(image.length > 1) galerie();
}

function galerie() {
	self.setTimeout("nextimage()",time);	
}

function nextimage() {
	if(effect == 1) { new Effect.Fade(image[current_image]); new Effect.Appear(image[next_image]); }
	if(effect == 2) { new Effect.BlindUp(image[current_image]); new Effect.BlindDown(image[next_image]); }
	
	if(next_image == (image.length-1)) {
		current_image = next_image;
		next_image = 0;
	} else {
		current_image = next_image;
		next_image++;
	}
	galerie();
}