function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	if (!ro) {
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	return ro;
}

function close_error(){
	document.getElementById("error_window").style.display="none";
}

function close_info(){
	document.getElementById("info_window").style.display="none";
}

function panier_action(act,id_art_ref){

	if(act=='update'){
		document.getElementById("choix_action").value=act;
		document.getElementById("panier_produits").submit();
	}
	
	if(act=='delete'){
		if(confirm("Etes vous sur de vouloir supprimer ce produit ?")){
			document.getElementById("choix_action").value=act;
			document.getElementById("id_art_ref").value=id_art_ref;
			document.getElementById("panier_produits").submit();
		}
		
	}
	if(act=='delete_panier'){
		if(confirm("Etes vous sur de vouloir supprimer tous les produits de votre panier ?")){
			document.getElementById("choix_action").value=act;
			document.getElementById("panier_produits").submit();
		}
	}
}

function setReferer(){
	var ref = document.referrer;
	var ref_http = createRequestObject();
	ref_http.open('get','core/ajax/ajax_referer.php?ref='+ref);
	ref_http.send(null);
}

function ajoutQt(id,id_ref) {
	val = document.getElementById("qte_"+id+"_"+id_ref).value;
	val++;
	document.getElementById("qte_"+id+"_"+id_ref).value = val;
}

function suppQt(id,id_ref) {
	val = document.getElementById("qte_"+id+"_"+id_ref).value;
	if (val>1) val--;
	document.getElementById("qte_"+id+"_"+id_ref).value = val;
}


function pass_perdu(){
	myWindow = window.open("index.php?module=contenu&contenu=pass_perdu-blank", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=340,height=170,left=100,top=100");
}
function comparatif_tailles(){
	myWindow = window.open("index.php?module=contenu&contenu=guide_taille", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=590,height=500,left=100,top=50");
}

function enreg_panier(){
        myWindow = window.open("/core/enreg_panier.php", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=340,height=170,left=100,top=100");
}
	
function alerte_stock(id_art_ref){
	myWindow = window.open("/core/alerte_client.php?id_art_ref="+id_art_ref, "Alerte", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=480,height=160,left=100,top=100");
}

function validCgv(){
	if(document.form_conditions.valid_cgv.checked==false){
		alert("Vous devez accepter les Conditions Générales de Vente pour pouvoir commander.");
		return false;
	}else{
		return true;
	}
}

function format_number(number,dec){
	var snum = new String(number);
	var sec = snum.split('.');
	var number_int = parseFloat(sec[0]);
	var number_float = parseFloat("0."+sec[1]);

	var res ="";
	if(number_float > 0){
		res = Math.round(number_float*Math.pow(10,dec));
		var res2 = Math.round(number_float*Math.pow(10,dec+1))-(res*10);
		if(res2 > 4){
			res++;
		}
	}else{
		 for(i=1 ; i<=dec;i++){
			res +="0";
		 }
	}
	return number_int+"."+res;
}

//Gestion du menu pour ie6
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

function close_addcart(){
	close_info();
}
setTimeout("close_addcart()",2000);

