<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function jsCCardLength(oStatus){
	var cCardNum = document.forms['register_order'].elements['cCardNum'].value;
	
	if(cCardNum.length < 16){
		oStatus.isvalid = false;
        //oStatus.errmsg = errMsg['errCCardLength'];
	}
}

function initPhotos(){
	var customProdList	= $('customProdList');
	if(customProdList) return;
	
	var photos	= $('photos');
	if(!photos) return;
	
	var items	= getElementsByClassName(photos, "div", "item");
	
	// loop dans la liste des images
	for(var i=0;i < items.length; i++){
		var item		= items[i];
		if(!item) return;
		
		item.quantity	= getElementsByClassName(item, "select", "quantity")[0];
		item.image		= getElementsByClassName(item, "img", "image")[0];
		item.file_name	= item.image.getAttribute('alt');
		
		item.add		= getElementsByClassName(item, "input", "add")[0];
		
		var button = item.add;
		
		button.item = item;
		button.onclick = function(){
			var objFormat 		= getElementsByClassName(this.item, "select", "format")[0].value.split("~");
			this.item.format	= objFormat[0];
			this.item.status	= objFormat[1];
			
			var paper 		= getElementsByClassName(this.item, "select", "paper")[0].value;
			addPrint(this.item.format, paper, this.item.quantity.value, this.item.file_name, this.item.status);
		}
	}
}

function addPrint(format, paper, quantity, file_name, status){
	//alert('addPrint(FORMAT: '+format+', PAPER: '+paper+', QUANTITY: '+quantity+', FILE_NAME: '+file_name+', status: '+status+')');
	
	var itemPrint			= $("item_" + format);
	var detail				= getElementsByClassName(itemPrint, "div", "detail")[0];
	
	if(isPrintInList(file_name, quantity, format, paper)){
		var nbPrintsForFormat 	= parseInt(getElementsByClassName(itemPrint, "span", "quantity")[0].innerHTML);
		getElementsByClassName(itemPrint, "span", "quantity")[0].innerHTML = nbPrintsForFormat + parseInt(quantity);
	
		var pricePerPrint 		= parseFloat(getElementsByClassName(itemPrint, "span", "unit_price")[0].innerHTML);
		var shipPerPrint 		= parseFloat(getElementsByClassName(itemPrint, "span", "unit_shipPrice")[0].innerHTML);
		var totalPriceForFormat = parseFloat(getElementsByClassName(itemPrint, "span", "printPrice")[0].innerHTML);
		//var newTotalPriceForFormat = totalPriceForFormat + shipPerPrint + (parseInt(quantity) * parseFloat(pricePerPrint));
		var newTotalPriceForFormat = totalPriceForFormat + (parseInt(quantity) * parseFloat(pricePerPrint));
		getElementsByClassName(itemPrint, "span", "printPrice")[0].innerHTML = newTotalPriceForFormat.toFixed(2);
		
		if(status == "true"){
			var imgStatus 		= "/images/icons/accept.gif";
		}else{
			var imgStatus 		= "/images/icons/error.gif";
		}
		
		var thePrint	= $(format + '_' + paper + '_' + file_name);
		var thePrintQty	= getElementsByClassName(thePrint, "span", "printQty")[0];
		//var thePrint	= getElementsByClassName(itemPrint, "div", file_name)[0];
		//var thePrintQty	= getElementsByClassName(thePrint, "span", "printQty")[0];
		
		thePrintQty.innerHTML = parseFloat(thePrintQty.innerHTML) + parseFloat(quantity);
	}else{
		var nbPrintsForFormat 	= parseInt(getElementsByClassName(itemPrint, "span", "quantity")[0].innerHTML);
		getElementsByClassName(itemPrint, "span", "quantity")[0].innerHTML = nbPrintsForFormat + parseInt(quantity);
	
		var pricePerPrint 		= parseFloat(getElementsByClassName(itemPrint, "span", "unit_price")[0].innerHTML);
		var shipPerPrint 		= parseFloat(getElementsByClassName(itemPrint, "span", "unit_shipPrice")[0].innerHTML);
		var totalPriceForFormat = parseFloat(getElementsByClassName(itemPrint, "span", "printPrice")[0].innerHTML);
		//var newTotalPriceForFormat = totalPriceForFormat + shipPerPrint + (parseInt(quantity) * parseFloat(pricePerPrint));
		var newTotalPriceForFormat = totalPriceForFormat + (parseInt(quantity) * parseFloat(pricePerPrint));
		getElementsByClassName(itemPrint, "span", "printPrice")[0].innerHTML = newTotalPriceForFormat.toFixed(2);
		
		if(status == "true"){
			var imgStatus 		= "/images/icons/accept.gif";
		}else{
			var imgStatus 		= "/images/icons/error.gif";
		}
		
		//detail.innerHTML += '<div class="singlePrint ' + file_name + '" id="' + format + '_' + paper + '_' + file_name + '">&nbsp;<img src="' + imgStatus + '" class="status" />&nbsp;<span class="printName">' + file_name + '</span>&nbsp;<span class="printPaper">' + paper + '</span>&nbsp;<span class="printQty">' + quantity + '</span>&nbsp;<img src="/images/icons/delete.gif" onClick="removePrint(\'' + file_name + '\', \'' + format + '\', \'' + paper + '\');" class="single_print_remove" /></div>';
		
		detail.innerHTML += '<div class="singlePrint ' + file_name + '" id="' + format + '_' + paper + '_' + file_name + '"><table width="418" border="0" cellspacing="0" cellpadding="0" bgcolor="#d6e8ff" align="right"><tr><td align="center" width="32"><img src="' + imgStatus + '" class="status" /></td><td align="center" width="233"><span class="printName">' + file_name + '</span></td><td align="center" width="52"><span class="printPaper">' + paper + '</span></td><td align="center" width="54"><span class="printQty">' + quantity + '</span></td><td align="center" width="47"><img src="/images/icons/delete.gif" onClick="removePrint(\'' + file_name + '\', \'' + format + '\', \'' + paper + '\');" class="single_print_remove" /></td></tr></table></div>';
	}
	
	var print_shipping = $('print_shipping');
	if(parseFloat(print_shipping.innerHTML) < parseFloat(shipPerPrint)){
		print_shipping.innerHTML = parseFloat(shipPerPrint.toFixed(2));
	}
	
	calcTotal();
}

