$(document).ready(function(){
	// links com target blank
	$('a[class*=blank]').click( function() {
        window.open(this.href);
        return false;
    });
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animation_speed:'normal',
		opacity: 0.80
	});
	
	// Fundo randômico
	var img = ['bg_1.jpg', 'bg_2.jpg', 'bg_3.jpg', 'bg_4.jpg', 'bg_5.jpg', 'bg_6.jpg', 'bg_7.jpg', 'bg_8.jpg', 'bg_9.jpg'];
	var x = parseInt(Math.floor(Math.random()*img.length));
	var bg = "url(http://www.vasco.com.br/site/public/images/" + img[x] + ")";
	$('html').css('background-image', bg);
	
	//classe "last" em todo fim de lista
	$('ul li:last-child').addClass('last');
	
	//efeito em botoes prev / next
	$('.bt_prev').not('#galeria_jogador .bt_prev').mouseenter(function(){
		$(this).animate({left: '-=2'}, 100);
	}).mouseleave(function(){
		$(this).animate({left: '+=2'}, 100);
	});
	$('.bt_next').not('#galeria_jogador .bt_next').mouseenter(function(){
		$(this).animate({right: '-=2'}, 100);
	}).mouseleave(function(){
		$(this).animate({right: '+=2'}, 100);
	});
	
	//cantos arendondados
	var corner_fields = '#abas_internas .abas a, #patrocinadores';
	if ($(corner_fields)[0]){
		$(corner_fields).corner("8px");
	}
	
	// Menu
	$('#menu ul li a').mouseenter(function(){
		$(this).addClass('active');
		$(this).parent('li').children('ul').slideDown(200);
	});
	$('#menu ul li').mouseleave(function(){
		$(this).children('a').removeClass('active');
		$(this).children('ul').slideUp(200);
	});
	
	//hover em �ltimas not�cias
	$('#noticias article').mouseenter(function(){
		$(this).addClass('hover');
	}).mouseleave(function(){
		$(this).removeClass('hover');
	});
	
	//Abas - Vasco na Rede
	$('nav#abas ul li').click(function(){
		var box = $(this).attr('title');
		$('#content-box').children('div').hide(100);
		$('nav#abas ul li').removeClass('active');
		$('#content-box div#box-'+box).show(100);
		$(this).addClass('active');
	});
	
	
	// Menu Lateral
	$('#menu_lateral ul li a').click(function(){
		$(this).parent('li').children('ul').slideToggle();												  
	});
        

        // Animação de zoom nas classes zoom
		$('p img.zoom').each(function(index, value) {
			w = $(this).width() / 2;
			h = $(this).height() / 2;
			
			html  = "<span class='zoom' id='zoom-0"+index+"'>";
			html += "<img src='" + $(this).attr('src') + "' width='"+w+"' height='"+h+"' />";
			html += "</span>";
			
			$(this).replaceWith(html);

			$('#zoom-0'+index).css({"width":w,"height":h}); 

		});
		
		$("p span.zoom").hover(function() {
			$(this).css({'z-index' : '10'});
			$(this).find('img').addClass("hover").stop()
				.animate({
					marginTop: '-' + $(this).height() + 'px', 
					marginLeft: '-' + $(this).width() + 'px', 
					top: '50%', 
					left: '50%', 
					width: $(this).width() * 2, 
					height: $(this).height() * 2
				}, 200);
			
			} , function() {
			$(this).css({'z-index' : '0'});
			$(this).find('img').removeClass("hover").stop()
				.animate({
					marginTop: '0', 
					marginLeft: '0',
					top: '0', 
					left: '0', 
					width: $(this).width(), 
					height: $(this).height()
				}, 400);
		});
   

        
        
	
	// LINHA DO TEMPO
	$('.ano .header .hgroup .bt_abre').click(function(){
			$(this).addClass('nodisplay');
			$(this).parent('.hgroup').children('.bt_fecha').removeClass('nodisplay');
			//$(this).parent('.hgroup').parent('.header').parent('.ano').children('.texto_linha').slideDown(500);
			$(this).parent('.hgroup').parent('.header').parent('.ano').children('.texto_linha').removeClass('nodisplay');
	});
	$('.ano .header .hgroup .bt_fecha').click(function(){
			$(this).addClass('nodisplay');
			$(this).parent('.hgroup').children('.bt_abre').removeClass('nodisplay');
			//$(this).parent('.hgroup').parent('.header').parent('.ano').children('.texto_linha').hide(500);
			$(this).parent('.hgroup').parent('.header').parent('.ano').children('.texto_linha').addClass('nodisplay');
	});
        
        //$('a.media').media();
	
	// Lista de Jogos
	$('#jogos_meses').change(function(){
		var link = $(this).attr("value");
		if (link.length != 0) {
			window.location.href = link;
		}
	});
	
	// abrir e fechar objetos\\
	
	$('.objectOpen').click(function(){
		var abrir = $(this).attr("rel");
		$('#'+abrir).toggle(500);
	});
	
});
