
// Sous Menu Collection
function closeMenuCollection(actif) {
	document.getElementById('mainMenuCollection').style.display='none';
	if(!actif)
		document.getElementById('btMenuCollection').style.backgroundPosition = "0 0";
}
function showMenuCollection() {
	$('mainMenuCollection').style.display='';
	$('btMenuCollection').style.backgroundPosition = "0 -18px";
}



// Menu type de produit
var menuType = {
	tagS:[],
	set : function() {
		var id=0;
		this.tagS = $('type_menu').getElementsByTagName('li');
		for(var i=0;i<this.tagS.length;i++) {
			if($(this.tagS[i]).hasClass('limenu')) {
				id++;
				$('smenu'+id).setStyle('opacity',0);
				$('smenu'+id).setStyle('display','none');
				this.tagS[i].saveVarID = id;
				this.tagS[i].onmouseover = function(){
					menuType.openCloseMenu(this.saveVarID,'',1);
					return false;
				}
				this.tagS[i].onmouseout = function(){
					menuType.openCloseMenu(this.saveVarID,'none',0);
					return false;
				}
			}
		}
	},
	openCloseMenu : function(id,display,fade) {
		$('smenu'+id).setStyle('display',display);
		$('smenu'+id).fade(fade);
	}

}


// pop up
function popen(urlstr,nom,larg,haut,top,gch,scrl,rsz) {
	new_win = window.open(urlstr, nom, 'toolbar=no, location=no, directories=no, status=no, scrollbars='+scrl+', resizable='+rsz+', menubar=no, width='+larg+', height='+haut+', top='+top+', left='+gch+'');
	new_win.focus();
	return;
}
function Popup_centre(page,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}


// Affiche/Masque Div
function ShowOrHide(d1, d2) {
	if (d1 != '') DoDiv(d1);
	if (d2 != '') DoDiv(d2);
  
}
function DoDiv(id) {
	var item = null;
	if (document.getElementById) {
	item = document.getElementById(id);
	} else if (document.all){
	item = document.all[id];
	} else if (document.layers){
	item = document.layers[id];
	}
	if (!item) {
	}
	else if (item.style) {
	if (item.style.display == "none"){ item.style.display = ""; }
	else {item.style.display = "none"; }
	}else{ item.visibility = "show"; }
}


// Panier : changement de quantité
function augmente_qte(val){
	eval("document.panier.qte_"+val+".value++");
	document.panier.submit();
}
function diminue_qte(val){
	if (eval("document.panier.qte_"+val+".value>1"))
		eval("document.panier.qte_"+val+".value--");
	
	document.panier.submit();
}
function verif_qte(val){
	// contrôle si la valeur d'un champ est un code postal conforme
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	
	for (i = 0; i < eval("document.panier.qte_"+val+".value.length") && IsNumber == true; i++) {
		eval("Char = document.panier.qte_"+val+".value.charAt("+i+")");
		
		if (ValidChars.indexOf(Char) == -1) {
			eval("document.panier.qte_"+val+".value='1'");
			IsNumber=false;
			document.panier.submit();
		}
		if (i==0 && Char=="0"){
			eval("document.panier.qte_"+val+".value='1'");
			IsNumber=false;
			document.panier.submit();
		}
		if (i>2) {
			eval("document.panier.qte_"+val+".value='1'");
			IsNumber=false;
			document.panier.submit();
		}
	}
	document.panier.submit();
}


// Roll Over
function swap_me(o,to_what,nochange,ext) {
	if (nochange=='') {
		var towhat, ext;
		towhat='/_img/'+to_what+'.'+ext;
		o.src	= towhat;
	}
}