function addCustomProd(){
	//Select contenant les infos du custom prod selectionne
	var objProdSel		= $('selCustomProd');
	//Array contenant le ID
	var productId		= objProdSel.options[objProdSel.selectedIndex].value;
	var productName	= objProdSel.options[objProdSel.selectedIndex].innerHTML;

	//Select contenant la quantite du custom prod selectionne
	var objProdQty		= $('customProdQty');
	var productQty		= objProdQty.options[objProdQty.selectedIndex].value
	//Select contenant la quantite du custom prod selectionne
	var objProdMinImg	= $('minImageProd');
	var productMinImg	= objProdMinImg.value;
	
	var photos			= $('photos');
	var items			= getElementsByClassName(photos, "div", "item");
	var arrChecked		= getElementsByClassName(photos, "input", "checkbox");
	var arrFileWidth	= getElementsByClassName(photos, "input", "file_width");
	var arrFileHeight	= getElementsByClassName(photos, "input", "file_height");
	var nbChecked 		= 0;
	var arrCheckedImg	= new Array();
		
	// loop dans la liste des images
	for(var i=0; i < items.length; i++){
		var item		= items[i];
		item.image		= getElementsByClassName(item, "img", "image")[0];
		item.file_name	= item.image.getAttribute('alt');
		
		//loop dans la liste des checkbox qui sont checked
		if(arrChecked[i].checked){
			arrCheckedImg[arrChecked[i].value]	= new Array();
			nbChecked++;

			arrCheckedImg[arrChecked[i].value]['product_minWidth']	= arrFileWidth[i].value;
			arrCheckedImg[arrChecked[i].value]['product_minHeight']	= arrFileHeight[i].value;
		}		
	}
	if(nbChecked != productMinImg || nbChecked == 0){
		alert(printf(errMsg['errNbImgChecked'], productMinImg));
		return;
	}

	//loop dans la liste d'image checked
	for(var checkedImg in arrCheckedImg){
		//Valide le status de chaque image checked par rapport au MIN width et height du custom prod
		if(((arrCustomProd[productId]['product_minWidth'] <= arrCheckedImg[checkedImg]['product_minWidth']) && (arrCustomProd[productId]['product_minHeight'] <= arrCheckedImg[checkedImg]['product_minHeight']))){
			//alert('IMG status : GOOD\n');
			arrCheckedImg[checkedImg]['status'] = '/images/icons/accept.gif';
		}else if(((arrCustomProd[productId]['product_minWidth'] <= arrCheckedImg[checkedImg]['product_minHeight']) && (arrCustomProd[productId]['product_minHeight'] <= arrCheckedImg[checkedImg]['product_minWidth']))){
			//alert('IMG status : GOOD\n');
			arrCheckedImg[checkedImg]['status'] = '/images/icons/accept.gif';
		}else{
			//alert('IMG status : BAD\n');
			arrCheckedImg[checkedImg]['status'] = '/images/icons/error.gif';
		}
	}

	var objProdList			= $('prodCustom');
	var singleCustomProd	= getElementsByClassName(objProdList, "div", "singleCustomProd");
	var nbCustomProd		= singleCustomProd.length;
	var newProd;
	
	//productQty
	var customProdTotalPrice = ((parseFloat(productQty) * parseFloat(arrCustomProd[productId]['product_price'])) + (parseFloat(productQty) * parseFloat(arrCustomProd[productId]['product_shippingCost'])));
	
newProd = '<div class="singleCustomProd">'+
			'<table width="451" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr>'+
			'<td align="center" width="32"><img src="/images/icons/minus.gif" class="show_hide" alt="Expand" onclick="showHideProd(this);" /></td>'+
			'<td align="center" width="118"><span class="nameCustom">' + productName + '</span></td>'+
			'<td align="center" width="23"><span class="qty">' + productQty + '</span></td>'+
			'<td align="center" width="80"><span class="unit_price">' + arrCustomProd[productId]['product_price'].toFixed(2) + '</span> $</td>'+
			'<td align="center" width="80"><span class="shipping">' + arrCustomProd[productId]['product_shippingCost'].toFixed(2) + '</span></td>'+
			'<td align="center" width="88"><span class="prodPrice">' + customProdTotalPrice.toFixed(2) + '</span></td>'+
			'<td align="center" width="30"><span class="remove"><img src="/images/icons/delete.gif" onclick="removeProduct(this);" class="removeProduct" /></span></td>'+
			'</tr><tr>'+
			'<td colspan="7" align="right"><div class="customProdList">';
	for(var theImage in arrCheckedImg){
		newProd += '<div class="customProdImageList">'+
					'<table width="451" border="0" cellspacing="0" cellpadding="0" bgcolor="#d6e8ff"><tr valign="top">'+
						'<td bgcolor="#90abdb" width="41" valign="top"></td>'+
						'<td bgcolor="#d6e8ff" width="410" align="center" valign="top"><span class="status"><img src="' + arrCheckedImg[theImage]['status'] + '" class="status" /> </span><strong><span class="nameImg"> ------------ >  ' + theImage + '</span></strong></td>'+
				   '</tr></table></div>';
	}
	newProd += '</td></div></tr></table></div>\n';
	
	objProdList.innerHTML += newProd;
	
	calcTotal();
}
function isPrintInList(filename, quantity, format, paper){
	var itemPrint			= $("item_" + format);
	var detail				= getElementsByClassName(itemPrint, "div", "detail")[0];
	var singlePrints		= getElementsByClassName(detail, "div", "singlePrint");

	for(i=0; i < singlePrints.length; i++){
		var singlePrint = singlePrints[i];
		var single_name	= getElementsByClassName(singlePrint, "span", "printName")[0].innerHTML;
		var single_paper= getElementsByClassName(singlePrint, "span", "printPaper")[0].innerHTML;
				
		if((filename == single_name) && (paper == single_paper)){
			//the print is in the list for the current print format
			return true;
		}		
	}
}

