/**
 * @author Erivaldo Alves de Oliveira Junior
 * @version 1.0
 * @mail junemil@gmail.com / esc326@msn.com
**/

// JavaScript Document
$(function(){
	$('div#noticiasContent').bind('mouseenter',function(){
		$('div.menuNoticias', $(this)).slideDown(1000);
	}).bind('mouseleave',function(){
		$('div.menuNoticias', $(this)).slideUp(1000);
	});
	
	startNoticias();
	
	$cont = 0;

	$('div#noticiasContent div.noticias').each(function(i){
		$cont++;
	});
	
	
});

startNoticias = function(){
	$item = 0;	
	$('div#contentNews div#showNews div').hide(0);
	$('div#contentNews div#showNews div#news0').show(0);
	$('div#contentNews div#itemNews div#item0').addClass('select');
	$('div#contentNews div#showNews div#news0 div.textoNews').show(1000);

	$('div#contentNews div#itemNews div.item').bind('click',function(){
		$item = $(this).attr('target');
		
		$('div#contentNews div#showNews div.news div.textoNews').hide(0);
		$('div#contentNews div#showNews div.news').hide(0);
		$('div#contentNews div#showNews div#news' + $item).show(0);
		$('div#contentNews div#itemNews div.item').removeClass('select');
		$('div#contentNews div#itemNews div#item' + $item).addClass('select');
		$('div#contentNews div#showNews div#news' + $item + ' div.textoNews').show(1000);
	});
	
	$('div#contentNews div#showNews div.news img').bind('click',function(){
		window.open('?p=noticias_detalhes&id=' + $(this).attr('target'), '_self');
	});
	
	$('div#contentNews div#showNews div.news div.textoNews').bind('click',function(){
		window.open('?p=noticias_detalhes&id=' + $(this).attr('target'), '_self');
	});
		
	setInterval(function(){
		$cont = 2;
		if ($item < $cont)
			$item++;
		else
			$item = 0;
			
		$('div#contentNews div#showNews div.news div.textoNews').hide(0);
		$('div#contentNews div#showNews div.news').hide(0);
		$('div#contentNews div#showNews div#news' + $item).show(0);
		$('div#contentNews div#itemNews div.item').removeClass('select');
		$('div#contentNews div#itemNews div#item' + $item).addClass('select');
		$('div#contentNews div#showNews div#news' + $item + ' div.textoNews').show(1000);
	}, 10000);	
}