/* begin Page */

cssFix = function(){
var u = navigator.userAgent.toLowerCase(),
addClass = function(el, val) {

	if(! el.className) {
		el.className = val;
	} else {
		var newCl = el.className;
		newCl+=(' '+val);
		el.className = newCl;
	}
},
is = function(t){return (u.indexOf(t)!=-1)};
$('html').addClass(
(!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
: is('firefox/2')?'gecko firefox2'
: is('firefox/3')?'gecko firefox3'
: is('gecko/')?'gecko'
: is('chrome/')?'chrome'
: is('opera/9')?'opera opera9':/opera (\d)/.test(u)?'opera opera'+RegExp.$1
: is('konqueror')?'konqueror'
: is('applewebkit/')?'webkit safari'
: is('mozilla/')?'gecko':'',
(is('x11')||is('linux'))?' linux'
: is('mac')?' mac'
: is('win')?' win':''
);
}();

var userAgent = navigator.userAgent.toLowerCase();
var browser = {
	version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
	safari: /webkit/.test(userAgent) && !/chrome/.test(userAgent),
	chrome: /chrome/.test(userAgent),
	opera: /opera/.test(userAgent),
	msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
	mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};

(function() {
	// fix ie blinking
	var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
	try { if (!!m) { m('BackgroundImageCache', false, true); } }
	catch (oh) { };
})();

var styleUrlCached = null;
function GetStyleUrl() {
    if (null == styleUrlCached) {
        var ns;
        styleUrlCached = '';
        ns = document.getElementsByTagName('link');
        for (var i = 0; i < ns.length; i++) {
            var l = ns[i];
            if (l.href && /style\.ie6\.css(\?.*)?$/.test(l.href)) {
                return styleUrlCached = l.href.replace(/style\.ie6\.css(\?.*)?$/, '');
            }
        }

        ns = document.getElementsByTagName('style');
        for (var i = 0; i < ns.length; i++) {
            var matches = new RegExp('import\\s+"([^"]+\\/)style\\.ie6\\.css"').exec(ns[i].innerHTML);
            if (null != matches && matches.length > 0)
                return styleUrlCached = matches[1];
        }
    }
    return styleUrlCached;
}

function fixPng(png) {
    var img = $(png);
    img.css({
        "width": img.width(),
        "height": img.height(),
        "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.attr("src") + "', sizingMethod='scale')"
    });
    img.attr("src", "/images/spacer.gif");
}

function proxyButton(imageButton, text)
{
  imageButton.each(function (index, elem)
  {
    var button = $('<input>', { 'type': 'button' });

    button.attr('id', $(elem).attr('id') + '_proxy');
    button.addClass('button').attr('value', text);
    button.click(function () { $(elem).click(); });

    button.insertAfter($(elem));
    $(elem).hide();
  });
};
$(function ()
{
  proxyButton($('input[id$="_MiniCart_IbCheckout"]'), 'Checkout');

  proxyButton($('input[id$="_ProductsList_IbAddtoCart"]'), 'View Cart');
  proxyButton($('input[id$="_ibAddToCart"]').filter('input[id*="_ProductsList_dtProductslist_"]'), 'Add to Cart');

  proxyButton($('input[id$="_Cart_ibContinueShopping"]'), 'Continue Shopping');
  proxyButton($('input[id$="_Cart_ibCheckout"]'), 'Checkout');
  proxyButton($('input[id$="_Cart_btnBack"]'), 'Continue Shopping');
  proxyButton($('input[id$="_Cart_btnMakePayment"]'), 'Checkout');
  proxyButton($('input[id$="_Cart_btnUpdate"]'), 'Update Quantity');

  proxyButton($('input[id$="_Confirm_btnBack"]'), 'Back');
  proxyButton($('input[id$="_Confirm_btnSubmit"]'), 'Submit Order');

  proxyButton($('input[id$="_ProductDetails_ibAddtoCart"]'), 'Add to Cart');
  proxyButton($('input[id$="_ProductDetails_btnBack"]'), 'Continue Shopping');
  proxyButton($('input[id$="_ProductDetails_btnViewCart"]'), 'View Cart');

  proxyButton($('input[id$="ibAddToCart2"]').filter('input[id*="_FeaturedProducts_dtFeaturedProducts_"]'), 'Add to Cart');

  $('select[id$="_Cart_ddlCountry"] > option[value!="US"]').remove();
  $('select[id$="_Step1_ddlCountry"] > option[value!="US"]').remove();
  $('select[id$="_Step2_ddlCountry"] > option[value!="US"]').remove();

  if ($('input:radio[name=dnn$RibbonBar.ascx$optMode]:checked').val() != "EDIT")
  {
    $('div.art-contentpane:has(div.ModSmithBuyNowC) .art-BlockHeader').hide();
  }
  //  $('div.art-contentpane:has(div.ModSmithBuyNowC) .art-BlockContent > div[class!=art-BlockContent-body]').hide();

  (function () {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
});

/* end Page */

/* begin Menu */
$(function() { $(".art-menu >li:not(:last-child)").after('<li><span class="art-menu-separator" /></li>') });

function Menu_IE6Setup() {
	var isIE6 = navigator.userAgent.toLowerCase().indexOf("msie") != -1
    && navigator.userAgent.toLowerCase().indexOf("msie 7") == -1;
	if (!isIE6) return;
	var aTmp2, i, j, oLI, aUL, aA;
	var aTmp = $("ul.art-menu");
	for (i = 0; i < aTmp.length; i++) {
		aTmp2 = aTmp[i].getElementsByTagName("li");
		for (j = 0; j < aTmp2.length; j++) {
			oLI = aTmp2[j];
			aUL = oLI.getElementsByTagName("ul");
			if (aUL && aUL.length) {
				oLI.UL = aUL[0];
				aA = oLI.getElementsByTagName("a");
				if (aA && aA.length)
					oLI.A = aA[0];
				oLI.onmouseenter = function() {
					this.className += " art-menuhover";
					this.UL.className += " art-menuhoverUL";
					if (this.A) this.A.className += " art-menuhoverA";
				};
				oLI.onmouseleave = function() {
					this.className = this.className.replace(/art-menuhover/, "");
					this.UL.className = this.UL.className.replace(/art-menuhoverUL/, "");
					if (this.A) this.A.className = this.A.className.replace(/art-menuhoverA/, "");
				};
			}
		}
	}
}
$(Menu_IE6Setup);
/* end Menu */

/* begin Button */
function artButtonsSetupJsHover(className) {
    var ts = $('html input.' + className + ':not(.art-button-wrapper), html a.' + className + ':not(.art-button-wrapper), html button.' + className + ':not(.art-button-wrapper)');
    ts.wrap('<span class="art-button-wrapper" />');
    ts.before('<span class="l" /><span class="r" />');
    ts.removeClass('art-button');
	ts.addClass('art-button');
	ts.mouseover(function(e) {
	    $(this).parent().removeClass('hover');
	    $(this).parent().addClass('hover');
	});
	ts.mouseout(function(e) {
	    $(this).parent().removeClass('hover');
	    if (!$(this).hasClass('active')) $(this).parent().removeClass('active');
	});
	ts.mousedown(function(e) {
	    if (!$(this).hasClass('active')) {
	        $(this).parent().removeClass('active');
	        $(this).parent().addClass('active');
	    }
	});
	ts.mouseup(function(e) {l
	    if (!$(this).hasClass('active')) {
	        $(this).parent().removeClass('active');
	    }
    });
}

$(function() { artButtonsSetupJsHover("art-button"); });
/* end Button */
$(function() { $(".art-menu ul li:last-child").addClass("last-child"); });
//$(function() { $(".art-menu ul li:last-child>a").corners("big transparent bottom"); });

$.extend({
    'QueryString': window.location.search.length <= 1 ? new Array() :
        function (a)
        {
            var b = new Array();
            for (var i = 0; i < a.length; ++i)
            {
                var p = a[i].split('=');
                b[p[0]] = unescape(p[1]);
            }
            return b;
        } (window.location.search.substr(1).split('&'))
    });