function removeProductId(id){
	var current = $(id);
	var parent = current.parentNode;
	
	parent.removeChild(current);
	calcTotal();
}

function removeProduct(obj){
	var objThisDiv = obj.parentNode.parentNode.parentNode.parentNode;
	var objParentDiv = objThisDiv.parentNode;
	
	objParentDiv.removeChild(objThisDiv);
	calcTotal();
}
function removePrint(fileName, format, paper){
	//valeurs associe au print qu'on enleve
	var thePrint	= $(format + '_' + paper + '_' + fileName);
	var thePrintQty	= getElementsByClassName(thePrint, "span", 'printQty')[0].innerHTML;
	
	//valeurs total par rapport a un type de format
	var theItem	= $('item_' + format);
	var formatQty		= getElementsByClassName(theItem, "span", "quantity")[0].innerHTML;
	var formatPrice		= getElementsByClassName(theItem, "span", "printPrice")[0].innerHTML;
	var formatUnitPrice	= getElementsByClassName(theItem, "span", "unit_price")[0].innerHTML;
	var formatShipPrice	= getElementsByClassName(theItem, "span", "unit_shipPrice")[0].innerHTML;

	//alert('thePrintQty: ' + thePrintQty + '\r\n formatQty: ' + formatQty + '\r\n formatPrice: ' + formatPrice + '\r\n formatUnitPrice: ' + formatUnitPrice+ '\r\n formatShipPrice: ' + formatShipPrice);
	
	getElementsByClassName(theItem, "span", "quantity")[0].innerHTML	= parseInt(formatQty) - parseFloat(thePrintQty);
	
	var newPrice = parseFloat(formatPrice) - (parseFloat(thePrintQty) * (parseFloat(formatUnitPrice)));
	
	getElementsByClassName(theItem, "span", "printPrice")[0].innerHTML		= newPrice.toFixed(2);	
	
	thePrint.parentNode.removeChild(thePrint);
	calcTotal();
}

