var timer;
$(document).ready( function() {
    $('.cat_header_fade').innerfade({
	    speed: 2000,
	    timeout: 5000,
	    type: 'sequence',
	    containerheight: '151px'
    });
    $('a[rel="external"]').attr("target", "_blank");
    $(".panel").hover(function() {
	clearTimeout(timer);
	$(this).animate({top: '17px'}, 100);
        $(this.firstChild).animate({opacity: '1.0'}, 100);
    },function() {
    timer = setInterval(highlight_cases, 2000);
	$(this).animate({top: '30px'}, 200);
        $(this.firstChild).animate({opacity: '0.4'}, 100);
    });
    $('.newsheaderimage').corners("8px transparent top");
    $('.productlist').corners("4px");
    $('#contact_form').corners("8px");
    $('.productlist h4').corners("4px transparent top");
    $('#showcase').corners("8px transparent top");
    $('h3.main').corners("4px transparent top");
    $('li.main').prev('.sub').children().corners("4px transparent bottom");
    $('li.main').prev('.sub').css('margin-bottom','5px');
    $('.category_navigation li:last a').corners("4px transparent bottom");
    $('#gallery a').lightBox({
	fixedNavigation:true,
	imageLoading: '/assets/images/lightbox-ico-loading.gif',
	imageBtnClose: '/assets/images/lightbox-btn-close.gif',
	imageBtnPrev: '/assets/images/lightbox-btn-prev.gif',
	imageBtnNext: '/assets/images/lightbox-btn-next.gif'
	});
    timer = setInterval(highlight_cases, 2000);
});

var last_highlight = 0;
var current_highlight = 0;

function highlight_cases() {
    $(".panel").each(
	function(intIndex) {
	    if(intIndex==last_highlight) {
		//if($(this.firstChild).css("opacity")=='0.4') {
		    $(this.firstChild).animate({opacity: '1.0'}, 500);
		    current_highlight = intIndex;
		//}
	    } else {
		if($(this.firstChild).css("opacity")=='1') {
		    $(this.firstChild).animate({opacity: '0.4'}, 0);   
		}
	    }
	}
    );
    if(current_highlight==6) {
	last_highlight = 0;
    } else { 
	last_highlight = current_highlight+1;
    }
}
