//<![CDATA[
// Copyright (c) GraphicWeb Interactive Solutions

function GWCal_ChangeSelect()
	{
	var gwindex=document.forms["gwcalform"].elements["gamme_form"].options[document.forms["gwcalform"].elements["gamme_form"].options.selectedIndex].value;
	for(i=document.forms["gwcalform"].elements["reference"].options.length;i>=0;i--) {document.forms["gwcalform"].elements["reference"].options[i]=null;}
	
	document.forms["gwcalform"].elements["reference"].options[0]=new Option("(Tous les Produits)","");
	for(i=0;i<gwcalproduits[gwindex].length;i++)
		{document.forms["gwcalform"].elements["reference"].options[(i)]=new Option(gwcalproduits[gwindex][(i)][1],gwcalproduits[gwindex][(i)][0]);}
	}

function GWCal_ChangeSelect_Gamme()
	{
	var gwindex=document.forms["gwcalform"].elements["gamme"].options[document.forms["gwcalform"].elements["gamme"].options.selectedIndex].value;
	for(i=document.forms["gwcalform"].elements["article"].options.length;i>=0;i--) {document.forms["gwcalform"].elements["article"].options[i]=null;}
	
	for(i=0;i<gwcalproduits[gwindex].length;i++)
		{document.forms["gwcalform"].elements["article"].options[(i)]=new Option(gwcalproduits[gwindex][(i)][1],gwcalproduits[gwindex][(i)][0]);}
	}

function GWCal_Init()
	{
	document.getElementById("gwcalheight_defaut").style.height=(parseInt(document.getElementById("gwcalheight").offsetHeight)-94)+"px";
	document.getElementById("gwcalheight_defaut").style.display="block";
	}


function GWCal_RefreshPrix(gwcal_gamme)
	{
	var quantite=document.forms["gwcalform"].elements["quantite"].value;var gwindex_start=null;
	
	if(gwcal_gamme=="CP" || gwcal_gamme=="CV") {var grille_tarif=new Array(250,500,1000,2000,3000,4000,5000,10000);}
	else if(gwcal_gamme=="AG") {var grille_tarif=new Array(60,120,220,320,420,520,760,1020);}
	else if(gwcal_gamme=="GW") {var grille_tarif=new Array(250,500,750,1000,1500,2000,3000,5000);}
	else{var grille_tarif=new Array(50,100,200,300,400,500,750,1000);}
	
	var nbcolor=document.forms["gwcalform"].elements["couleurs"].options[document.forms["gwcalform"].elements["couleurs"].options.selectedIndex].value;var gwcal_alert="";
	
	if(nbcolor>0)
		{
		for(i=0;i<8;i++) {if(gwtarif[nbcolor][i]!=0 && gwindex_start==null) {gwindex_start=i;}}
		
		if(quantite<grille_tarif[gwindex_start])
			{
			quantite=grille_tarif[gwindex_start];
			gwcal_alert="La quantit&eacute; que vous demandez pour<br />cet Article et ce marquage est impossible...<br /><br />Le champ a donc "
				+"&eacute;t&eacute; actualis&eacute;<br />avec la valeur minimum requise...";
			}
		
		for(i=gwindex_start;i<8;i++) {if(quantite>=grille_tarif[i]) {var prix_unit=gwtarif[nbcolor][i];}}
		}
	else
		{
		var prix_unit=gwtarif[0][1];
		if(quantite<gwtarif[0][0])
			{
			quantite=gwtarif[0][0];
			gwcal_alert="La quantit&eacute; que vous demandez pour<br />cet Article et ce marquage est impossible...<br /><br />Le champ a donc "
				+"&eacute;t&eacute; actualis&eacute;<br />avec la valeur minimum requise...";
			}
		}
	
	document.getElementById("gwcal_devis_alert").innerHTML=gwcal_alert;document.forms["gwcalform"].elements["prix_unit"].value=prix_unit.toFixed(2);
	document.forms["gwcalform"].elements["quantite"].value=quantite;document.forms["gwcalform"].elements["prix"].value=(prix_unit*quantite).toFixed(2);
	}

function GWCal_RetourForm()
	{
	document.forms["gwcalform"].elements["etape"].value=1;
	document.forms["gwcalform"].submit();
	}

function GWCal_Submit(gwtype)
	{document.forms["gwcal_form"].elements["gwcal_modif"].value=gwtype;document.forms["gwcal_form"].submit();}
//]]>
