$(document).ready(function() {
    $.switcher = {
	initialFrequency: 5000,
	animTime: 1500,
	
	init: function(){
	    var $banners = $('.header_image');
	    $banners.not(':first').css('opacity', 0).hide();
	    window.setTimeout($.switcher.fadeNext, $.switcher.initialFrequency);
	},
	
	fadeNext: function(){
	    var $banners = $('.header_image');
	    var $current = $('.header_image:visible');
	    var current_index = $banners.index($current);
	    var next = $banners[current_index + 1] === undefined ? $banners[0]:$banners[current_index + 1];
	    
	    $current.animate({'opacity':0}, $.switcher.animTime, function(){
		$(this).hide();
		$(next).show().animate({'opacity':1}, $.switcher.animTime, function(){
		    window.setTimeout($.switcher.fadeNext, $.switcher.initialFrequency);
		});
	    });
	}
    };
    
    $.switcher.init();
    
    //$('a.popout').each(function(){
    //    $this = $(this);
    //    if(!$this.parent('.Product_Categories').length){
    //        $this.fancybox({ 'titleShow':false });
    //    }else{
    //       $this.remove();
    //    }
    //});
    
//    $('div.product-details').each(function(i,div){
//        var $this = $(this);
//	if(!$this.hasClass('Product_Categories')){
//	    var link = $this.find('h1').children('a');
//	    var text = link.text();
//	    link.parent('h1').html(text);    
//	    
//	    $this.next('.product-details-image').each(function(){
//		var img = $(this).find('img');
//		img.unwrap();
//	    });
//	}
//    });
});
