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()}$(window).load(function(){$(window).trigger("resize")})}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=getMainWidget(),e=(b?((YAHOO.util.Dom.getXY(b.getContainerDiv())[1]+$(b.getContainerDiv()).height()+90)||0):0)+($w("frmPayPal")?90:0),d=$($w("cfooter").getContainerDiv()).height(),i=($(".modalunderlay").length>0?$(".modalunderlay").height()-23:0),k=$(window).height()-d,c=(h>e?h:e),f=$("#lightboxImage").length>0?$("#lightboxImage").height()+105:0,g,j=$w("cAdminHeader")&&$w("cAdminHeader").getVisible()?$($w("cAdminHeader").getContainerDiv()).height():0,a=$w("ccontentdetails")&&$w("ccontentdetails").getVisible()?$($w("ccontentdetails").getContainerDiv()).height():0;if(i>c){c=i}else{$(".modalunderlay").css({height:c+22})}if(i>0&&j>0){$(".modalunderlay").css({height:Math.max(c,i)+22})}g=Math.max(Math.max(c,k),f);$w("cwrapper").getContainerDiv().style.height=(g-j-a)+"px";$w("cfooter").getContainerDiv().style.top=g+"px"}function getMainWidget(){if($w("mainwidget_x")&&$w("mainwidget_x").getVisible()){return $w("mainwidget_x")
}else{if($w("mainwidget")&&$w("mainwidget").getVisible()){return $w("mainwidget")}else{for(var a=1;a<=10;a++){if($w("mainwidget"+a)&&$w("mainwidget"+a).getVisible()){return $w("mainwidget"+a)}}}}return null}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(g,b,m){var h=(b?$(g).parent().width():$(g).width()),j=$(g).find(".floater"),k=$(j[0]).width(),f=Math.floor(h/k),l;if(f>j.length){f=j.length}l=Math.floor(h-(k*f));if(l>0){var a=Math.floor((l-0)/((f-1)+4));var e=((a*2));e-=2;if(e<0){e=0}g.style.left=e+"px";g.style.right=e+"px";if(m){g.style.position="relative"}for(var d=0;d<j.length;d++){j[d].style.marginRight=((d+1)%f==0?"0px":a+"px")}}}function addToCart(b,d,k){if($w("cart1")){var a=dataset("ds-cart");var c=dataset(k);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 getAnnouncement(a){window.open("www/announcements/"+a)}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(d){var c=d.getAttribute("action");var b=d.getAttribute("actiontype");if(c||b!=""){navigate(b,c)}}function setMailLink(){$(".maillink")[0].innerHTML=dataset("ds-customermodel-settings").getCurrentRowValue("address");$(".maillink").attr("href",dataset("ds-customermodel-settings").getCurrentRowValue("addresslink"))}function adjustHintsAndTipsBlockHeights(){var b,a=Number.MIN_VALUE;$(".floater.gallery200").each(function(){b=$(this).height();if(b>a){a=b}});$(".floater.gallery200").each(function(){$(this).css({height:a})})}function hideModal(){$($w("modal").getContainerDiv()).find("img").fadeOut("medium");$($w("modal").getContainerDiv()).fadeOut("medium")};

