function doLoad(){if($w("cart1")){$w("cart1").addHandler("oncartitemadded",resetHeight);$w("cart1").addHandler("oncartitemremoved",resetHeight)}if($("#paypalform").length>0){movePayPalForm();document.forms.paypal.submit()}if($(".maillink").length>0){setMailLink()}$(window).bind("resize",function(){resetWidth();resetHeight()});$(".text-edit-search").focus(function(){$(this).removeClass("searchinactive");if($(this).attr("value")=="Search"){$(this).attr("value","")}});$(".text-edit-search").blur(function(){$(this).addClass("searchinactive");if($(this).attr("value")==""){$(this).attr("value","Search")}});$(".text-edit-search").blur();var A=$(window).width();resetWidth();resetHeight();if($(window).width()!=A){resetWidth()}}function getSessionID(){var A=getClientIDField().replace("Aviarc.clientID=","");A=A.substring(0,A.length-1);return A}function setupSpinners(){$(".ui-spinner-box").each(function(A,B){$(B).spinner({max:100,min:1})})}function resetHeight(){var H=($w("crighticons")?YAHOO.util.Dom.getXY($w("crighticons").getContainerDiv())[1]+$($w("crighticons").getContainerDiv()).height():0),B=$w("mainwidget_x")?($w("mainwidget_x").getVisible()?$w("mainwidget_x"):$w("mainwidget")):$w("mainwidget"),E=(B?((YAHOO.util.Dom.getXY(B.getContainerDiv())[1]+$(B.getContainerDiv()).height()+50)||0):0)+($w("frmPayPal")?90:0),D=$($w("cfooter").getContainerDiv()).height(),J=$(window).height()-D,C=(H>E?H:E),F=$("#lightboxImage").length>0?$("#lightboxImage").height()+105:0,G,I=$w("cAdminHeader")&&$w("cAdminHeader").getVisible()?$($w("cAdminHeader").getContainerDiv()).height():0,A=$w("ccontentdetails")&&$w("ccontentdetails").getVisible()?$($w("ccontentdetails").getContainerDiv()).height():0;G=Math.max(Math.max(C,J),F);$w("cwrapper").getContainerDiv().style.height=(G-I-A)+"px";$w("cfooter").getContainerDiv().style.top=G+"px"}function resetWidth(){if(YAHOO.env.ua.ie==6){return }var B=$w("mainwidget_x")?($w("mainwidget_x").getVisible()?$w("mainwidget_x"):$w("mainwidget")):$w("mainwidget");if(B){if($(B.getContainerDiv()).find(".floater").length>0){var G=B.getContainerDiv(),C=$(G).find(".floater-container");
if(C.length>0){for(var A=0;A<C.length;A++){resetContainerWidth(C[A],true,true)}}else{resetContainerWidth(G,true,false)}}else{if($(".content-wrapper").length>0){var D=$(B.getContainerDiv()).width();var F=parseInt($(".content-wrapper").attr("maxwidth"))+2;var E=Math.floor((D-F)/2);$(".content-wrapper").css("width",F+"px");$(".content-wrapper").css("left",E+"px")}}}}function resetContainerWidth(F,B,K){var G=(B?$(F).parent().width():$(F).width()),H=$(F).find(".floater"),I=$(H[0]).width(),E=Math.floor(G/I),J;if(E>H.length){E=H.length}J=Math.floor(G-(I*E));if(J>0){var A=Math.floor((J-0)/((E-1)+4));var D=((A*2));D-=2;if(D<0){D=0}F.style.left=D+"px";F.style.right=D+"px";if(K){F.style.position="relative"}for(var C=0;C<H.length;C++){H[C].style.marginRight=((C+1)%E==0?"0px":A+"px")}}}function addToCart(B,D,I){if($w("cart1")){var A=dataset("ds-cart");var C=dataset(I);var H;if(!D||isNaN(D)||D<1){D=1}for(var F=0;F<C.rows.length;F++){if(C.rows[F].getField("productid")==B){H={productid:C.rows[F].getField("productid"),code:C.rows[F].getField("code"),name:C.rows[F].getField("name"),scale:C.rows[F].getField("scale"),usdprice:C.rows[F].getField("usdprice"),quantity:Number(D)};var G=false;for(var E=0;E<A.rows.length;E++){if(A.rows[E].getField("productid")==H.productid){A.rows[E].setField("quantity",Number(A.rows[E].getField("quantity"))+H.quantity);H.datarow=A.rows[E];G=true;A.rows[E].markRowEdited()}}if(!G){A.createRow();A.setCurrentRowValue("productid",H.productid);A.setCurrentRowValue("code",H.code);A.setCurrentRowValue("name",H.name);A.setCurrentRowValue("scale",H.scale);A.setCurrentRowValue("usdprice",H.usdprice);A.setCurrentRowValue("quantity",H.quantity);H.datarow=A.getCurrentRow();A.markRowCreated()}$w("cart1").addProduct(H);resetWidth();return }}}}function removeFromCart(A){var D=dataset("ds-cart");for(var B=0;B<D.rows.length;B++){if(D.rows[B].getField("productid")==A){D.rows[B].makeCurrentRow();D.markRowDeleted();var C=document.getElementById("product"+A);Aviarc.doAjaxRequestDatasetReplace({ajaxAction:"cart/wf-cart-ajax",handlerFunc:function(){$w("mainwidget").recalculate();
$w("cTerms").setVisible(D.getRowCount()>0);$w("cPayPal").setVisible(D.getRowCount()>0)},customErrorFunc:function(E){},formFields:[{name:"action",value:"remove product"}]});$("#product"+A).fadeOut("slow",function(){});return }}}function navigate(at,a,ff){if(at=="wf"||at=="ea"){var formFields=[{name:"navaction",value:a},{name:"navactiontype",value:at}];if(ff){formFields=formFields.concat(ff)}Aviarc.submitScreen({actionName:"wf-navigate",validate:false,formFields:formFields})}else{if(at=="js"){eval(a)()}}}function getProduct(B,A){navigate("wf","product",[{name:"producttype",value:B},{name:"productid",value:A}],"public")}function getProductCategory(C,A){var B=dataset("ds-product");if(B){A=B.getCurrentRowValue("productid")}if(A){navigate("wf","productdetail",[{name:"categoryid",value:C},{name:"productid",value:A}])}else{navigate("wf","photogallery",[{name:"categoryid",value:C},{name:"blockoffset",value:"0"}])}}function setupDraggableElements(){var A=$(".draggable");A.draggable("destroy");A.draggable({helper:"clone",appendTo:"body",cursorAt:{top:0,left:0},start:function(B,C){}})}function setupDroppableElements(){var A=$(".droppable");A.droppable("destroy");A.droppable({accept:".draggable",hoverClass:"droppable-hover",drop:function(C,D){var B=$(D.draggable)[0].attributes.productid.value;var E=$("#qty"+B)[0].value;addToCart(B,E)}})}function search(){var A=dataset("ds-search-query").getCurrentRowValue("searchquery");navigate("wf","search",[{name:"searchquery",value:A},{name:"blockoffset",value:"0"},{name:"processedsearchquery",value:""}])}function treenav_onLevel1Selected(D){var B=D.getAttribute("code");var C=D.getAttribute("itemid");var A=D.getAttribute("itemtype");if(B==""){navigate("wf","photogallery",[{name:"categoryid",value:C},{name:"productid",value:""}])}else{getProduct(A,C)}}function treenav_onLevel0Selected(C){var B=C.getAttribute("action");var A=C.getAttribute("actiontype");if(B||A!=""){navigate(A,B)}}function setMailLink(){$(".maillink")[0].innerHTML=dataset("ds-customermodel-settings").getCurrentRowValue("address");
$(".maillink").attr("href",dataset("ds-customermodel-settings").getCurrentRowValue("addresslink"))};
