// JavaScript Document

function window_resize(){
	$('#topo-flash').css({
		'width': parseInt($('#content').innerWidth() - parseInt($('#content').innerWidth() / 2)) + 'px'
	});
}

function resize_flash(up){          
     up = up || false;     
     $('#topo-flash').css({
          height: (up ? 420 : 700)
     });
}

$(document).ready(function(){
	$('a[rel=external]').attr('target', '_blank');	
     resizeWrapper();
     try {
          $('a[rel=lightbox]').lightBox({
               imageLoading: URL_BASE + 'img/lightbox/lightbox-ico-loading.gif',               
               imageBtnPrev: URL_BASE + 'img/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image               
				imageBtnNext: URL_BASE +'img/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
				imageBtnClose:URL_BASE +'img/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
				imageBlank:   URL_BASE + 'img/lightbox/lightbox-blank.gif',
               txtImage: 'Imagem', 
               txtOf:'de'
          });
			
     } catch (err){}
     
	$('#topo-flash').media({
		width: '100%',
		height: '100%',
		src: URL_BASE + "swf/topo_home.swf",          
		autoplay: true,
		params: {
			quality: 'high',
			wmode: 'transparent'
		}, 		
		flashvars: {
			URL_BASE: URL_BASE
		}
	}),

	$('#main #content #destaques-home').media({
		width: 442,
		height: 446,
		src: URL_BASE + "swf/destaques.swf",          
		autoplay: true,
		params: {
			quality: 'high',
			wmode: 'transparent'
		}, 		
		flashvars: {
			URL_BASE: URL_BASE
		}
	}),$('#main #content .wrapper #barra-lateral #imagem-destaque').media({
		width: 400,
		height: 245,
		src: URL_BASE + "swf/slide_internas.swf",          
		autoplay: true,
		params: {
			quality: 'high',
			wmode:'transparent'
		}, 		
		flashvars: {
			URL_BASE: URL_BASE,
			CURRENT_VIEW: CURRENT_VIEW
		}
          
        }),$('#main #content .wrapper #conteudo #miolo #simulador').media({
		width: 454,
		height: 244,
		src: URL_BASE + "swf/simulador.swf",          
		autoplay: true,
		params: {
			quality: 'high',
			wmode: 'transparent'
		}, 		
		flashvars: {
			URL_BASE: URL_BASE
		}
	});
	
	window_resize();
	$(window).bind('resize', function(){window_resize()});
});

		var size = $('.wrapper #conteudo #miolo').css('font-size');	
		size = (parseInt(size));
		var alturaMax;
				
		$('.wrapper #conteudo #miolo .zoom a#zoom_out').click(function(e){
			e.preventDefault();						
			if(size > 11){
				size--;	
				$('.wrapper #conteudo #miolo').css({'font-size':size+'px'});
                    resizeWrapper();
			}
		});
		
		$('.wrapper #conteudo #miolo .zoom a#zoom_in').click(function(e){
			e.preventDefault();			
				
			if(size < 15){
				size++;
				$('.wrapper #conteudo #miolo').css({'font-size':size+'px'});
                    resizeWrapper();
                    
			}
		});
          
          function resizeWrapper(){
               alturaMax = parseInt($("#main #content .wrapper #conteudo #miolo").innerHeight());
               //alert(alturaMax);
               $("#main #content .wrapper").css({"height":alturaMax+350}); 
          }