$(document).ready(function() {
   // slider hero
$.featureList(
				$("#tabs li a"),
				$("#output li"), {
					start_item	:	0
				}
			);
	//default elements to be removed					   
$("#line1, #line2, td.bar, td.g, td.l, #topbar, .leftnav-col").remove();
										 
$("img").each(function(i){
			if($(this).attr("src").indexOf("1.gif")!=-1) {
					$(this).remove();
			}  
});
		
$("table").each(function(i){
			$(this).attr('cellpadding','0');
			$(this).attr('cellspacing','0');	
});
		
$("td").each(function(i){
			if($(this).attr("width")== '10') {
					$(this).remove();
	}  
			if($(this).attr("width")== '16') {
					$(this).remove();
	} 
			if($(this).attr("width")== '100%') {
					$(this).attr('width','');
	}
			if($(this).attr("align")== 'right') {
					$(this).attr("align","left");
	}  
});

$("#bgmdlcontent").append($("table.content"));
$("table.main").remove();
$("table.content").children().children().children().children("table").attr("id","maincontenttable");
$("tr#dataNames").next().children().attr('style','padding-top:10px');
$("a#safeandsecureA").parent().attr('id','secure');
$("img").each(function(i){
			if($(this).attr("title").indexOf("Continue Shopping")!=-1) {
					$(this).parent().parent().attr('id','continueshop');
			}  
		});

$("table.dataTable tr:last").children('td').eq(0).attr('class','total');
$("td.total").parent('tr').attr('id','total');


/*dropdown*/


});

/*home page lower slider*/
$.fn.infiniteCarousel = function () {

    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        var $wrapper = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
            
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), 
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * n;
            
            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
					
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;
				
            });                
            
            return false;
        }
        
        $wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');
        
        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);     
			
			
        });
        
        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
			
        });
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
		
		
    });  
};

$(document).ready(function () {
$('.infiniteCarousel').infiniteCarousel();
$(".productdiv").hover(function(){
$(".buynow").attr('style','display:block');
$(this).append($(".buynow"));
linkurl = $(".buynow").parent().children("a").attr("href");
$(".buynow").children("a#buyaltoids").attr("href",linkurl);
}, 
  function () {
 $(".buynow").attr('style','display:none');
  }
);
test = $(".buynow").parent().children("a").attr("href");
$(".buynow").parent("a#buyaltoids").attr("href",test);

/*facebook*/
$('html').attr('xmlns','http://www.w3.org/1999/xhtml');
$('html').attr('lang','en');
$('html').attr('xml:lang','en');
$('html').attr('xmlns:fb','http://www.facebook.com/2008/fbml');
$('html').attr('xmlns:og','http://opengraphprotocol.org/schema/');

/*product detail page*/
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51yW-AJnDRL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/prod1.png');
	
	$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/peppermint.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/peppermint.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	
	}

if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51pgNp71hlL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/prod2.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/wintergreen.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/wintergreen.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51Ky6XKqX4L._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/prod3.png');
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/cinnamon.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/cinnamon.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	
	}

if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/41aCcMMxTmL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/prod4.png');
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/spearmint.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/spearmint.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/31z6GbEHSjL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/producthoney.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/producthoney.png","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/producthoney.png","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/31DlsW-af3L._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/productcreme.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/productcreme.png","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/productcreme.png","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51aA3nvMAfL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/prod5.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/liquorice.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/liquorice.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51thuwybVcL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/prod6.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/ginger.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/ginger.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/31W5kTw65mL._SL150_.jpg'){
	
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/productpepSmall.png');
	
	$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/productpepSmall.png","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/productpepSmall.png","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
		
}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51cpRmIDb3L._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/productwintSmall.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/wintergreensmall.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/wintergreensmall.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/51gT-1LvLfL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/productcinSmall.png');
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/cinnamonsmall.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/cinnamonsmall.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	
	}
	
if($('#productImage').attr('src') == 'http://ecx.images-amazon.com/images/I/41psycLI6WL._SL150_.jpg'){
	$('#productImage').attr('src','http://wm-wrigley-jr-company3.amazonwebstore.com/images/simplemint.png');
	
		$('#productImage').parent().removeAttr('onclick');
	$('#productImage').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/simplemint.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})

	$('img.wba_zoom_btn').parent().removeAttr('onclick');
	$('img.wba_zoom_btn').parent().click(function(){
	window.open("http://wm-wrigley-jr-company3.amazonwebstore.com/images/simplemint.gif","mywindow","toolbar=no,location=no,status=no,titlebar=no,scrollbars=no,resizable=1,width=700,height=570");
	})
	
	}
});




	

