


function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function focus_input_text(obj){
	//alert( $(obj).val() +' - '+ $(obj).attr('rel') );
	if( $(obj).val() == $(obj).attr('rel') ){
		$(obj).val('');
	}
}
function blur_input_text(obj){
	//alert( $(obj).val() +' - '+ $(obj).attr('rel') );
	if( $(obj).val() == '' ){
		$(obj).val( $(obj).attr('rel') );
	}
}

function newslatter(email){
	carregar("iframe_news.php?email="+email,"receber_news");
}

function slideSwitch() {
	var $active = $('#slideshow IMG.active');

	if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

	// use this to pull the images in the order they appear in the markup
	var $next =  $active.next().length ? $active.next()
		: $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
}

function album(){
	// quantidade de albuns:
	var albuns_qtd = $('#home_albuns_list li').length;
	
	// pegar album atual:
	var active_album = $('#home_albuns_list .active:first').attr('id').replace('album_','');
	
	// definir qual será próximo álbum
	if( active_album < albuns_qtd ){
		var medida = $('#home_albuns_list_holder').width() * active_album;
		var prox_id = parseInt(active_album) + 1;
	}
	else{
		var medida = 0;
		var prox_id = 1;
	}
	
	//alert( prox_id );
	$('#home_albuns_list li').removeClass('active');
	$('#album_'+prox_id).addClass('active');
	$('#home_albuns_list').animate({left:'-'+medida},{queue:false,duration:800,easing:'swing'});
}

//remover imagem com erro
function remove_img(img){
	jQuery(img).remove();
}


jQuery(document).ready(function($){
	
	//Imagem Rollover
	$(".ro").mouseover(function(){
		var oversrc=$(this).attr("oversrc");
		$(this).attr("oversrc",$(this).attr("src"));
		$(this).attr("src",oversrc);
	});
	$(".ro").mouseout(function(){
		var src=$(this).attr("src");
		$(this).attr("src",$(this).attr("oversrc"));
		$(this).attr("oversrc",src);
	});
	
	// corrigir alinhamento deficiente do editor de texto.
	$('img').each(function(){
		
	});

	// menu
	$('#menu_principal li a').mouseover(function(){
		var query = $(this).attr('href');
		if( query == '?s=onde' || query == '?s=imprensa' ){
			query = '?s=nada.php';
		}
		carregar('categorias.php'+query, 'categorias');
	})
	
	$('#header h1, #header form, #content').mouseover(function(){
		if( $('#categorias').html() != '' ){
			carregar('categorias.php?s=nada.php', 'categorias');
		}
	});
	
	// destaque home
	if( $('#destaques_home').length > 0 ){
		// iniciar slideshow se tiver mais de uma imagem
		if( $('#slideshow img').length > 1 ){
			setInterval( "slideSwitch()", 5000 );
		}
	}
	
	if( $('#home_albuns').length > 0 ){
		
		// albuns home: scroll
		
			// adicionar class 'active' ao primeiro elemento
		$('#home_albuns_list li:first').addClass('active');
			// largura do holder
		$('#home_albuns_list').width($('#home_albuns_list li').length * $('#home_albuns_list li:first').width());
			// interval
		setInterval( "album()", 5000 );
	}
	
	
	// controle de tamanho de fonte
	if( $('#sizer').length > 0 ){
		dw_fontSizerDX.init();
	}
	
	// accordion
	$("#accordion").accordion({
		header: "h3",
		autoheight: false
	});
	
	// ficha
	if( $('#ficha_completa').length > 0 ){
		$('#ficha_content').slideUp();
		$('#ficha_open').addClass('close');
		$('#ficha_open').toggle(
			function(){
				$(this).removeClass('close');
				$('#ficha_content').slideDown();
			},
			function(){
				$(this).addClass('close');
				$('#ficha_content').slideUp();
			}
		);
		
		// google maps
		initialize();
	}
	
	// campo de texto da busca
	if( $('#nome').length > 0 ){
		$('#nome').focus(function(){
			focus_input_text( this );
		});
		$('#nome').blur(function(){
			blur_input_text( this );
		});
	}

});
