$(document).ready(function(){
	
	$('.newsWrapper .bg').css({opacity: '0.5'});
	
	$('.newsWrapper')
		.each(function(){
			$(this).hover(function(t){
					$(this).children('.bg').css({opacity: '0.3'});
					//alert($(this).width());
				},function(t){
					$(this).children('.bg').css('opacity', '0.5');
			});
		});
	
	/*	
	$('#paginadoNews #btn-prev, #paginadoNews #btn-next')
		.hover(function(){
				$(this).css('background-position','0 -20px');
				$('#msg').html($(this).attr('title'));
			},function(){
				$(this).css('background-position','0 0px');
				$('#msg').html('');
		})
		.click(function(){
			alert('No hay mas noticias.');
		});
	*/
	
	$('.sliderNews').each(function(){
		var datos 		= new Object();
		datos.movible 	= $(this).children('.slideContainer div').find('.movible');
		datos.btnPrev	= $('#btn-prev');
		datos.btnNext	= $('#btn-next');
		
		datos.sliderTotal = datos.movible.children().size();
		datos.sliderActual = 1;
		
		updateSlide(datos);
		
		datos.btnNext
			.click(function(){
				if(datos.sliderActual < datos.sliderTotal){
					datos.movible.animate({'left': '-=765px'}, 'fast');
					datos.sliderActual++;
					updateSlide(datos);
				}
			})
			.hover(function(){
					if(datos.sliderActual < datos.sliderTotal){
						$(this).css('background-position','0 -20px');
					}
				},function(){
					if(datos.sliderActual < datos.sliderTotal){
						$(this).css('background-position','0 0px');
					}
			});
		
		datos.btnPrev
			.click(function(){				
				if(datos.sliderActual > 1){
					datos.movible.animate({'left': '+=765px'}, 'fast');
					datos.sliderActual--;
					updateSlide(datos);
				}
			})
			.hover(function(){
					if(datos.sliderActual > 1){
						$(this).css('background-position','0 -20px');
					}
				},function(){
					if(datos.sliderActual > 1){
						$(this).css('background-position','0 0px');
					}
			});
	});
	
});


/*
|| Lanza el popup de la encuesta
||
*/
function openEncuesta(cual)
{
	window.open(cual,"mywindow","menubar=0,resizable=0,width=450,height=550");

}