function checkProductOptions(a,c){var b=$("form[name=product_"+a+"]").length?$("form[name=product_"+a+"] > select[name=id]"):$("select#productOptionsSelect");if(b.val()=="0"||b.val()==""){alert("Please select a product option");b.focus();return false}if(b.length)a=b.val();b="";if(typeof c!="undefined")b="/mod/"+c;document.location.href=SG_URL_PREFIX+"shopping/cart/add/"+a+b;return false}
function checkProductMultiOptions(a){a=$("form[name=product_"+a+"]");var c=$("input.product-qty",a),b=$("select.product-child",a),d=$("input.product-parent",a);if(d.length==0&&(isNaN(b.val())||b.val()==0)){alert("Please select a product option");b.focus();return false}isNaN(c.val())||c.val()==0?c.val(1):c.val(Math.round(c.val()));a.submit();return false}var g_tax_cost=0,g_shipping_cost=0;
function updateTotal(a){a=parseFloat(g_subtotal)+parseFloat(g_tax_cost)+parseFloat(g_shipping_cost);a="$"+a.toFixed(2);$(".cart_total_value").html(a)}
function ajaxInsertShippingInfo(a){var c,b,d,e,g,f,h,i;b=a.shippingInfo;g_tax_rate=a.taxInfo.rate;g_tax_desc=a.taxInfo.desc;g="";a='checked="checked"';c="";if(g_shipping_method)c=$("#"+g_shipping_method);if(g_shipping_method!=""&&c.length>0)a="";c='<table width="100%" border="0" cellspacing="0" cellpadding="2" id="shippingDetails">';for(d=0;d<b.length;++d){c+='<tr><td colspan="3"><span class="acctH3">'+b[d].company+"</span></td></tr>";for(e=0;e<b[d].rates.length;++e){c+='<tr><td style="padding-right: 100px;">'+
b[d].company+" "+b[d].rates[e].method+"</td>";if(b[d].rates[e].original_cost&&b[d].rates[e].original_cost>b[d].rates[e].cost){c+='<td style="text-align: right;"><span class="price-old">$'+b[d].rates[e].original_cost+"</span>";c+=' <span class="price-sale">$'+b[d].rates[e].cost+"</span></td>"}else c+='<td style="text-align: right;">$'+b[d].rates[e].cost+"</td>";c+='<td><input id="'+clean_form_name(b[d].company+" "+b[d].rates[e].method)+'" name="shipping_price" class="shipping_radio" company="'+b[d].company+
'" method="'+b[d].rates[e].method+'" type="radio" value="'+b[d].rates[e].cost+'" '+a+"></td></tr>";if(a!=""){f=b[d].company;h=b[d].rates[e].method;i=b[d].rates[e].cost;g+='<input type="hidden" id="shipping_company" name="shipping_company" value="'+b[d].company+'" >';g+='<input type="hidden" id="shipping_method" name="shipping_method" value="'+b[d].rates[e].method+'" >';g_shipping_method=clean_form_name(f+" "+h)}a=""}}c+="</table>";c+=g;$("#cart_shipping_loading_notice").html("");$("#shippingDetails").before(c).remove();
update_shipping_method();if(g_shipping_method!=""){c=$("#"+g_shipping_method);c.length||(c=$(".shipping_radio:eq(0)"));c.click();if(!f){f=c.attr("company");h=c.attr("method");i=c.val();if(!$("#shipping_company").length){g="";g+='<input type="hidden" id="shipping_company" name="shipping_company" value="'+f+'" >';g+='<input type="hidden" id="shipping_method" name="shipping_method" value="'+h+'" >';$("#shippingDetails").append(g)}}}b='<tr  id="shippingRow">';b+='<td class="cartSummary-Key">Shipping <em id="cart_shipping_desc">('+
f+" "+h+"):</em></td>";b+='<td class="cartSummary-Value" id="cart_shipping_value">$'+parseFloat(i).toFixed(2)+"</td></tr>";h=$("#shippingRow");f=$("#taxRow");if(h.length)h.before(b).remove();else f.length?f.before(b):$("#preTaxRow").before(b);g_shipping_cost=i}$(function(){var a;function c(){$(this).attr("checked")?$("#giftNoteContainer").slideDown():$("#giftNoteContainer").slideUp()}a=$("#sub_gift");a.click(c);c.call(a)});
function accountShippingInfoToggle(){var a=$("#shipping_info");$("#enter_shipping").click(function(){this.checked?a.removeClass("hide"):a.addClass("hide")})}function account_submit_buttons(){$(".btnAccountCreate").click(function(){submitHack($("#acctCreate"));return false});$(".btnAccountLogin").click(function(){submitHack($("#acctLogin"));return false})}
function productSorting(){$(".product_sort").change(function(){var a=document.location.href,c=a.split(/\/orderBy/),b=$(this).val();if(c.length>1)a=c[0];document.location.href=b===""?a:a+"/orderBy/"+escape(b)});$(".paging_next").click(function(){document.location.href=base_url_args+"/page/"+(parseInt($(this).attr("rel"))+1);return false});$(".paging_last").click(function(){document.location.href=base_url_args+"/page/"+parseInt($(this).attr("rel"));return false});$(".paging_prev").click(function(){document.location.href=
base_url_args+"/page/"+(parseInt($(this).attr("rel"))-1);return false});$(".paging_first").click(function(){document.location.href=base_url_args+"/page/"+parseInt($(this).attr("rel"));return false});$(".paging_form").submit(function(){document.location.href=base_url_args+"/page/"+parseInt($(this).find(".paging_input").val());return false});$(".paging_viewall").click(function(){document.location.href=base_url_args+"/view/all";return false})}
$(document).ready(function(){accountShippingInfoToggle();account_submit_buttons();productSorting()});function is_shipping_different(){return $("#enter_shipping").attr("checked")==true}
function accountCustomValidation(){var a=document.forms.acctCreate;if(a.password.value!=a.password_confirm.value){alert("Check that your password matches the Confirmation password");return false}else if(a.email.value!=a.email_confirm.value){alert("Check that your Email address matches the Confirmation Email address");return false}else return true}
function accountPasswordCustomValidation(){var a=document.forms.acctCreate;if(a.password.value!=""&&a.password.value!=a.password_confirm.value){alert("Check that your password matches the Confirmation password");return false}else if(a.email.value!=""&&a.email.value!=a.email_confirm.value){alert("Check that your Email address matches the Confirmation Email address");return false}else return true}
function account_create_validate_setup(){$("#enter_shipping").click(function(){account_create_validate()});account_create_validate()}
function account_create_validate(){var a=new Validator("acctCreate");a.clearAllValidations();a.addValidation("firstname","req","Please enter your Firstname");a.addValidation("lastname","req","Please enter your Lastname");a.addValidation("address","req","Please enter your Address");a.addValidation("city","req","Please enter your City");a.addValidation("state","req","Please enter your State");a.addValidation("zip","req","Please enter your Zip or Postal code");a.addValidation("country","req","Please enter your Country");
a.addValidation("telephone","req","Please enter your Telephone Number");if(is_shipping_different()){a.addValidation("s_firstname","req","Please enter your Shipping Firstname");a.addValidation("s_lastname","req","Please enter your Shipping Lastname");a.addValidation("s_address","req","Please enter your Shipping Address");a.addValidation("s_city","req","Please enter your Shipping City");a.addValidation("s_state","req","Please enter your Shipping State");a.addValidation("s_zip","req","Please enter your Shipping Zip or Postal code");
a.addValidation("s_country","req","Please enter your Shipping Country");a.addValidation("s_telephone","req","Please enter your Shipping Telephone Number")}a.addValidation("email","req","Please enter your Email Address");a.addValidation("email","email","Please enter a valid Email Address");a.addValidation("email_confirm","req","Please enter your Confirm Email Address");a.addValidation("email_confirm","email","Please enter a valid Confirm Email Address");a.addValidation("password","req","Please enter a password");
a.addValidation("password_confirm","req","Please confirm your password");a.setAddnlValidationFunction("accountCustomValidation")}function account_edit_validate_setup(){$("#enter_shipping").click(function(){account_edit_validate()});account_edit_validate()}
function account_edit_validate(){var a=new Validator("acctCreate");a.clearAllValidations();a.addValidation("firstname","req","Please enter your Firstname");a.addValidation("lastname","req","Please enter your Lastname");a.addValidation("address","req","Please enter your Address");a.addValidation("city","req","Please enter your City");a.addValidation("state","req","Please enter your State");a.addValidation("zip","req","Please enter your Zip or Postal code");a.addValidation("country","req","Please enter your Country");
a.addValidation("telephone","req","Please enter your Telephone Number");if(is_shipping_different()){a.addValidation("s_firstname","req","Please enter your Shipping Firstname");a.addValidation("s_lastname","req","Please enter your Shipping Lastname");a.addValidation("s_address","req","Please enter your Shipping Address");a.addValidation("s_city","req","Please enter your Shipping City");a.addValidation("s_state","req","Please enter your Shipping State");a.addValidation("s_zip","req","Please enter your Shipping Zip or Postal code");
a.addValidation("s_country","req","Please enter your Shipping Country");a.addValidation("s_telephone","req","Please enter your Shipping Telephone Number")}}function account_password_validate(){var a=new Validator("acctCreate");a.addValidation("email","email","Please enter a valid Email Address");a.addValidation("email_confirm","email","Please enter a valid Confirm Email Address");a.setAddnlValidationFunction("accountPasswordCustomValidation")};
