
	/*
	Front-end Developer
	@Mikael Carrara (http://www.mikaelcarrara.com)
	*/

	jQuery(document).ready(function(){

		$('div#gameNews ul li:last-child, ul#eventos li:last-child, ul#posts li:last-child, ul#posts2 li:last-child, ul.solicitacoes li:last-child, ul#friendsList li:last-child, ul#bannersAdm li:last-child, ul#bannersLocals li:last-child').css({margin:'0',padding:'0',border:'none'});
		$('ul.balaoLista li.premio:odd, ul#creditos li:last-child, div.category ul li:eq(5), div.category ul li:eq(11), div.category ul li:eq(17), div.category ul li:eq(23), div.category ul li:eq(29), div.category ul li:eq(35), ul#news li:eq(2), ul#news li:eq(5), ul#mesa li:eq(1), ul#diGames li a:eq(1), ul#blocos li:eq(1)').css('margin-right','0');
		$('ul.balaoLista li.premio:gt(3), ul.gamesLista li:last-child, ul.balaoLista li:last-child, ul.myProjects li:last-child, ul.analises li:last-child').css('margin-bottom','0');
		
		$('ul.balaoLista li.user:eq(2), ul.balaoLista li.user:eq(5), ul.balaoLista li.user:eq(8), ul#acompAdm li:eq(2), ul#acompAdm li:eq(5), ul#acompAdm li:eq(8), ul#gameModTutorials li:eq(2), ul#gameModTutorials li:eq(5), ul#gameModTutorials li:eq(8), ul#gameModTutorials li:eq(11), ul#gameModTutorials li:eq(14)').css('margin-right','0');
		$('body.clube ul.balaoLista li.user:eq(6), body.clube ul.balaoLista li.user:eq(7), body.clube ul.balaoLista li.user:eq(8)').css('margin-bottom','0');

		$('ul#news li:gt(2)').css('padding-bottom','35px');
		$('ul.listaGameMod li:odd').css('margin-right','0');

		$('div#contentBusca ul.balaoLista li:last-child').css('margin-bottom','20px');

		/*Tabs*/
		$('#tabMenu div').hide();
		$('#tabMenu div:first').show();
		$('#tabMenu ul li:first').addClass('active');
		$('#tabMenu ul#tabs li a').click(function(){
			$('#tabMenu ul#tabs li').removeClass('active');
			$(this).parent().addClass('active');var currentTab=$(this).attr('href');
			$('#tabMenu div').hide();$(currentTab).show();
			return false
		});
		
		/*Dropdown*/
		$('div#minhaConta').hover(function(){
			$(this).find('div#userSystem:hidden').fadeIn('3000');
		},
		function(){
			$(this).find('div#userSystem:visible').fadeOut('3000');
		});

		$('div#userSystem').hover(function(){
			$('div#minhaConta').removeClass('normal').addClass('selected');
		});
		$('div#userSystem').mouseout(function(){
			$('div#minhaConta').removeClass('selected').addClass('normal');
		});
		
		/*More Credits*/
		$('#maisCredits').click(function(){
			$('div#adicionarCreditos').fadeIn('slow');
		});

		/*Projetos*/
		$('div.excluir a.exc').click(function(){
			$(this).hide();
			$(this).parent().children('.confirm').show();
		});
		$('div.excluir a.no').click(function(){
			$('.confirm').hide();
			$('div.excluir a.exc').show();
		});

		$('div.excluir a.yes').click(function(e){
			e.preventDefault();
			var parent = $(this).parent().parent().parent();
			$.ajax({
				type:'get',
				url:'php/del_projects.php',
				data:'ajax=1&yes=' + parent.attr('id').replace('record-',''),
				beforeSend:function(){
					parent.hide('slow');
				},
				success:function(){
					parent.fadeOut(3000,function(){
						parent.remove();
					});
				}
			});
		});
		
		/*Full Games*/
		$('div.excluirFull a.exc').click(function(){
			$(this).hide();
			$(this).parent().children('.confirm').show();
		});
		$('div.excluirFull a.no').click(function(){
			$('.confirm').hide();
			$('div.excluir a.exc').show();
		});

		$('div.excluirFull a.yes').click(function(e){
			e.preventDefault();
			var parent = $(this).parent().parent().parent();
			$.ajax({
				type:'get',
				url:'php/del_fullgames.php',
				data:'ajax=1&yes=' + parent.attr('id').replace('record-',''),
				beforeSend:function(){
					parent.hide('slow');
				},
				success:function(){
					parent.fadeOut(3000,function(){
						parent.remove();
					});
				}
			});
		});

		/*User List (Clube)*/
		$('ul#friendsList li a.exc').click(function(){
			$(this).hide();
			$(this).parent().children('.confirmFriend').show();
		});
		$('ul#friendsList li a.no').click(function(){
			$('.confirmFriend').hide();
			$('ul#friendsList li a.exc').show();
		});

		$('ul#friendsList li a.yes').click(function(e){
			e.preventDefault();
			var parent = $(this).parent().parent();
			$.ajax({
				type:'get',
				url:'php/del_friends.php',
				data:'ajax=1&yes=' + parent.attr('id').replace('record-',''),
				beforeSend:function(){
					parent.fadeOut('3000');
				},
				success:function(){
					parent.fadeOut(3000,function(){
						parent.remove();
					});
				}
			});
		});

		/*Character*/
		jQuery.fn.counter=function(){$(this).each(function(){var max=$(this).attr('rows');var val=$(this).attr('value');var cur=0;if(val)cur=val.length;var left=max-cur;$(this).after("<div class='counter'>"+left.toString()+" caracteres"+"<\/div>");$(this).keyup(function(i){var max=$(this).attr('rows');var val=$(this).attr('value');var cur=0;if(val)cur=val.length;var left=max-cur;$(this).next(".counter").text(left.toString()+" caracteres");if(left<=3){$('.counter').css('color','#ff0000')}else{$('.counter').css('color','#adadad')}return this})});return this}
		$(document).ready(function(){$(".word_count").counter();});

		/*External Links*/
		$('a[rel="external"]').attr('target','_blank');

		/*User Tooltip*/
		$('ul.friends li').hover(function(){
			$(this).find('div.balao:hidden').fadeIn('3000');
		},
		function(){
			$(this).find('div.balao:visible').fadeOut('3000');
		});
		
		/*Inventário Tooltip*/
		$('div.category ul li').hover(function(){
			$(this).find('div.balaoInv:hidden').show();
		},
		function(){
			$(this).find('div.balaoInv:visible').fadeOut('3000');
		});
		
		/*Ranking*/
		$('table.rankingGames tr:even').css('background','#e6ebef');
		
		/*Credits Tooltip*/
		$('ul#creditos li').hover(function(){
			$(this).find('span.CreditsPreco:hidden').show();
		},
		function(){
			$(this).find('span.CreditsPreco:visible').fadeOut('3000');
		});
		
		/*Cartao Pagamento*/
		$('#pagBoleto').click(function(){$('ul#formasPagamento').hide('3000');$('ul#vezesPagBoleto').show('3000');});
		$('.back').click(function(){$('ul#vezesPagBoleto').hide();$('ul#formasPagamento').fadeIn('3000');});
		
		$('#pagVisa').click(function(){$('ul#formasPagamento').hide('3000');$('ul#vezesPagVisa').show('3000');});
		$('.back').click(function(){$('ul#vezesPagVisa').hide();$('ul#formasPagamento').fadeIn('3000');});
		
		$('#pagMaster').click(function(){ $('ul#formasPagamento').hide('3000');$('ul#vezesPagMaster').show('3000');});
		$('.back').click(function(){$('ul#vezesPagMaster').hide();$('ul#formasPagamento').fadeIn('3000');});
		
		$('#pagSeguro').click(function(){$('ul#formasPagamento').hide('3000');$('ul#vezesPagSeguro').show('3000');});
		$('.back').click(function(){$('ul#vezesPagSeguro').hide();$('ul#formasPagamento').fadeIn('3000');});

		/*Table*/
		$('table#shopCart th, table.relatory th, table.permissions th').css({background:'#996699',color:'#fff'});
		$('table#shopCart tr:odr, table.relatory tr:odr, table.permissions tr:odr').css('background','#e6ebef');
		$('table#shopCart tr:odd, table.relatory tr:odd, table.permissions tr:odd').css('background','#f5f7f8');
		
		/*MC Eu Buy Avaliation*/
		$('a.avaliarAciona').click(function(){	
			$(this,'div.productAction').parent().hide();
			$(this,'div.productAction').parent().next().slideDown('slow');
		});
		
		$('a.avaliarBack').click(function(){				  
			$(this).parent().closest('div.productReview').hide();
			$(this).parent().closest('div.productReview').prev().fadeIn('3000');
		});

		/*MC Eu Buy Indication*/
		$('a.indicarAciona').click(function(){	
			$(this,'div.productAction').parent().hide();
			$(this,'div.productAction').parent().next().next().slideDown('slow');
		});
		
		$('a.indicarBack').click(function(){				  
			$(this).parent().closest('div.productIndication').hide();
			$(this).parent().closest('div.productIndication').prev().prev().fadeIn('3000');
		});

		/*Focus*/
		$('input[type="text"], input[type="password"], textarea').focus(function(){
			$(this).css('border-color', '#adadad');
		});
		$('input[type="text"], input[type="password"], textarea').blur(function(){
			$(this).css('border-color', '#c9d6de');
		});
		
		/*Canal Header*/
		$('ul#breadCrumbs li#exibirHeader a').click(function(){
			$('ul#breadCrumbs li#exibirHeader').hide();
			$('ul#breadCrumbs li#ocultarHeader').show();
			$('body.dicartas div#header').css('margin-top','0');
		});
		$('ul#breadCrumbs li#ocultarHeader a').click(function(){
			$('ul#breadCrumbs li#ocultarHeader').hide();	
			$('ul#breadCrumbs li#exibirHeader').show();
			$('body.dicartas div#header').css('margin-top','-99px');
		});

	}); /*jQuery*/