function massAdd(){
	var imgList = $('photos');
	var items = getElementsByClassName(imgList, "div", "item");
		
	// loop dans la liste des images
	for(var i=0;i < items.length; i++){
		var item = items[i];
		var format 	= getElementsByClassName(item, "select", "format")[0];
		var file_name	= getElementsByClassName(item, "input", "file_name")[0];

		var mass		= $('mass');
		var massQty		= getElementsByClassName(mass, "select", "quantity")[0];
		var massFormat	= getElementsByClassName(mass, "select", "format")[0];
		var massPaper	= getElementsByClassName(mass, "select", "paper")[0];

		//alert(format.options[massFormat.selectedIndex].value);
		//alert('massFormat.selectedIndex : ' + massFormat.selectedIndex);
		
		var arr_temp	= format.options[massFormat.selectedIndex].value.split("~");
		var status		= arr_temp[1];
		
		var paper		= massPaper.value;
		
		addPrint(massFormat.value, paper, massQty.value, file_name.value, status);
	}
}

function showHideFormat(id){
	var obj	= document.getElementById('detail_' + id);
	var img	= document.getElementById('item_' + id);
	
	var imgSource	= getElementsByClassName(img, "img", "show_hide")[0].src;
	
	if(obj.style.display == '' || obj.style.display == 'none'){
		obj.style.display = 'block';
		getElementsByClassName(img, "img", "show_hide")[0].src = imgSource.replace('add.gif', 'minus.gif');
	}else{
		obj.style.display = 'none';
		getElementsByClassName(img, "img", "show_hide")[0].src = imgSource.replace('minus.gif', 'add.gif');
	}
}
function showHideProd(obj){
	var expend		= obj.src;
	var theProd 	= obj.parentNode.parentNode.parentNode;	
	var prodImgs	= getElementsByClassName(theProd, "div", "customProdImageList");
	var spanRemove	= getElementsByClassName(theProd, "span", "remove");
	
	for(id in prodImgs){
		if(prodImgs[id].style.display == '' || prodImgs[id].style.display == 'block'){
			prodImgs[id].style.display = 'none';
			spanRemove[0].style.display = 'none';
			obj.src = expend.replace('minus.gif', 'add.gif');
		}else{
			prodImgs[id].style.display = 'block';
			spanRemove[0].style.display = 'block';
			obj.src = expend.replace('add.gif', 'minus.gif');
		}
		
	}
}
function show(id){
	var obj	= document.getElementById('detail_' + id);
	var img	= document.getElementById('item_' + id);
	
	var imgSource	= getElementsByClassName(img, "img", "show_hide")[0].src;
	
	if(obj.style.display == '' || obj.style.display == 'none'){
		obj.style.display = 'block';
		getElementsByClassName(img, "img", "show_hide")[0].src = imgSource.replace('add.gif', 'minus.gif');
	}
}

