$(document).ready(function(){
	if( typeof $.prettyPhoto != 'undefined' ) $("#conteudo a[rel^=prettyPhoto]").prettyPhoto({theme:'light_square'});

	$('#FormBuscaTextoTopo').parseFormNoLabels();
	
	$("#TextoKeysTopo").focus(function () {
		if($('#TextoKeysTopo').val() == 'Buscar no site'){
			$('#TextoKeysTopo').val('');
		}
	});
	$("#TextoKeysTopo").blur(function () {
		if($('#TextoKeysTopo').val() == ''){
			$('#TextoKeysTopo').val('Buscar no site');
		}
	});
	
	// slides de destaques de noticias
	$('#topo div.globalSuperiorEsquerdo ul').SlidesTopo();
	$('#topo div.oferecimento ul').SlidesOferecimento();
	$('#colunaAuxiliar div.bannerSuperior ul').SlidesAuxiliar();
	$('#playerCompleto div.anuncio ul').SlidesPlayer();
	
	// menu Difusora 910
	$('#topo ul.navegacao li.difusora910 a').click( function( evt ){
		evt.preventDefault();
	});
	$('#topo ul.navegacao li.difusora910 a').mouseover( function(){
		$('#topo div.navegacaoDifusora910').css( 'display','block');
	});
	$('#topo div.navegacaoDifusora910').mouseover( function(){
		$('#topo div.navegacaoDifusora910').css( 'display','block');
	});
	$('#topo ul.navegacao li.difusora910 a').mouseout( function(){
		$('#topo div.navegacaoDifusora910').css( 'display','none');
	});
	$('#topo div.navegacaoDifusora910').mouseout( function(){
		$('#topo div.navegacaoDifusora910').css( 'display','none');
	});

	
	// msn dropdown 
	$('#topo div.redesSociais li.msn a').click( function( evt ){
		evt.preventDefault();
	});
	$('#topo div.redesSociais li.msn a').mouseover( function(){
		$('#apareceMsn').css( 'display','block');
	});
	$('#topo div.redesSociais li.msn a').mouseout( function(){
		$('#apareceMsn').css( 'display','none');
	});
	$('#apareceMsn').mouseover( function(){
		$('#apareceMsn').css( 'display','block');
	});
	$('#apareceMsn').mouseout( function(){
		$('#apareceMsn').css( 'display','none');
	});
	
	Saf=/a/.__proto__=='//';
	if(Saf==true){
		$('#topo ul.navegacao li').addClass('saf');
	}
	
	/************Menu Select Player**************/
	$(".ouvir").click(function(evt){
		evt.preventDefault();
		location.href = $("#players").val();
	});
	
});

// Usabilidade (aumentar/diminuir fonte)
var tam = 12;

function mudaFonte(tipo,elemento){
	if (tipo=='mais') {
		if(tam<45) tam+=1;
	//	tam+=1;
		createCookie('fonte',tam,365);
	} else {
		if(tam>9) tam-=1;
	//	tam-=1;
		createCookie('fonte',tam,365);
	}
	$('.corpo').css('font-size',tam+'px');
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+date.toGMTString();
	} else var expires = '';
	document.cookie = name+'='+value+expires+'; path=/';
}

