var 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)};
  addClass(document.getElementsByTagName('html')[0],[
    (!(/opera|webtv/i.test(u))&&/msie (\d)/.test(u))?('ie ie'+RegExp.$1)
      :is('firefox/2')?'gecko ff2'
      :is('firefox/3')?'gecko ff3'
      :is('gecko/')?'gecko'
      :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':''
  ].join(" "));
}();


BlackBurn = {
		menu : function(){
            jQuery('.nav-container').hover(function(){
                jQuery('.nav-frame')
                    .stop(true, true)
                    .delay(200)
                    .animate({
                        height:'show',
                        opacity:'show'
                    }, 500);
            }, function(){
                jQuery('.nav-frame')
                    .stop(true, true)
                    .delay(200)
                    .animate({
                        height:'hide',
                        opacity:'hide'
                    }, 500);
            });
			$jQ('#nav .parent').hover(
				function(){
					$jQ(this).children('ul')
                        .stop(true, true)
                        .delay(100)
                        .animate({
                            height:'show',
                            opacity:'show'
                        }, 300);
				},
				function(){
					$jQ(this).children('ul')
                        .stop(true, true)
                        .delay(100)
                        .animate({
                            height:'hide',
                            opacity:'hide'
                        }, 400);
				});
		},
        gridDecorated : function(){
            var productHeightMax = new Array;
            var productPriceHeightMax = new Array;
            var size =  $jQ('.products-grid').size();
            for(i = 0; i < size; i++){
                productHeightMax[i] = 0;
                productPriceHeightMax[i] = 0;
                $jQ('.product-name','.products-grid:eq(' + i + ')').each(function(){
                    var productHeight = $jQ(this).height();
                    if(productHeightMax[i] < productHeight){
                            productHeightMax[i] = productHeight;
                    }
                });
                $jQ('.product-name','.products-grid:eq(' + i + ')').height(productHeightMax[i]);
                $jQ('.price-box','.products-grid:eq(' + i + ')').each(function(){
                    var productPriceHeight = $jQ(this).height();
                    if(productPriceHeightMax[i] < productPriceHeight){
                            productPriceHeightMax[i] = productPriceHeight;
                    }
                });
                $jQ('.price-box','.products-grid:eq(' + i + ')').height(productPriceHeightMax[i]);
            }
            $jQ('.products-grid:has(.rating-box) .price-box').css('padding-bottom','13px');
            $jQ('.products-grid li:has(.rating-box) .price-box').css('padding-bottom','0');
        },
		compareTable : function(){
			var coln = $jQ('#product_comparison tr:first td').size();
			var bodyWidth = $jQ('body').width();
			var tableWidth = bodyWidth - 275;
			var tdWidth = tableWidth / coln;
			var bodyMinWidth = coln * 175 + 263;
			for(i=0; i<coln; i++){
				$jQ('#product_comparison').prepend('<col width="' + tdWidth + '" />');
			}
			$jQ('#product_comparison').prepend('<col width="143" />');
			$jQ('html').css('min-width',bodyMinWidth);
		},
		compareTableResize : function(){
			var coln = $jQ('#product_comparison tr:first td').size();
			var bodyWidth = $jQ('body').width();
			var tableWidth = bodyWidth - 275;
			var tdWidth = tableWidth / coln;
			$jQ('#product_comparison col').attr('width',tdWidth);
			$jQ('#product_comparison col:first').attr('width',143);
		},
		_ieAlert : function(){
			var widthMessages = $jQ('.ie7 .messages ul').width();
			var padMessagesError = -(widthMessages / 2 + 75);
			var padMessagesSuccess = -(widthMessages / 2 + 100);
			$jQ('.ie7 .messages li.error-msg ul').css('margin-left',padMessagesError + 'px');
			$jQ('.ie7 .messages li.success-msg ul').css('margin-left',padMessagesSuccess + 'px');
		}
}

jQuery(function() {
    BlackBurn.menu();
	BlackBurn._ieAlert();
    jQuery('#topCompareContent div.scrollable').each(function(){
        var compareTemp = jQuery('#compare-items').height();
        if (compareTemp < 296) {
            jQuery('#topCompareContent div.scrollable').css({
                'height' : compareTemp
            });
        }
    }); 
   jQuery('#topCartContent div.scrollable').each(function(){
        var compareTempFix27 = jQuery('#mini-cart').height();
        if (compareTempFix27 < 296) {
            jQuery('#topCartContent div.scrollable').css({
                'height' : compareTempFix27
            });
        }
    });
    
    jQuery('div.category-products ul.products-grid').each(function(){
        var hTemp = 0;
        jQuery(this).find('li').each(function(){
            var hTemp2 = jQuery(this).height();
            if (hTemp < hTemp2){hTemp =hTemp2}
        });
        jQuery(this).find('li').each(function(){
            jQuery(this).css({
                'height' : hTemp
            });
        });
	});
	jQuery('body.checkout-multishipping-overview #virtual-overview-table tfoot tr').each(function(){
		jQuery(this).find('td:first').attr({
				colspan : 3
			});
	});
    jQuery('tfoot#review-totals tr').each(function(){
		jQuery(this).find('td:first').addClass('first');
        jQuery(this).find('td:last').addClass('last');
	}); 
    jQuery('div.my-account ol.additional-address').each(function(){
		jQuery(this).find('li:even').addClass('even');
	});
    jQuery('#checkoutSteps #opc-login').each(function(){
		jQuery('body').addClass('checkoutsteps-login-body')
    });
    jQuery('#review-totals tr').each(function(){
        var TempColor = jQuery(this);
		jQuery(this).find('th').each(function(){
            jQuery(TempColor).addClass('extra-red');
        });
    });
    jQuery('#review-totals tr').each(function(){
		jQuery(this).find('td:first').attr({
				colspan : 4
			});
        jQuery(this).find('td:last').addClass('last');
	});
    jQuery('div.page > ul.messages').each(function(){
		jQuery(this).find('li:first').append('<span class="close">close</span>');
        var TempMessage = jQuery(this);
        jQuery(this).find('span.close').click(function(){
            jQuery(TempMessage).css({'display':'none'});
        });
	});
    jQuery('div.page div.top-container div.event-container').each(function(){
		jQuery(this).append('<span class="close">close</span>');
        var TempMessage = jQuery(this);
        jQuery(this).find('span.close').click(function(){
            jQuery(TempMessage).css({'display':'none'});
        });
	});
 });
jQuery(window).load(function(){
    jQuery('table.cart-table td.card-wrapper-holder').each(function(){
		var cTemp = jQuery(this).height();
		var cTemp2 = jQuery(this).find('div.card-wrapper').height();
		var cTemp3 =cTemp - 7 -(Math.round((cTemp/2) - (cTemp2/2)));
		 jQuery(this).find('ul.action-list').css({
                'top' : cTemp3
            });
	});
});

