// 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){}

		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());
		console.log(alturaMax);
		$("#main #content .wrapper").css({"height":alturaMax+550}); 
	}




	function resizeWrapperTeste(){
		alturaMax = parseInt($("#main #content .wrapper #conteudo #miolo").innerHeight());
		console.log(alturaMax);
		$("#main #content .wrapper").css({"height":alturaMax+265}); 
	}
/**************************************************************/

jQuery(document).ready(function(){
	
	// mostra imagem inicial de destaque 
	$('#simple-slider li:first-child').show('slow').addClass("selected");
	
	// algoritimo que troca as imagens de destaque das paginas 
	setInterval(function(){
             if($('#simple-slider li:visible').length == 0)
                {
                   $('#simple-slider li:first-child').show('slow').addClass("selected");
                   // $(this).show("slow");
                   // $(this).addClass("selected");
                }
				else if ($('#simple-slider li').length == 1){
					return;
				}
                else{
                    var next = $('#simple-slider li.selected').next();
                    if( next.length == 0){
                        next = $('#simple-slider li:first-child');
                    } 
                    $('#simple-slider li.selected').fadeOut(300, function(){
                         next.addClass("selected").fadeIn(750);
                    }).removeClass("selected");
                   
                }
        }, 4000);
	
	//$('#simple-slider').simpleSlider();
	
	var flashvars = {
		URL_BASE: URL_BASE
		}
	var params = {
		quality: 'high',
		wmode: 'transparent'
	}
	var attributes = {
		}

	swfobject.embedSWF(URL_BASE + "swf/simulador.swf", 'simulador-content', '454', '244', '8.0.0', URL_BASE + "swf/expressInstall.swf", flashvars, params, attributes); 

});