function readCookie(name) {
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

(function ($) {
// PARSE FORM NO LABELS
$.fn.parseFormNoLabels = function() {
	return this.each(function(i){
	var f = $(this);
	f.addClass( 'parsed' );
	f.find( 'label' ).css( {'position':'absolute', 'cursor':'text', 'display':'block' });
	f.find( 'input[type=text], select' ).each( function(){ this.label=$('label[for='+this.id+']'); } );
	f.find( 'input[type=text], select' ).focus( function() { $(this.label).css('opacity','0.5'); } );
	f.find( 'input[type=text], select' ).blur( function() { $(this.label).css('opacity','1'); } );
	f.find( 'input[type=text], select' ).bind( 'keyup change', function() {
		if( $(this).val() ) $(this.label).css('display','none');
		else $(this.label).css('display','inline');
	} );
	});
};
})(jQuery);


(function($) {

	$.SlidesTopo = {
		tempo			:	15000,
		itensControle	:	[],
		atual			:	0,
		interval		:	null,
		imgs			:	[],
		tgt				:	null
	};

	$.fn.SlidesTopo = function(settings) {

		if (settings) $.extend($.SlidesTopo, settings);

		var ulOriginal = $(this).addClass( 'js' );




		ulOriginal
			.mouseover( interrompeTempo )
			.mouseout( iniciaTempo );


		$.SlidesTopo.tgt = ulOriginal.find( 'li' );

		$.SlidesTopo.tgt.css('display','none');



/*
		// criando os controles
		ulOriginal.after( '<div id="SlidesTopoControle"></div>' );

		var controle = $('#SlidesTopoControle');
		var ht = '';
		for( var i=0, l=$.SlidesTopo.tgt.length; i<l; i++ ) {
			ht += '<a href="javascript:;" rel="'+ i +'">'+ (i+1) +'</a>';
		}

		controle.html( ht );

		$('a', controle).click( function() {
			trocaSlide( parseFloat($(this).attr('rel')) );
		} );
 */

		trocaSlide( 0 );

		return this;


	};


	var proximo = function() { trocaSlide( $.SlidesTopo.atual+1 ); }
	var anterior = function() { trocaSlide( $.SlidesTopo.atual-1 ); }

	var iniciaTempo = function() { $.SlidesTopo.interval = setTimeout( proximo, $.SlidesTopo.tempo ); }
	var interrompeTempo = function() { clearTimeout( $.SlidesTopo.interval ); }


	var trocaSlide = function( slide )
	{

		if( slide > $.SlidesTopo.tgt.length-1 ) slide = 0;
		if( slide < 0 ) slide = $.SlidesTopo.tgt.length-1;

		$.SlidesTopo.atual = slide;

		var atual = $( $.SlidesTopo.tgt[$.SlidesTopo.atual] );
		
		
		$.SlidesTopo.tgt.each( function(){
			if( this != $.SlidesTopo.tgt[$.SlidesTopo.atual] ){
				$(this).css('display','none'); //IE8
				$(this).fadeOut();
			}
		} );


		atual.fadeIn();

		interrompeTempo();
		iniciaTempo();

	/*	$('#SlidesTopoControle a').removeClass('atual');
		$('#SlidesTopoControle a[rel='+ slide +']').addClass('atual');*/
		
	}

})(jQuery);


(function($) {
	
	$.SlidesOferecimento = {
			tempo			:	5000,
			itensControle	:	[],
			atual			:	0,
			interval		:	null,
			imgs			:	[],
			tgt				:	null
	};
	
	$.fn.SlidesOferecimento = function(settings) {
		
		if (settings) $.extend($.SlidesOferecimento, settings);
		
		var ulOriginal = $(this).addClass( 'js' );
		
		
		
		
		ulOriginal
		.mouseover( interrompeTempo )
		.mouseout( iniciaTempo );
		
		
		$.SlidesOferecimento.tgt = ulOriginal.find( 'li' );
		
		$.SlidesOferecimento.tgt.css('display','none');
		
		
		
		/*
		// criando os controles
		ulOriginal.after( '<div id="SlidesOferecimentoControle"></div>' );

		var controle = $('#SlidesOferecimentoControle');
		var ht = '';
		for( var i=0, l=$.SlidesOferecimento.tgt.length; i<l; i++ ) {
			ht += '<a href="javascript:;" rel="'+ i +'">'+ (i+1) +'</a>';
		}

		controle.html( ht );

		$('a', controle).click( function() {
			trocaSlide( parseFloat($(this).attr('rel')) );
		} );
		 */
		
		trocaSlide( 0 );
		
		return this;
		
		
	};
	
	
	var proximo = function() { trocaSlide( $.SlidesOferecimento.atual+1 ); }
	var anterior = function() { trocaSlide( $.SlidesOferecimento.atual-1 ); }
	
	var iniciaTempo = function() { $.SlidesOferecimento.interval = setTimeout( proximo, $.SlidesOferecimento.tempo ); }
	var interrompeTempo = function() { clearTimeout( $.SlidesOferecimento.interval ); }
	
	
	var trocaSlide = function( slide )
	{
		
		if( slide > $.SlidesOferecimento.tgt.length-1 ) slide = 0;
		if( slide < 0 ) slide = $.SlidesOferecimento.tgt.length-1;
		
		$.SlidesOferecimento.atual = slide;
		
		var atual = $( $.SlidesOferecimento.tgt[$.SlidesOferecimento.atual] );
		
		
		$.SlidesOferecimento.tgt.each( function(){
			if( this != $.SlidesOferecimento.tgt[$.SlidesOferecimento.atual] ){
				$(this).css('display','none'); //IE8
				$(this).fadeOut();
			}
		} );
		
		
		atual.fadeIn();
		
		interrompeTempo();
		iniciaTempo();
		
		/*	$('#SlidesOferecimentoControle a').removeClass('atual');
		$('#SlidesOferecimentoControle a[rel='+ slide +']').addClass('atual');*/
		
	}
	
})(jQuery);


(function($) {
	
	$.SlidesAuxiliar = {
			tempo			:	15000,
			itensControle	:	[],
			atual			:	0,
			interval		:	null,
			imgs			:	[],
			tgt				:	null
	};
	
	$.fn.SlidesAuxiliar = function(settings) {
		
		if (settings) $.extend($.SlidesAuxiliar, settings);
		
		var ulOriginal = $(this).addClass( 'js' );
		
		
		
		
		ulOriginal
		.mouseover( interrompeTempo )
		.mouseout( iniciaTempo );
		
		
		$.SlidesAuxiliar.tgt = ulOriginal.find( 'li' );
		
		$.SlidesAuxiliar.tgt.css('display','none');
		
		
		
		/*
		// criando os controles
		ulOriginal.after( '<div id="SlidesAuxiliarControle"></div>' );

		var controle = $('#SlidesAuxiliarControle');
		var ht = '';
		for( var i=0, l=$.SlidesAuxiliar.tgt.length; i<l; i++ ) {
			ht += '<a href="javascript:;" rel="'+ i +'">'+ (i+1) +'</a>';
		}

		controle.html( ht );

		$('a', controle).click( function() {
			trocaSlide( parseFloat($(this).attr('rel')) );
		} );
		 */
		
		trocaSlide( 0 );
		
		return this;
		
		
	};
	
	
	var proximo = function() { trocaSlide( $.SlidesAuxiliar.atual+1 ); }
	var anterior = function() { trocaSlide( $.SlidesAuxiliar.atual-1 ); }
	
	var iniciaTempo = function() { $.SlidesAuxiliar.interval = setTimeout( proximo, $.SlidesAuxiliar.tempo ); }
	var interrompeTempo = function() { clearTimeout( $.SlidesAuxiliar.interval ); }
	
	
	var trocaSlide = function( slide )
	{
		
		if( slide > $.SlidesAuxiliar.tgt.length-1 ) slide = 0;
		if( slide < 0 ) slide = $.SlidesAuxiliar.tgt.length-1;
		
		$.SlidesAuxiliar.atual = slide;
		
		var atual = $( $.SlidesAuxiliar.tgt[$.SlidesAuxiliar.atual] );
		
		
		$.SlidesAuxiliar.tgt.each( function(){
			if( this != $.SlidesAuxiliar.tgt[$.SlidesAuxiliar.atual] ){
				$(this).css('display','none'); //IE8
				$(this).fadeOut();
			}
		} );
		
		
		atual.fadeIn();
		
		interrompeTempo();
		iniciaTempo();
		
		/*	$('#SlidesAuxiliarControle a').removeClass('atual');
		$('#SlidesAuxiliarControle a[rel='+ slide +']').addClass('atual');*/
		
	}
	
})(jQuery);

(function($) {
	
	$.SlidesPlayer = {
			tempo			:	15000,
			itensControle	:	[],
			atual			:	0,
			interval		:	null,
			imgs			:	[],
			tgt				:	null
	};
	
	$.fn.SlidesPlayer = function(settings) {
		
		if (settings) $.extend($.SlidesPlayer, settings);
		
		var ulOriginal = $(this).addClass( 'js' );
		
		
		
		
		ulOriginal
		.mouseover( interrompeTempo )
		.mouseout( iniciaTempo );
		
		
		$.SlidesPlayer.tgt = ulOriginal.find( 'li' );
		
		$.SlidesPlayer.tgt.css('display','none');
		
		
		
		/*
		// criando os controles
		ulOriginal.after( '<div id="SlidesPlayerControle"></div>' );

		var controle = $('#SlidesPlayerControle');
		var ht = '';
		for( var i=0, l=$.SlidesPlayer.tgt.length; i<l; i++ ) {
			ht += '<a href="javascript:;" rel="'+ i +'">'+ (i+1) +'</a>';
		}

		controle.html( ht );

		$('a', controle).click( function() {
			trocaSlide( parseFloat($(this).attr('rel')) );
		} );
		 */
		
		trocaSlide( 0 );
		
		return this;
		
		
	};
	
	
	var proximo = function() { trocaSlide( $.SlidesPlayer.atual+1 ); }
	var anterior = function() { trocaSlide( $.SlidesPlayer.atual-1 ); }
	
	var iniciaTempo = function() { $.SlidesPlayer.interval = setTimeout( proximo, $.SlidesPlayer.tempo ); }
	var interrompeTempo = function() { clearTimeout( $.SlidesPlayer.interval ); }
	
	
	var trocaSlide = function( slide )
	{
		
		if( slide > $.SlidesPlayer.tgt.length-1 ) slide = 0;
		if( slide < 0 ) slide = $.SlidesPlayer.tgt.length-1;
		
		$.SlidesPlayer.atual = slide;
		
		var atual = $( $.SlidesPlayer.tgt[$.SlidesPlayer.atual] );
		
		
		$.SlidesPlayer.tgt.each( function(){
			if( this != $.SlidesPlayer.tgt[$.SlidesPlayer.atual] ){
				$(this).css('display','none'); //IE8
				$(this).fadeOut();
			}
		} );
		
		
		atual.fadeIn();
		
		interrompeTempo();
		iniciaTempo();
		
		/*	$('#SlidesPlayerControle a').removeClass('atual');
		$('#SlidesPlayerControle a[rel='+ slide +']').addClass('atual');*/
		
	}
	
})(jQuery);
