function calcul_typea(montant, nbpieces)
{
	nb_colis = document.cart_quantity.qty.value;
	
	if( (isNaN(nb_colis) == true) || (nb_colis=='') || (nb_colis=='0') )
 	{
		document.getElementById('divmontant').innerHTML='0';
		document.getElementById('divnbpieces').innerHTML='0';
		document.getElementById('btnsubmit').style.display='none';
		
		document.cart_quantity.nb_colis.value = '0';
		document.cart_quantity.nb_pieces.value = '0';
		document.cart_quantity.montant.value = '0';
	}
	else
	{
		
		total_int = montant * nb_colis; 
		total = total_int.toString();
		if(total.indexOf(".") < 0)
			total = total + ".00";
		else
		{
			
			if(	 (total.indexOf(".")+2) <= total.length)
				total = total + "0";
			else	
				total = total.substring(0,total.indexOf(".")+3);
		}

		nb_total =  nbpieces * nb_colis; 
		nb_total = nb_total.toString();
		document.getElementById('divnbpieces').innerHTML=nb_total;
		document.getElementById('divmontant').innerHTML=total;
		document.getElementById('btnsubmit').style.display='block';
		
		document.cart_quantity.nb_colis.value = nb_colis;
		document.cart_quantity.nb_pieces.value = nb_total;
		document.cart_quantity.montant.value = total_int;
	}
}


function calcul_typeb(montant, nbpieces, champs)
{
	
	total_colis = 0;
	
	len_champs = champs.length;
	fini = false;
	while(fini == false)
	{
		i=0;
		pos_virgule = champs.indexOf(",");
		if(pos_virgule==-1)
		{
			champ_courant = champs;
			fini = true;
		}
		else	
			champ_courant = champs.substr(i,pos_virgule);
		
		val_champ = eval("document.cart_quantity.qty_"+champ_courant+".value");
		
		if( (isNaN(val_champ) == true) || (val_champ=='') || (val_champ=='0') )
			eval("document.cart_quantity.qty_"+champ_courant+".value='0'");
		else
		{
			if(val_champ.substr(0,1)=="0")
				val_champ = val_champ.substr(1,(val_champ.length-1));
				
			total_colis+=parseInt(val_champ);
		}
		
		len_courant = champ_courant.length;
		i+=len_courant+1; 
		len_champs-=len_courant;
		champs = champs.substr(i,len_champs);
		
	}
	
	if(total_colis>0)
	{
		total_int = montant * total_colis; 
		total = total_int.toString();
		if(total.indexOf(".") < 0)
			total = total + ".00";
		else
		{
			
			if(	 (total.indexOf(".")+2) <= total.length)
				total = total.substring(0,total.indexOf(".")+2) + "0";
			else	
				total = total.substring(0,total.indexOf(".")+3);
		}
		
		nb_total =  nbpieces * total_colis; 
		nb_total = nb_total.toString();
		document.getElementById('divnbpieces').innerHTML=nb_total;
		document.getElementById('divnbcolis').innerHTML=total_colis;
		document.getElementById('divmontant').innerHTML=total;
		document.getElementById('btnsubmit').style.display='block';
		
		document.cart_quantity.nb_colis.value = total_colis;
		document.cart_quantity.nb_pieces.value = nb_total;
		document.cart_quantity.montant.value = total_int;
	}
	else
	{
		document.getElementById('divmontant').innerHTML='0';
		document.getElementById('divnbcolis').innerHTML='0';
		document.getElementById('divnbpieces').innerHTML='0';
		document.getElementById('btnsubmit').style.display='none';
		
		document.cart_quantity.nb_colis.value = '0';
		document.cart_quantity.nb_pieces.value = '0';
		document.cart_quantity.montant.value = '0';
	}

}

