/*################################## 
POWERED BY TRENDS Agência SEM
site: www.agenciatrends.com.br
fone:(11) 2338-4668 / 2308-4667
##################################*/

(function(c){c.fn.lightBox=function(b){b=jQuery.extend({overlayBgColor:'#DDD',overlayOpacity:0.8,fixedNavigation:true,imageLoading:'/biblioteca/lightbox/images/lightbox-ico-loading.gif',imageBtnPrev:'/biblioteca/lightbox/images/lightbox-btn-prev.gif',imageBtnNext:'/biblioteca/lightbox/images/lightbox-btn-next.gif',imageBtnClose:'/biblioteca/lightbox/images/lightbox-btn-close.gif',imageBlank:'/biblioteca/lightbox/images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},b);var p=this;function q(){r(this,p);return false}function r(a,d){c('embed, object, select').css({'visibility':'hidden'});s();b.imageArray.length=0;b.activeImage=0;if(d.length==1){b.imageArray.push(new Array(a.getAttribute('href'),a.getAttribute('title')))}else{for(var e=0;e<d.length;e++){b.imageArray.push(new Array(d[e].getAttribute('href'),d[e].getAttribute('title')))}}while(b.imageArray[b.activeImage][0]!=a.getAttribute('href')){b.activeImage++}g()}function s(){c('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+b.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+b.imageBtnClose+'"></a></div></div></div></div>');var e=j();c('#jquery-overlay').css({backgroundColor:b.overlayBgColor,opacity:b.overlayOpacity,width:e[0],height:e[1]}).fadeIn();var f=k();c('#jquery-lightbox').css({top:f[1]+(e[3]/10),left:f[0]}).show();c('#jquery-overlay,#jquery-lightbox').click(function(){h()});c('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){h();return false});c(window).resize(function(){var a=j();c('#jquery-overlay').css({width:a[0],height:a[1]});var d=k();c('#jquery-lightbox').css({top:d[1]+(a[3]/10),left:d[0]})})}function g(){c('#lightbox-loading').show();if(b.fixedNavigation){c('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide()}else{c('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide()}var a=new Image();a.onload=function(){c('#lightbox-image').attr('src',b.imageArray[b.activeImage][0]);t(a.width,a.height);a.onload=function(){}};a.src=b.imageArray[b.activeImage][0]};function t(a,d){var e=c('#lightbox-container-image-box').width();var f=c('#lightbox-container-image-box').height();var l=(a+(b.containerBorderSize*2));var m=(d+(b.containerBorderSize*2));var u=e-l;var v=f-m;c('#lightbox-container-image-box').animate({width:l,height:m},b.containerResizeSpeed,function(){w()});if((u==0)&&(v==0)){if(c.browser.msie){n(250)}else{n(100)}}c('#lightbox-container-image-data-box').css({width:a});c('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:d+(b.containerBorderSize*2)})};function w(){c('#lightbox-loading').hide();c('#lightbox-image').fadeIn(function(){x();y()});z()};function x(){c('#lightbox-container-image-data-box').slideDown('fast');c('#lightbox-image-details-caption').hide();if(b.imageArray[b.activeImage][1]){c('#lightbox-image-details-caption').html(b.imageArray[b.activeImage][1]).show()}if(b.imageArray.length>1){c('#lightbox-image-details-currentNumber').html(b.txtImage+' '+(b.activeImage+1)+' '+b.txtOf+' '+b.imageArray.length).show()}}function y(){c('#lightbox-nav').show();c('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+b.imageBlank+') no-repeat'});if(b.activeImage!=0){if(b.fixedNavigation){c('#lightbox-nav-btnPrev').css({'background':'url('+b.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){b.activeImage=b.activeImage-1;g();return false})}else{c('#lightbox-nav-btnPrev').unbind().hover(function(){c(this).css({'background':'url('+b.imageBtnPrev+') left 15% no-repeat'})},function(){c(this).css({'background':'transparent url('+b.imageBlank+') no-repeat'})}).show().bind('click',function(){b.activeImage=b.activeImage-1;g();return false})}}if(b.activeImage!=(b.imageArray.length-1)){if(b.fixedNavigation){c('#lightbox-nav-btnNext').css({'background':'url('+b.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){b.activeImage=b.activeImage+1;g();return false})}else{c('#lightbox-nav-btnNext').unbind().hover(function(){c(this).css({'background':'url('+b.imageBtnNext+') right 15% no-repeat'})},function(){c(this).css({'background':'transparent url('+b.imageBlank+') no-repeat'})}).show().bind('click',function(){b.activeImage=b.activeImage+1;g();return false})}}A()}function A(){c(document).keydown(function(a){B(a)})}function o(){c(document).unbind()}function B(a){if(a==null){keycode=event.keyCode;escapeKey=27}else{keycode=a.keyCode;escapeKey=a.DOM_VK_ESCAPE}key=String.fromCharCode(keycode).toLowerCase();if((key==b.keyToClose)||(key=='x')||(keycode==escapeKey)){h()}if((key==b.keyToPrev)||(keycode==37)){if(b.activeImage!=0){b.activeImage=b.activeImage-1;g();o()}}if((key==b.keyToNext)||(keycode==39)){if(b.activeImage!=(b.imageArray.length-1)){b.activeImage=b.activeImage+1;g();o()}}}function z(){if((b.imageArray.length-1)>b.activeImage){objNext=new Image();objNext.src=b.imageArray[b.activeImage+1][0]}if(b.activeImage>0){objPrev=new Image();objPrev.src=b.imageArray[b.activeImage-1][0]}}function h(){c('#jquery-lightbox').remove();c('#jquery-overlay').fadeOut(function(){c('#jquery-overlay').remove()});c('embed, object, select').css({'visibility':'visible'})}function j(){var a,d;if(window.innerHeight&&window.scrollMaxY){a=window.innerWidth+window.scrollMaxX;d=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){a=document.body.scrollWidth;d=document.body.scrollHeight}else{a=document.body.offsetWidth;d=document.body.offsetHeight}var e,f;if(self.innerHeight){if(document.documentElement.clientWidth){e=document.documentElement.clientWidth}else{e=self.innerWidth}f=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){e=document.documentElement.clientWidth;f=document.documentElement.clientHeight}else if(document.body){e=document.body.clientWidth;f=document.body.clientHeight}if(d<f){pageHeight=f}else{pageHeight=d}if(a<e){pageWidth=a}else{pageWidth=e}arrayPageSize=new Array(pageWidth,pageHeight,e,f);return arrayPageSize};function k(){var a,d;if(self.pageYOffset){d=self.pageYOffset;a=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){d=document.documentElement.scrollTop;a=document.documentElement.scrollLeft}else if(document.body){d=document.body.scrollTop;a=document.body.scrollLeft}arrayPageScroll=new Array(a,d);return arrayPageScroll};function n(a){var d=new Date();e=null;do{var e=new Date()}while(e-d<a)};return this.unbind('click').click(q)}})(jQuery);$(function(){$('#imgGallery a').lightBox()});function embeds(a,d,e){document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+d+'" height="'+e+'">');document.write('<param name="movie" value="'+a+'">');document.write('<param name="quality" value="high">');document.write('<param name="wmode" value="transparent">');document.write('<param name="menu" value="false">');document.write('<embed src="'+a+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+d+'" height="'+e+'" wmode="transparent"></embed>');document.write('</object>')}function action(a,d,e){alert("Campo "+d+" "+e+"!");a.elements[d].style.border="1px dotted #f00";a.elements[d].focus();return false}function valida(a){var d=new Array("nome","email","ddd","telefone");for(i=0;i<=d.length-1;i++){if(a.elements[d[i]].value=="")return action(a,[d[i]],"obrigatório");if([d[i]]=="email"){valido=/^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/;if(!valido.exec(a.elements[d[i]].value))return action(a,[d[i]],"inválido")}}}function showItemPagina(){document.formItensPagina.submit()}function confirmar(a){if(window.confirm(' Deseja realmente excluir? ')){document.getElementById("formApagar"+a).submit()}else{return}}function busca(a){a=document.formBusca.palavra.value;a=a.toLocaleLowerCase();a=a.replace("/","");a=a.replace(" /","");a=a.replace(" / ","");a=a.replace(" ","+");a=a.replace("  ","+");a=a.replace("   ","+");a=a.replace("    ","+");a=a.replace("     ","+");a=a.replace("      ","+");a=a.replace("       ","+");a=a.replace("        ","+");a=a.replace("         ","+");a=a.replace("          ","+");document.formBusca.action='/buscar/'+a;document.formBusca.submit()}function keyPress(){if(event.keyCode==13){busca()}}function lookup(d){if(d.length<3){$('#suggestions').hide()}else{$.post("/frontend/templates/busca-suggest.php",{queryString:""+d+""},function(a){if(a.length>3){$('#suggestions').show();$('#autoSuggestionsList').html(a)}})}}function fill(a){$('#inputString').val(a);setTimeout("$('#suggestions').hide();",200);palavra=a}function filtroProd(a,d,e,f){document.getElementById('idFab').value=a;document.getElementById('fabNome').value=d;document.getElementById('fabProd').value=e;document.getElementById('fabFiltro').value=f;document.formFiltroProd.submit()}

/* BUSCA LIMPAR CAIXA DE TEXTO */
function limpar  (objeto, msg) { if (objeto.value == msg)objeto.value = ''; }
function mostrar (objeto, msg) { if (objeto.value == '')objeto.value = msg; }


/* SLIDE DE PRODUTOS EM DESTAQUE */

$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 10}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 5 seconds
	setInterval('gallery()',5000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 9.0}, 1000);

	//Hide the current image
	current.animate({opacity: 4.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:200 }).animate({height: '70px'}, { queue:true, duration:400 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '50px'},400 );
	
	//Display the content
	$('#gallery .content').html(caption);
	
	
}