function changeDisplay(id){
	var obj	= $(id);
		
	if(obj.style.display == '' || obj.style.display == 'none'){
		obj.style.display = 'block';
	}else{
		obj.style.display = 'none';
	}
}
function changeDisplay_2(id){
	var obj	= $(id);
	
	if(id == "add_print"){
		var obj_mod	= $('mod_print');
		var obj_del	= $('del_print');

		obj.style.display = 'block';
		obj_mod.style.display = 'none';
		obj_del.style.display = 'none';
	}else if(id == "mod_print"){
		var obj_add	= $('add_print');
		var obj_del	= $('del_print');
		
		obj.style.display = 'block';
		obj_add.style.display = 'none';
		obj_del.style.display = 'none';
	}else if(id == "del_print"){
		var obj_add	= $('add_print');
		var obj_mod	= $('mod_print');
		
		obj.style.display = 'block';
		obj_add.style.display = 'none';
		obj_mod.style.display = 'none';
	}	
}
function changeDisplay_3(id){
	var obj	= $(id);
	
	if(id == "add_product"){
		var obj_mod	= $('mod_product');
		var obj_del	= $('del_product');

		obj.style.display = 'block';
		obj_mod.style.display = 'none';
		obj_del.style.display = 'none';
	}else if(id == "mod_product"){
		var obj_add	= $('add_product');
		var obj_del	= $('del_product');
		
		obj.style.display = 'block';
		obj_add.style.display = 'none';
		obj_del.style.display = 'none';
	}else if(id == "del_product"){
		var obj_add	= $('add_product');
		var obj_mod	= $('mod_product');
		
		obj.style.display = 'block';
		obj_add.style.display = 'none';
		obj_mod.style.display = 'none';
	}	
}
function changeTargetImage(id){
	var theImage	= $(id);
	var path		= theImage.src.substr(0, theImage.src.lastIndexOf("/") + 1);

	var theProd		= $('selCustomProd');
	var selProdId	= theProd.options[theProd.selectedIndex].value;
	var qtyImg		= $('qtyImg');
	
	var hidMinImageProd		= $('minImageProd');
	var hidMinWidthProd		= $('minWidthProd');
	var hidMinHeightProd	= $('minHeightProd');
	
	for(var prodId in arrCustomProd){
		if(prodId == selProdId){
			theImage.src			= path + arrCustomProd[prodId]['product_img'];
			qtyImg.innerHTML		= 'Selection image(s): ' + arrCustomProd[prodId]['product_minPhotos'];
			hidMinImageProd.value	= arrCustomProd[prodId]['product_minPhotos'];
			hidMinWidthProd.value	= arrCustomProd[prodId]['product_minWidth'];
			hidMinHeightProd.value	= arrCustomProd[prodId]['product_minHeight'];
		}		
	}
}