function calcul_typec(montant, champs)
{
	total_pieces = 0;
	
	len_champs = champs.length;
	fini = false;
	while(fini == false)
	{
		i=0;
		pos_virgule = champs.indexOf(",");
		if(pos_virgule==-1)
		{
			champ_courant = champs;
			fini = true;
		}
		else	
			champ_courant = champs.substr(i,pos_virgule);
		
		val_champ = eval("document.cart_quantity.qty_"+champ_courant+".value");
		
		if( (isNaN(val_champ) == true) || (val_champ=='') || (val_champ=='0') )
			eval("document.cart_quantity.qty_"+champ_courant+".value='0'");
		else
		{
			if(val_champ.substr(0,1)=="0")
				val_champ = val_champ.substr(1,(val_champ.length-1));
			
			total_pieces+=parseInt(val_champ);
		}
		
		len_courant = champ_courant.length;
		i+=len_courant+1; 
		len_champs-=len_courant;
		champs = champs.substr(i,len_champs);
		
	}

	if(total_pieces>0)
	{
		total_int = montant * total_pieces; 
		
		unite_vente = document.cart_quantity.unite_vente.value;
		total_pieces = total_pieces * parseInt(unite_vente);
		
		total = total_int.toString();
		if(total.indexOf(".") < 0)
			total = total + ".00";
		else
		{
			
			if(	 (total.indexOf(".")+2) <= total.length)
			{
				total = total.substring(0,total.indexOf(".")+2) + "0";
			}
			else	
			{
				total = total.substring(0,total.indexOf(".")+3);
			}
		}
		
		
		document.getElementById('divnbpieces').innerHTML=total_pieces;
		document.getElementById('divmontant').innerHTML=total;
		document.getElementById('btnsubmit').style.display='block';
		
		document.cart_quantity.nb_colis.value = '0';
		document.cart_quantity.nb_pieces.value = total_pieces;
		document.cart_quantity.montant.value = total_int;
	}
	else
	{
		document.getElementById('divmontant').innerHTML='0';
		document.getElementById('divnbpieces').innerHTML='0';
		document.getElementById('btnsubmit').style.display='none';
		
		document.cart_quantity.nb_colis.value = '0';
		document.cart_quantity.nb_pieces.value = '0';
		document.cart_quantity.montant.value = '0';
	}

}

function confirm_commande()
{
	if(confirm("Etes-vous certain de vouloir transmettre votre sélection ?"))
		document.commander.submit();//.href='checkout_process.php';
	else
		return false;
}

/*==== Focus sur les fields ====*/
function GetFocus(field) {
	if (field.value==field.title) {field.value=''}
}

/*==== Blur sur les fields ====*/
function GetBlur(field) {
	if (field.value=='') {
		field.value=field.title;
	} 
}

/*==== Show seubmenu ====*/
function showSubmenu(id_menu) {
	var submenu = document.getElementById('submenu_'+id_menu);
	submenu.style.display = "block";
	
	var menu = document.getElementById('menu_'+id_menu);
	menu.className = "level-1-active";
	
	/*==== Détection IE6 ====*/
	var IE6 = false;
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChStart = strChUserAgent.substring(0,intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	var strChEnd = strChUserAgent.substring(strChEnd);
	
	if(strChMid.indexOf("MSIE 6") != -1) IE6 = true;
	 
	if(IE6 && document.getElementById('select_filtre'))
		document.getElementById('select_filtre').style.visibility = "hidden";
		
	if(IE6 && document.getElementById('select_tri'))
		document.getElementById('select_tri').style.visibility = "hidden";
}

/*==== Hide seubmenu ====*/
function hideSubmenu(id_menu) {
	var submenu = document.getElementById('submenu_'+id_menu);
	submenu.style.display = "none";
	
	var menu = document.getElementById('menu_'+id_menu);
	menu.className = "level-1";
	
	/*==== Détection IE6 ====*/
	var IE6 = false;
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChStart = strChUserAgent.substring(0,intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	var strChEnd = strChUserAgent.substring(strChEnd);
	
	if(strChMid.indexOf("MSIE 6") != -1) IE6 = true;
	
	if(IE6 &&  document.getElementById('select_filtre'))
		document.getElementById('select_filtre').style.visibility = "visible";
		
	if(IE6 &&  document.getElementById('select_tri'))
		document.getElementById('select_tri').style.visibility = "visible";
}

/*==== Show Pad ====*/
function showPad(pad) {
	var pad = document.getElementById(pad);
	pad.style.display = "block";
}
/*==== Hide Pad ====*/
function hidePad(pad) {
	var pad = document.getElementById(pad);
	pad.style.display = "none";
}


///Ajouter aux favoris
function setBookmark() {
	if (navigator.appName != 'Microsoft Internet Explorer' )
	{ 
		window.sidebar.addPanel("Extranet BAUER Sportswear","http://www.bauer-sportswear.com/extranet/",""); 
	}
	else 
	{
		window.external.AddFavorite("http://www.bauer-sportswear.com/extranet/","Extranet BAUER Sportswear"); 
	} 
}

//Change Thum produit
function changeProductVisu(newNormal, newZoom)
{
	document.getElementById('lien_visu').href=newZoom;
	document.getElementById('lien_visu_zoom').href=newZoom;
	document.getElementById('id_image_test').src=newZoom;
	return false;
}
