function addZebraStriping(a){jQuery("#"+a+" div.form_row:even").addClass("form_row_even");jQuery("#"+a+" div.form_row:odd").addClass("form_row_odd")}function moveFooter(){var a=parseInt(jQuery("#left_sidebar_above_footer").css("height"));var b=parseInt(jQuery("#main_content").css("height"));if(a<b){var c=(b-a)+54;jQuery("#footer").css("margin-top",c+"px")}else{jQuery("#footer").css("margin-top","0px")}}function resizeImage(a,b){var c=190;var d=190;if(b=="large"){c=400;d=400}else if(b=="image_strip"){c=230;d=230}else if(b=="merchant"){c=180;d=300}var e=0;var f=jQuery(a).width();var g=jQuery(a).height();if(f>c){e=c/f;jQuery(a).css("width",c);jQuery(a).css("height",g*e);g=g*e;f=f*e}if(g>d){e=d/g;jQuery(a).css("height",d);jQuery(a).css("width",f*e);f=f*e}jQuery(a).show()}function minimizeFieldset(a){jQuery("#"+a+" img.minimize").hide();jQuery("#"+a+" img.restore").show();jQuery("#"+a+" div.content").hide()}function restoreFieldset(a){jQuery("#"+a+" img.minimize").show();jQuery("#"+a+" img.restore").hide();jQuery("#"+a+" div.content").show()}function closeFieldset(a){jQuery("#"+a).hide();if(a=="ajax_window"){toggleProfile(true)}}function toggleFieldset(a){var b=jQuery("#"+a+" div.content").get(0);if(b){if(b.style.display=="none"){restoreFieldset(a)}else{minimizeFieldset(a)}}}function toggleRecipientDivClear(){var a=jQuery("#by_recipient_clear_span").get(0);if(isRecipientDivClear()){a.style.display="none"}else{a.style.display=""}toggleAgeDivClear();togglePersonalityDivClear();toggleLifestyleDivClear();togglePhilosophyDivClear();toggleSaveRecipientDivClear()}function toggleAgeDivClear(){var a=jQuery("#age_clear_span").get(0);if(isAgeDivClear()){a.style.display="none"}else{a.style.display=""}}function togglePersonalityDivClear(){var a=jQuery("#personality_clear_span").get(0);if(a){if(isPersonalityDivClear()){a.style.display="none"}else{a.style.display=""}}}function toggleLifestyleDivClear(){var a=jQuery("#lifestyle_clear_span").get(0);if(a){if(isLifestyleDivClear()){a.style.display="none"}else{a.style.display=""}}}function togglePhilosophyDivClear(){var a=jQuery("#philosophy_clear_span").get(0);if(a){if(isPhilosophyDivClear()){a.style.display="none"}else{a.style.display=""}}}function toggleSaveRecipientDivClear(){var a=jQuery("#save_recipient_clear_span").get(0);if(isSaveRecipientDivClear()){a.style.display="none"}else{a.style.display=""}}function isRecipientDivClear(){var a=jQuery("#recipientTypeList").get(0);var b=jQuery("#relationshipList").get(0);var c=true;var d=a.options[a.selectedIndex].value;if(d!=""){c=false}if(!isAgeDivClear()){c=false}if(!isPersonalityDivClear()){c=false}if(!isLifestyleDivClear()){c=false}if(!isPhilosophyDivClear()){c=false}if(!isSaveRecipientDivClear()){c=false}return c}function clearRecipientDiv(){var a=jQuery("#recipientTypeList").get(0);var b=jQuery("#relationshipList").get(0);a.selectedIndex=0;loadRelationshipList();clearAgeDiv();clearPersonalityDiv();clearLifestyleDiv();clearPhilosophyDiv();clearSaveRecipientDiv();toggleRecipientDivClear();checkOccasionList();jQuery("#createRecipientSpan").text("New Recipient");var c=jQuery("#recipientCodeField").get(0);if(c){c.value="-1"}var b=jQuery("#relationshipList").get(0);if(b){b.selectedIndex=-1}jQuery("#sessionAjaxDiv").load("/products/remove_current_recipient/");jQuery("span.listingRecipient").hide();jQuery("span.listingRefresh").show()}function isAgeDivClear(){var a=true;var b=jQuery("#birthDateMonthList_recipient").get(0);var c=jQuery("#birthDateDayField_recipient").get(0);var d=jQuery("#birthDateYearList_recipient").get(0);var e=jQuery("#approximateYearCheckbox_recipient").get(0);var f=jQuery("#approximateAgeField_recipient").get(0);if(c){if(c.value.length>0){a=false}}if(f){if(f.value.length>0){a=false}}return a}function clearAgeDiv(){var a=jQuery("#birthDateMonthList_recipient").get(0);var b=jQuery("#birthDateDayField_recipient").get(0);var c=jQuery("#birthDateYearList_recipient").get(0);var d=jQuery("#approximateYearCheckbox_recipient").get(0);var e=jQuery("#approximateAgeField_recipient").get(0);if(b){b.value=""}if(d){d.checked=false}if(e){e.value=""}a.style.color="";b.style.color="";c.style.color="";c.style.fontStyle="";toggleAgeDivClear();toggleRecipientDivClear()}function refreshSearchResults(){var a=jQuery("#searchForm").get(0);if(a){a.submit()}}function toggleSearchOption(a,b){var c=true;var d=jQuery("#"+a+"_div").get(0);if(d){if(b){if(b=="on"){c=false}else if(b=="off"){c=true}}else{if(d.style.display=="none"){c=false}}if(c){jQuery("#"+a+"_div").hide();jQuery("#"+a+"_ellipse").removeClass("selected");jQuery("#"+a+"_ellipse").addClass("unselected");jQuery("#"+a+"_link").removeClass("selected");jQuery("#"+a+"_link").addClass("unselected")}else{jQuery("#"+a+"_div").show();jQuery("#"+a+"_ellipse").removeClass("unselected");jQuery("#"+a+"_ellipse").addClass("selected");jQuery("#"+a+"_link").removeClass("unselected");jQuery("#"+a+"_link").addClass("selected")}}moveFooter()}function toggleSubItemsForCategory(a,b,c,d,e,f){var g=jQuery("#"+a+"_link").get(0);if(g){var h=jQuery("#"+a+"_link").text();if(h=="+"){jQuery("#"+a+" a.search_option_expand").text("-");jQuery("#"+b).show();if(jQuery("#"+b+" div").size()==0){jQuery("#"+b).append("<center><img align = 'center' src = '/img/loading.gif' width = '16' height = '16' alt = 'loading...' /></center>");jQuery("#"+b).load("/products/ajax_load_child_categories/"+c+"/"+d+"/"+e+"/"+f+"/")}}else{jQuery("#"+a+" a.search_option_expand").text("+");jQuery("#"+b).hide()}}}function toggleSubItemsForNarrowingCategory(a,b,c,d,e,f,g){var h=jQuery("#"+a+"_link").get(0);if(h){var i=jQuery("#"+a+"_link").text();if(i=="+"){jQuery("#"+a+" a.search_option_expand").text("-");jQuery("#"+b).show();if(jQuery("#"+b+" div").size()==0){jQuery("#"+b).append("<center><img align = 'center' src = '/img/loading.gif' width = '16' height = '16' alt = 'loading...' /></center>");jQuery("#"+b).load("/products/ajax_load_child_categories_for_narrowing/"+c+"/"+d+"/"+e+"/"+f+"/"+g+"/")}}else{jQuery("#"+a+" a.search_option_expand").text("+");jQuery("#"+b).hide()}}}function toggleSubItemsForProductAdminCategory(a,b,c,d,e,f,g,h){var i=jQuery("#"+a+"_link").get(0);if(i){var j=jQuery("#"+a+"_link").text();if(j=="+"){jQuery("#"+a+"_link").text("-");jQuery("#"+b).show();jQuery("#"+b).load("/products/ajax_load_child_categories_for_product_admin/"+c+"/"+d+"/"+e+"/"+f+"/"+g+"/"+h+"/")}else{jQuery("#"+a+"_link").text("+");jQuery("#"+b).hide()}}}function selectCategorySearchOption(a){jQuery("#by_category_div div.search_option_strip h2").removeClass("search_option_strip_selected");jQuery("#by_category_div div.search_option_strip #search_option_by_category_"+a).addClass("search_option_strip_selected");arrangeCategorySearchOptions()}function selectRelationshipSearchOption(a){jQuery("#by_relationship_div div.search_option_strip h2").removeClass("search_option_strip_selected");jQuery("#by_relationship_div div.search_option_strip #search_option_by_relationship_"+a).addClass("search_option_strip_selected");arrangeRelationshipSearchOptions()}function change_num_results(a){var b=jQuery("#hiddenNumProducts").get(0);if(b){b.value=a}refreshSearchResults()}function change_sort(a){var b=jQuery("#hiddenSort").get(0);if(b){b.value=a}refreshSearchResults()}function toggleNewList(a){var b=true;var c=jQuery("#"+a+"_div").get(0);if(c){if(c.style.display=="none"){b=false}if(b){jQuery("#"+a+"_div").hide();jQuery("#"+a+"_ellipse").removeClass("selected");jQuery("#"+a+"_ellipse").addClass("unselected");jQuery("#"+a+"_link").removeClass("selected");jQuery("#"+a+"_link").addClass("unselected")}else{jQuery("#"+a+"_div").show();jQuery("#"+a+"_ellipse").removeClass("unselected");jQuery("#"+a+"_ellipse").addClass("selected");jQuery("#"+a+"_link").removeClass("unselected");jQuery("#"+a+"_link").addClass("selected")}}}function bringToFront(a,b){var c=jQuery("#"+a).get(0);if(c){if(c.style.display!="none"){jQuery("div."+b).css("z-index","3000");jQuery("#"+a).css("z-index","4000")}}}function activateProduct(a,b){var c=jQuery("#"+a+"_activation_button").get(0);if(c.value=="Deactivate Product"){jQuery.post("/products/deactivate_product/"+b+"/","");c.value="Activate Product"}else{jQuery.post("/products/activate_product/"+b+"/","");c.value="Deactivate Product"}}function mergeProduct(a,b){var c=jQuery("#"+b).get(0);if(c){var d=c.value;if(d.length>0&&!isNaN(d)){jQuery.post("/products/merge_product/"+a+"/"+d+"/","");if(confirm("A new merchant has been added for this product.  Would you like to reload the page now or later to edit the new merchant?")){window.location.reload()}}}}function toggleUpdateButton(a,b){var c=jQuery("#"+a+"_update_button").get(0);if(c){c.disabled=b}}function updateName(a,b){var c=jQuery("#"+a+"_field").get(0);if(c){var d=c.value.replace(/&/g,"--amp--");jQuery.post("/products/set_product_name/"+b+"/","data[name]="+d);toggleUpdateButton(a,true)}}function updateDescription(a,b){var c=jQuery("#"+a+"_field").get(0);if(c){var d=c.value.replace(/&/g,"--amp--");jQuery.post("/products/set_product_text/"+b+"/","data[description]="+d);toggleUpdateButton(a,true)}}function saveMerchant(a,b,c){if(c=="add"){c=-1}var d=0;if(c==-1){var e=jQuery("#"+b+"_merchant_code").get(0);d=e.options[e.selectedIndex].value}var f=jQuery("#"+b+"_sku").get(0);var g=jQuery("#"+b+"_link_href").get(0);var h=jQuery("#"+b+"_img_href").get(0);var i=jQuery("#"+b+"_embed_href").get(0);var j=jQuery("#"+b+"_thumb_href").get(0);var k=jQuery("#"+b+"_text").get(0);var l=jQuery("#"+b+"_price").get(0);var m=jQuery("#"+b+"_minimum_price").get(0);var n=jQuery("#"+b+"_maximum_price").get(0);var o=jQuery("#"+b+"_average_price").get(0);var p=jQuery("#"+b+"_use_product_merchant").get(0);if(f){jQuery.post("/products/save_product_merchant/"+a+"/"+c+"/","data[merchant_code]="+d+"&data[sku]="+f.value.replace(/&/g,"--amp--")+"&data[link_href]="+g.value.replace(/&/g,"--amp--")+"&data[img_href]="+h.value.replace(/&/g,"--amp--")+"&data[embed_href]="+i.value.replace(/&/g,"--amp--")+"&data[thumb_href]="+j.value.replace(/&/g,"--amp--")+"&data[description]="+k.value.replace(/&/g,"--amp--")+"&data[price]="+l.value.replace(/&/g,"--amp--")+"&data[minimum_price]="+m.value.replace(/&/g,"--amp--")+"&data[maximum_price]="+n.value.replace(/&/g,"--amp--")+"&data[average_price]="+o.value.replace(/&/g,"--amp--")+"&data[use_product_merchant]="+p.options[p.selectedIndex].value);if(c==-1){if(confirm("A new merchant has been added for this product.  Would you like to reload the page now or later to edit the new merchant?")){window.location.reload()}else{}}else{alert("Your merchant changes have been saved.")}}}function toggleProductCategory(a,b,c){var d=jQuery("#"+a+"_toggle_category_button").get(0);if(d.value=="Remove from Category"){jQuery.post("/products/set_product_category/"+b+"/"+c+"/0/","");d.value="Add to Category"}else{jQuery.post("/products/activate_product/"+b+"/","");jQuery.post("/products/set_product_category/"+b+"/"+c+"/1/","");d.value="Remove from Category"}}function toggleCheckbox(a,b,c,d){var e=jQuery("#"+b).get(0);if(e){var f=0;if(e.checked){if(d){f=0;e.checked=false}else{f=1}}else{if(d){f=1;e.checked=true}else{f=0}}if(c=="occasion"){jQuery.post("/products/set_product_occasion/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="category"){jQuery.post("/products/set_product_category/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="age"){jQuery.post("/products/set_product_age/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="gender"){jQuery.post("/products/set_product_gender/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="relationship"){jQuery.post("/products/set_product_relationship/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="personality"){jQuery.post("/products/set_product_personality/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="lifestyle"){jQuery.post("/products/set_product_lifestyle/"+a+"/"+e.value+"/"+f+"/","")}else if(c=="philosophy"){jQuery.post("/products/set_product_philosophy/"+a+"/"+e.value+"/"+f+"/","")}}}function toggleSubcategories(a){jQuery("#"+a).toggle()}function toggleStandardAges(a,b){toggleCheckbox(a,b+'1','age',true);toggleCheckbox(a,b+'2','age',true);toggleCheckbox(a,b+'8','age',true)}function toggleAllGenders(a,b){toggleCheckbox(a,b+'1','gender',true);toggleCheckbox(a,b+'2','gender',true)}function toggleStandardMaleRelationships(a,b){toggleCheckbox(a,b+'1','relationship',true);toggleCheckbox(a,b+'2','relationship',true);toggleCheckbox(a,b+'3','relationship',true);toggleCheckbox(a,b+'4','relationship',true);toggleCheckbox(a,b+'5','relationship',true);toggleCheckbox(a,b+'6','relationship',true);toggleCheckbox(a,b+'7','relationship',true);toggleCheckbox(a,b+'8','relationship',true);toggleCheckbox(a,b+'9','relationship',true);toggleCheckbox(a,b+'10','relationship',true)}function toggleStandardFemaleRelationships(a,b){toggleCheckbox(a,b+'19','relationship',true);toggleCheckbox(a,b+'20','relationship',true);toggleCheckbox(a,b+'21','relationship',true);toggleCheckbox(a,b+'22','relationship',true);toggleCheckbox(a,b+'23','relationship',true);toggleCheckbox(a,b+'24','relationship',true);toggleCheckbox(a,b+'25','relationship',true);toggleCheckbox(a,b+'26','relationship',true);toggleCheckbox(a,b+'27','relationship',true);toggleCheckbox(a,b+'28','relationship',true)}function toggleCoupleRelationships(a,b){toggleCheckbox(a,b+'37','relationship',true);toggleCheckbox(a,b+'38','relationship',true);toggleCheckbox(a,b+'39','relationship',true);toggleCheckbox(a,b+'40','relationship',true);toggleCheckbox(a,b+'41','relationship',true);toggleCheckbox(a,b+'42','relationship',true);toggleCheckbox(a,b+'46','relationship',true)}function toggleGroupRelationships(a,b){toggleCheckbox(a,b+'43','relationship',true);toggleCheckbox(a,b+'44','relationship',true);toggleCheckbox(a,b+'45','relationship',true)}function toggleStandardOccasions(a,b){toggleCheckbox(a,b+'1','occasion',true);toggleCheckbox(a,b+'3','occasion',true);toggleCheckbox(a,b+'5','occasion',true);toggleCheckbox(a,b+'6','occasion',true)}function toggleStandardMaleOccasions(a,b){toggleCheckbox(a,b+'1','occasion',true);toggleCheckbox(a,b+'3','occasion',true);toggleCheckbox(a,b+'5','occasion',true)}function toggleStandardFemaleOccasions(a,b){toggleCheckbox(a,b+'1','occasion',true);toggleCheckbox(a,b+'3','occasion',true);toggleCheckbox(a,b+'6','occasion',true)}