function getList(){
	var prints		= $('prints');
	var items		= getElementsByClassName(prints, "div", "item");
	var fullPrints	= prints.innerHTML;
	var arrPrints	= "";

	for(var i=0; i < items.length; i++){
		var format	= getElementsByClassName(items[i], "span", "format_detail")[0].innerHTML;
		var image	= getElementsByClassName(items[i], "div", "singlePrint");
		
		arrPrints += '}[' + format + ']';
		
		for(var j=0; j < image.length; j++){
			var imageName		= getElementsByClassName(image[j], "span", "printName");
			var imageQty		= getElementsByClassName(image[j], "span", "printQty");
			var imageStatus		= getElementsByClassName(image[j], "img", "status")[0];
			var tmpImageName	= imageName[0].innerHTML;
			var tmpImageQty		= imageQty[0].innerHTML;
			var tmpImageStatus	= imageStatus.src.substr(imageStatus.src.lastIndexOf('/') + 1);
			
			//alert('tmpImageStatus: ' + tmpImageStatus);
			
			if(tmpImageQty != null && tmpImageName != null){
				arrPrints += '~' + tmpImageStatus + ', ' + tmpImageQty + ', ' + tmpImageName;
			}			
		}
	}
	
	var prodCustom	= $('prodCustom');
	var arrProds	= getElementsByClassName(prodCustom, "div", "singleCustomProd");
	var strProd		= "";
	
	for(prod in arrProds){
		var nameCustom	= getElementsByClassName(arrProds[prod], "span", "nameCustom")[0].innerHTML;
		var qtyCustom	= getElementsByClassName(arrProds[prod], "span", "qty")[0].innerHTML;
		var priceCustom	= getElementsByClassName(arrProds[prod], "span", "prodPrice")[0].innerHTML;
		var shippingCustom	= getElementsByClassName(arrProds[prod], "span", "shipping")[0].innerHTML;
		
		//strProd += '[' + nameCustom + ']~[' + qtyCustom + ']~[' + priceCustom + ']~'; //[' + shipping + ']~';
		strProd += '}' + nameCustom + '; ' + qtyCustom + '; ' + priceCustom + '; ' + shippingCustom + ';]';
		
		var customProdImageList	= getElementsByClassName(arrProds[prod], "div", "customProdImageList");
		for(customProdImage in customProdImageList){
			var nameImg			= getElementsByClassName(customProdImageList[customProdImage], "span", "nameImg")[0].innerHTML;
			var objStatusImg	= getElementsByClassName(customProdImageList[customProdImage], "img", "status")[0];
			var statusImg		= objStatusImg.src.substr(objStatusImg.src.lastIndexOf('/') + 1);
			
			//alert('Name: ' + nameImg + '\r\n' + 'Status: ' + statusImg);
			
			if(nameImg != null && statusImg != null){
				strProd += statusImg + ', ' + nameImg + '~';			
			}
		}
	}

	document.prints_list.fullPrints.value	= fullPrints;
	document.prints_list.strPrint.value		= arrPrints;
	document.prints_list.strProd.value		= strProd;
}

