function shipto_initialize(){jQuery('div.shipto_select').show();jQuery('div.shipto_name').hide();}
function shipto_array(){if(jQuery.cookie('shipto_names')){var shipto_array=jQuery.cookie('shipto_names').split('||');shipto_array=unique(shipto_array);shipto_array.sort();return shipto_array;}else{return false;}}
function shipto_select(){jQuery('div.shipto_select').find('select').html('');var shipto_options='';var shipto=shipto_array();if(shipto){jQuery.each(shipto,function(i,val){if(val!='null'&&val!=''&&val!='me'){shipto_options+='<option value="'+val+'">'+val+'<\/option>';}});shipto_options+='<option value="">- - - - - - - - -<\/option>';}
shipto_options+='<option value="add_new">Add a new recipient...<\/option>';shipto_options+='<option value="">- - - - - - - - -<\/option>';shipto_options+='<option selected="selected" value="me">Yourself<\/option>';jQuery('div.shipto_select').find('select').html(shipto_options);jQuery('div.shipto_select').find('select').change(function(){if(jQuery(this).val()=='add_new'){jQuery(this).parents('form').find('div.shipto_name').show();jQuery(this).parents('form').find('input[name="shipto"]').val('');}else{jQuery(this).parents('form').find('div.shipto_name').hide();jQuery(this).parents('form').find('input[name="shipto"]').val(jQuery(this).val());}});if(jQuery.cookie('shipto_name_recent')!=''){jQuery('div.shipto_select').find('select').selectOptions(jQuery.cookie('shipto_name_recent'));}else{jQuery('div.shipto_select').find('select').selectOptions('me');}}
function shipto_multiples(){jQuery('input[name="shipto"]').change(function(){jQuery(this).parents('form').find('input[name="shipto"]').val(jQuery(this).val());});}
jQuery(document).ready(function(){shipto_initialize();shipto_select();shipto_multiples();});function fc_PreProcess(){if(typeof fc_PreProcess_custom=="function"){fc_PreProcess_custom();}
var error=false;var shipto_cookie=jQuery.cookie('shipto_names');var shipto_new=jQuery('input[name="shipto"]').eq(0).val();jQuery.cookie('shipto_name_recent','',{expires:-1,path:'/',domain:location.host.match('[^.]+.[^.]+$')});jQuery.cookie('shipto_name_recent',shipto_new,{expires:300,path:'/',domain:location.host.match('[^.]+.[^.]+$')});if((shipto_new!='undefined')&&(shipto_new!='null')&&(shipto_new!='me')){jQuery.cookie('shipto_names','',{expires:-1,path:'/',domain:location.host.match('[^.]+.[^.]+$')});jQuery.cookie('shipto_names',shipto_cookie+'||'+shipto_new,{expires:300,path:'/',domain:location.host.match('[^.]+.[^.]+$')});}
return true;}
function fc_BuildFoxyCart(){shipto_initialize();shipto_select();}
function unique(a){tmp=new Array(0);for(i=0;i<a.length;i++){if(!contains(tmp,a[i])){tmp.length+=1;tmp[tmp.length-1]=a[i];}}
return tmp;}
function contains(a,e){for(j=0;j<a.length;j++)if(a[j]==e)return true;return false;}
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};jQuery.fn.selectOptions=function(value){this.each(function(){if(this.nodeName.toLowerCase()!="select")return;var optionsLength=this.options.length;for(var i=0;i<optionsLength;i++){if(this.options[i].value==value){this.options[i].selected=true;};}})
return this;}
