// ==============================================
// ibergres.pt 2006
// ==============================================
$(document).ready(function() {
var thumbs = 0, foto = $('#produto img')[0], produto = $('#produto');
$('.jcarousel-list a').each(function(i, trigger) {
thumbs += 1;
var thumb = $(trigger).children()[0], thumbCor = new Image();
thumbCor.src = thumb.src.replace('.jpg', '-cor.jpg');
$(trigger).click(function() {
if (thumb.src.replace('/thumbs', '').replace('-cor.jpg', '.jpg') == foto.src)
return false;
produto.addClass('loading');
$(foto).fadeOut('fast');
var preloader = new Image();
$(preloader).load(function() {
produto.animate({height: preloader.height}, 'fast', function() {
foto.src = preloader.src;
$(foto).attr('height', preloader.height).attr('width', preloader.width);
//alert(preloader.src);
$(foto).fadeIn('slow', function() {
produto.removeClass('loading');
$('#produto h4').html($(thumb).attr('alt'));
});
});
}).error(function() {
produto.removeClass('loading');
});
preloader.src = thumb.src.replace('/thumbs', '').replace('-cor.jpg', '.jpg');
return false;
});
$(trigger).hover(
function() { thumb.src = thumbCor.src; return false; },
function() {
thumb.src = thumbCor.src.replace('-cor.jpg', '.jpg');
return false;
}
);
});
if (thumbs > 6) {
$('#produtos').prepend(
$(document.createElement('div')).addClass('jcarousel-prev')).prepend(
$(document.createElement('div')).addClass('jcarousel-next')).jcarousel({
itemWidth : 90,
itemHeight : 80,
itemVisible: 6,
itemScroll: 5,
scrollAnimation: "slow",
nextButtonStateHandler: function() {},
prevButtonStateHandler: function() {}
});
$('.jcarousel-clip').css({
width: 510+'px',
margin: '0 0 0 19px'
});
}
var marcasList = $('#marcas ul')
var trigger = $(document.createElement('a')).attr('href', '').append('Marcas').click(function() {
marcasList.slideToggle('fast', function() {
if (marcasList.css('display') == 'none') {
createCookie('marcas.esconder', '1', 15);
} else {
eraseCookie('marcas.esconder');
}
});
return false;
});
$('#marcas').append($(document.createElement('h4')).append(trigger));
if (readCookie('marcas.esconder')) {
$('#marcas ul').hide();
}
$('#marcas ul a').attr('target', '_blank').click(function() {
if (this.href.indexOf('#') >= 0) return false;
});
$('#marcas ul img').each(function(i, img) {
var cor = new Image();
cor.src = img.src.replace('.jpg', '-cor.jpg');
}).hover(
function() { this.src = this.src.replace('.jpg', '-cor.jpg'); },
function() { this.src = this.src.replace('-cor.jpg', '.jpg'); }
);
});