function calcTotal(){
	var prints			= $('prints');
	var printPrice		= getElementsByClassName(prints, "span", "printPrice");
	var printQuantity	= getElementsByClassName(prints, "span", "quantity");
	var printShipping	= getElementsByClassName(prints, "span", "shipping");
		
	var prodCustom		= $('prodCustom');
	var prodPrice		= getElementsByClassName(prodCustom, "span", "prodPrice");
	var prodUnitPrice	= getElementsByClassName(prodCustom, "span", "unit_price");
	var prodQuantity	= getElementsByClassName(prodCustom, "span", "qty");
	var prodShipping	= getElementsByClassName(prodCustom, "span", "shipping");
	
	var grp_total_total	= $('grp_total_total');
	var total_total		= $('total_total');
	var total_shipping	= $('total_shipping');
	var total_tax		= $('total_tax');
	
	var totalPrintPrice		= 0;
	var totalPrintQuantity	= 0;
	var totalPrintShip		= parseFloat($('print_shipping').innerHTML);
	for(single in printPrice){
		totalPrintPrice		+= parseFloat(printPrice[single].innerHTML);
		totalPrintQuantity	+= parseInt(printQuantity[single].innerHTML);
	}
	//alert('totalPrintPrice: ' + totalPrintPrice);
	//var printTax = ((totalPrintPrice * 1.05) * 0.075);
	var printTax_1 = ((totalPrintPrice * 0.05));
	var printTax_2 = ((totalPrintPrice + printTax_1) * 0.075);
	var printTax = (printTax_1 + printTax_2);
	
	var print_total_taxed = parseFloat(totalPrintPrice + printTax + totalPrintShip);
	
	var totalProdPrice		= 0;
	var totalProdQuantity	= 0;
	var totalProdShipping	= 0;
	for(single in prodPrice){
		totalProdPrice		+= parseFloat(prodPrice[single].innerHTML);
		totalProdQuantity	+= parseInt(prodQuantity[single].innerHTML);
		totalProdShipping	+= (parseFloat(prodShipping[single].innerHTML) * parseInt(prodQuantity[single].innerHTML));
	}
	//var prodTax = ((totalProdPrice * 1.05) * 0.075);
	var prodTax_1 = ((totalProdPrice * 0.05));
	var prodTax_2 = ((totalProdPrice + prodTax_1) * 0.075);
	var prodTax = (prodTax_1 + prodTax_2);
	
	var prod_total_taxed = parseFloat(totalProdPrice + prodTax + totalProdShipping);

	//prints
	$('print_total').innerHTML		= totalPrintPrice.toFixed(2);
	$('print_total_total').innerHTML		= totalPrintPrice.toFixed(2);
	//$('print_shipping').innerHTML	= totalPrintShip.toFixed(2);
	$('print_tax').innerHTML		= printTax.toFixed(2);
	$('print_total_taxed').innerHTML= print_total_taxed.toFixed(2);
	//prods
	$('prod_total').innerHTML		= totalProdPrice.toFixed(2);
	$('prod_total_total').innerHTML		= totalProdPrice.toFixed(2);
	$('prod_shipping').innerHTML	= totalProdShipping.toFixed(2);
	$('prod_tax').innerHTML			= prodTax.toFixed(2);
	$('prod_total_taxed').innerHTML	= prod_total_taxed.toFixed(2);
	
	var total_total		= parseFloat(totalPrintPrice.toFixed(2)) + parseFloat(totalProdPrice.toFixed(2));
	var total_shipping	= parseFloat(15) + parseFloat(totalProdShipping.toFixed(2));
	var total_tax		= parseFloat(printTax.toFixed(2)) + parseFloat(prodTax.toFixed(2));
	var total_taxed		= parseFloat(print_total_taxed.toFixed(2)) + parseFloat(prod_total_taxed.toFixed(2));
	//total
	//$('total_total').innerHTML		= total_total.toFixed(2);
	//$('total_shipping').innerHTML	= total_shipping.toFixed(2);
	//$('total_tax').innerHTML		= total_tax.toFixed(2);
	$('total_total').innerHTML		= total_taxed.toFixed(2);
	
	/*
	alert('Print:\n\rprintPrice: ' + printPrice.length + '\n\rprintQuantity ' + printQuantity.length);
	alert('Prod:\n\rprodPrice: ' + prodPrice.length + '\n\rprodUnitPrice: ' + prodUnitPrice.length + '\n\rprodQuantity: ' + prodQuantity.length + '\n\rprodShipping: ' + prodShipping.length);
	alert('Total:\n\rtotal_total: ' + total_total + '\n\rtotal_shipping: ' + total_shipping + '\n\rtotal_tax: ' + total_tax);
	*/
}

/* Function printf(format_string,arguments...)
 * Javascript emulation of the C printf function (modifiers and argument types 
 *    "p" and "n" are not supported due to language restrictions)
 *
 * Copyright 2003 K&L Productions. All rights reserved
 * http://www.klproductions.com 
 *
 * Terms of use: This function can be used free of charge IF this header is not
 *               modified and remains with the function code.
 * 
 * Legal: Use this code at your own risk. K&L Productions assumes NO resposibility
 *        for anything.
 ********************************************************************************/
