$.fn.defaultValue = function(value){
	$(this)
	.val(value)
	.focus(function(){
		if ($(this).val() == value)
			$(this).val("");
	})
	.blur(function(){
		if ($(this).val() == "")
			$(this).val(value);
	});

};
$(function(){
	
	if( $("#captcha").val() == "" ) 
		$("#captcha").defaultValue("Digite o texto da imagem");

	
	$(".box-twitter ul").getTwitter({
		userName: "fbnplayers",
		numTweets:6,
		loaderText: "Carregando tweets...",
		slideIn: true,
		slideDuration: 750,
		showHeading: true,
		headingText: " ",
		showProfileLink: true,
		showTimestamp: true
	});
	
	$("#compartilhe").fancybox({
		'width'	: 260,
		'height' : 140,
		'transitionOut'	: 'none',
		'titlePosition' : 'inside',
		'type':'iframe',
		'padding': 0,
		'centerOnScroll': true,
		'overlayColor' : '#000',
		'overlayOpacity': 0.3
	});
	
	$('a[rel="external"]').attr('target', '_blank');
	
	$("#img").fancybox({
		'width': 600,
    	'height':1500,
    	'autoScale':false,
    	'overlayColor':'#000',
    	'overlayOpacity': 0.6,
    	'padding':0
	});
	
	$( ".djs" ).autocomplete(djs, {
		multiple:false
	});	

	$('.bt-regras').fancybox({
		'titlePosition'	: 'inside',
		'width': 640
	});
	
	$('.bt-newsletter').click(function(){
		$('#cadastro_mailman').submit();
	});
	
	$('.votacao').click(function(){
		if($('#melhordj1').val() == ''){
			alert('Você deve votar em uma opção para Melhor DJ');
			return false;
		}
		if ($('#email').val() != '') {
			email = $('#email').val();
			if ((email.indexOf(".") > 0) && (email.indexOf("@") > 0) && (email.length > 3) && (email != "@.")) {
				if ($('#nome').val() != '') {
					if ($('#cidade').val() != '') {
						if ($('#captcha').val() != '') {
							$('#votacao').submit();
						} else {
							alert('Preencha o código da imagem.');
							$('#captcha').focus();
							return false;
						}
					} else {
						alert('Selecione uma cidade.');
						$('#cod_cidades').focus();
						return false;
					}
				} else {
					alert('Preencha o campo nome.');
					$('#nome').focus();
					return false;
				}
			} else {
				alert('E-mail inválido.');
				$('#email').focus();
				return false;
			}
		} else {
			alert('Preencha o campo e-mail!');
			$('#email').focus();
			return false;
		}
		
		
	});
	
	
	
	
});

