
$(document).ready(function(){$("#basket :checkbox").change(function(){var id=$(this).attr("id").replace("Del","");if($(this).is(":checked")){$("#product"+id).addClass("selected");}else{$("#product"+id).removeClass("selected");}});});function reloadBasketToolbar(){$("#baskettoolbar").load($("#BasketUrl").val()+"/Toolbar",function(){$("#baskettoolbar").effect("shake",{},100);});}
function closeBasketPopup(){if(overlay!=null){$(overlay).fadeOut(function(){overlay=null;});}
$("#basketpopup").fadeOut(function(){$(this).html("");});}
function clearBasket(){if(confirm("Are you sure you want to clear all the items from your basket and cancel your order?")){jsonPost({url:$("#BasketUrl").val()+"/Clear",data:null,success:function(data){location.reload(true);},error:function(){alert("Sorry, there was an error clearing your basket, please close your browser and try again.");}});}}
function updateBasket_Success(data){if(data.Success){if(data.Reload){location.reload(true);}else{reloadBasketToolbar();$("#basket :text").each(function(){if($(this).val()=="0"){var id=$(this).attr("id").replace("Qty","");removeBasketRow(id);}else if($(this).val()>100){$(this).val("100");}});$("#basket :checkbox:checked").each(function(){var id=$(this).attr("id").replace("Del","");removeBasketRow(id);});$("#subtotal").text(data.Subtotal);}}else{alert("Sorry, there was an error updating your basket, please try again.");}}
function removeBasketRow(id){$("#product"+id).fadeOut(function(){$(this).remove();});}
function updateBasket_Failure(){alert("Sorry, there was an error updating your basket, please contact customer services.");}﻿
$(document).ready(function(){$(document).ready(function(){$("#accordion").accordion({autoHeight:false});$("#BillingAddress_Country").change(function(){disableNonUK("BillingAddress_");});$("#DispatchToBilling").change(function(){checkForCopy(true);});$("#DeliveryAddress_Country").change(function(){disableNonUK("DeliveryAddress_");updateDeliveryCost();});});});function prev(index){$("#accordion").accordion("activate",index-1);return false;}
function next(index){var proceed=true;$("#step"+index+"fields :input:not(button, :hidden)").each(function(){var valid=$("#mainbody > form").validate().element("#"+$(this).attr("id"));proceed=proceed&&valid;});if(proceed){index++;$("#step"+index).show(50,function(){$("#accordion").accordion("activate",index);});if(index>=2){checkForCopy();updateDeliveryCost();}}
return false;}
function checkForCopy(clear){var checked=$("#DispatchToBilling").is(":checked");if(checked||clear){$("#DeliveryAddress_Name").val(clear?"":$("#BillingAddress_Name").val());$("#DeliveryAddress_Line1").val(clear?"":$("#BillingAddress_Line1").val());$("#DeliveryAddress_Line2").val(clear?"":$("#BillingAddress_Line2").val());$("#DeliveryAddress_Line3").val(clear?"":$("#BillingAddress_Line3").val());$("#DeliveryAddress_Line4").val(clear?"":$("#BillingAddress_Line4").val());$("#DeliveryAddress_Town").val(clear?"":$("#BillingAddress_Town").val());$("#DeliveryAddress_County").val(clear?"":$("#BillingAddress_County").val());$("#DeliveryAddress_Postcode").val(clear?"":$("#BillingAddress_Postcode").val());var country=$("#BillingAddress_Country > option:selected").val();$("#DeliveryAddress_Country").removeAttr("selected");$("#DeliveryAddress_Country > option[value='"+(clear?"":country)+"']").attr("selected",true);$("#DeliveryAddress_Country").change();}
if(checked){$("#deliveryaddress").hide();}else{$("#deliveryaddress").show();}}
function updateDeliveryCost(){var country=$("#DeliveryAddress_Country").val();if(country==null||country.length==0){reviewOrderButton().hide();return;}
$("#deliverycharge").text(" updating, please wait...");$("#totalcharge").text(" updating, please wait...");jsonPost({url:$("#BasketUrl").val()+"/CalculateDelivery",data:{country:country},success:function(data){if(data===false||isNaN(data)){reviewOrderButton().hide();return;}
var deliveryCharge=parseFloat(data);var totalCharge=parseFloat($("#ProductsTotal").val())+deliveryCharge;$("#deliverycharge").text(deliveryCharge.toFixed(2));$("#totalcharge").text(totalCharge.toFixed(2));reviewOrderButton().show();},error:function(){alert("There was an error calculating your delivery charge, please contact customer services.");reviewOrderButton().hide();}});}
function reviewOrderButton(){return $("#step3fields input[type='submit']");}
function checkUnderstand(){var proceed=true;if($("#Understand").attr("checked")!="checked"){var text=$("label[for='Understand']").text();proceed=confirm(text);}
return proceed;}﻿
$(document).ready(function(){$(".homegallery").hover(function(){$(this).children(".galleryviewimage").fadeIn("fast");},function(){$(this).children(".galleryviewimage").hide();});});﻿
$(document).ready(function(){setupFitCrop();});function setupFitCrop(){if(selectedMethod()==null){setDefaultMethod();}
$("#fitcropmethod").delegate("input","change",function(){updateRatio(currentRatio());});$("#croporient").delegate("input","change",function(){updateRatio(currentRatio());});updateRatio(null);}
function setDefaultMethod(){$("#fc_Crop").attr("checked",true);}
function selectedMethod(){return $("#fitcropmethod input[name='FitCropModel.FitCrop']:radio:checked").val();}
var mask_width;var mask_height;var mask_ratio;var resizes=0;var image_width;var image_height;var jcrop_api;var action_desc;function updateRatio(ratio,image,mask,method,callback,data){if(ratio!=null){mask_ratio=ratio;$("#FitCropModel_Ratio").val(ratio);}
if(image==null){image=$("#imagemask > img");}
if(resizes==0){image_width=$(image).width();image_height=$(image).height();}
if(jcrop_api!=null){jcrop_api.destroy();jcrop_api=null;}
if(mask_ratio!=null&&image_width>0&&image_height>0){$("#FitCropModel_IW").val(image_width);$("#FitCropModel_IH").val(image_height);var image_ratio=image_width/image_height;var landscape=false;var portrait=false;if(image_width>=image_height){landscape=true;}
else if(image_height>image_width){portrait=true;}
if(mask==null){mask=$("#imagemask");}
if(mask_width==null)mask_width=$(mask).width();if(mask_height==null)mask_height=$(mask).height();if((landscape&&mask_ratio<1)||(portrait&&mask_ratio>1)){mask_ratio=1/mask_ratio;}
var highlight=function(name){$(action_desc).stop(true,true);$(action_desc).hide();action_desc=$("#"+name+"desc");$(action_desc).show();for(i=0;i<3;i++){if($(action_desc).css("display")!="none"){$(action_desc).effect("highlight",{color:"yellow"},600);}}};resizes++;if(method==null){method=selectedMethod();}
if(method=="Fit"||method=="None"){$("#croporient").hide();if(method=="Fit"){highlight("fit");}else{$(action_desc).stop(true,true);$("#imagecolumn > p").hide();mask_ratio=image_ratio;mask_width=image_width;mask_height=image_height;ratio=image_ratio;}
if($.browser.msie){$(mask).width(10);$(mask).height(10);$(image).width(10);$(image).height(10);}
var new_mask_width=mask_width;var new_mask_height=mask_width;if((landscape&&mask_ratio>1)||(portrait&&mask_ratio<1)){new_mask_height=mask_width/mask_ratio;}
else if((landscape&&mask_ratio<1)||(portrait&&mask_ratio>1)){new_mask_height=mask_width*mask_ratio;}
$(mask).width(new_mask_width);$(mask).height(new_mask_height);mask_ratio=new_mask_width/new_mask_height;if(image_ratio>mask_ratio){$(image).width(new_mask_width);$(image).height(new_mask_width/image_ratio);}
else if(image_ratio<mask_ratio){$(image).width(new_mask_height*image_ratio);$(image).height(new_mask_height);}
else{$(image).width(new_mask_width);$(image).height(new_mask_height);}
var diff=new_mask_height-$(image).height();if(diff>0){diff=Math.floor(diff/2);}else{diff=0;}
$(image).css("margin",diff+"px 0px");}
else if(method=="Crop"){$("#croporient").show();highlight("crop");if(data){var w=getValue("w",data);var h=getValue("h",data);if(w>=h){$("#croporientlandscape").attr("checked",true);}else{$("#croporientportrait").attr("checked",true);}}
var flip=false;if($("#croporient input:radio:checked").length==0){if(landscape){$("#croporientlandscape").attr("checked",true);}
else if(portrait){$("#croporientportrait").attr("checked",true);}
$("#croporient").buttonset("refresh");}
else{var orient=$("#croporient input:radio:checked").val();if((orient=="landscape"&&portrait)||(orient=="portrait"&&landscape)){flip=true;}}
$(image).width(image_width);$(image).height(image_height);$(mask).width(mask_width);$(mask).height(mask_height);$(image).css("margin","0px");if(flip){mask_ratio=1/mask_ratio;}
var new_mask_width=image_width;var new_mask_height=image_height;if((landscape&&image_ratio>mask_ratio)||(portrait&&image_ratio>mask_ratio)){if(flip&&landscape){new_mask_width=image_height*mask_ratio;}
else if(flip&&portrait){new_mask_width=image_height/mask_ratio;}
else{new_mask_width=image_height*mask_ratio;}}
else if((landscape&&image_ratio<mask_ratio)||(portrait&&image_ratio>mask_ratio)){if(flip&&landscape){new_mask_height=image_width*mask_ratio;}
else if(flip&&portrait){new_mask_height=image_width/mask_ratio;}
else{new_mask_height=image_width*mask_ratio;}}
var min_ratio=0.85;var min_width=new_mask_width*0.85;var min_height=new_mask_height*0.85;var x1=0;var y1=0;var x2=new_mask_width;var y2=new_mask_height;if(data){var data_ratio=image_width/getValue("iw",data);var x1=parseInt(getValue("x1",data)*data_ratio);var y1=parseInt(getValue("y1",data)*data_ratio);var x2=parseInt(getValue("x2",data)*data_ratio);var y2=parseInt(getValue("y2",data)*data_ratio);}
jcrop_api=$.Jcrop(image,{allowMove:true,allowSelect:false,aspectRatio:mask_ratio,bgOpacity:0.35,minSize:[min_width,min_height],maxSize:[new_mask_width,new_mask_height],onChange:captureCoordinates,setSelect:[x1,y1,x2,y2],sideHandles:true});}
if(callback!=null){callback();}}}
function captureCoordinates(c){$("#FitCropModel_X1").val(c.x);$("#FitCropModel_Y1").val(c.y);$("#FitCropModel_X2").val(c.x2);$("#FitCropModel_Y2").val(c.y2);$("#FitCropModel_W").val(c.w);$("#FitCropModel_H").val(c.h);}
function applyFitCrop(id,data){$(window).load(function(){if(data.substring(0,4)=="crop"){var fix_width=200;var x1=getValue("x1",data);var y1=getValue("y1",data);var x2=getValue("x2",data);var y2=getValue("y2",data);var iw=getValue("iw",data);var ih=getValue("ih",data);var ratio=fix_width/iw;var mask=$("#thumb"+id+" .imagemask");mask.width(fix_width).height(ih*ratio);var thumb=$("#thumb"+id+" img");thumb.width(fix_width).height(ih*ratio);x1=parseInt(x1*ratio);y1=parseInt(y1*ratio);x2=parseInt(x2*ratio);y2=parseInt(y2*ratio);$.Jcrop(thumb,{setSelect:[x1,y1,x2,y2],allowMove:false,allowResize:false,allowSelect:false,bgOpacity:0.2});}else{updateRatio(getValue("ratio",data),$("#thumb"+id+" img"),$("#thumb"+id+" > div.imagemask"),"Fit");mask_width=null;mask_height=null;mask_ratio=null;resizes=0;image_width=null;image_height=null;jcrop_api=null;}});}
function getValue(key,data){var re=new RegExp(key+"\\[([\\d\\.]+)\\]","i");if(re.exec(data)){var match=re.exec(data);return(match[1]);}}﻿
$(document).ready(function(){$(".helpbutton").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");}).click(function(){if($(this).hasClass("selected")==false){var id=$(this).attr("id").replace("helpbutton","");$(".helpbutton").removeClass("selected");$(".helptab").removeClass("selected").hide();$(this).addClass("selected");$("#helptab"+id).addClass("selected").show();}});});function showHelp(tab){$("#help").dialog({draggable:false,height:580,modal:true,resizable:false,title:'Fit / Crop Help',width:685});$("#helpbutton"+tab).click();flowplayer("helpplayer",$("#CropHelpSwf").val(),{clip:{autoPlay:false,autoBuffering:true},playlist:[$("#CropHelpFlv").val()],canvas:{backgroundColor:"transparent"},plugins:{controls:{volume:false,mute:false}}});}﻿
$(document).ready(function(){$("input[name='Product']").change(function(){$("#LastCategory").val("0");var id=parseInt($(this).attr("id").replace("Product",""));onChange(id);});$("#LastCategory").change(function(){$("input[name='Product']").attr("checked",false);var id=parseInt($(this).val());onChange(id);});$("#Quantity").change(function(){updateQuantity()});});function updateQuantity(){var id=$("#TitleProductID").val();onChange(id,true);}
function currentRatio(){return $("#Ratio"+$("#TitleProductID").val()).val();}
function onChange(id,changingQuantity){if(isNaN(parseInt(id)))return;$("#TitleProductID").val(id);var price=parseFloat($("#Price"+id).val());var quantity=parseInt($("#Quantity").val());if(price>0&&quantity>0){if(quantity>100){$("#Quantity").val("100");quantity=100;}
var cost=$.format.number(price*quantity,"#,###,##0.00");$("#productcost").show();$("#productcost > input").button("option","disabled",false);$("#productcost > span").text(cost);if($.browser.msie&&$.browser.version=="7.0"){$("#wrapper").css("height","auto");}}else{$("#productcost").hide();}
if(!changingQuantity){var ratio=$("#Ratio"+id).val();if(ratio==null){ratio=1;}
if(ratio=="0.0000"){$("#fc_None").attr("checked",true);$("#fc_Fit").closest("li").hide();$("#fc_Crop").closest("li").hide();$("#fc_None").closest("li").show();$("#prod-fitcrop").hide();$("#Quantity").val(1).attr("readonly",true);$("#productspecial").hide();}else{if(selectedMethod()=="None"){setDefaultMethod();$("#SpecialInstructions").val("");}
$("#fc_Fit").closest("li").show();$("#fc_Crop").closest("li").show();$("#fc_None").closest("li").hide();$("#prod-fitcrop").show();$("#Quantity").removeAttr("readonly");$("#productspecial").show();}
updateRatio(ratio);}}
function addSpecialInstructions(){$("#addspecialinstructions > textarea").val($("#SpecialInstructions").val());$("#addspecialinstructions").dialog({buttons:{Cancel:function(){$(this).dialog("close");},Save:function(){$("#SpecialInstructions").val($("#addspecialinstructions > textarea").val());$(this).dialog("close");}},height:300,modal:true,resizable:false,title:"Special Instructions",width:400});}
var overlay=null;function addProduct_Begin(a,b){if(parseInt($("#Quantity").val())==0){return false;}
if(currentRatio()=="0.0000"){var phone1=prompt("Please enter the phone number you would like this MMS to be delivered to","");if(isValidPhone(phone1)==false){alert("The phone number you entered is not a valid phone number, please try again.");return false;}
var phone2=prompt("Please confirm the phone number you entered","");if(phone1==phone2){$("#SpecialInstructions").val(phone1);b.data=$("#productscolumn").serialize();}else{alert("The phone numbers you entered did not match, please try again.");return false;}}
$("#productcost > input").button("option","disabled",true).val("Adding, please wait...");}
function addProduct_Success(data){$("#productcost > input").button("option","disabled",false).val("Add to Basket");if(data){reloadBasketToolbar();if($.browser.msie&&$.browser.version=="7.0"){overlay=null;}else{overlay=$("<div></div>").addClass("ui-widget-overlay").appendTo(document.body).css({width:$(document).width(),height:$(document).height(),"z-index":"998"});}
$("#basketpopup").show().html(data);}else{alert("Sorry, there was an error adding the product to your basket, please try again.");}}
function addProduct_Failure(){alert("Sorry, there was an error adding the product to your basket, please contact customer services.");}
﻿
function sendFriend(){$("#sendtoafriend").dialog({buttons:{"Cancel":function(){$(this).dialog("close");},"Send Image":function(){$("#sendtoafriend > form").submit();}},draggable:false,height:450,modal:true,resizable:false,title:"Send to a Friend",width:550});}
function sendFriend_failure(){alert("Sorry, we couldn't send the email, please could you check the form and try again?");}
function sendFriend_success(data){if(data.result==true){$("#sendtoafriend").dialog("close");alert("Thank you for sharing this photo!");}else{sendFriend_failure();}}﻿
$(document).ready(function(){setupZoom();});function setupZoom(){var zoomUrl=$("#ImageZoomUrl").val()+"&mode=within&";var size_ratio=0.85;var width=$(window).width()*size_ratio;var height=$(window).height()*size_ratio;width=Math.floor(width);height=Math.floor(height);$("#zoomin > p").show();$("#zoominimage").hide().attr("src",zoomUrl+"width="+width+"&height="+height).load(function(){$("#zoomin > p").hide();$("#zoominimage").fadeIn("fast");});return{width:width,height:height};}
function zoom(){var size=setupZoom();$("#zoomin").dialog({draggable:false,height:size.height+50,modal:true,resizable:false,title:$("#zoominimage").attr("alt"),width:size.width+30});}﻿
var addressFieldPrefix;function lookupPostcode(postcode,insertInto,prefix){addressFieldPrefix=prefix;$("#"+insertInto).show().html("<p>Searching, please wait...</p>").load(controllerUrl+"/PostcodeLookup",{postcode:postcode});return false;}
function selectAddress(select){jsonPost({url:controllerUrl+"/AddressLookup",data:{addressId:$(select).val()},success:function(data){$(select).closest("div").hide();if(data==null||data.IsError){selectAddress_Failure();}else{copyAddress(addressFieldPrefix,data.Results[0]);}},failure:function(){$(select).closest("div").hide();selectAddress_Failure();}})}
function selectAddress_Failure(){alert("Sorry, we were unable to retrieve your address, please try again, or type it in manually.");}
function disableNonUK(prefix){var current=$("#"+prefix+"Country").children(":selected").val();if(current==""||current=="GB"){if($("#"+prefix+"Postcode").val()=="N/A"){$("#"+prefix+"Postcode").val("").show().siblings("span").text("*").siblings("button").show();}}else{$("#"+prefix+"Postcode").val("N/A").hide().siblings("span").text("N/A").siblings("button").hide();}}
function copyAddress(prefix,data){var line1=data==null?"":data.Line1;if(data!=null&&data.OrganisationName){line1=data.OrganisationName+", "+line1;}
$("#"+prefix+"Line1").val(line1);$("#"+prefix+"Line2").val(data==null?"":data.Line2);$("#"+prefix+"Line3").val(data==null?"":data.Line3);$("#"+prefix+"Line4").val(data==null?"":data.Line4);$("#"+prefix+"Town").val(data==null?"":data.PostTown);$("#"+prefix+"County").val(data==null?"":data.County);$("#"+prefix+"Postcode").val(data==null?"":data.Postcode);var country="GB";if(data!=null&&data.Country!=undefined){country=data.Country;}
$("#"+prefix+"Country > option").removeAttr("selected");$("#"+prefix+"Country > option[value='"+country+"']").attr("selected",true);$("#"+prefix+"Country").change();}﻿
$(document).ready(function(){$.xhrPool=[];$.xhrPool.abortAll=function(){$.each($.xhrPool,function(i,xhr){if(xhr!=null){xhr.abort();}});};$.ajaxSetup({beforeSend:function(xhr){$.xhrPool.push(xhr);},cache:false});$("button, a.button, input.button").button();$("#s").focus(function(){$("#searchhelp").fadeIn("fast");}).blur(function(){$("#searchhelp").hide();});if($.browser.msie&&$.browser.version=="7.0"){$("#basket > a.basketlink").hide();}
$("#search > form").submit(function(){var text=$("#s").val();text=$.trim(text);if(text.length<=3){alert("Please enter a search query of three letters or more.");return false;}});});function gotoPage(page,query){var url="?p="+page;if(query.substring(0,7)!="gallery"){url+="&s="+encodeURI(query);}
location.href=url;}
function jsonPost(options){return $.ajax({type:"post",url:options.url,data:JSON.stringify(options.data),contentType:"application/json",dataType:"json",success:options.success,error:options.error});}
function isValidPhone(phonenumber){if(phonenumber!=null&&phonenumber!=""){var goodChars=" 1234567890"
for(i=0;i<phonenumber.length;i++){var c=phonenumber.charAt(i);if(goodChars.indexOf(c)<0)return false;}
return true;}else{return false;}}
