function montreHaut(id) {
  var elem = document.getElementById(id);
  var img = document.getElementById(id+'_img');
  
  hideAllMenus();
  
  if(elem && img) {
    img.src = img.src.replace(/_off/, "_on");
    elem.style.display = 'block';
    menuIsOpen = true;
  }
  return false;
}

function cache(id) {
  var elem = document.getElementById(id);
  var img = document.getElementById(id+'_img');
  
  if(elem && img) {
    img.src = img.src.replace(/_on/, "_off");
    elem.style.display = 'none';
  }
  return false;
}

function hideAllMenus() {
  var model = "smenuhaut";
  var limit = 8;
  
  for(var i=1; i<=limit; i++) {
    var elem = document.getElementById(model+i);
    var img = document.getElementById(model+i+'_img');
    if(elem && img) {
      img.src = img.src.replace(/_on/, "_off");
      elem.style.display = 'none';
    }
  }
}

function hideAllHover1() {
	var model = "theme";
	var limit = 5;
	
	for(var i=1; i<=limit; i++) {
		var elem = document.getElementById(model+i);
		if(elem) {
			elem.className = 'recherche_boutique_theme1';
		}
	}
}

function hideAllHover2(num) {
	var model = "type"+num+"_";
	var limit = 10;
	
	for(var i=1; i<=limit; i++) {
		var elem = document.getElementById(model+i);
		if(elem) {
			elem.className = 'recherche_boutique_type1';
		}
	}
}

function montreHover1(id) {
	var elem = document.getElementById(id);

	hideAllHover1();
	
	if(elem) {
		elem.className = 'recherche_boutique_theme1_hover';
	}
}

function montreHover2(id, num) {
	var elem = document.getElementById(id);

	hideAllHover2(num);
	
	if(elem) {
		elem.className = 'recherche_boutique_type1_hover';
	}
}

function hideAllType() {
	var model = "recherche_boutique_theme_type";
	var limit = 10;
	
	for(var i=1; i<=limit; i++) {
		var elem = document.getElementById(model+i);
		if(elem) {
			elem.className = 'type_hidden';
		}
	}
}

function hideAllMag(type) {
	var model = "recherche_boutique_theme_mag"+type+"_";
	var limit = 30;
	
	for(var i=1; i<=limit; i++) {
		var elem = document.getElementById(model+i);
		if(elem) {
			elem.className = 'type_hidden';
		}
	}
}

function montreType(num) {
	var model = "recherche_boutique_theme_type";
	var elem = document.getElementById(model+num);

	hideAllType();
	
	if(elem) {
		elem.className = 'type_show';
	}

}

function montreMag(num, type) {
	var model = "recherche_boutique_theme_mag";
	var elem = document.getElementById(model+type+"_"+num);

	hideAllMag(type);
	
	if(elem) {
		elem.className = 'type_show';
	}

}


var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			/* styled */
			//if(inputs[a].id == "centres") {
			if(inputs[a].id == "centresX") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
			/* styled2 */
			if((inputs[a].id =="select_theme") || (inputs[a].id =="selection_boutique")) {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select2";
				span[a].id = "select2" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose2;
			}
			/* styled3 */
			//if((inputs[a].id == "select_theme") || (inputs[a].id == "selection_boutique")) {
			if((inputs[a].id == "select_themeX") || (inputs[a].id == "selection_boutiqueX")) {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select3";
				span[a].id = "select3" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose3;
			}
			if(inputs[a].className == "styled4") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select4";
				span[a].id = "select4" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose4;
			}
			if(inputs[a].className == "styled5") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select5";
				span[a].id = "select5" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose5;
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	},
	choose2: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select2" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	},
	choose3: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select3" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	},
	choose4: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select4" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	},
	choose5: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select5" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}