/*--------------------------------------------------------------------------*
*
* Copyright (C) 2010 Brand Labs LLC
*
*--------------------------------------------------------------------------*/

var Discounts={URL:'/v/discounts/product_get_discounts.asp',load:function(){try{if(location.pathname.toLowerCase()=='/productdetails.asp'||location.pathname.toLowerCase().indexOf('-p/')!=-1||location.pathname.toLowerCase().indexOf('_p/')!=-1){Discounts.windowLoadProduct();}}
catch(e){}},windowLoadProduct:function(){var productCode=null;var element=null;var elements=null;productCode=Discounts.getProductCodeFromURL(window.location.href);if(productCode==null){return;}
productCode=productCode.toUpperCase();elements=$$('table.colors_pricebox');if(elements==null||elements.size()<=0){return;}
element=elements.last();if(element==null){return;}
new Ajax.Updater(element,Discounts.URL,{insertion:'after',parameters:{productCode:productCode},method:'get',evalJS:false,evalJSON:false,encoding:'windows-1252'});},getProductCodeFromURL:function(url){var matches=null;if(url==null){return null;}
matches=url.match(/\/productdetails\.asp\?(?:[\&]?.*\=.*)*productcode=([^\&\#]+)/i);if(matches!=null&&matches.length>=2){return unescape(matches[1]);}
matches=url.match(/(?:_p|-p)\/(.+)\.htm/i);if(matches!=null&&matches.length>=2){return unescape(matches[1]);}
return null;}};Event.observe(window,'load',Discounts.load);
