function runOnLoad(a){if(runOnLoad.loaded){a()}else{runOnLoad.funcs.push(a)}}runOnLoad.funcs=[];runOnLoad.loaded=false;runOnLoad.run=function(){if(runOnLoad.loaded){return}for(var a=0;a<runOnLoad.funcs.length;a++){try{runOnLoad.funcs[a]()}catch(b){}}runOnLoad.loaded=true;delete runOnLoad.funcs;delete runOnLoad.run};if(window.addEventListener){window.addEventListener("load",runOnLoad.run,false)}else{if(window.attachEvent){window.attachEvent("onload",runOnLoad.run)}else{window.onload=runOnLoad.run}}String.empty="";String.format=function(){if(arguments.length==0){return String.empty}var a=arguments[0];var c=[];if(typeof(arguments[1])=="object"){c=arguments[1]}else{for(var b=1;b<arguments.length;b++){c[c.length]=arguments[b]}}for(var b=0;b<c.length;b++){a=a.replaceAll("\\{"+(b)+"}",c[b])}return a};String.prototype.format=function(){return String.format(this,arguments)};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};String.prototype.contains=function(a){return this.indexOf(a)>-1};String.prototype.replaceAll=function(searchTerm,replacementText,isCaseSensitive){var regex="/"+searchTerm+"/g";if(!isCaseSensitive){regex+="i"}return this.replace(eval(regex),replacementText)};var DEBUG_LEVEL_TYPE={NONE:0,CRITICAL:1,WARNING:2,LOG:3,ENTERING:5,LEAVING:6,INFO:9,FULL:15};var debug={level:DEBUG_LEVEL_TYPE.NONE,logAllObjects:true,loggedObjects:[],logMessagesFromAnonymousObjects:false,isLoggingEnabledFor:function(a){if(debug.logAllObjects){return true}var c=false;if(debug.loggedObjects.length>0){var d=(a.className)?a.className:debug.getVarName(a);if(undefined==d){c=debug.logMessagesFromAnonymousObjects}for(var b in debug.loggedObjects){if(d==debug.loggedObjects[b]){c=true;break}}}return c},setLevel:function(a){debug.level=a},enableLoggingForObjectsNamed:function(a){debug.loggedObjects[debug.loggedObjects.length]=a},log:function(c,b,a){if(c<=debug.level&&debug.isLoggingEnabledFor(a)){if(undefined!=console){debug.logToFireBug(c,b)}else{alert(b)}}},logToFireBug:function(b,a){switch(b){case DEBUG_LEVEL_TYPE.CRITICAL:console.error(a);break;case DEBUG_LEVEL_TYPE.WARNING:console.warn(a);break;default:console.log(a)}},getVarName:function(a){return debug.obSub(window).map(function(b){if(window[b]===a){return b}}).sort()[0]},obSub:function(a){var c=[];var b=0;for(var d in a){if(a.hasOwnProperty(d)){c[b++]=d}}return c}};function SET_DEBUG_CRITICAL(){debug.setLevel(DEBUG_LEVEL_TYPE.CRITICAL)}function SET_DEBUG_WARN(){debug.setLevel(DEBUG_LEVEL_TYPE.WARNING)}function SET_DEBUG_LOG(){debug.setLevel(DEBUG_LEVEL_TYPE.LOG)}function SET_DEBUG_INFO(){debug.setLevel(DEBUG_LEVEL_TYPE.INFO)}function SET_DEBUG_ENTERING(){debug.setLevel(DEBUG_LEVEL_TYPE.ENTERING)}function SET_DEBUG_LEAVING(){debug.setLevel(DEBUG_LEVEL_TYPE.LEAVING)}function SET_DEBUG_FULL(){debug.setLevel(DEBUG_LEVEL_TYPE.FULL)}function ADD_DEBUG_OBJECT(a){debug.enableLoggingForObjectsNamed(a)}function DEBUG_CRITICAL(b,a){debug.log(DEBUG_LEVEL_TYPE.CRITICAL,b,a)}function DEBUG_WARNING(b,a){debug.log(DEBUG_LEVEL_TYPE.WARNING,b,a)}function DEBUG_LOG(b,a){debug.log(DEBUG_LEVEL_TYPE.LOG,"  "+b,a)}function DEBUG_INFO(b,a){debug.log(DEBUG_LEVEL_TYPE.INFO,"  "+b,a)}function DEBUG_ENTERING(b,a){debug.log(DEBUG_LEVEL_TYPE.ENTERING,"Entering: "+b,a)}function DEBUG_LEAVING(b,a){debug.log(DEBUG_LEVEL_TYPE.LEAVING,"Leaving: "+b,a)}function ClassEvent(){this.className="ClassEvent";DEBUG_ENTERING("ClassEvent::ClassEvent()",this);this.handlers=new Array();this.firedCount=0;this.handlersCount=0;DEBUG_LEAVING("ClassEvent::ClassEvent()",this)}ClassEvent.prototype.add=function(a){DEBUG_ENTERING("ClassEvent::add()",this);this.handlers[this.handlers.length]=a;this.handlersCount++;DEBUG_LEAVING("ClassEvent::add()",this)};ClassEvent.prototype.fire=function(){DEBUG_ENTERING("ClassEvent::fire()",this);this.firedCount++;for(var i=0;i<this.handlers.length;i++){var handler=this.handlers[i];var handlerType=typeof(handler);DEBUG_LOG("handlerType",this);switch(handlerType){case"string":eval(handler);break;case"function":handler();break}}DEBUG_LEAVING("ClassEvent::fire()",this)};ClassEvent.prototype.hasFired=function(){DEBUG_ENTERING("ClassEvent::hasFired()",this);DEBUG_INFO("Has Fired: "+(this.firedCount>0)+"; firedCount: "+this.firedCount);DEBUG_LEAVING("ClassEvent::hasFired()",this);return this.firedCount>0};SET_DEBUG_CRITICAL();var SiteEngine={isSecureHost:function(){return window.location.hostname.indexOf("https://")>-1},isHostKingCart:function(){return window.location.hostname.indexOf("king")>-1},getCommonImageRoot:function(){return(SiteEngine.isHostKingCart())?"/store/USCFSales/":"/Common/Images/Layout"},getCommonIncludeRoot:function(){return(SiteEngine.isHostKingCart())?"/store/USCFSales/":"/Common/Include"},getCommonDataRoot:function(){return(SiteEngine.isHostKingCart())?"/store/USCFSales/":"/Common/Data"},registeredComponents:{list:[],onAllItemsComplete:new ClassEvent(),add:function(a){this.list[a]=false},markItemComplete:function(a){this.list[a]=true;this.checkAllItemsComplete()},checkAllItemsComplete:function(){var a=true;for(var b in this.list){if(!this.list[b]){a=false;break}}if(a){this.onAllItemsComplete.fire()}}}};SiteEngine.registeredComponents.add("allImagesLoaded");runOnLoad(function(){SiteEngine.registeredComponents.markItemComplete("allImagesLoaded")});var lpMTagConfig={lpServer:"server.iad.liveperson.net",lpNumber:"72199819",lpProtocol:"https"};function lpAddMonitorTag(b){if(typeof(b)=="undefined"||typeof(b)=="object"){b=(lpMTagConfig.lpMTagSrc)?lpMTagConfig.lpMTagSrc:"/hcp/html/mTag.js"}if(b.indexOf("http")!=0){b=lpMTagConfig.lpProtocol+"://"+lpMTagConfig.lpServer+b+"?site="+lpMTagConfig.lpNumber}else{if(b.indexOf("site=")<0){if(b.indexOf("?")<0){b=b+"?"}else{b=b+"&"}b=b+"site="+lpMTagConfig.lpNumber}}var a=document.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("charset","iso-8859-1");a.setAttribute("src",b);document.getElementsByTagName("head").item(0).appendChild(a)}if(window.attachEvent){window.attachEvent("onload",lpAddMonitorTag)}else{window.addEventListener("load",lpAddMonitorTag,false)}var formManager={productInstance:"",wsmInstance:"",pricingManagerInstance:"",wsmAttemptCount:0,createKingCartProduct:function(){DEBUG_ENTERING("formManager:createKingCartProduct",this);try{productIdString=$("#orderInfo").attr("name");DEBUG_INFO("productIdString: "+productIdString);formManager.productInstance=new product(productIdString);formManager.productInstance.onReadyForUse.add(formManager.createWoodSelectionOptions);formManager.productInstance.initialize()}catch(a){DEBUG_CRITICAL(a,this)}DEBUG_LEAVING("formManager:createKingCartProduct",this)},createWoodSelectionOptions:function(){DEBUG_ENTERING("formManager:createWoodSelectionOptions",this);DEBUG_LOG("Attempt number "+(formManager.wsmAttemptCount+1),this);try{formManager.wsmInstance=new woodSelectionManager(formManager.productInstance);formManager.wsmInstance.onReadyForUse.add(function(){if(formManager.wsmInstance.isMultiplePricing){formManager.spanMultiPricingSwatches()}});formManager.wsmInstance.onReadyForUse.add(formManager.createPricingManager);formManager.wsmInstance.initialize()}catch(a){DEBUG_CRITICAL(a,this);formManager.wsmAttemptCount++;formManager.wsmInstance=0;if(formManager.wsmAttemptCount<5){setTimeout(formManager.createWoodSelectionOptions,3000)}}DEBUG_LEAVING("formManager:createWoodSelectionOptions",this)},createPricingManager:function(){DEBUG_ENTERING("formManager:createPricingManager",this);try{formManager.pricingManagerInstance=new pricingManager(formManager.productInstance,formManager.wsmInstance);formManager.pricingManagerInstance.onReadyForUse.add(formManager.initializeComplete);formManager.pricingManagerInstance.initialize()}catch(a){DEBUG_CRITICAL(a,this)}formManager.applyValidationRulesToProductForm();DEBUG_LEAVING("formManager:createPricingManager",this)},spanMultiPricingSwatches:function(){var a={1:256,2:128,3:64,4:32,5:16,6:8};var g=formManager.wsmInstance.woodSelectionOptions.length;var c=Math.floor((g-1)/6)+1;var f=$("#WoodSelectionRowCount");if(f.length==1){var d=f.text();c=(d>c)?d:c}var e=Math.round(g/c);var b=(a[e])/2;DEBUG_LOG("Found '"+g+"' options",this);$(".woodSelectionMultiItem").css({marginLeft:b,marginRight:b});$("#woodSelectionOptionsContainer").css({width:"660px",textAlign:"center"})},applyValidationRulesToProductForm:function(){DEBUG_ENTERING("formManager::applyValidationRulesToProductForm()",this);$("#WoodSelectionLayoutTable").before('<a name="productOptions"></a>');$("#btnAddToCart").click(function(){if(formManager.wsmInstance.isMultiplePricing){if(!formManager.areMultiplePriceOptionsValid()){DEBUG_LOG("Form is NOT valid",this);window.location="#productOptions";alert("Please specify the quantities you wish to purchase.")}else{DEBUG_LOG("Form is valid",this);return true}}});DEBUG_LEAVING("formManager::applyValidationRulesToProductForm()",this)},areMultiplePriceOptionsValid:function(){DEBUG_ENTERING("formManager::areMultiplePriceOptionsValid()",this);var a=$("[type=text]:regex(name,^option.+)");var b=a.length==0;a.each(function(){var c=$(this).attr("value");if(undefined!=c&&c>0){b=true;return false}});DEBUG_LOG("Form is valid: "+b,this);DEBUG_LEAVING("formManager::areMultiplePriceOptionsValid()",this);return b},initialize:function(){DEBUG_ENTERING("formManager:initialize",this);try{if(0<$("#woodSelectionOptionsContainer").length){SiteEngine.registeredComponents.add("HosFormManager");formManager.createKingCartProduct()}}catch(a){DEBUG_CRITICAL(a,this)}DEBUG_LEAVING("formManager:initialize",this)},initializeComplete:function(){DEBUG_ENTERING("formManager:initializeComplete",this);SiteEngine.registeredComponents.markItemComplete("HosFormManager");DEBUG_LEAVING("formManager:initializeComplete",this)}};$(function(){formManager.initialize()});function updateOptionPrice(a){}function formatDollar(b){var a=parseFloat(b);if(isNaN(a)){return"0.00"}else{if(a.toFixed){return a.toFixed(2)}else{return a}}}function pricingManager(a,b){this.className="pricingManager";DEBUG_ENTERING("pricingManager::pricingManager()",this);this.productInstance=a;this.woodSelectionManagerInstance=b;this.quantity=1;this.elPriceEstimateDisplayElement;this.onReadyForUse=new ClassEvent();DEBUG_LEAVING("pricingManager::pricingManager()",this)}pricingManager.prototype.initialize=function(){DEBUG_ENTERING("pricingManager::initialize()",this);this.initializePriceEstimateDisplayElement();this.initializeProductInstance();this.initializeWoodSelectionManager();this.initializeQuantityElement();this.setDisplayPriceForTheFirstTime();this.onReadyForUse.fire();DEBUG_LEAVING("pricingManager::initialize()",this)};pricingManager.prototype.setDisplayPriceForTheFirstTime=function(){DEBUG_ENTERING("pricingManager::setDisplayPriceForTheFirstTime()",this);var a=!this.woodSelectionManagerInstance||(this.woodSelectionManagerInstance&&this.woodSelectionManagerInstance.onReadyForUse.hasFired());if(this.productInstance&&this.productInstance.onReadyForUse.hasFired()&&a){this.setDisplayPrice()}DEBUG_LEAVING("pricingManager::setDisplayPriceForTheFirstTime()",this)};pricingManager.prototype.initializePriceEstimateDisplayElement=function(){DEBUG_ENTERING("pricingManager::initializePriceEstimateDisplayElement()",this);var a=$('<div><span class="label">Price: $</span></div>');this.elPriceEstimateDisplayElement=$("<span></span>");a.append(this.elPriceEstimateDisplayElement);$("#quantitySelection").after(a);DEBUG_LEAVING("pricingManager::initializePriceEstimateDisplayElement()",this)};pricingManager.prototype.initializeQuantityElement=function(){DEBUG_ENTERING("pricingManager::initializeQuantityElement()",this);var a=this;var b=$("#orderInfo");if(!this.productInstance.isMultiplePricing||!this.woodSelectionManagerInstance){b.attr("name",this.productInstance.idFullText).attr("value","1").attr("size","4").addClass("qty").keyup(function(){a.singlePricingQuantityChanged(b.get(0))},false)}else{this.quantity=0;b.val(this.quantity);var c=b.parent();c.addClass("hide");$(".multiplePricingQuantityField").each(function(){$(this).blur(function(){a.multiplePricingQuantityChanged(this)},false)})}DEBUG_LEAVING("pricingManager::initializeQuantityElement()",this)};pricingManager.prototype.initializeProductInstance=function(){DEBUG_ENTERING("pricingManager::initializeProductInstance()",this);if(this.productInstance){this.productInstance.onReadyForUse.add(this.setDisplayPriceForTheFirstTime);this.productInstance.selectedOptionsChanged=this.getSelectedOptionChanged()}DEBUG_LEAVING("pricingManager::initializeProductInstance()",this)};pricingManager.prototype.initializeWoodSelectionManager=function(){DEBUG_ENTERING("pricingManager::initializeWoodSelectionManager()",this);if(this.woodSelectionManagerInstance){this.woodSelectionManagerInstance.onReadyForUse.add(this.setDisplayPriceForTheFirstTime);if(!this.productInstance.isMultiplePricing){this.woodSelectionManagerInstance.woodSelectionChanged=this.getSelectedOptionChanged()}}DEBUG_LEAVING("pricingManager::initializeWoodSelectionManager()",this)};pricingManager.prototype.multiplePricingQuantityChanged=function(a){DEBUG_ENTERING("pricingManager::multiplePricingQuantityChanged()",this);if(a.value.length==0){DEBUG_INFO("Source element had no stored value",this);DEBUG_LEAVING("pricingManager::multiplePricingQuantityChanged()",this);return}var e=a.value;var d=true;var b=this;if(isNaN(e)){e=(isNaN(parseInt(e))?1:parseInt(e));a.value=e;d=false;DEBUG_INFO("Source element's value is not a number",this)}this.quantity=0;$(".multiplePricingQuantityField").each(function(g){if($(this).attr("name")!=""){var f=parseInt(this.value);if(!isNaN(f)){b.quantity+=f}DEBUG_INFO("Parsing option; total quantity is now: "+b.quantity,b)}});var c=$("#orderInfo").val(this.quantity);this.setDisplayPrice();DEBUG_LEAVING("pricingManager::multiplePricingQuantityChanged()",this);return d};pricingManager.prototype.singlePricingQuantityChanged=function(a){DEBUG_ENTERING("pricingManager::singlePricingQuantityChanged()",this);if(a.value.length==0){return}var c=a.value;var b=true;if(isNaN(c)){c=(isNaN(parseInt(c))?1:parseInt(c));a.value=c;b=false}if(c==0){c=1}if(this.quantity!=c){this.quantity=c;this.setDisplayPrice()}DEBUG_LEAVING("pricingManager::singlePricingQuantityChanged()",this);return b};pricingManager.prototype.getSelectedOptionChanged=function(){DEBUG_ENTERING("pricingManager::getSelectedOptionChanged()",this);var a=this;DEBUG_LEAVING("pricingManager::getSelectedOptionChanged()",this);return function(){a.setDisplayPrice()}};pricingManager.prototype.setDisplayPrice=function(){DEBUG_ENTERING("pricingManager::setDisplayPrice()",this);if(this.elPriceEstimateDisplayElement.length==0){DEBUG_WARNING("No price estimate display element found",this);DEBUG_LEAVING("pricingManager::setDisplayPrice()",this);return}var c=this.productInstance.getQuantityPrice(this.quantity);var b=0;var d=this.productInstance.getSelectedOptionsPrice();var a=0;if(this.woodSelectionManagerInstance){this.woodSelectionManagerInstance.updateOptionDisplayPrice(c);if(this.woodSelectionManagerInstance.selectedOption){b=this.woodSelectionManagerInstance.selectedOption.price}}a=formatDollar((c+b+d)*this.quantity);this.elPriceEstimateDisplayElement.text(a);DEBUG_LEAVING("pricingManager::setDisplayPrice()",this)};function product(a){DEBUG_ENTERING("product::product()",this);var b=a.split("|");this.idFullText=a;this.id=b[0];this.category=b[1];this.basePrice=b[2];this.name=b[3];this.imageFile=b[4];this.shippingWeight=b[5];this.isMultiplePricing=false;this.options=new Array();this.pricingTable=new Array();this.onReadyForUse=new ClassEvent();this.selectedOptionsChanged=function(){};DEBUG_LEAVING("product::product()",this);return this}product.prototype.initialize=function(){DEBUG_ENTERING("product::initialize()",this);var b=this.basePrice.split(",");for(var a=0;a<b.length;a++){this.pricingTable[a]=new productPriceItem(b[a])}if(this.pricingTable.length>1){this.isMultiplePricing=true}else{$(".priceData").css("display","none")}this.initializeOptions();this.onReadyForUse.fire();DEBUG_LEAVING("product::initialize()",this)};product.prototype.initializeOptions=function(){DEBUG_ENTERING("product::initializeOptions()",this);var c=document.getElementsByTagName("input");for(var a=0;a<c.length;a++){var b=c[a];if(b.name&&b.name.toLowerCase().indexOf("option|")>-1){this.appendToOptionGroup(b)}}DEBUG_LEAVING("product::initializeOptions()",this)};product.prototype.parseProductId=function(){DEBUG_ENTERING("product::parseProductId()",this);DEBUG_LEAVING("product::parseProductId()",this);return this.id.replace("item-","")};product.prototype.getQuantityPrice=function(c){DEBUG_ENTERING("product::getQuantityPrice()",this);if(this.isMultiplePricing){var a=this.pricingTable.length-1;for(var b=a;b>=0;b--){if(c>=this.pricingTable[b].quantityThreshold){DEBUG_LEAVING("product::getQuantityPrice()",this);return this.pricingTable[b].publicPrice}}DEBUG_LEAVING("product::getQuantityPrice()",this);return this.pricingTable[a].publicPrice}else{DEBUG_LEAVING("product::getQuantityPrice()",this);return this.pricingTable[0].publicPrice}DEBUG_WARN("Could not determine whether this product supports multiple pricing.",this);DEBUG_LEAVING("product::getQuantityPrice()",this);return 0};product.prototype.getSelectedOptionsPrice=function(){DEBUG_ENTERING("product::getSelectedOptionsPrice()",this);var b=0;for(var a=0;a<this.options.length;a++){b+=this.options[a].selectedOption.price}DEBUG_LEAVING("product::getSelectedOptionsPrice()",this);return b};product.prototype.appendToOptionGroup=function(b){DEBUG_ENTERING("product::appendToOptionGroup()",this);var a;if(!(a=this.containsOptionGroup(b.name))){a=this.options.length;this.options[a]=new productOptionGroup(this,b.name)}this.options[a].addOption(b);DEBUG_LEAVING("product::appendToOptionGroup()",this)};product.prototype.containsOptionGroup=function(a){DEBUG_ENTERING("product::containsOptionGroup()",this);for(var b=0;b<this.options.length;b++){if(this.options[b].name==a){DEBUG_INFO("Return Value: "+b);DEBUG_LEAVING("product::containsOptionGroup()",this);return b.toString()}}DEBUG_INFO("Return Value: false",this);DEBUG_LEAVING("product::containsOptionGroup()",this);return false};function productOption(b,a){DEBUG_ENTERING("productOption::productOption()",this);this.parentGroup=b;this.element=a;this.price=0;this.initialize();DEBUG_LEAVING("productOption::productOption()",this)}productOption.prototype.initialize=function(){DEBUG_ENTERING("productOption::initialize()",this);if(this.element.value){var a=this.element.value.split("|");if(a.length>=1){this.price=parseFloat(formatDollar(a[1]))}}if(this.element.checked){this.parentGroup.selectedOption=this}$(this.element).click(this.getSelectFunction());DEBUG_LEAVING("productOption::initialize()",this)};productOption.prototype.getSelectFunction=function(){DEBUG_ENTERING("productOption::getSelectFunction()",this);var a=this;DEBUG_LEAVING("productOption::getSelectFunction()",this);return function(){a.parentGroup.setSelectedOption(a)}};function productOptionGroup(b,a){this.className="productOptionGroup";DEBUG_ENTERING("productOptionGroup::productOptionGroup()",this);this.options=new Array();this.name=a;this.selectedOption;this.parentProduct=b;DEBUG_LEAVING("productOption::productOptionGroup()",this)}productOptionGroup.prototype.addOption=function(a){DEBUG_ENTERING("productOptionGroup::addOption()",this);this.options[this.options.length]=new productOption(this,a);DEBUG_LEAVING("productOptionGroup::addOption()",this)};productOptionGroup.prototype.setSelectedOption=function(a){DEBUG_ENTERING("productOptionGroup::setSelectedOption()",this);this.selectedOption=a;this.parentProduct.selectedOptionsChanged();DEBUG_LEAVING("productOptionGroup::setSelectedOption()",this)};function productPriceItem(a){DEBUG_ENTERING("productPriceItem::productPriceItem()",this);this.publicPrice;this.dealerPrice;this.quantityThreshold=1;this.priceText=a;this.initialize();DEBUG_LEAVING("productPriceItem::productPriceItem()",this);return this}productPriceItem.prototype.initialize=function(){DEBUG_ENTERING("productPriceItem::initialize()",this);if(this.priceText.indexOf("&")>-1){this.setDealerPrice()}if(this.priceText.indexOf("/")>-1){this.setQuantityThreshold()}this.setPublicPrice();this.priceText=null;DEBUG_LEAVING("productPriceItem::initialize()",this)};productPriceItem.prototype.setDealerPrice=function(){DEBUG_ENTERING("productPriceItem::setDealerPrice()",this);var a=this.priceText.split("&");this.priceText=a[0];this.dealerPrice=this.parsePrice(a[1]);DEBUG_LEAVING("productPriceItem::setDealerPrice()",this)};productPriceItem.prototype.setQuantityThreshold=function(){DEBUG_ENTERING("productPriceItem::setQuantityThreshold()",this);var a=this.priceText.split("/");this.priceText=a[0];this.quantityThreshold=parseInt(a[1]);DEBUG_LEAVING("productPriceItem::setQuantityThreshold()",this)};productPriceItem.prototype.setPublicPrice=function(){DEBUG_ENTERING("productPriceItem::setPublicPrice()",this);this.publicPrice=this.parsePrice(this.priceText);if(!this.dealerPrice){this.dealerPrice=this.publicPrice}DEBUG_LEAVING("productPriceItem::setPublicPrice()",this)};productPriceItem.prototype.parsePrice=function(a){DEBUG_ENTERING("productPriceItem::parsePrice()",this);if(a&&a.length>0){DEBUG_INFO("Parsed price: "+a.replace(" ea",""));DEBUG_LEAVING("productPriceItem::parsePrice()",this);return parseFloat(a.replace(" ea",""))}DEBUG_INFO("Parsed price: 0 (default case)",this);DEBUG_LEAVING("productPriceItem::parsePrice()",this);return 0};function woodSelection(a){DEBUG_ENTERING("woodSelection::woodSelection()",this);this.caption=this.getCaption(a);this.swatchImage=this.getSwatchImage(a);this.description=this.getDescription(a);DEBUG_LEAVING("woodSelection::woodSelection()",this)}woodSelection.prototype.getCaption=function(a){DEBUG_ENTERING("woodSelection::getCaption()",this);var b=a.getAttribute("woodType");if(!b||b==String.empty){b=a.getAttribute("squareSize")}DEBUG_INFO("Caption is: "+b);DEBUG_LEAVING("woodSelection::getCaption()",this);return b};woodSelection.prototype.getSwatchImage=function(a){DEBUG_ENTERING("woodSelection::getSwatchImage()",this);DEBUG_LEAVING("woodSelection::getSwatchImage()",this);return a.getAttribute("swatchImage")};woodSelection.prototype.getDescription=function(a){DEBUG_ENTERING("woodSelection::getDescription()",this);DEBUG_LEAVING("woodSelection::getDescription()",this);return $("description:first",a).text()};function woodSelectionManager(a){this.className="woodSelectionManager";DEBUG_ENTERING("woodSelectionManager::woodSelectionManager()",this);this.isMultiplePricing=false;this.allSelectionOptions=new Array();this.xmlDoc;this.woodSelectionOptions=new Array();this.selectionContainerEl=String.empty;this.previewElementEl=String.empty;this.descriptionEl=String.empty;this.selectionContainerAltEl=String.empty;this.previewElementAltEl=String.empty;this.productInstance=a;this.selectedOption;this.productBasePrice=0;this.woodSelectionChanged=function(){};this.availableOptionList;this.target="Wood";this.onReadyForUse=new ClassEvent();DEBUG_LEAVING("woodSelectionManager::woodSelectionManager()",this)}woodSelectionManager.prototype.initialize=function(){DEBUG_ENTERING("woodSelectionManager::initialize()",this);var b=$("#orderInfo").attr("name").split("|");this.isMultiplePricing=b[2].split(",").length>1;DEBUG_INFO("Does this product support multiple pricing? "+this.isMultiplePricing);var a=$("#WoodSelectionChoiceList");if(a.length==0){DEBUG_INFO("Current product is a chessboard. Using 'SquareSize' features.",this);a=$("#SquareSizeSelectionChoiceList");this.target="SquareSize"}else{DEBUG_INFO("Current product is a chess set. Using 'wood selection' features.",this)}if(!a){DEBUG_INFO("No selection Choice List Element found",this);DEBUG_LEAVING("woodSelectionManager::initialize()",this);return}this.availableOptionList=a.text();$.get(SiteEngine.getCommonDataRoot()+this.target+"SelectionOptions.xml",this.getallSelectionOptionsLoaderFunction());DEBUG_LEAVING("woodSelectionManager::initialize()",this)};woodSelectionManager.prototype.getallSelectionOptionsLoaderFunction=function(){DEBUG_ENTERING("woodSelectionManager::getallSelectionOptionsLoaderFunction()",this);oThis=this;DEBUG_LEAVING("woodSelectionManager::getallSelectionOptionsLoaderFunction()",this);return function(a){$("selection",a).each(function(b){oThis.allSelectionOptions[b]=new woodSelection(this)});oThis.initializeWoodSelectionOptions();oThis.onReadyForUse.fire()}};woodSelectionManager.prototype.initializeWoodSelectionOptions=function(){DEBUG_ENTERING("woodSelectionManager::initializeWoodSelectionOptions()",this);var e=0;var c=this.availableOptionList.split("|");var d=this;this.selectionContainerEl=$("#woodSelectionOptionsContainer");this.previewElementEl=$("#woodSelectionOptionPreview");this.descriptionEl=$("#woodSelectionOptionDescription");this.selectionContainerAltEl=$("#woodSelectionOptionsContainerAlt");this.previewElementAltEl=$("#woodSelectionOptionPreviewAlt");if(this.isMultiplePricing){$("#quantitySelection").css("display","none");this.previewElementEl.parent().parent().remove();this.descriptionEl.parent().remove();this.selectionContainerEl.parent().attr({width:"100%",colspan:"3"});this.selectionContainerEl.parent().parent().prev().remove();this.selectionContainerAltEl.attr("width","100%");this.selectionContainerAltEl.parent().prev().remove();var a=$('<div style="padding-top: 165px"></div>').append($("#border7").parent().clone());this.selectionContainerAltEl.after(a);this.selectionContainerAltEl.parent().attr("align","center")}this.selectionContainerEl.empty();this.selectionContainerAltEl.empty();$(c).each(function(b){if(this!=String.empty&&d.addWoodSelectionOption(this).isDefault){e=b}});this.woodSelectionOptions[e].select();this.updateSelectedItemDescription(this.woodSelectionOptions[e]);this.showPreview(this.woodSelectionOptions[e]);DEBUG_LEAVING("woodSelectionManager::initializeWoodSelectionOptions()",this)};woodSelectionManager.prototype.getWoodSelectionClickFunction=function(b){DEBUG_ENTERING("woodSelectionManager::getWoodSelectionClickFunction()",this);var a=this;DEBUG_LEAVING("woodSelectionManager::getWoodSelectionClickFunction()",this);return function(){if(!a.isMultiplePricing){a.resetWoodSelections();b.select();a.updateSelectedItemDescription(b);a.showPreview(b)}a.woodSelectionChanged()}};woodSelectionManager.prototype.addWoodSelectionOption=function(a){DEBUG_ENTERING("woodSelectionManager::addWoodSelectionOption()",this);var b=new woodSelectionOption(this,a);this.woodSelectionOptions[this.woodSelectionOptions.length]=b;try{this.selectionContainerEl.append(b.woodSelectorNode);this.selectionContainerAltEl.append(b.woodSelectorAltNode)}catch(c){DEBUG_CRITICAL("err",this)}DEBUG_LEAVING("woodSelectionManager::addWoodSelectionOption()",this);return b};woodSelectionManager.prototype.resetWoodSelections=function(){DEBUG_ENTERING("woodSelectionManager::resetWoodSelections()",this);$(this.woodSelectionOptions).each(function(){this.deselect()});DEBUG_LEAVING("woodSelectionManager::resetWoodSelections()",this)};woodSelectionManager.prototype.showPreview=function(b){DEBUG_ENTERING("woodSelectionManager::showPreview()",this);var c="http://uscfsales.com/Images/swatches/"+b.swatchImage;try{this.previewElementEl.attr("src",c);this.previewElementEl.attr("alt",b.caption);this.previewElementAltEl.attr("src",c);this.previewElementAltEl.attr("alt",b.caption)}catch(a){DEBUG_CRITICAL("err",this)}DEBUG_LEAVING("woodSelectionManager::showPreview()",this)};woodSelectionManager.prototype.updateSelectedItemDescription=function(a){DEBUG_ENTERING("woodSelectionManager::updateSelectedItemDescription()",this);$(this.descriptionEl).html(a.description);DEBUG_LEAVING("woodSelectionManager::updateSelectedItemDescription()",this)};woodSelectionManager.prototype.updateOptionDisplayPrice=function(a){DEBUG_ENTERING("woodSelectionManager::updateOptionDisplayPrice()",this);if(this.productBasePrice!=a){this.productBasePrice=a;for(i=0;i<this.woodSelectionOptions.length;i++){this.woodSelectionOptions[i].updateDisplayPrice(this.productBasePrice)}}DEBUG_LEAVING("woodSelectionManager::updateOptionDisplayPrice()",this)};function woodSelectionOption(a,b){DEBUG_ENTERING("woodSelectionOption::woodSelectionOption()",this);this.manager=a;this.price=0;this.outOfStockFlag=false;this.uniqueId=String.empty;this.caption=String.empty;this.outOfStockMessage=String.empty;this.swatchImage=String.empty;this.description=String.empty;this.itemIndex=0;this.woodSelectorNode=String.empty;this.captionEl=String.empty;this.checkboxEl=String.empty;this.woodSelectorAltNode=String.empty;this.captionAltEl=String.empty;this.checkboxAltEl=String.empty;this.priceEl=String.empty;this.priceAltEl=String.empty;this.isDefault=false;this.initializeMe(b);DEBUG_LEAVING("woodSelectionOption::woodSelectionOption()",this);return this}woodSelectionOption.prototype.initializeMe=function(c){DEBUG_ENTERING("woodSelectionOption::initializeMe()",this);var a=this;if(c.indexOf("*")!=-1){this.isDefault=true;c=c.replace("*",String.empty)}var b=c.split(";");this.itemIndex=b[0];this.price=parseFloat(b[1]);this.outOfStockFlag=(b[2])?b[2]==1:false;this.outOfStockMessage=(b[3])?b[3]:String.empty;this.uniqueId="woodSelectionOption"+this.itemIndex;if(this.manager.allSelectionOptions.length>this.itemIndex){this.caption=this.manager.allSelectionOptions[this.itemIndex].caption;this.swatchImage=this.manager.allSelectionOptions[this.itemIndex].swatchImage;this.description=this.manager.allSelectionOptions[this.itemIndex].description}if(this.manager.isMultiplePricing){this.generateMultiSelectOption(false);this.generateMultiSelectOption(true);this.optionQuantityEl.blur(function(){a.optionQuantityAltEl.val(a.optionQuantityEl.val())});this.optionQuantityAltEl.blur(function(){a.optionQuantityEl.val(a.optionQuantityAltEl.val())})}else{this.generateSingleSelectOption(false);this.generateSingleSelectOption(true);this.deselect()}DEBUG_LEAVING("woodSelectionOption::initializeMe()",this)};woodSelectionOption.prototype.select=function(){DEBUG_ENTERING("woodSelectionOption::select()",this);if(!this.manager.isMultiplePricing){this.checkboxEl.attr("checked","checked");this.checkboxAltEl.attr("checked","checked");this.checkboxEl.attr("id","baseOptionSelected");this.captionEl.attr("for","baseOptionSelected");this.manager.selectedOption=this}DEBUG_LEAVING("woodSelectionOption::select()",this)};woodSelectionOption.prototype.deselect=function(){DEBUG_ENTERING("woodSelectionOption::deselect()",this);this.checkboxEl.removeAttr("checked");this.checkboxAltEl.removeAttr("checked");this.checkboxEl.attr("id",this.uniqueId);this.captionEl.attr("for",this.uniqueId);DEBUG_LEAVING("woodSelectionOption::deselect()",this)};woodSelectionOption.prototype.generateMultiSelectOption=function(d){DEBUG_ENTERING("woodSelectionOption::generateMultiSelectOption()",this);var c=$("<div></div>");var h=$("<img />");var f=$("<span></span>");var b=$('<input type="text" />');var g=$("<span></span>");c.addClass("woodSelectionMultiItem");f.addClass("woodSelectionMultiItemCaption");f.text(this.caption);h.attr("src","http://houseofstaunton.com/KingCart/Common/Image/Swatch/"+this.swatchImage);h.attr("alt",this.caption);c.append(f);c.append(h);c.append("<br />");if(this.outOfStockFlag){var a=$("<span></span>");var e="Out of Stock";if(this.outOfStockMessage!=String.empty){e=" {0}: {1}".format(e,this.outOfStockMessage)}else{e="   ({0}) ".format(e)}a.addClass("woodSelectionOutOfStock");a.text(e);c.append(a)}else{if(this.outOfStockMessage!=String.empty){var a=$("<span></span>");var e=" {0}".format(this.outOfStockMessage);a.addClass("woodSelectionOutOfStock");a.text(e);c.append(a)}else{b.attr("value","");b.addClass("multiplePricingQuantityField");b.blur(this.manager.getWoodSelectionClickFunction(this));if(!d){b.attr("name","option|Option-{0}|{1}".format(this.caption,this.manager.productInstance.parseProductId()))}c.append(document.createTextNode("QUANTITY: "));c.append(b)}}if(!d){this.woodSelectorNode=c;this.captionEl=f;this.optionQuantityEl=b;this.priceEl=g}else{this.woodSelectorAltNode=c;this.captionAltEl=f;this.optionQuantityAltEl=b;this.priceAltEl=g}DEBUG_LEAVING("woodSelectionOption::generateMultiSelectOption()",this)};woodSelectionOption.prototype.generateSingleSelectOption=function(c){DEBUG_ENTERING("woodSelectionOption::generateSingleSelectOption()",this);var b=$("<div></div>");var f=$("<label></label>");var g=$("<span></span>");var d=$('<input type="radio"></input>');b.addClass("woodSelectionItem");f.addClass("woodSelectionItemCaption");f.text(this.caption+": ");g.addClass("woodSelectionPrice");d.val("Option-"+this.caption+": |"+formatDollar(this.price)+" ea");d.click(this.manager.getWoodSelectionClickFunction(this));if(!c){d.attr("name","option|1|"+this.manager.productInstance.parseProductId())}f.append(g);if(this.outOfStockFlag){var a=$("<span></span>");var e="Out of Stock";if(this.outOfStockMessage!=String.empty){e=" {0}: {1}".format(e,this.outOfStockMessage)}else{e="   ({0}) ".format(e)}a.addClass("woodSelectionOutOfStock");a.text(e);f.append(a);d.css("display","none")}else{if(this.outOfStockMessage!=String.empty){var a=$("<span></span>");var e=" {0}".format(this.outOfStockMessage);a.addClass("woodSelectionOutOfStock");a.text(e);f.append(a)}}b.append(f);b.append(d);if(!c){this.woodSelectorNode=b;this.captionEl=f;this.checkboxEl=d;this.priceEl=g}else{this.woodSelectorAltNode=b;this.captionAltEl=f;this.checkboxAltEl=d;this.priceAltEl=g}DEBUG_LEAVING("woodSelectionOption::generateSingleSelectOption()",this)};woodSelectionOption.prototype.updateDisplayPrice=function(a){DEBUG_ENTERING("woodSelectionOption::updateDisplayPrice()",this);var b="$"+formatDollar(a+this.price);this.priceAltEl.text(b);this.priceEl.text(b);DEBUG_LEAVING("woodSelectionOption::updateDisplayPrice()",this)};(function($){$(function(){jQuery.expr[":"].regex=function(elem,index,match){var matchParams=match[3].split(","),validLabels=/^(data|css):/,attr={method:(matchParams[0].match(validLabels))?matchParams[0].split(":")[0]:"attr",property:matchParams.shift().replace(validLabels,"")},regexFlags="ig",regex=new RegExp(matchParams.join("").replace(/^\s+|\s+$/g,""),regexFlags);return regex.test(jQuery(elem)[attr.method](attr.property))};var inbox="sales";var domain="uscfsales";var world="com";$(".emailGoesHere").each(function(){$(this).html(inbox+"@"+domain+"."+world)});$("input:radio").each(function(){$(this).css({background:"transparent",border:"none",padding:"0",margin:"0"})});var searchFunction={defaultText:"Search USCF Sales",keywordsBox:false,focus:function(){var currentText=$(this).attr("value");if(currentText===searchFunction.defaultText){$(this).attr("value","")}},blur:function(){var currentText=$(this).attr("value");if(currentText===""){$(this).attr("value",searchFunction.defaultText)}},keydown:function(event){if(event.keyCode==13){return searchFunction.doSearch()}return true},doSearch:function(){var keywords=searchFunction.keywordsBox.attr("value");var searchMode=searchFunction.searchMode();if(!keywords||keywords==""||keywords==searchFunction.defaultText){alert("Search is empty! Please enter some search terms");searchFunction.keywordsBox.focus();return false}searchFunction.updateDatabase(keywords,searchMode);if(searchMode=="Standard"){}else{var searchUrl="http://www.kingcart.com/USCFSales/product_name=searchUrl/exact_match=exact";$.get(SiteEngine.getCommonDataRoot()+"/ProductCatelogId.xml",function(xml){var name;$(xml).find("item").each(function(){if($(this).attr("id")==keywords){name=$("name",this).text();searchUrl=searchUrl.replace("searchUrl",name);searchUrl=$.trim(searchUrl);return false}});if(name){window.location=searchUrl}else{alert("Catalog item not found. Please try again or use the product name")}})}},updateDatabase:function(keywords,searchMode){if(searchMode=="Standard"){var searchUrl="http://uscfsales.com/Search/add.php?keywords=KEYWORDS_GO_HERE&searchMode=SEARCHMODE_GOES_HERE&referrer=REFERRER_GOES_HERE";var referrer=escape(window.location);keywords=escape(keywords);searchUrl=searchUrl.replace(/KEYWORDS_GO_HERE/g,keywords);searchUrl=searchUrl.replace(/SEARCHMODE_GOES_HERE/g,searchMode);searchUrl=searchUrl.replace(/REFERRER_GOES_HERE/g,referrer);window.location=searchUrl}else{if(!SiteEngine.isHostKingCart()){$.get(searchUrl,{keywords:keywords,searchMode:searchMode})}}},searchMode:function(){if($("#btnSearchAllText").attr("checked")){return"Standard"}else{return"Catalog"}},initialize:function(keywordsBoxId,searchButtonId){searchFunction.keywordsBox=$(keywordsBoxId).attr("value",searchFunction.defaultText).focus(searchFunction.focus).blur(searchFunction.blur).keydown(searchFunction.keydown);$(searchButtonId).click(searchFunction.doSearch)}};searchFunction.initialize("#tbSearch","#btnKingCartSearch");$("#icpsignupForm").validate();var HtmlIncluder={pendingRequests:0,completionHandlers:[],getIncludePath:function(){return SiteEngine.getCommonIncludeRoot()},Start:function(){SiteEngine.registeredComponents.add("HtmlIncluder");var $includes=$(".include");if(SiteEngine.isSecureHost()||$includes.length==0){HtmlIncluder.PendingRequestsComplete();return}$includes.each(function(i){$(this).html("");var ds=$(this).attr("class").replace("include ","");var oThis=this;$.ajax({url:HtmlIncluder.getIncludePath()+ds,beforeSend:function(){HtmlIncluder.pendingRequests++},success:function(data){$(oThis).append(data);HtmlIncluder.PendingRequestsComplete()}})})},RegisterCompletionHandler:function(handler){HtmlIncluder.completionHandlers[HtmlIncluder.completionHandlers.length]=handler},PendingRequestsComplete:function(){HtmlIncluder.pendingRequests--;if(HtmlIncluder.pendingRequests==0){$(HtmlIncluder.completionHandlers).each(function(index,value){if(typeof(value)=="string"){eval(value)}else{if(typeof(value)=="function"){value()}}});SiteEngine.registeredComponents.markItemComplete("HtmlIncluder")}}};HtmlIncluder.Start();function setHeight(){var divHeight,minHeight=900;div=document.getElementById("sidebar1");if(div){divHeight=minHeight;if(div.offsetHeight){divHeight=div.offsetHeight}else{if(div.style.pixelHeight){divHeight=div.style.pixelHeight}}if(minHeight<divHeight){minHeight=divHeight}}div=document.getElementById("sidebar2");if(div){divHeight=minHeight;if(div.offsetHeight){divHeight=div.offsetHeight}else{if(div.style.pixelHeight){divHeight=div.style.pixelHeight}}if(minHeight<divHeight){minHeight=divHeight}}div=document.getElementById("content");if(div){divHeight=0;if(div.offsetHeight){divHeight=div.offsetHeight}else{if(div.style.pixelHeight){divHeight=div.style.pixelHeight}}if(divHeight<minHeight){div.style.height=minHeight+"px"}}}$(window).resize(setHeight);$("#sidebar1").resize(setHeight);$("#sidebar2").resize(setHeight);$("#content").resize(setHeight);SiteEngine.registeredComponents.onAllItemsComplete.add(setHeight);$.fn.MakeSideMenu=function(options){options=$.extend({speed:250,fadeInEffect:"fast",fadeOutEffect:false},options||{});this.each(function(){function getSubMenu(el){return $("ul:first",el)}function hideItem(el){getSubMenu(el).css("z-index","9").hide(options.fadeOutEffect).end()}function hideLevel(el){var level=($(el).hasClass("L1"))?".L1":".L2";$(level).each(function(){if(this!=el){hideItem(this)}})}function hoverOver(){var $this=$(this);if($this.hasClass("submenu")){$this.css({cursor:"pointer",background:"#2f7b8f url("+SiteEngine.getCommonImageRoot()+"/sidemenu_right_arrow_over.gif) no-repeat right"})}else{$this.css({cursor:"pointer",background:"#2f7b8f"})}}function hoverOut(){var $this=$(this);if($this.hasClass("submenu")){$this.css("background","transparent url("+SiteEngine.getCommonImageRoot()+"/sidemenu_right_arrow.gif) no-repeat right")}else{$this.css("background","transparent")}}function dynamicallyLocateAndTagAllSubMenus(el){$("li>ul",el).each(function(){$(this).parent().addClass("submenu").addClass("L1").end()});$("li.submenu li.submenu",el).each(function(){$(this).removeClass("L1").addClass("L2").end()})}function attachSubmenuAction(el){$(".submenu",el).each(function(){$(this).click(function(){hideLevel(this);getSubMenu(this).toggle(options.fadeInEffect,function(){$(this).css("z-index","10")});return false})});$("li",el).each(function(){$(this).click(function(){var href=$("a:first",this).attr("href");if(undefined!=href&&href!=""&&href!=window.location){window.location=href}})});$("body").click(function(){$(".submenu",el).each(function(){hideItem(this)})})}function correctDisplayIssuesInIe(el){if(!$.browser.msie){return}if($.browser.version>=7){$("li ul>li",el).each(function(){$(this).width("auto");$("a",this).width("auto")})}else{$("li ul>li",el).each(function(){var $this=$(this);var width=$this.parent().width();$this.width(width);$("a",this).width("auto")});$("ul>li",el).each(function(){$(this).hover(hoverOver,hoverOut)})}}function initialize(el){dynamicallyLocateAndTagAllSubMenus(el);attachSubmenuAction(el);correctDisplayIssuesInIe(el)}initialize(this)})};if(SiteEngine.isHostKingCart()){HtmlIncluder.RegisterCompletionHandler('$("#leftNav").MakeSideMenu()')}else{$("#leftNav").MakeSideMenu()}var kcOption={$contents:"",$settings:"",displayMode:"",width:0,initialize:function(){DEBUG_ENTERING("kcOption.initialize()",this);kcOption.$contents=$("#optionsfileContents");kcOption.$settings=$("optionsfileSettings");kcOption.setDisplayMode();kcOption.setWidth();kcOption.configureDialog();DEBUG_LEAVING("kcOption.initialize()",this)},setDisplayMode:function(){DEBUG_ENTERING("kcOption.setDisplayMode()",this);if(kcOption.$contents.length==0||!kcOption.productHasOptionsFile()){kcOption.displayMode="hidden"}else{if(kcOption.$settings.attr("displayMode")){kcOption.displayMode=kcOption.$settings.attr("displayMode")}else{kcOption.displayMode="inline"}}DEBUG_LEAVING("kcOption.setDisplayMode()",this)},setWidth:function(){DEBUG_ENTERING("kcOption.setWidth()",this);if(kcOption.displayMode!="popup"){return}if(kcOption.$settings.attr("width")){kcOption.width=kcOption.$settings.attr("width")}else{kcOption.width=($.trim(kcOption.$contents.text()).length>500)?750:300}DEBUG_LEAVING("kcOption.setWidth()",this)},productHasOptionsFile:function(){DEBUG_ENTERING("kcOption.productHasOptionsFile()",this);var noOptionsText="[There are no available options for this item.]";var actualText=$.trim(kcOption.$contents.text());DEBUG_LOG("productHasOptionsFile: "+(actualText!=noOptionsText));DEBUG_LEAVING("kcOption.productHasOptionsFile()",this);return actualText!=noOptionsText},productUsesOptionsFile:function(){DEBUG_ENTERING("kcOption.productUsesOptionsFile()",this);DEBUG_LOG("productUsesOptionsFile: "+(kcOption.displayMode!="hidden"));DEBUG_LEAVING("kcOption.productUsesOptionsFile()",this);return kcOption.displayMode!="hidden"},openDialog:function(){DEBUG_ENTERING("kcOption.openDialog()",this);kcOption.$contents.dialog("open");DEBUG_LEAVING("kcOption.openDialog()",this)},closeDialog:function(){DEBUG_ENTERING("kcOption.closeDialog()",this);$(this).dialog("close");DEBUG_LEAVING("kcOption.closeDialog()",this)},createDialog:function(){DEBUG_ENTERING("kcOption.createDialog()",this);$("#btnAddToCart").hide();$("#btnShowOptionsDialog").show().css("cursor","pointer").click(kcOption.openDialog);kcOption.$contents.dialog({autoOpen:false,modal:true,width:parseInt(kcOption.width),buttons:{Cancel:kcOption.closeDialog,"Add to Cart":productManager.addToCart}});DEBUG_LEAVING("kcOption.createDialog()",this)},destroyDialog:function(){DEBUG_ENTERING("kcOption.destroyDialog()",this);kcOption.$contents.dialog("close");kcOption.$contents.dialog("destroy");DEBUG_LEAVING("kcOption.destroyDialog()",this)},configureDialog:function(){DEBUG_ENTERING("kcOption.configureDialog()",this);switch(kcOption.displayMode){case"popup":kcOption.createDialog();break;case"inline":kcOption.$contents.parent().removeClass("hidden");default:kcOption.hideDialogButtons();productManager.applyValidationRules()}DEBUG_LEAVING("kcOption.configureDialog()",this)},hideDialogButtons:function(){DEBUG_ENTERING("kcOption.hideDialogButtons()",this);$("#btnAddToCart").show();$("#btnShowOptionsDialog").hide();DEBUG_LEAVING("kcOption.hideDialogButtons()",this)},CopyOptionsToForm:function(){DEBUG_ENTERING("kcOption.copyOptionToForm()",this);var copyOptionToForm=function(){var $this=$(this);var $option=$('<input type="hidden"></input>');$option.attr("name",$this.attr("name"));$option.val($this.val());$optionCopy.append($option)};var $optionCopy=$("#optionsDialogCopy").html("&nbsp;");$("input:checked, :text, select",kcOption.$contents).each(copyOptionToForm);DEBUG_LEAVING("kcOption.copyOptionToForm()",this)}};var productManager={productOptions:"",applyValidationRules:function(){DEBUG_ENTERING("productManager.applyValidationRules()",this);$("#productForm").validate({submitHandler:function(){DEBUG_ENTERING("productManager.submitHandler()",this);if(productManager.validate()){form.submit()}else{alert("Please select an option before submitting your order.");window.location="#productOptions"}DEBUG_LEAVING("productManager.submitHandler()",this)}});DEBUG_LEAVING("productManager.applyValidationRules()",this)},addToCart:function(){DEBUG_ENTERING("productManager.addToCart()",this);if(productManager.validate()){kcOption.CopyOptionsToForm();$("#btnAddToCart").click()}else{alert("Please check your options")}DEBUG_LEAVING("productManager.addToCart()",this)},validate:function(){DEBUG_ENTERING("productManager.validate()",this);var formIsValid=productManager.productOptions.length==0;productManager.productOptions.each(function(){if($(this).attr("value")!=""){formIsValid=true;return false}});DEBUG_LOG("formIsValid: "+formIsValid);DEBUG_LEAVING("productManager.validate()",this);return formIsValid},configureValidation:function(){DEBUG_ENTERING("productManager.configureValidation()",this);if(productManager.productOptions.length>0){$("#quantitySelection").hide();productManager.productOptions.each(function(){$(this).attr({onblur:"","class":"number",min:"0"})})}else{$("#quantitySelection").show();$("#productForm").validate()}DEBUG_LEAVING("productManager.configureValidation()",this)},initialize:function(){DEBUG_ENTERING("productManager.initialize()",this);productManager.productOptions=$("[type=text]:regex(name,^option.+)");kcOption.initialize();productManager.configureValidation();DEBUG_LEAVING("productManager.initialize()",this)}};productManager.initialize();$("#referAFriendForm").validate();$("#shipcostform").validate();$("input:image").each(function(){$(this).css("border","0")});$(".productImage a").each(function(){$(this).append("<div>Click to Enlarge</div>")});var targ="http://uscfsales.com/Main/RecommendAProduct?caller="+window.location;$("#recommendAProduct").css("cursor","pointer").click(function(){window.open(targ,"","","")}).end();function addToFavorites(){if(window.sidebar){window.sidebar.addPanel(document.title,window.location,"")}else{if(window.external){window.external.AddFavorite(window.location,document.title)}else{alert("We apologize, this feature is not supported in your browser. Please press 'ctrl-D' to bookmark this page.")}}return false}$("#addToFavorites").css("cursor","pointer").click(addToFavorites).end();function fixContentWidth(contentElement){var contentElement=$("#"+contentElement);if(contentElement.length==1){var contentDefaultWidth=625;var contentWidth=contentElement.width();var deltaWidth;if((deltaWidth=contentWidth-contentDefaultWidth)>0){var page=$("#page");page.width(page.width()+deltaWidth).css("max-width","2000px")}}}SiteEngine.registeredComponents.onAllItemsComplete.add(function(){fixContentWidth("categoryTable");fixContentWidth("productWrap")})})})(jQuery);