/* 
Les tableaux avec  prix et textes fait
par : Marc-Andre Menard
tout droits reserve
derniers changements : le 14-02-2010
*/

function maketable(currency,type,langue)
{

var target = document.getElementById("droite");
var holdingtable;
var tabletitre;
var tableprix;
var tabledeprepress;
var tablespec;
var realprice;
var unitprice;

var quantite = 500;

/* *************** Taux de change  ********************* */
var CAD = 1.0;
var USD = 1.00;
var EUR = 1.3264;

/* *****converter *** */

USD = 1/USD;
EUR = 1/EUR;

if (currency=="CAD") {facteur=CAD};
if (currency=="USD") {facteur=USD};
if (currency=="EUR") {facteur=EUR};

/* *************** variable des titres ********************* */
var titre;
if (langue=="FRA" && type=="CA") {titre="D&eacute;tail du prix pour cartes d'affaire en lenticulaire";}
if (langue=="ANG" && type=="CA") {titre="Price details for lenticular business cards";}
if (langue=="FRA" && type=="CP") {titre="D&eacute;tail du prix pour cartes postales en lenticulaire";}
if (langue=="ANG" && type=="CP") {titre="Price details for lenticular postal cards";}

var tauxdechange;
if (langue=="FRA") {tauxdechange="* Prix bas&eacute;s sur un taux de change variable de : ";}
if (langue=="ANG") {tauxdechange="* Price based on a variable exchange rate of :";}


/* *************** Load the right text in the tableauprepresstexte array ********************* */
var tableauprepressFRA = new Array();
	tableauprepressFRA[0]="Pr&eacute;press, entrelacement et prototype";
	tableauprepressFRA[1]="Flip 2 images";
	tableauprepressFRA[2]="Flip 3 images";
	tableauprepressFRA[3]="Morphologie";
	tableauprepressFRA[4]="Animations 12 images";
	tableauprepressFRA[5]="Animation vid&eacute;o";
	tableauprepressFRA[6]="3 dimensions multi plans";
	
var tableauprepressANG = new Array();
	tableauprepressANG[0]="Prepress, Interlacing and Prototype";
	tableauprepressANG[1]="2 Images Flip";
	tableauprepressANG[2]="3 images flip";
	tableauprepressANG[3]="Morphing";
	tableauprepressANG[4]="12 frames animation";
	tableauprepressANG[5]="Video animation";
	tableauprepressANG[6]="3D with multi layers";

var tableauprepresstexte = new Array(); 

if (langue=="FRA") {tableauprepresstexte=tableauprepressFRA;}
if (langue=="ANG") {tableauprepresstexte=tableauprepressANG;}

/* *************** Load the right prices in the price array ********************* */
var priceca = new Array();
	priceca[0]=350;
	priceca[1]=575;
	priceca[2]=745;
	priceca[3]=910;
	priceca[4]=1100;
	priceca[5]=1250;
	priceca[6]=1450;
	priceca[7]=1600;
	priceca[8]=1800;
	priceca[9]=2000;
	
var pricecp = new Array();
	pricecp[0]=850;
	pricecp[1]=1420;
	pricecp[2]=1860;
	pricecp[3]=2300;
	pricecp[4]=2775;
	pricecp[5]=3240;
	pricecp[6]=3710;
	pricecp[7]=4120;
	pricecp[8]=4545;
	pricecp[9]=4950;
	
var price = new Array(); 

if (type=="CA") {price=priceca;}
if (type=="CP") {price=pricecp;}

/* *************** Load the right prices in the prepress array ********************* */
var prepressca =  new Array();
	prepressca[0]=175;
	prepressca[1]=225;
	prepressca[2]=350;
	prepressca[3]=450;
	prepressca[4]=500;
	prepressca[5]=550;
	
var prepresscp =  new Array();
	prepresscp[0]=200;
	prepresscp[1]=250;
	prepresscp[2]=400;
	prepresscp[3]=500;
	prepresscp[4]=550;
	prepresscp[5]=600;	
	
var prepressprice =  new Array();

if (type=="CA") {prepressprice=prepressca;}
if (type=="CP") {prepressprice=prepresscp;}
	
/* *************** Load the spec text in the array ********************* */
var specfra =  new Array();
	specfra[0]="Lentille";
	specfra[1]="APET 75 lpi, 49&deg;, 18 pts";
	specfra[2]="Impression";
	specfra[3]="Recto : 4 coul. Verso : noir &agrave; 50%";
	specfra[4]="Finition";
	specfra[5]="Coup&eacute;  4 faces, coins carr&eacute;";
	specfra[6]="Format fini";
	if (type=="CA") {specfra[7]="3.5\" x 2\"";}
	if (type=="CP") {specfra[7]="4\" x 6\"";}
	specfra[8]="Taxes";
	specfra[9]="En surplus si applicables.";
	specfra[10]="Prix";
	specfra[11]="Sujet &agrave; changements sans pr&eacute;avis";
	
var specang =  new Array();
	specang[0]="Lens";
	specang[1]="APET 75 lpi, 49&deg;, 18 pts";
	specang[2]="Printing";
	specang[3]="Front : 4 coul. Back : Black at 50%";
	specang[4]="Finishing";
	specang[5]="Cut on 4 faces, square corner";
	specang[6]="Final size";
	if (type=="CA") {specang[7]="3.5\" x 2\"";}
	if (type=="CP") {specang[7]="4\" x 6\"";}
	specang[8]="Taxes";
	specang[9]="Additional taxes if applicable";
	specang[10]="Price";
	specang[11]="Subject to change witout notice";
	
var spec =  new Array();

if (langue=="FRA") {spec=specfra;}
if (langue=="ANG") {spec=specang;}

/* *************** Clear Everything ********************* */
while (target.hasChildNodes()) target.removeChild(target.childNodes[0]);

/* *************** Table titre ********************** */
tabletitre = "<tr> <td colspan=\"3\"><div align=\"left\"><span class=\"textebold\">" + titre +"</span> </div> </td> </tr>";

/* *************** Table Header ********************** */
tableprix = "<table valign=\"top\" cellspacing=\"0\" class=\"tableclass\">";

if (langue=="FRA") {tableprix += "<th width=\"75\"><div align=\"center\"><strong>Quantit&eacute;</strong></div></th>";}
if (langue=="ANG") {tableprix += "<th width=\"75\"><div align=\"center\"><strong>Quantity</strong></div></th>";}

if (langue=="FRA") {tableprix += "<th width=\"150\"><div align=\"center\">Prix impression</div></th>";}
if (langue=="ANG") {tableprix += "<th width=\"150\"><div align=\"center\">Printing price</div></th>";}

if (langue=="FRA") {tableprix += "<th width=\"150\"><div align=\"center\">Prix unitaire</div></th>";}
if (langue=="ANG") {tableprix += "<th width=\"150\"><div align=\"center\">Price each</div></th>";}

/* *************** table prix  ********************* */
var i=0; for (i=0;i<=9;i++)
{
	realprice = price[i] * facteur;
	realprice = Math.round(realprice);
	unitprice = realprice/(quantite * (i+1));
	
	tableprix += "<tr>";
	
	tableprix += "<td><div align=\"center\"><strong>" + quantite * (i+1) + "</strong></div></td>"; /*quantite*/
	tableprix += "<td><div align=\"center\"> " + realprice.toFixed(2) + " <span class=\"petit\">" + currency +"</span></div></td>"; /*prix total*/
	
	if (langue=="FRA") {tableprix += "<td><div align=\"center\"> " + unitprice.toFixed(2) + " <span class=\"petit\">" + currency +"<span class=\"petit\"> / ch.</span></div></td>";}/*prix unitaire*/
	if (langue=="ANG") {tableprix += "<td><div align=\"center\"> " + unitprice.toFixed(2) + " <span class=\"petit\">" + currency +"<span class=\"petit\"> / ea.</span></div></td>";}/*prix unitaire*/
	
	tableprix += "</tr>";
}

tableprix += "</table>";

/* *************** Currency  ******************** */
tableprix += "<p></p>";

/* tableprix += "<div align=\"left\"><span class=\"mcbottom\">" + tauxdechange + "1.00 CAD = "+facteur.toFixed(2)+ " " + currency +"</span></div>"; */

/* *************** table prepress  ********************* */
tabledeprepress = "<table valign=\"top\" cellspacing=\"0\" class=\"tableclass\">";
tabledeprepress += "<th colspan=\"2\"><div align=\"left\"><strong>" + tableauprepresstexte[0] + "</strong></div></th>";

var i=0; for (i=0;i<=5;i++)
{
	tabledeprepress += "<tr> <td width=\"250\"><div align=\"left\"><strong>" + tableauprepresstexte[i+1] + "</strong></div></td>";
	
	realprice = prepressprice[i] * facteur;
	realprice = Math.round(realprice);
	tabledeprepress += "<td width=\"150\"><div align=\"center\"> " + realprice.toFixed(2) + " <span class=\"petit\">" + currency + "</span></div></td> </tr>";
}

tabledeprepress += "</table>";

/* *************** table spec  ********************* */
tablespec = "<table valign=\"top\" cellspacing=\"0\" class=\"tableclass\">";

if (langue=="FRA") {tablespec += "<th colspan=\"2\"><div align=\"left\"><strong>Spr&eacute;cifications techniques</strong></div></th>";}
if (langue=="ANG") {tablespec += "<th colspan=\"2\"><div align=\"left\"><strong>Technical specifications</strong></div></th>";}

var i=0; for (i=0;i<=10;i+=2)
{
	tablespec += "<tr>";
	tablespec += "<td width=\"100\"><div align=\"left\"><strong>" + spec[i] + "</strong></div></td>";
	tablespec += "<td width=\"300\"><div align=\"left\"> " + spec[i+1] +"</div></td>";
	tablespec += "</tr>";
}

tablespec += "</table>";

/* **************** Create holding table ********************* */
holdingtable = "<table valign=\"top\" cellspacing=\"0\">";

holdingtable += tabletitre;

holdingtable += "<tr> <td valign=\"top\" width=\"350\">";

holdingtable += tabledeprepress;
holdingtable += "<br>";
holdingtable += tablespec;
holdingtable += "</td>";

holdingtable += "</td>";

holdingtable += "<td width=\"10\"></td> "; /*center spacer*/

holdingtable += "<td>";

holdingtable += tableprix;

holdingtable += "</tr> </table>";

/*make the whole table*/
target.innerHTML = holdingtable;

}
