 //Taxes
var tps=0.05;   //6%
var tvq=0.075;  //7.5%

//Prix livraisons
var livqTirage=7.86;  //Livraison au Qubec
var livcTirage=12.20; //Livraison ailleurs au Canada
var livwTirage=14.05; //Livraison International

//Prix livraisons cartes Postale et tampons
var livqCarteTampons=1.10;  //Livraison au Qubec
var livcCarteTampons=1.10; //Livraison ailleurs au Canada
var livwCarteTampons=2.20; //Livraison International

//Prix livraisons signets
var livqSignet=1.10;  //Livraison au Qubec
var livcSignet=1.10; //Livraison ailleurs au Canada
var livwSignet=2.20; //Livraison International

//Prix livraisons affichettes
var livqAffichettes=2.75;  //Livraison au Qubec
var livcAffichettes=6.80; //Livraison ailleurs au Canada
var livwAffichettes=13.60; //Livraison International

var livqjpKit=1.10;  //Livraison au Qubec
var livcjpKit=1.10; //Livraison ailleurs au Canada
var livwjpKit=3.90; //Livraison International

var livq; //Livraison au Qubec
var livc; //Livraison ailleurs au Canada
var livw; //Livraison International

function calcPrice(prod_price, liv_type,prod_type) {
 
	switch(prod_type){
		 case 'tirage':
		 	livq=livqTirage; //Livraison au Qubec
			livc=livcTirage; //Livraison ailleurs au Canada
			livw=livwTirage; //Livraison International
			tps=0.05;   //6%
			tvq=0.075;  //7.5%
			break;
			
		 case 'affichette':
		 	livq=livqAffichettes; //Livraison au Qubec
			livc=livcAffichettes; //Livraison ailleurs au Canada
			livw=livwAffichettes; //Livraison International
			tps=0.05;   //6%
			tvq=0.075;  //7.5%
			break;
			
		case 'carte':
			
		 	livq=livqCarteTampons; //Livraison au Qubec
			livc=livcCarteTampons; //Livraison ailleurs au Canada
			livw=livwCarteTampons; //Livraison International
			tps=0.05;   //6%
			tvq=0.075;  //7.5%
			break;
				
		case 'tampon':
		 	livq=livqCarteTampons; //Livraison au Qubec
			livc=livcCarteTampons; //Livraison ailleurs au Canada
			livw=livwCarteTampons; //Livraison International
			tps=0.05;   //6%
			tvq=0.075;  //7.5%
			break;
		
		case 'signet':
		 	livq=livqSignet; //Livraison au Qubec
			livc=livcSignet; //Livraison ailleurs au Canada
			livw=livwSignet; //Livraison International
			tps=0.05;   //6%
			tvq=0.075;  //7.5%
			break;
			
		case 'fondecran':
		 	livq=0; //Livraison au Qubec
			livc=0; //Livraison ailleurs au Canada
			livw=0; //Livraison International
			tps=0.5;   //0%
			tvq=0.075;  //0%
			break;
			
		case 'serigraphie':
		 	livq=7.86; //Livraison au Qubec
			livc=12.20; //Livraison ailleurs au Canada
			livw=14.05; //Livraison International
			tps=0.05;   //0%
			tvq=0.075;  //0%
			break;
			
		case 'jpkit':
		 	livq=1.10; //Livraison au Qubec
			livc=1.10; //Livraison ailleurs au Canada
			livw=3.90; //Livraison International
			tps=0.05;   //0%
			tvq=0.075;  //0%
			break;
	}
    if (isNaN(prod_price)) return 0;

    var total = prod_price;
    switch (liv_type) {
        case 'q':
			total = total + livq;
            total += total * tps;
            total += total * tvq;
            break;
        case 'c':
            total = total + livc;
            total += total * tps;
            break;
        case 'w':
            total = total + livw;
            break;
    }
    if (isNaN(total)) return 0;

    var total2 = new Number(total);
    total2 = total2.toFixed(2);
    if (isNaN(total2)) return total;
    return total2;
}

