var currencySymbol="&pound;";function writeCartTable(b){html="";html+='<div id="backLink"><a href="#" onclick="history.back();return false;">Back</a></div>';if(b.length){html+='<form id="cartForm" style="margin:0px;border:0px;" name="cartForm" target="_blank" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/811732459637082" method="post">';html+='<table id="cartTable" cellpadding="0" cellspacing="0">';html+="<tr>";html+="<th>Photo</th>";html+="<th>Caption</th>";html+="<th>Option</th>";html+="<th>Price</th>";html+="<th>Quantity</th>";html+="<th>Total price</th>";html+='<td><input type="Button" value="Clear cart" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" onclick="if(confirm(\'Clear items?\')){deleteCookie(\'DEANOSCOTTY\'); window.location.reload(false);}"></td>';html+="</tr>";for(var a=0;a<b.length;a++){id=b[a].id;if(photos[id]){if(b[a].payment_id!=0){payment_id=b[a].payment_id;option=paymentOptions[payment_id].payment_option;price=paymentOptions[payment_id].price}else{option=photos[id].purchase_instruction;price=photos[id].item_price}caption=photos[id].caption;src=photos[id].thumbnail;if(option.length==0){option="&nbsp;"}if(caption.length==0){caption="&nbsp;"}html+=writeCartTableRow(b,src,a,photos[id].id,caption,option,price,b[a].quantity)}else{html+='<tr><td colspan="7">ITEM NOT FOUND - '+id+"</td></tr>"}}html+="<tr>";html+="<td>&nbsp;</td>";html+="<td>&nbsp;</td>";html+="<td>&nbsp;</td>";html+="<td>&nbsp;</td>";html+="<td>Total</td>";html+='<td id="orderTotal">'+currencySymbol+orderTotal()+"</td>";html+='<td><input type="Image" src="https://checkout.google.com/buttons/checkout.gif?merchant_id=811732459637082&w=160&h=43&style=trans&variant=text&loc=en_GB" onclick="this.submit" style="margin-left:-6px;"></td>';html+="</tr>";html+='<input type="hidden" name="site" value="DEANOSCOTTY">';html+="</table>";html+="</form>"}else{html+='<p id="cartEmpty">Basket empty</p>'}$("#cartDiv").html(html)}function writeCartTableRow(f,a,h,g,i,d,e,b){var c=parseInt(h,10)+1;id=g;ref="";if(photos[id].photo_ref!=""){ref=photos[id].photo_ref+" - "+i}else{ref=g+" - "+i}html="";html+='<input type="hidden" name="item_quantity_'+c+'" value="'+b+'">';html+='<input type="hidden" name="item_currency_'+c+'" value="GBP">';html+='<input type="hidden" name="item_name_'+c+'" value="'+ref+'">';html+='<input type="hidden" name="quantity_'+c+'" value="'+b+'">';html+='<input type="hidden" name="item_ref_'+c+'" value="'+ref+'">';html+='<input type="hidden" name="item_title_'+c+'" value="'+photos[id].caption+'">';html+='<input type="hidden" name="item_description_'+c+'" value="'+d+'">';html+='<input type="hidden" name="item_price_'+c+'" value="'+e+'">';html+='<input type="hidden" name="id_'+c+'" value="'+g+'">';html+='<input type="hidden" name="amount_'+c+'" value="'+e+'">';html+="<tr>";html+='<td class="image"><img src="'+a+'"></td>';html+="<td>"+i+"</td>";html+="<td>"+d+"</td>";html+="<td>"+currencySymbol+e+"</td>";html+='<td><input type="Text" size="5" class="cartInputField" value="'+b+'" onkeyup="quantityOnKeyUp(arrayOfItems, this.value, cartForm, '+c+", "+g+');"></td>';html+='<td id="totalPrice_'+c+'">'+currencySymbol+totalPrice(e,b)+"</td>";html+='<td id="remove_'+c+'"><input type="Button" value="Remove" class="button" onmouseover="this.className=\'buttonHi\';" onmouseout="this.className=\'button\';" onclick="confirmRemove(\'Remove item?\', cartForm, '+c+", "+g+');"></td>';html+="</tr>";return html}function quantityOnKeyUp(g,d,b,c,a){if(isInteger(d)&&isPositive(d)){updateQuantity(b,a,g[parseInt(c)-1].payment_id,d);b["item_quantity_"+c].value=d;b["quantity_"+c].value=d;setHTML("totalPrice_"+c,currencySymbol+totalPrice(b["amount_"+c].value,d));setHTML("orderTotal",currencySymbol+orderTotal())}if(d==0){try{clearTimeout(removeAlert)}catch(f){}removeAlert=setTimeout("confirmRemove('Remove item?', '"+b.name+"', "+c+", "+a+")",3000)}else{try{clearTimeout(removeAlert)}catch(f){}}};