﻿$('document').ready(function(){		
	
	$.ajax({
		url: 'calendario.php',
		type: 'get',
		success: function(resp){
			$("#calendar").html(resp);
		}
	});
	
	$("#nome, #email, .formContact").click(function(){
		$(this).val("");
	});
	
	$("#nome, #email, .formContact").focusout(function(){
		if($(this).val() == "")
			$(this).val($(this).attr("label"));
	});
	
	$("#sliderContainer").vsSlider({
		automatico: true,
		tempo: 5000,
		transicao: 500,
		stopclick: false
	});
	
    $('.lightbox').lightBox();
	$('.lightbox').click(function(){	
		$(".movie_wrapper").css("visibility","hidden");
	});
	
	$('.musicItem').click(function(){
		$.ajax({
			url: 'player.php',
			data: 'musica='+$(this).attr("href"),
			success: function(resp){
				$("#divPlayer").html(resp);
			},
			error: function(){
				alert("Erro");
			}
		});
		return false;
	});
	
	$('.stopItem').click(function(){
		$("#divPlayer").html("");
		return false;
	});
	
	$("#twitter_app").tweet({
		username: "velocette_rock",
		join_text: "auto",
		avatar_size: null,
		count: 5,
		auto_join_text_default: "", 
		auto_join_text_ed: "",
		auto_join_text_ing: "",
		auto_join_text_reply: "",
		auto_join_text_url: "",
		loading_text: "loading tweets..."
	}); 
	
});

function atualizaCalendario(mes, ano) {
	
	$.ajax({
		url:"calendario.php",
		data:"mes="+mes+"&ano="+ano,
		type:"get",
		success:function(resp){
			$("#calendar").html(resp);
		},
		error: function(){
			$("#calendar").html("Erro ao carregar o calendário\nMes:"+mes+"\nAno:"+ano);
		}
	});
	return false;	
}

function validaForm(form){
	for(i = 0; i < form.elements.length; i++){
		//alert(form.elements[i].getAttribute('required'));
		if(form.elements[i].getAttribute('required') == 'true'){
			if(form.elements[i].value == null || form.elements[i].value == "" || form.elements[i].value == form.elements[i].getAttribute('label')){
				alerta = form.elements[i].getAttribute('alert');
				alert("O campo "+alerta+" é obrigatório");
				return false;
			}
		}
	}
	return true;
}