function orderItem(prod_type, price,prodNo) {
prodNo--;
    var frmobj = document.forms.frmboutique;
    frmobj.amount.value = price;

    switch(prod_type){
		case 'tirage'://#00000 - 09999	
		frmobj.item_name.value = oeuvres_name[prodNo];
    		frmobj.item_number.value = oeuvres_no[prodNo];
		if (document.forms.form5.region.selectedIndex == 0)
			{ showError(document.forms.form5); return false;}
		break;
		
		case 'carte'://#10000 - 19999
		frmobj.item_name.value = cartes_name[prodNo];
    		frmobj.item_number.value = cartes_no[prodNo];
		if (document.forms.form3.region.selectedIndex == 0)
			{ showError(document.forms.form3); return false;}
		
		break;
		
		
		case 'affichette':
		frmobj.item_name.value = affichette_name[prodNo];
    		frmobj.item_number.value = affichette_no[prodNo];
		if (document.forms.form2.region.selectedIndex == 0)
			{ showError(document.forms.form2); return false;}
		break;
				
				
    		case 'tampon'://#20000 - 29999
		frmobj.item_name.value = tamponTxt;
    		frmobj.item_number.value = '20000';
		if (document.forms.form6.region.selectedIndex == 0)
			{ showError(document.forms.form6); return false;}
		break;
		
		case 'signet'://#30000 - 39999
		frmobj.item_name.value = signetTxt;
    		frmobj.item_number.value = '30000';
		if (document.forms.form1.region.selectedIndex == 0)
			{ showError(document.forms.form1); return false;}
		break;
		
		case 'jpkit'://#
		frmobj.item_name.value = jpKitTxt;
    		frmobj.item_number.value = '60000';
		if (document.forms.form6.region.selectedIndex == 0)
			{ showError(document.forms.form6); return false;}
		break;
			
		case 'fondecran'://#40000 - 49999
		frmobj.item_name.value = fond_name[prodNo];
    		frmobj.item_number.value = fond_no[prodNo];
		if (document.forms.form4.region.selectedIndex == 0)
			{ showError(document.forms.form4); return false;}
		break;

		case 'affiche'://#40000 - 49999
		frmobj.item_name.value = affiche_name[prodNo];
    		frmobj.item_number.value = affiche_no[prodNo];
		if (document.forms.form1.region.selectedIndex == 0)
			{ showError(document.forms.form1); return false;}
		break;

		case 'serigraphie'://#50000 - 59999
		frmobj.item_name.value = seri_name[prodNo];
    		frmobj.item_number.value = seri_no[prodNo];
		if (document.forms.form7.region.selectedIndex == 0)
			{ showError(document.forms.form7); return false;}
		break;
	}
    
    
    if (!isNaN(price))
        frmobj.submit();
    else {
        var div2 = document.getElementById(prod_type+"Info");
        div2.innerHTML = "<font style='color: #990000;'>There is an error with the price. <a href='mailto: info@fredericback.com'>Notify us</a> please.</font>";
    }
}

function showError(f)
{
	alert(commandeErr);
	f.region.focus();
}


    // Change oeuvres lists if more than 25
var oeuvresArr = new Array();
var currOeuvreInd=0;

    //To emulate push function in IE 5.0
if (typeof Array.prototype.push == "undefined") {
    Array.prototype.push = Array_push;
}
function Array_push() {
    var A_p = 0;
    for (A_p = 0; A_p < arguments.length; A_p++) {
        this[this.length] = arguments[A_p];
    }
    return this.length;
}

function addOeuvre(SName) {
	//alert(oeuvresArr.length);
	oeuvresArr.push(SName);
	
}

/*function gotoPage(page) {
    var tobjnext = document.getElementById('next');
    var tobjprev = document.getElementById('previous');
    if (typeof tobjnext == "undefined" || typeof tobjprev == "undefined") return;

    if (page < oeuvresArr.length-1)
        tobjnext.style.visibility = "visible";
    else
        tobjnext.style.visibility = "hidden";
    if (page >= 1)
        tobjprev.style.visibility = "visible";
    else
        tobjprev.style.visibility = "hidden";

    var divObjCur = document.getElementById(oeuvresArr[currOeuvreInd]);
    var divObj2Change = document.getElementById(oeuvresArr[page]);
    divObjCur.style.display = (divObjCur.style.display == 'none')?'block':'none';
    divObj2Change.style.display = (divObj2Change.style.display == 'none')?'block':'none';
    currOeuvreInd=page;
}*/

function chgOList(pos) {
    var tobjnext = document.getElementById('suivant');
    var tobjprev = document.getElementById('precedent');
    if (typeof tobjnext == "undefined" || typeof tobjprev == "undefined") return;

    if (currOeuvreInd+pos < oeuvresArr.length-1)
        tobjnext.style.visibility = "visible";
    else
        tobjnext.style.visibility = "hidden";
    if (currOeuvreInd+pos >= 1)
        tobjprev.style.visibility = "visible";
    else
        tobjprev.style.visibility = "hidden";

    /*if (currOeuvreInd+pos > oeuvresArr.length-2) toggleVisibility('next', false);
    else if (currOeuvreInd+pos < 1) { toggleVisibility('previous', false); }
    else {
        if (currOeuvreInd+pos+1 == oeuvresArr.length) toggleVisibility('next', true);
        if (currOeuvreInd+pos >= 1) toggleVisibility('previous', true);
    }*/

    var divObjCur = document.getElementById(oeuvresArr[currOeuvreInd]);
    var divObj2Change = document.getElementById(oeuvresArr[currOeuvreInd+pos]);
    divObjCur.style.display = (divObjCur.style.display == 'none')?'block':'none';
    divObj2Change.style.display = (divObj2Change.style.display == 'none')?'block':'none';

    currOeuvreInd=currOeuvreInd+pos;
}
