var sep="::",itemSep="##";function setCookie(a,b,c){var d=new Date;d.setTime(d.getTime()+c*24*60*60*1E3);expires=d.toGMTString();document.cookie=a+"="+escape(b)+"; expires="+expires+"; path=/;";return unescape(readCookie(a))==b}function readCookie(a){a=a+"=";for(var b=document.cookie.split(";"),c=0;c<b.length;c++){for(var d=b[c];d.charAt(0)==" ";)d=d.substring(1,d.length);if(d.indexOf(a)==0)return d.substring(a.length,d.length)}}
function addItemToBasket(a,b,c,d,e){b=b||photos;b=b[a];if(b.payment_id!=0&&e!=0){option=paymentOptions[e].payment_option;price=paymentOptions[e].price}else{option=photos[a].purchase_instruction;price=photos[a].item_price}ref=b.photo_ref?b.photo_ref:a;name=b.caption;itemQuantity=d?d:1;existingData=unescape(readCookie(c));d="";if(existingData!="null"&&existingData!=""&&existingData!="undefined"){d=unescape(existingData).split(itemSep);e=[];e[0]="";var f=0;for(b=0;b<d.length;b++){var g=d[b].split(sep);
if(g[0]==a&&g[3]==option){f=g[0]+sep+g[1]+sep+g[2]+sep+g[3]+sep+g[4]+sep+(parseInt(g[5],10)+itemQuantity);e[1]=f;f=1}else e[0]=e[0]!=""?e[0]+itemSep+d[b]:d[b]}d=f&&e[0]!=""?e[0]+itemSep+e[1]:e[0]!=""?e[0]+itemSep+a+sep+ref+sep+name+sep+option+sep+price+sep+itemQuantity:e[1]}else d=a+sep+ref+sep+name+sep+option+sep+price+sep+itemQuantity;return setCookie(c,d,7)}function deleteCookie(a){setCookie(a,"",-1)}
function purchaseItem(a,b,c,d,e,f){this.id=a;this.ref=b;this.name=c;this.option=d||c||b;this.price=parseFloat(e).toFixed(2);this.quantity=f}function updateCartValue(a,b){a.item_option.value=b}var arrayOfItems=null;function getListOfDataInCookie(a){arrayOfItems=[];if(a!=undefined){a=unescape(a).split(itemSep);for(var b=0;b<a.length;b++){var c=a[b].split(sep);arrayOfItems[b]=new purchaseItem(c[0],c[1],c[2],c[3],c[4],c[5])}}}
function getOrderDetails(a){getListOfDataInCookie(readCookie(a));data={quantity:0,price:0};for(var b in arrayOfItems)data.quantity+=parseInt(arrayOfItems[b].quantity);data.price=orderTotal();return data}function dspOrderDetails(a,b){var c=getOrderDetails(a);$("#shopping-cart-total-quantity").html(c.quantity);$("#shopping-cart-total-price").html(c.price);c.quantity==0&&b&&$("#"+b).hide()}
function writeItemsArrayToCookie(a){for(var b="",c=0;c<arrayOfItems.length;c++){var d="";d+=arrayOfItems[c].id+sep;d+=arrayOfItems[c].ref+sep;d+=arrayOfItems[c].name+sep;d+=arrayOfItems[c].option+sep;d+=arrayOfItems[c].price+sep;d+=arrayOfItems[c].quantity;b=b==""?d:b+itemSep+d}b!=""?setCookie(a,b,7):deleteCookie(a)}
function updateQuantity(a,b,c,d){if(isPositive(d)&&isInteger(d)){if(d=="")d=0;for(var e=0;e<arrayOfItems.length;e++)if(arrayOfItems[e].id==b&&arrayOfItems[e].option==c){arrayOfItems[e].quantity=d;break}writeItemsArrayToCookie(a)}}function removeItem(a,b){arrayOfItems.splice(b,1);writeItemsArrayToCookie(a)}function isNumber(a){return(new Number(a)).toString()=="NaN"?0:1}function isInteger(a){return isNumber(a)?a.indexOf(".")!=-1?0:1:0}
function isPositive(a){return isNumber(a)?new Number(a)>=0?1:0:0}function totalPrice(a,b){return parseFloat(a*b).toFixed(2)}function orderTotal(){for(var a=0,b=0;b<arrayOfItems.length;b++)a=parseFloat(a)+parseFloat(totalPrice(arrayOfItems[b].price,arrayOfItems[b].quantity));return parseFloat(a).toFixed(2)}function setHTML(a,b){try{document.getElementById(a).innerHTML=b}catch(c){document.all[a].innerHTML=b}}function getArrayIndex(a,b){for(var c=0;c<a.length;c++)if(a[c].id==b)return c}
function opacity(a,b){var c=null;try{c=document.getElementById(a).style}catch(d){c=document.all[a].style}c.filter="alpha(opacity="+b+")";c.opacity=b/100;c.MozOpacity=b/100;c.KhtmlOpacity=b/100}function fadeIn(a,b){var c=1;if(b==null)b=6;for(var d=0;d<=100;d++){setTimeout("opacity('"+a+"', "+d+")",b*c);c++}}function fadeOut(a,b){var c=1;if(b==null)b=6;for(var d=100;d>=0;d--){setTimeout("opacity('"+a+"', "+d+")",b*c);c++}}var xmlHttp;
function ajaxFunction(){try{xmlHttp=new XMLHttpRequest}catch(a){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){alert("Your browser doesn't support AJAX!");return false}}}}function confirmRemove(a,b,c){if(confirm(a)){removeItem(b,c);navigator.userAgent.indexOf("Safari")==-1?window.location.replace(unescape(window.location.href)):window.location.reload(false)}}
function divShowing(a){var b=null;try{for(var c=0;c<document.styleSheets[0].cssRules.length;c++)if(document.styleSheets[0].cssRules[c].selectorText=="div#"+a)b=document.styleSheets[0].cssRules[c].style.opacity}catch(d){try{for(c=0;c<document.styleSheets[0].cssRules.length;c++)if(document.styleSheets[0].cssRules[c].selectorText=="div#"+a)b=document.styleSheets[0].cssRules[c].style.MozOpacity}catch(e){for(c=0;c<document.styleSheets[0].rules.length;c++)if(document.styleSheets[0].rules[c].selectorText==
"DIV#"+a){var f=document.styleSheets[0].rules[c].style.filter.split("=");if(f.length>1){f=f[1].split(")");b=f[0]}}}}var g=c=null,h=null;c=document.getElementById(a).style.opacity;g=document.getElementById(a).style.MozOpacity;a=new String(document.getElementById(a).style.filter);if(a!="undefined"){f=a.split("=");if(f.length>1){f=f[1].split(")");h=f[0]}}return b>0||c>0||g>0||h>0?1:0};