function printf(fstring)
  { var pad = function(str,ch,len)
      { var ps='';
        for(var i=0; i<Math.abs(len); i++) ps+=ch;
        return len>0?str+ps:ps+str;
      }
    var processFlags = function(flags,width,rs,arg)
      { var pn = function(flags,arg,rs)
          { if(arg>=0)
              { if(flags.indexOf(' ')>=0) rs = ' ' + rs;
                else if(flags.indexOf('+')>=0) rs = '+' + rs;
              }
            else
                rs = '-' + rs;
            return rs;
          }
        var iWidth = parseInt(width,10);
        if(width.charAt(0) == '0')
          { var ec=0;
            if(flags.indexOf(' ')>=0 || flags.indexOf('+')>=0) ec++;
            if(rs.length<(iWidth-ec)) rs = pad(rs,'0',rs.length-(iWidth-ec));
            return pn(flags,arg,rs);
          }
        rs = pn(flags,arg,rs);
        if(rs.length<iWidth)
          { if(flags.indexOf('-')<0) rs = pad(rs,' ',rs.length-iWidth);
            else rs = pad(rs,' ',iWidth - rs.length);
          }    
        return rs;
      }
    var converters = new Array();
    converters['c'] = function(flags,width,precision,arg)
      { if(typeof(arg) == 'number') return String.fromCharCode(arg);
        if(typeof(arg) == 'string') return arg.charAt(0);
        return '';
      }
    converters['d'] = function(flags,width,precision,arg)
      { return converters['i'](flags,width,precision,arg); 
      }
    converters['u'] = function(flags,width,precision,arg)
      { return converters['i'](flags,width,precision,Math.abs(arg)); 
      }
    converters['i'] =  function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        var rs = ((Math.abs(arg)).toString().split('.'))[0];
        if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
        return processFlags(flags,width,rs,arg); 
      }
    converters['E'] = function(flags,width,precision,arg) 
      { return (converters['e'](flags,width,precision,arg)).toUpperCase();
      }
    converters['e'] =  function(flags,width,precision,arg)
      { iPrecision = parseInt(precision);
        if(isNaN(iPrecision)) iPrecision = 6;
        rs = (Math.abs(arg)).toExponential(iPrecision);
        if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs.replace(/^(.*)(e.*)$/,'$1.$2');
        return processFlags(flags,width,rs,arg);        
      }
    converters['f'] = function(flags,width,precision,arg)
      { iPrecision = parseInt(precision);
        if(isNaN(iPrecision)) iPrecision = 6;
        rs = (Math.abs(arg)).toFixed(iPrecision);
        if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs + '.';
        return processFlags(flags,width,rs,arg);
      }
    converters['G'] = function(flags,width,precision,arg)
      { return (converters['g'](flags,width,precision,arg)).toUpperCase();
      }
    converters['g'] = function(flags,width,precision,arg)
      { iPrecision = parseInt(precision);
        absArg = Math.abs(arg);
        rse = absArg.toExponential();
        rsf = absArg.toFixed(6);
        if(!isNaN(iPrecision))
          { rsep = absArg.toExponential(iPrecision);
            rse = rsep.length < rse.length ? rsep : rse;
            rsfp = absArg.toFixed(iPrecision);
            rsf = rsfp.length < rsf.length ? rsfp : rsf;
          }
        if(rse.indexOf('.')<0 && flags.indexOf('#')>=0) rse = rse.replace(/^(.*)(e.*)$/,'$1.$2');
        if(rsf.indexOf('.')<0 && flags.indexOf('#')>=0) rsf = rsf + '.';
        rs = rse.length<rsf.length ? rse : rsf;
        return processFlags(flags,width,rs,arg);        
      }  
    converters['o'] = function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        var rs = Math.round(Math.abs(arg)).toString(8);
        if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
        if(flags.indexOf('#')>=0) rs='0'+rs;
        return processFlags(flags,width,rs,arg); 
      }
    converters['X'] = function(flags,width,precision,arg)
      { return (converters['x'](flags,width,precision,arg)).toUpperCase();
      }
    converters['x'] = function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        arg = Math.abs(arg);
        var rs = Math.round(arg).toString(16);
        if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
        if(flags.indexOf('#')>=0) rs='0x'+rs;
        return processFlags(flags,width,rs,arg); 
      }
    converters['s'] = function(flags,width,precision,arg)
      { var iPrecision=parseInt(precision);
        var rs = arg;
        if(rs.length > iPrecision) rs = rs.substring(0,iPrecision);
        return processFlags(flags,width,rs,0);
      }
    farr = fstring.split('%');
    retstr = farr[0];
    fpRE = /^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/;
    for(var i=1; i<farr.length; i++)
      { fps=fpRE.exec(farr[i]);
        if(!fps) continue;
        if(arguments[i]!=null) retstr+=converters[fps[4]](fps[1],fps[2],fps[3],arguments[i]);
        retstr += fps[5];
      }
    return retstr;
  }
/* Function printf() END */

addLoadEvent(initPhotos);