(function($){$.fn.wsdatepicker=function(options){$(this).datepicker(options);return $(this).focus(function(){input=this;$('#ui-datepicker-nodate').click(function()
{$(input).val('No Date');});});}})(jQuery);;$(document).ready(function()
{$("#search_textbox").focus(function(){$(this).filter(function(){return $(this).val()==""||$(this).val()=="keyword or product #"}).removeClass("watermark").val("");}).blur(function(){$(this).filter(function(){return $(this).val()=="";}).addClass("watermark").val("keyword or product #");});$("#surveytext").focus(function(){$(this).select();});});;var tracking_visible=false;var login_visible=false;var tote_visible=false;var toteupdate_visible=false;var slide_speed="slow";var on_color="#F0EEEC";var off_color="#E2DEDA";var hover_color="#E9E6E3";var tote_max=400;var popup_timer_close=1500;var popup_timer_open=500;var popup_timer=0;var input_focus=null;$(document).ready(function()
{$("#trackingpopup_close, #tp_close").click(function(){input_focus=null;closePopups();});$("#tote_popup, #tracking_popup, #wishlist_popup").hover(function(){clearTimeout(popup_timer);},function(){clearTimeout(popup_timer);popup_timer=setTimeout('closePopups()',popup_timer_close);});$('#headerbox input').focus(function(){clearTimeout(popup_timer);if(tracking_visible){input_focus='tracking';}else if(login_visible){input_focus='login';}});$("#shoppingbag_menu ul li.left, #partner_header_links #left").click(function(){input_focus=null;if(tracking_visible){closePopups();}else{openPopupTracking();}});$("#shoppingbag_menu ul li.left").hover(function(){if(login_visible)
$(this).css("background-color",hover_color);else
$(this).css("background-color",on_color);},function(){if(!tracking_visible)
$(this).css("background-color",off_color);});$("#wishlistpopup_close").livequery('click',function(){input_focus=null;closePopups();});$("#shoppingbag_menu ul li.right, #partner_header_links #right").click(function(){input_focus=null;if(login_visible){closePopups();}else{openPopupLogin();}});$("#shoppingbag_menu ul li.right").hover(function(){if(tracking_visible)
$(this).css("background-color",hover_color);else
$(this).css("background-color",on_color);},function(){if(!login_visible)
$(this).css("background-color",off_color);});$("#wishlist_popup .features .help").livequery('click',function(){$("#wishlist_popup .description").hide();$(this).next().show();});$("#wishlist_popup .description .close").livequery('click',function(){$(this).parent().hide();});$("#wishlist_popup #log_out").livequery('click',function(){var page=location.pathname.substring(1);$("#wishlist_popup .loading").css('top','100px');$("#wishlist_popup .loading").show();$.getJSON('/ajax/accountlogout',{page_id:page},function(json){switch(page){case'checkout':top.location='cart';break;case'cart':$('#ajaxclear').html(json.content);default:$('div#shoppingbag_menu #right_text').text('LOGIN TO MY ACCOUNT ');$('#wishlist_popup').html(json.account);$("#account_login div").show();$('#tote_quantity').html('0 items');$('#tote_price').html(json.price);break;}
$("#wishlist_popup .loading").hide();});});$("form#wishlist_login #account_password").livequery('keyup',function(e){if(e.keyCode==13){$("form#wishlist_login #wishlist_submit").focus();$("form#wishlist_login").submit();}});$("form#wishlist_login").livequery('submit',function(){var page=location.pathname.substring(1);var input=$(this).formSerialize()+'&page='+page;$("#wishlist_popup .loading").css('top','100px');$("#wishlist_popup .loading").show();$.post('/ajax/accountlogin',input,function(json)
{if(json.dealer){window.location="http://controlpanel."+json.host;}else if(json.tote){$('div#shoppingbag_menu #right_text').text('MY ACCOUNT ');$('#wishlist_popup').html(json.account);toteRefresh(json.tote);if(json.content!=null){$('#content').html(json.content);}}else{$("#account_login").html(json.account);$("#account_login div").show();}
$("#wishlist_popup .loading").hide();},'json');return false;});$("form#wishlist_register").livequery(function(){$(this).ajaxForm({url:'/account/register_popup/format/html',beforeSubmit:function(){$("#wishlist_popup .loading").css('top','225px');$("#wishlist_popup .loading").show();},success:function(response){if($(response).find('.error-notice').size()==0){$('div#shoppingbag_menu #right_text').text('MY ACCOUNT ');$("#wishlist_popup").html(response);updatePageElements();}else{$("#account_create").html(response);$("#account_create div").show();}
$("#wishlist_popup .loading").hide();}});});$("#shoppingbag span.header, #shoppingbag_image").click(function(){if($('#tote_quantity').html()!='0 items'){openPopupTote();}});$("#shoppingbag span.header, #shoppingbag_image").hover(function(){if($('#tote_quantity').html()!='0 items'){clearTimeout(popup_timer);popup_timer=setTimeout('openPopupTote()',popup_timer_open);}},function(){if($('#tote_quantity').html()!='0 items'){clearTimeout(popup_timer);popup_timer=setTimeout('closePopups()',popup_timer_close);}});$(".tp_rem").click(function(){removeToteItem($(this).attr('id'));});$("#account_login > span").livequery('click',function(){$("#account_create div").slideUp();$("#account_login div").slideDown();});$("#account_create > span").livequery('click',function(){$("#account_create div").slideDown();$("#account_login div").slideUp();});$("#wishlist_popup #account_wedding_date").livequery(function(){var weddingDate=this;$(this).prev().click(function(){$(weddingDate).focus();});});$('div.tp_info .removePersonalization').livequery('click',function(){var row=$(this).parent().parent().parent().parent();var ptext=$(this).parent().parent();var code=$(this).attr('id').replace('rp_','');row.slideUp('slow');$.post('/cart/personalizeremove',{code:code,tote:true},function(json){ptext.html('<div class="personalization_header">Not Personalized</div><br/><div class="personalization_actions">> <span class="hover editPersonalization" id="ep_'+json.newCode+'">Edit Personalization</span></div>');row.html(row.html().replace(eval("/"+code+"/g"),json.newCode));row.slideDown('slow');$('#tote_price').html(json.shipping);},'json');});$('.editPersonalization').livequery('click',function(){setupPopup('');$.post('/ajax/personalizecartedit',{hash:$(this).attr('id').replace('ep_',''),mode:'edit'},function(json){setupPersonalization(json);},'json');});$('#liveChat').click(function(){this.newWindow=window.open('http://service.velaro.com/visitor/requestchat.aspx?siteid=5103&showwhen=inqueue','VelaroChat','toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=yes,replace=no');this.newWindow.focus();this.newWindow.opener=window;return false;});$('#dealer_logout').click(function(){setupPopup('Logging out...');$.post('/ajax/accountlogout',null,function(){top.location.replace('http://wholesale.weddingstar.com');});})});function closePopups(popup)
{clearTimeout(popup_timer);if((tote_visible)&&(popup!='tote')){$("#tote_popup").slideUp(slide_speed);tote_visible=false;}
if((tracking_visible)&&(input_focus!='tracking')){$("#tracking_popup").slideUp(slide_speed,function(){$("#shoppingbag_menu ul li.left").css("background-color",off_color);});tracking_visible=false;}
if((login_visible)&&(input_focus!='login')){$("#account_create div").hide();$("#account_login div").hide();$("#wishlist_popup").slideUp(slide_speed,function(){$("#shoppingbag_menu ul li.right").css("background-color",off_color);});login_visible=false;}
if(toteupdate_visible){$("#cart_div").slideUp(slide_speed);toteupdate_visible=false;}
$("#partner_header_links > a").removeClass("active");$("#wishlist_popup .description").hide();}
function openPopupTote()
{input_focus=null;closePopups('tote');if((!tote_visible)&&($('#tote_quantity').html()!='0 items')){if($('#tp_item_wrapper').height()>tote_max){$("#tp_close").css('margin-top','5px');$("#tp_close").css('margin-right','30px');}else{$("#tp_item_wrapper").css('height','auto');$("#tp_close").css('margin-top','0px');$("#tp_close").css('margin-right','10px');}
$("#tote_popup").slideDown(slide_speed);tote_visible=true;}}
function openPopupTracking()
{if(input_focus!='tracking'){input_focus=null;}
closePopups();if(!tracking_visible){$("#shoppingbag_menu ul li.left").css("background-color",on_color);$("#partner_header_links #left").addClass("active");$("#tracking_popup").slideDown(slide_speed);tracking_visible=true;}}
function openPopupLogin()
{if(input_focus!='login'){input_focus=null;}
closePopups();if(!login_visible){$("#shoppingbag_menu ul li.right").css("background-color",on_color);$("#partner_header_links #right").addClass("active");$("#account_create div").hide();$("#wishlist_popup").slideDown(slide_speed,function(){$("#account_login div").slideDown(slide_speed);});login_visible=true;}}
function openPopupToteUpdate()
{input_focus=null;closePopups();if(!toteupdate_visible){$("#cart_div").slideDown(slide_speed);popup_timer=setTimeout('closePopups()',popup_timer_close);toteupdate_visible=true;}}
function handleCartPopup(div)
{$('#cart_div').html(div);$("#cart_close").click(function(){closePopups();});clearTimeout(popup_timer);popup_timer=setTimeout('openPopupToteUpdate()',popup_timer_open);}
function removeToteItem(id)
{var page=location.pathname.substring(1);$.getJSON('/ajax/removetoteitem',{rem_id:id,page_id:page},function(json){$('#tp_item_wrapper').html(json.tote);if($('#quantity_update').val()==1){$('#tote_quantity').html('1 item');}else{$('#tote_quantity').html($('#quantity_update').val()+' items');}
$('#tote_price').html($('#price_update').val());if($('#quantity_update').val()==0){if(page=='checkout')
top.location='cart';closePopups();}else{$(".tp_rem").click(function(){removeToteItem($(this).attr('id'));});}
if(page=='cart'){$('#content').html(json.content);cartInitActions();}});}
function toteRefresh(data)
{$('#tp_item_wrapper').html(data);$('.tp_rem').click(function(){removeToteItem($(this).attr('id'));});if($('#quantity_update').val()==1){$('#tote_quantity').html('1 item');}else{$('#tote_quantity').html($('#quantity_update').val()+' items');}
$('#tote_price').html($('#price_update').val());};var box_on='url(/images/button/checkbox_active.gif)';var box_off='url(/images/button/checkbox_inactive.gif)';var load_small='<img src="/images/loading_small.gif" alt="Please wait..."/>';var qty_0='quantity must be greater than 0';$(document).ready(function()
{$("a[rel='external']").click(function()
{window.open($(this).attr('href'),'popup','toolbar=0,scrollbars=0,location=0,status=0,menubar=0');return false;});$('#description p:last').after('  <nobr><span id="more">[See More]</span></nobr>');$('#description p:first').nextAll('p').each(function(){$(this).hide();});var sidebar_height=$("#sidebar_content").height();var content_height=$("#content").height();if(sidebar_height>content_height)
$("#content").height(sidebar_height);});function finishClose()
{$('#overlay').fadeOut('fast');$('#overlay').css('height',0);$(document).unbind();}
function handleKeypress(e)
{if(e==null){keycode=event.keyCode;escapeKey=27;}else{keycode=e.keyCode;escapeKey=e.DOM_VK_ESCAPE;}
if(keycode==escapeKey)
{$('.quick_popup').hide();finishClose();}}
function setupPopup(note)
{if($('#loading_note').length){if(note=='')
note='Loading...';$('#loading_note').html(note);}else{$('body').append('<div id="overlay"></div>');$('#overlay').bgiframe();if(note=='')
note='Loading...';$('body').append('<div id="loading"><img src="/images/loading.gif" /><div id="loading_note">'+note+'</div></div>');}
startPopup();}
function destroyPopup()
{if($('#loading_note').length>0){$('#loading_note').html('<br/>returning you to the page...');$("#overlay").fadeOut('fast');$("#loading").fadeOut('slow');}}
function startPopup()
{$("#overlay").css('height',$(document).height());$("#overlay").css('opacity',0.5).fadeIn('fast');var scrollTop=$(document).scrollTop();var scrollLeft=$(document).scrollLeft();var windowHeight=$(window).height();var windowWidth=$(window).width();$("#loading").fadeIn('fast');$("#loading").css('left',Math.round((windowWidth-$("#loading").width())/2)+scrollLeft)
$("#loading").css('top',Math.round((windowHeight-$("#loading").height())/2)+scrollTop);$("#overlay").click(function(){$('.quick_popup').hide();$("#loading").fadeOut('slow');finishClose();});}
function showPopup(id)
{$('#loading').fadeOut('fast',function()
{$(id).fadeIn('slow');positionPopup(id);$(document).keydown(function(e)
{handleKeypress(e);});});}
function positionPopup(id)
{var scrollTop=$(document).scrollTop();var scrollLeft=$(document).scrollLeft();var windowHeight=$(window).height();var windowWidth=$(window).width();var top=Math.round((windowHeight-$(id).height())/2)+scrollTop;if(top<0)
top=0;$(id).animate({left:Math.round((windowWidth-$(id).width())/2)+scrollLeft,top:top},'normal','linear');}
function buildProductCodeArray(retValues,personalize)
{var type=$('#productpage_type').val();retValues.doPost=false;var min_quantity=1;if(personalize){min_quantity=Math.max($('#personalize_min_quantity').val(),$('#product_min_quantity').val());}else{min_quantity=$('#product_min_quantity').val();}
min_quantity=parseInt(min_quantity);var multiple_of=$('#product_multiples_of').val();var boxValue=0;if(type=='input'){$("input[name='quantity']").each(function(){boxValue=parseInt($(this).val(),10);if(isNaN(boxValue)){boxValue=0;}
if(boxValue<=0){$(this).next().html(qty_0);}else if(boxValue<min_quantity){$(this).next().html('quantity must be '+min_quantity+' or more');}else if(boxValue%multiple_of!=0){$(this).next().html('quantity must be a multiple of '+multiple_of);}else{retValues.productcodeArray[retValues.productcodeArray.length]=$(this).attr('productcode')+'_'+boxValue;retValues.doPost=true;$(this).next().html('');}});if(retValues.doPost){$("input[name='quantity']").each(function(){if($(this).val()==0){$(this).next().html('');}});}}else if(type=='dropdown'){$('.quantity_box').each(function(){boxValue=parseInt($(this).val(),10);if(isNaN(boxValue)){boxValue=0;}
if(phpEmpty(boxValue)){$(this).next().html(qty_0);}else if(boxValue<min_quantity){$(this).next().html('quantity must be '+min_quantity+' or more');}else if(boxValue%multiple_of!=0){$(this).next().html('quantity must be a multiple of '+multiple_of);}else{var productCode=$(this).parent().prev();if(!productCode.hasClass('product_info_section')){productCode=productCode.prev();}
productCode=productCode.children('.productcode_dropdown').val();retValues.doPost=true;retValues.productcodeArray[retValues.productcodeArray.length]=productCode+'_'+boxValue;$(this).next().html('');}});if(retValues.doPost){$('.quantity_box').each(function(){if($(this).val()==0){$(this).next().html('');}});}}}
function isEmpty(obj)
{for(value in obj){return false;}
return true;}
function objSize(obj)
{var size=0;for(var i in obj){size++;}
return size;}
function phpEmpty($var)
{if($var===undefined){return true;}
if($var==''){return true;}
if($var==0){return true;}
return false;};$(function(){$('#change_cur_container img').click(function(){$('#change_cur').slideToggle('slow');});$('#change_cur .popup_close').click(function()
{$('#change_cur').slideUp('slow');});$('#left button').click(function(){var currency=$('#left select').val();$.post('/ajax/setCurrency',{cur:currency},function(){location.reload(true);});});});;var itemNum='';(function($)
{$.fn.personalize=function(options)
{var defaults={};var options=$.extend(defaults,options);return this.each(function()
{$(this).click(function()
{var retValues=new Object();retValues.productcodeArray=new Array();buildProductCodeArray(retValues,true);if(retValues.doPost){setupPopup('');$.post('/ajax/personalizearray/',{id:$(this).attr('product_id'),product_info:JSON.stringify(retValues.productcodeArray),designStyle:$('#product_design_style').val()},function(json){setupPersonalization(json);},'json');}});});}})(jQuery);$(document).ready(function()
{$(".image_container").hover(function(){$(this).addClass('image_border');},function(){$(this).removeClass('image_border');}).click(function(){$("#image img").attr('src','/images/products/medium/'+$("img",$(this)).attr('filename'));$(".preview_image").attr('href',$("img",$(this)).attr('link'));});$(".letter_style_option, .design_style_option, .logo_option, .wrapper_style_option, .sticker_style_option, .swatch_option, .monogram_color_option, .ribbon_style_option").livequery(function(){$(this).hover(function(){$(this).addClass('image_border')},function(){$(this).removeClass('image_border')});$(this).click(function(){$(".letter_style_option, .design_style_option, .logo_option, .wrapper_style_option, .sticker_style_option, .swatch_option, .monogram_color_option, .ribbon_style_option").each(function(){$(this).removeClass('letter_style_selected');$(this).removeClass('letter_style_selected_border');});$(this).addClass('letter_style_selected');$(this).addClass('letter_style_selected_border');});},function(){$(this).unbind('mouseover').unbind('mouseout').unbind('click');});$('#addtocartpersonalize').livequery('click',function(){$('#navigation_buttons').html(load_small);$.post('/ajax/addtototepersonalizeproduct',{hash:$('#hash').val()},function(json){if(json.added){handleCartPopup(json.added);}
if(json.oldCode){$('#personalize_div').fadeOut('slow',function(){$('#overlay').fadeOut('slow',function(){var row='row_'+json.oldCode;row=document.getElementById(row)||document.getElementById(row.replace(/\:/,'\\:'));if(row!=null){var targetOffset=$(row).offset().top-15;var allow_scroll=true;$('html,body').animate({scrollTop:targetOffset},'slow',function(){if(allow_scroll){allow_scroll=false;$(row).slideUp('slow',function(){$(row).remove();if(json.updatedCodes){if(json.newCodes){personalizeUpdatedCode(json.updatedCodes,json.newCodes);}else{personalizeUpdatedCode(json.updatedCodes);}}else if(json.newCodes){personalizeNewCode(json.newCodes);}});}});$('#ajax1').fadeOut('fast').html(json.shipping).fadeIn('fast');}});});}else if(json.multiple){loadPersonalizeDiv(json.multiple);}else{$('#personalize_div').hide();$('#overlay').hide();$('input[name=quantity]').val('');}
if(json.tote){toteRefresh(json.tote);}},'json');});$("#previous_step").livequery(function(){$(this).click(function(){$('#navigation_buttons').html(load_small);$.post('/ajax/personalizePrevious',{id:$('#id').val(),previous:$('#previous').val(),code:$('#code').val(),hash:$('#hash').val()},function(data){loadPersonalizeDiv(data);});});});$("#next_step").livequery(function(){$(this).click(function(){var selected=undefined;var data=undefined;var id=$('#id').val();var error=undefined;var index=0;var swatch=null;var logo=undefined;$('#personalize_error').text('');$('.letter_style_option, .design_style_option, .logo_option, .wrapper_style_option, .sticker_style_option, .swatch_option, .monogram_color_option').each(function(){if($(this).hasClass('letter_style_selected')){selected=true;if($(this).hasClass('design_style_option')){data={paramName:"design",design:$(this).attr('id')};}else if($(this).hasClass('wrapper_style_option')){data={paramName:"wrapper",wrapper:$(this).attr('id')};}else if($(this).hasClass('sticker_style_option')){data={paramName:"sticker",sticker:$(this).attr('id')};}else if($(this).hasClass('swatch_option')){swatch=$(this).attr('id').replace('swatch_','');}else if($(this).hasClass('monogram_color_option')){data={paramName:"monogramColor",monogramColor:$(this).attr('id')};}else{data={paramName:"style",style:$(this).attr('id')};}}else{error='You must select one of the styles.';}});if($('.text_line').length){selected=true;switch($('#type').val()){case'ribbons':data={paramName:"text",swatch:swatch,sameAll:$('#same_allitems').val()};break;default:data={paramName:"text",sameAll:1};}}
if($('#personalize_div li.logo').length>0){selected=true;index=0;logo=new Array();$('#personalize_div li.logo select').each(function(i,item){if($(item).val()!='no icon'){logo[index]=$(item).val();index++;}});data={paramName:"logo",logo:logo,sameAll:$('#same_allitems').val(),type:$('#type').val()};}
if($('#personalize_div li.swatch').length>0){selected=true;index=0;swatch=new Array();$('#personalize_div li.swatch select').each(function(i,item){swatch[index]=$(item).val();index++;});}
if($('#personalize_div input:text, #personalize_div select.list').size()>0){selected=true;index=0;text=new Array();$('#personalize_div input:text, #personalize_div select.list').each(function(){var id=$(this).attr('name');if($(this).attr('disabled')){$(this).val('');}
text[index]=id+'_'+$(this).val();index++;});switch($('#type').val()){case'candles':data={paramName:"text",text:text,sameAll:$('#same_allitems').val()};break;case'engraving':if(logo===undefined){data={paramName:"text",text:text,sameAll:$('#same_allitems').val()};}else{data={paramName:"text",text:text,logo:logo,sameAll:$('#same_allitems').val()};}
break;case'embroidery':case'ribbons':data={paramName:"text",text:text,swatch:swatch,sameAll:$('#same_allitems').val()};break;case'napkins':case'coffee':case'chocolate_bars':data={paramName:"text",text:text,swatch:swatch,sameAll:1};break;default:data={paramName:"text",text:text,sameAll:1};}}
if($('#personalize_preface').length>0){selected=true;data={paramName:'preface'};}
if(selected){var prior=$('#navigation_buttons').html();$('#navigation_buttons').html(load_small);$.post('/ajax/personalize',{id:id,code:$('#code').val(),hash:$('#hash').val(),data:JSON.stringify(data)},function(json){if(json.error){$('#personalize_error').text(json.error).slideDown();$('#personalize_div').height($('#personalize_div').height()+$('#personalize_error').height()+10);$('#navigation_buttons').html(prior);}else{loadPersonalizeDiv(json.html);window.location.hash=json.hash;}},'json');}else{$('#personalize_error').text(error).slideDown();$('#personalize_div').height($('#personalize_div').height()+$('#personalize_error').height()+10);}});},function(){$(this).unbind('click');});$('.personalize_details').livequery(function(){var sel='#personalize_popup';$(this).click(function(){var id=$(this).attr('id').replace('detail_','');var icon=$(this);if(id=='logo'){personalizePopupLogoOnly(icon);}else{popupImg=new Image();popupImg.src='/images/personalization/alphabets/cropped/'+id.toLowerCase()+'.gif';popupImg.onload=function(){$('#personalize_popup div').html(popupImg);$(sel).css('top',icon.position().top+icon.height());$(sel).css('left',icon.position().left-((popupImg.width-icon.width())/2));$(sel).hide().fadeIn('slow');}}});$(this).hover(function(){},function(){$(sel).fadeOut('slow');});});$('#personalize_logos div').livequery(function(){var sel='#personalize_popup';$(this).click(function(){var id=$(this).attr('id');var icon=$(this);popupImg=new Image();popupImg.src='/images/personalization/alphabets/cropped/'+id.toLowerCase()+'.jpg';popupImg.onload=function(){$('#personalize_popup div').html(popupImg);$(sel).css('top',icon.position().top-popupImg.height-40);$(sel).css('left',icon.position().left-((popupImg.width-icon.width())/2)-15);$(sel).hide().fadeIn('slow');}});$(this).hover(function(){},function(){$(sel).fadeOut('slow');});},function(){$(this).unbind('mouseover').unbind('mouseout');});$('#engraving_text #personalize_logo_container').livequery(function()
{$(this).hover(function()
{},function(){$('#logo_preview').fadeOut('slow');$('.piece_text, #piece_options').css('visibility','visible');});},function()
{$(this).unbind('mouseover').unbind('mouseout');});$('#breadcrumbs .active').livequery('click',function(){$.post('/ajax/personalizebreadcrumb',{id:$('#id').val(),phase:$(this).attr('id'),code:$('#code').val(),hash:$('#hash').val()},function(json){loadPersonalizeDiv(json.html);window.location.hash=json.hash;},'json');});$('.logo input[type=hidden], .swatch input[type=hidden]').livequery(function(){$(this).siblings('select').val($(this).val());});$('.edit').livequery('click',function(){var itemNum=$(this).attr('id').replace('edit_','');$.post('/ajax/personalizereviewedit',{id:$('#id').val(),itemNum:itemNum,code:$('#code').val(),hash:$('#hash').val()},function(json){loadPersonalizeDiv(json.html);window.location.hash=json.hash;},'json');});$('#review_scroll').livequery(function(){if($(this).height()>=400){$(this).height($(this).css('max-height'));$(this).css('margin-top','20px');$('.piece').each(function(){$(this).width($(this).width()-10);});$(this).css('overflow','auto');}});$('#piece_options .text_line').livequery('click',function(){var id='#'+$(this).attr('id').replace('_wrapper','');var box=id+'_box';if($(id).val()==1){$(box).css('backgroundImage',box_off);$(id).val(0);}else{$(box).css('backgroundImage',box_on);$(id).val(1);}});$('#same_pieces_wrapper').livequery('click',function(){var id=$('#same_pieces');var box=$('#same_pieces_box');if(id.val()==1){box.css('backgroundImage',box_off);id.val(0);}else{box.css('backgroundImage',box_on);id.val(1);personalizeCloneFirst();}});$('.piece_text input[type=text]').livequery('change',function(){var parent=$(this).parent().parent().parent().attr('id');var parentIndex=parent.split('_');parentIndex=parentIndex[parentIndex.length-1];if(parentIndex==0&&($('#same_pieces').val()==1)){personalizeCloneFirst();}else{personalizeHasSameText();}});$('#same_pieces').livequery(function(){personalizeHasSameText();});$('#same_allitems_wrapper').livequery('click',function(){var qty=1;var id=$('#same_allitems');var box=$('#same_allitems_box');if(id.val()==1){id.val(0);box.css('backgroundImage',box_off);if(itemNum!=''){$('#item_num').html(itemNum);}else{qty=$.trim($('#item_num').html()).substring(0,1);$('#item_num').html('Item 1 of '+qty);}}else{id.val(1);box.css('backgroundImage',box_on);itemNum=$.trim($('#item_num').html());qty=itemNum.substring(itemNum.length-1);if(qty=='1')
qty+=' item';else
qty+=' items';$('#item_num').html(qty);}});$('#same_allitems').livequery(function(){itemNum='';if($(this).val()==1){$('#same_allitems_box').css('backgroundImage',box_on);}});$('#personalize_div select.text_input').livequery(function(){personalizeApplyRestrictions($(this).children('option:selected'));});$('#personalize_div select.text_input').livequery('change',function(){personalizeApplyRestrictions($(this).children('option:selected'));});$('#personalize_close').livequery('click',function(){$('#personalize_div').fadeOut();$('#overlay').fadeOut();});});function loadPersonalizeDiv(data)
{var imgArray=getImgArray(data);var timer=window.setInterval(function(){if(!checkImg(imgArray))
return;window.clearInterval(timer);$('#personalize_div_inner').fadeTo('normal',0,function(){$('#ajax_loader').html(data);var height=$('#ajax_loader').height();$('#personalize_div').animate({height:height},'slow','linear',function(){$('#personalize_div_inner').html(data);personalizeReapplySettings();if($('#personalize_div').height()!=$('#ajax_loader').height())
$('#personalize_div').animate({height:$('#ajax_loader').height()},'fast','linear');$('#personalize_div_inner').fadeTo('normal',1);positionPopup('#personalize_div');});});},1000);}
function getImgArray(context)
{var imgArray=[];var count=0;$('img',context).each(function(){imgArray[count]=new Image();imgArray[count].src=$(this).attr('src');count++;});return imgArray;}
function personalizeStart(personalize_div)
{$('#ajax_loader').html(personalize_div);var height=$('#ajax_loader').height();$('#personalize_div_inner').html(personalize_div);personalizeReapplySettings();$('#personalize_div').height(height);showPopup('#personalize_div');$('div.checkbox',personalize_div).click(function(){if($(this).attr('s')=='false'){$(this).attr('s','true');}else{$(this).css('background-image','');$(this).attr('s','false');}});$('.image_select').click(function(){$(this).next('div').slideToggle('fast');});$('.image_select_dropdown div').hover(function(){$(this).css('border','1px solid #A66181');},function(){$(this).css('border','');}).click(function(){$(this).parent().slideToggle('fast');var container=$(this).parent().parent().parent().attr('id');var count=0;$(this).children('span').each(function(){if(count==0){$(this).parent().parent().parent().children('.image_select').text($(this).text());$('#'+container+' .product_info_name').text($(this).text());}else if(count==1)
$('#'+container+' .product_info_designs').text($(this).text());else if(count==2)
$('#'+container+' .product_info_price_range').text($(this).text());else if(count==3)
$('#'+container).children('img').attr('src',$(this).text());else if(count==4)
$('#'+container+' div.checkbox').attr('product_code',$(this).text());count++;});});}
function checkImg(imgArray)
{for(var i=0;i<imgArray.length;i++){if(!imgArray[i].complete)
return false;}
return true;}
function checkOptions()
{var code='';if($("#sticker_div div.checkbox").attr('s')=='true')
code=code+$("#sticker_div div.checkbox").attr('product_code');else
code=code+'0';code+='|';if($("#card_div div.checkbox").attr('s')=='true')
code=code+$("#card_div div.checkbox").attr('product_code');else
code=code+'0';code+='|';if($("#ribbon_div div.checkbox").attr('s')=='true')
code=code+$("#ribbon_div div.checkbox").attr('product_code');else
code=code+'0';code+='|';if($("#craftpunch_div div.checkbox").attr('s')=='true')
code=code+$("#craftpunch_div div.checkbox").attr('product_code');else
code=code+'0';code+='|';if($("#dazzler_div div.checkbox").attr('s')=='true')
code=code+$("#dazzler_div div.checkbox").attr('product_code');else
code=code+'0';return code;}
function setupPersonalization(json)
{var data=json.html;window.location.hash=json.hash;var personalize_div=$(data);var imgArray=getImgArray(personalize_div);var timer=window.setInterval(function(){if(!checkImg(imgArray))
return;window.clearInterval(timer);personalizeStart(personalize_div);},1000);}
function personalizeReapplySettings()
{var id=undefined;var selected=undefined;if($('#letter_style_selected').length>0){id=$('#letter_style_selected').val();selected='#letter_style #'+id;}else if($('#design_style_selected').length>0){id=$('#design_style_selected').val();selected='#design_style #'+id;}else if($('#wrapper_style_selected').length>0){id=$('#wrapper_style_selected').val();selected='#wrapper_style #'+id;}else if($('#sticker_style_selected').length>0){id=$('#sticker_style_selected').val();selected='#sticker_style #'+id;}else if($('#swatch_selected').length>0){id=$('#swatch_selected').val();selected='#swatch_'+id;}else if($('#monogram_color_selected').length>0){id=$('#monogram_color_selected').val();selected='#monogram_color #'+id;}
$(selected).addClass('letter_style_selected');$(selected).addClass('letter_style_selected_border');}
function personalizeCloneFirst()
{template=new Array();var i=0;$('#piece_wrapper_0 input[type=text]').each(function(){template[i++]=$(this).val();});$('.piece_text').each(function(){var id='#'+$(this).attr('id');i=0;$(id+' input[type=text]').each(function(){$(this).val(template[i++]);});});}
function personalizeHasSameText()
{var exitCall=false;template=new Array();var i=0;$('#piece_wrapper_0 input[type=text]').each(function(){template[i++]=$(this).val();});$('.piece_text').each(function(){var id='#'+$(this).attr('id');i=0;$(id+' input[type=text]').each(function(){if($(this).val()!=template[i++]){$('#same_pieces').val(0);$('#same_pieces_box').css('backgroundImage',box_off);exitCall=true;return false;}});if(exitCall)return false;});if(exitCall)return false;$('#same_pieces').val(1);$('#same_pieces_box').css('backgroundImage',box_on);return true;}
function personalizeUpdatedCode(jsonUpdatedCodes,jsonNewCodes)
{if(jsonUpdatedCodes.length>0){var updatedCodes=jsonUpdatedCodes.shift();var row='row_'+updatedCodes['code'];row=document.getElementById(row)||document.getElementById(row.replace(/\:/,'\\:'));var targetOffset=$(row).offset().top-15;var allow_scroll=true;$('html,body').animate({scrollTop:targetOffset},'slow',function(){if(allow_scroll){allow_scroll=false;$(row).children('div.qty').children('input.cart_udpate_box').val(updatedCodes['qty']).effect("pulsate",{times:3},300,function(){$(row).children('div.total').children('div.base_cost').html(updatedCodes['price']).effect("pulsate",{times:3},300,function(){if($(row).children('div.total').children('div.fee_cost').length){$(row).children('div.total').children('div.fee_cost').html(updatedCodes['fee']).effect("pulsate",{times:3},300,function(){if(jsonUpdatedCodes.length>0){personalizeUpdatedCode(jsonUpdatedCodes,jsonNewCodes);}else if(jsonNewCodes){personalizeNewCode(jsonNewCodes);}});}else if(jsonUpdatedCodes.length>0){personalizeUpdatedCode(jsonUpdatedCodes,jsonNewCodes);}else if(jsonNewCodes){personalizeNewCode(jsonNewCodes);}});});}});}}
function personalizeNewCode(jsonNewCodes)
{if(jsonNewCodes.length>0){var newCode=$(jsonNewCodes.shift()).hide();var targetOffset=$('#cart').offset().top+$('#cart').height()-15;var allow_scroll=true;$('html,body').animate({scrollTop:targetOffset},'slow',function(){if(allow_scroll){allow_scroll=false;newCode.appendTo($('#cart')).slideDown('slow',function(){$('#cart').append('<div class="clearfix"></div>');$('.product_personalization div').css('display','none').css('display','block');if(jsonNewCodes.length>0){personalizeNewCode(jsonNewCodes);}});}});}}
function personalizeApplyRestrictions(menu)
{var line2=$(menu).parent().parent().next().next().children('input:text');if($(menu).hasClass('restriction_1')){$(line2).attr('disabled','disabled');}else if($(line2).attr('disabled')){$(line2).removeAttr('disabled');}}
function personalizePopupLogoOnly(icon)
{var sel=$('#personalize_popup');sel.css('top',icon.position().top-icon.height()-250);sel.css('left',icon.position().left);$('#personalize_popup div').html('<div style="text-align:center;"><img src="/images/loading.gif" alt="loading, please wait..." />');sel.show();$.post('/ajax/personalizelogoonlypopup',{id:$('#id').val()},function(html){$('#personalize_popup div').width(480).html(html);sel.hide().fadeIn('slow');});};var change_country_visible=false;$(document).ready(function()
{$('#change_country_div').click(function()
{if(change_country_visible)
$('#change_country_popup').slideUp('fast');else
$('#change_country_popup').slideDown('fast');change_country_visible=!change_country_visible;});$('#change_country_popup .popup_close').click(function()
{$('#change_country_popup').slideUp('fast');change_country_visible=false;});$('#checkout_button').click(function()
{top.location='/cart';});});;;(function($){$.fn.addOption=function()
{var add=function(el,v,t,sO)
{var option=document.createElement("option");option.value=v,option.text=t;var o=el.options;var oL=o.length;if(!el.cache)
{el.cache={};for(var i=0;i<oL;i++)
{el.cache[o[i].value]=i;}}
if(typeof el.cache[v]=="undefined")el.cache[v]=oL;el.options[el.cache[v]]=option;if(sO)
{option.selected=true;}};var a=arguments;if(a.length==0)return this;var sO=true;var m=false;var items,v,t;if(typeof(a[0])=="object")
{m=true;items=a[0];}
if(a.length>=2)
{if(typeof(a[1])=="boolean")sO=a[1];else if(typeof(a[2])=="boolean")sO=a[2];if(!m)
{v=a[0];t=a[1];}}
this.each(function()
{if(this.nodeName.toLowerCase()!="select")return;if(m)
{for(var item in items)
{add(this,item,items[item],sO);}}
else
{add(this,v,t,sO);}});return this;};$.fn.ajaxAddOption=function(url,params,select,fn,args)
{if(typeof(url)!="string")return this;if(typeof(params)!="object")params={};if(typeof(select)!="boolean")select=true;this.each(function()
{var el=this;$.getJSON(url,params,function(r)
{$(el).addOption(r,select);if(typeof fn=="function")
{if(typeof args=="object")
{fn.apply(el,args);}
else
{fn.call(el);}}});});return this;};$.fn.removeOption=function()
{var a=arguments;if(a.length==0)return this;var ta=typeof(a[0]);var v,index;if(ta=="string"||ta=="object"||ta=="function")
{v=a[0];if(v.constructor==Array)
{var l=v.length;for(var i=0;i<l;i++)
{this.removeOption(v[i],a[1]);}
return this;}}
else if(ta=="number")index=a[0];else return this;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return;if(this.cache)this.cache=null;var remove=false;var o=this.options;if(!!v)
{var oL=o.length;for(var i=oL-1;i>=0;i--)
{if(v.constructor==RegExp)
{if(o[i].value.match(v))
{remove=true;}}
else if(o[i].value==v)
{remove=true;}
if(remove&&a[1]===true)remove=o[i].selected;if(remove)
{o[i]=null;}
remove=false;}}
else
{if(a[1]===true)
{remove=o[index].selected;}
else
{remove=true;}
if(remove)
{this.remove(index);}}});return this;};$.fn.sortOptions=function(ascending)
{var sel=$(this).selectedValues();var a=typeof(ascending)=="undefined"?true:!!ascending;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return;var o=this.options;var oL=o.length;var sA=[];for(var i=0;i<oL;i++)
{sA[i]={v:o[i].value,t:o[i].text}}
sA.sort(function(o1,o2)
{o1t=o1.t.toLowerCase(),o2t=o2.t.toLowerCase();if(o1t==o2t)return 0;if(a)
{return o1t<o2t?-1:1;}
else
{return o1t>o2t?-1:1;}});for(var i=0;i<oL;i++)
{o[i].text=sA[i].t;o[i].value=sA[i].v;}}).selectOptions(sel,true);return this;};$.fn.selectOptions=function(value,clear)
{var v=value;var vT=typeof(value);if(vT=="object"&&v.constructor==Array)
{var $this=this;$.each(v,function()
{$this.selectOptions(this,clear);});};var c=clear||false;if(vT!="string"&&vT!="function"&&vT!="object")return this;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return this;var o=this.options;var oL=o.length;for(var i=0;i<oL;i++)
{if(v.constructor==RegExp)
{if(o[i].value.match(v))
{o[i].selected=true;}
else if(c)
{o[i].selected=false;}}
else
{if(o[i].value==v)
{o[i].selected=true;}
else if(c)
{o[i].selected=false;}}}});return this;};$.fn.copyOptions=function(to,which)
{var w=which||"selected";if($(to).size()==0)return this;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return this;var o=this.options;var oL=o.length;for(var i=0;i<oL;i++)
{if(w=="all"||(w=="selected"&&o[i].selected))
{$(to).addOption(o[i].value,o[i].text);}}});return this;};$.fn.containsOption=function(value,fn)
{var found=false;var v=value;var vT=typeof(v);var fT=typeof(fn);if(vT!="string"&&vT!="function"&&vT!="object")return fT=="function"?this:found;this.each(function()
{if(this.nodeName.toLowerCase()!="select")return this;if(found&&fT!="function")return false;var o=this.options;var oL=o.length;for(var i=0;i<oL;i++)
{if(v.constructor==RegExp)
{if(o[i].value.match(v))
{found=true;if(fT=="function")fn.call(o[i],i);}}
else
{if(o[i].value==v)
{found=true;if(fT=="function")fn.call(o[i],i);}}}});return fT=="function"?this:found;};$.fn.selectedValues=function()
{var v=[];this.selectedOptions().each(function()
{v[v.length]=this.value;});return v;};$.fn.selectedTexts=function()
{var t=[];this.selectedOptions().each(function()
{t[t.length]=this.text;});return t;};$.fn.selectedOptions=function()
{return this.find("option:selected");};})(jQuery);;$(document).ready(function()
{$('.not_in_list').livequery('click',function(){var other='#'+$(this).attr('id').replace('_wrapper','_other');$(other).parent().slideToggle('fast');});$('.checkbox_wrapper').livequery('click',function(){var id='#'+$(this).attr('id').replace('_wrapper','');var box=id+'_box';var proxy=id+'_hidden';if($(proxy).val()==1){$(box).css('backgroundImage',box_off);$(proxy).val(0);}else{$(box).css('backgroundImage',box_on);$(proxy).val(1);}});$('#set_shipping select').livequery('change',function(){var id='#'+$(this).attr('id');var box=id+'_box';var proxy=id+'_hidden';var other=id+'_other';if($(proxy).val()==1){$(proxy).val(0);$(box).css('backgroundImage',box_off);$(other).parent().slideToggle('fast');}});$('.other').livequery(function(){var id=$(this).attr('id');var proxy='#'+id.replace('_other','_hidden');if($(proxy).val()!=1){$(this).parent().hide();}});$('.box_proxy').livequery(function(){var id=$(this).attr('id');var box='#'+id.replace('_hidden','_box');if($(this).val()==1){$(box).css('backgroundImage',box_on);}});$('#change_shipping').livequery('click',function(){$('#set_shipping').slideToggle('slow');});$('#set_shipping_close').livequery('click',function(){$('#set_shipping').slideUp('slow');});$('#set_shipping_submit').livequery('click',function(){$.post('/cart/shipping',$('#form-ship').formSerialize(),function(data){$('#ajax1').html(data);});});$('#set_shipping #errorState').livequery(function(){if($(this).val()==1){$('#set_shipping').show();}});$('#set_shipping #province, #set_shipping #province_other, #set_shipping #country, #set_shipping #country_other').livequery('change',function(){cartUpdateShippingMethod();});$('#set_shipping .checkbox_wrapper').livequery('click',function(){cartUpdateShippingMethod();});$('.cart_recommend_item').livequery('hover',function(){$(this).css('border','1px solid #D3D4D6');},function(){$(this).css('border','1px solid white');});$('table#cart tr').livequery('hover',function(){$(this).css('background-color','#F0EEEC');},function(){$(this).css('background-color','white');});$('#continue_link').livequery('click',function(){history.back();});$('.cart_remove_box').livequery('click',function(){var id=$(this).attr('id').replace('box_','remove_');var sel=document.getElementById(id)||document.getElementById(id.replace(/\:/,'\\:'));if($(this).css('backgroundImage')==box_on){$(this).css('backgroundImage',box_off);$(sel).val(0);}else{$(this).css('backgroundImage',box_on);$(sel).val(1);}});$('.cart_udpate_box').livequery('change',function(){var id=$(this).attr('name');var qty=$(this).val();var min=parseInt($(this).attr('min'));var b=id.replace('quantity_','box_');var r=id.replace('quantity_','remove_');var m=id.replace('quantity_','min_');var box=document.getElementById(b)||document.getElementById(b.replace(/\:/,'\\:'));var rem=document.getElementById(r)||document.getElementById(r.replace(/\:/,'\\:'));var emin=document.getElementById(m)||document.getElementById(r.replace(/\:/,'\\:'));qty=qty.replace(/[^0-9]/g,'');if((qty==0)||(qty=='')){qty=0;if($(rem).val()==0){$(box).css('backgroundImage',box_on);$(rem).val(1);}}else{if($(rem).val()==1){$(box).css('backgroundImage',box_off);$(rem).val(0);}
if(qty<min){qty=min;if(min>1){$(emin).show();}}}
$(this).val(qty);});$('.add_qty').livequery('change',function(){var qty=$(this).val();qty=qty.replace(/[^0-9]/g,'');if(qty<1){qty=1;}
$(this).val(qty);});$('.add_code').livequery('change',function(){var code=$(this).val();code=code.replace(/[\s]/g,'');$(this).val(code);});$('#cart_addtotote').livequery('click',function(){cartAddToTote();});$('#cart_additems input').livequery('keyup',function(e){switch(e.keyCode){case 13:cartAddToTote();default:break;}});$('#clear_tote').livequery('click',function(){var dialog='#clear_sure';if($(dialog).length>0){$(dialog).show();}else{var div='<div id="clear_sure">'
+'<div>Are you sure you want to clear your tote?</div>'
+'<div>'
+'<div class="buttons" id="clear_yes">Yes</div>'
+'<div class="buttons" id="clear_no">No</div>'
+'<div class="clearfix"></div>'
+'</div>'
+'</div>';$('body').append(div);$('#clear_sure').bgiframe();var scrollTop=$(document).scrollTop();var scrollLeft=$(document).scrollLeft();var windowHeight=$(window).height();var windowWidth=$(window).width();$(dialog).css('left',Math.round((windowWidth-$(dialog).width())/2)+scrollLeft)
$(dialog).css('top',Math.round((windowHeight-$(dialog).height())/2)+scrollTop);$('#clear_no').click(function(){$('#clear_sure').hide();});$('#clear_yes').click(function(){$(dialog).hide();setupPopup('please wait while we clear your tote...');$.post('/cart/clearcart',null,function(data)
{$('#ajaxclear').html(data);$('#tote_quantity').html('0 items');$('#tote_price').html($('#price_clear').val());destroyPopup();});});}});$('#save_changes').livequery('click',function(){$(this).css('visibility','hidden');setupPopup('please wait while we update your tote...');$.post('/cart/savechanges',$('#cart_review').formSerialize(),function(json)
{$('#ajaxclear').html(json.content);toteRefresh(json.tote);destroyPopup();},'json');});$('#proceed_to_checkout').livequery('click',function(){$(this).css('visibility','hidden');setupPopup('please wait...');top.location='/checkout';});$('#code_1').livequery(function(){if($('#tote_quantity').html().substr(0,1)=='0'){$(this).focus();}});$('div#cart .removePersonalization').livequery('click',function(){var row=$(this).parent().parent().parent().parent();var ptext=$(this).parent().parent();var code=$(this).attr('id').replace('rp_','');row.slideUp('slow');$.post('/cart/personalizeremove',{code:code},function(json){var newCode='input[name=quantity_'+json.newCode+']';if($(newCode).length>0){row.remove();var targetOffset=$(newCode).offset().top-15;var allow_callback=true;$('html,body').animate({scrollTop:targetOffset},'slow',function(){if(allow_callback){allow_callback=false;$(newCode).val(json.qty).effect('pulsate',{times:3},300);$(newCode).parent().parent().children('.total').children('.base_cost').html(json.price).effect('pulsate',{times:3},300);}});}else{ptext.html('<div class="personalization_header">Not Personalized</div><br/><div class="personalization_actions">> <span class="hover editPersonalization" id="ep_'+json.newCode+'">Edit Personalization</span></div>');row.children('.price').children('.fee_cost').each(function(){$(this).remove();});row.html(row.html().replace(eval("/"+code+"/g"),json.newCode));row.attr('id','row_'+json.newCode);row.slideDown('slow');}
$('#ajax1').fadeOut('fast').html(json.shipping).fadeIn('fast');},'json');});$('#select_all').livequery('click',function(){$('.cart_remove_box').each(function(){$(this).css('backgroundImage',box_on);$(this).next('input').val(1);});});});function cartAddToTote()
{var max=$('#add_qty').val();var hasProduct=false;for(var i=1;i<max;i++){var code='#code_'+i;if($(code).val()!='')
hasProduct=true;}
if(hasProduct){$('#cart_addtotote').css('visibility','hidden');setupPopup('please wait while we add these items to your tote...');$.post('/cart/manualadd',$('#form_additems').formSerialize(),function(json){if($(json.content).find('#update_cart_add_max').val()>1){$('#cart_additems').html(json.content);$('#add_qty').val($('#update_cart_add_max').val());$('#cart_addtotote').show();}else{$('#content').html(json.content);}
toteRefresh(json.tote);destroyPopup();},'json');}else{$('#code_1').focus();}}
function cartUpdateShippingMethod()
{$.post('/cart/shippingmethod',$('#form-ship').formSerialize(),function(data){$('#ajax2').html(data);});}