// JavaScript Document
$(document).ready(function(){
		$.colorbox({href:"video_james_brownse.html",title:"O Velho James Browse J&aacute; Dizia - Novas Lendas da Etnia Toshi Babaa"});;
	    player();
		slider();
		scrollbar();
		tweet();
		discografia();	
		imgFoto();
		topLink();
		validaContato();		
});

function player(){
		var bucket = "mp3/",
					songs = [
					{
			"url": bucket + "d7e56984a1aa261e56f41ba0243f2a1d.mp3",
			"title": "01. Constela&ccedil;&atilde;o Carinhoca",
		},
		{
			"url": bucket + "4a1997f2f57043f6a7d9aa1d057f389a.mp3",
			"title": "02. Eduarda Fissura do &Aacute;tomo",
		},
		{
			"url": bucket + "13c3ab815a9539d1e6e7344301142a73.mp3",
			"title": "03. Se eu tivesse F&eacute; - Fucking Shit",
		},
		{
			"url": bucket + "35a5d0822e4095b06e5ef537f4e87bc1.mp3",
			"title": "04. O Velho James Browse j&aacute; dizia",
		},
		{
			"url": bucket + "b6f11d4bcc3155de064d91ea23001ee9.mp3",
			"title": "05. O Var&atilde;o e a Fadinha",
		},
		{
			"url": bucket + "5da7bc99f39b972da7600b29f7106d65.mp3",
			"title": "06. Cab&ocirc;cocopyleft",
		},
		{
			"url": bucket + "7454c2ba3a3a6703ae85ba76f89db843.mp3",
			"title": "07. Soneto do Envelhecido sem Pretexto",
		},
		{
			"url": bucket + "e2061759b2ee73b2adc32a243f7cad8d.mp3",
			"title": "08. A Fuma&ccedil;a do Paj&eacute; Miti Subitxxiii",
		},
		{
			"url": bucket + "326db50664af1795e9d6d861ebaa09eb.mp3",
			"title": "09. Ela &eacute; Indie",
		},
		{
			"url": bucket + "b129ebf03e903fc08d9066e0a00e830e.mp3",
			"title": "10. Nenhum Crist&atilde;o na via L&aacute;ctea",
		},
		{
			"url": bucket + "50b908015671ada50094531fd8209e9b.mp3",
			"title": "11. Tua Carne Black Label",
		}
				];
 
 
				$('#swagg-player').SwaggPlayer({
					data : songs,
					buttonsDir : 'images/',
					autoPlay:false,
					buttonHover : true,
					debug: false,
					lazyLoad: true,
		morphArt: true,
		html5Audio: true,
					
					
					
					whilePlaying: function(){
			var api = window.swaggPlayerApi;
			$('#time').html( api.currSong.getCurrTimeAsString() + ' | ' + api.currSong.getTotalTimeAsString() );
		},
		onStop: function(){
			$('#time').html('00:00 / 00:00');	
		},		
		});
}

function slider(){
	$('ul.nav a').bind('click',function(event){
				    var $anchor = $(this);
                    
                    $('html, body').stop().animate({
                        scrollTop: $($anchor.attr('href')).offset().top
                    }, 1500,'easeInOutExpo');
                    /*
                    if you don't want to use the easing effects:
                    $('html, body').stop().animate({
                        scrollTop: $($anchor.attr('href')).offset().top
                    }, 1000);
                    */
                    event.preventDefault();
					
   });
}

function scrollbar(){
	$('#scrollbar1').tinyscrollbar();
	$('#scrollbar2').tinyscrollbar();
}

function tweet(){
	$(".tweet").tweet({
            username: "mundo_livre_sa",
            join_text: "auto",
            avatar_size: 0,
            count: 3,
            auto_join_text_default: "", 
            auto_join_text_ed: "",
            auto_join_text_ing: "",
            auto_join_text_reply: "",
            auto_join_text_url: "",
            loading_text: "Carregando Tweets..."
        }).bind("loaded",function(){$(this).find("a").attr("target","_blank");});
}
function discografia(){
	$(function() {
        
		//vars
		var conveyor = $(".content-conveyor", $("#sliderContent")),
		item = $(".item", $("#sliderContent"));
		
		//set length of conveyor
		conveyor.css("width", item.length * parseInt(item.css("width")));
				
        //config
        var sliderOpts = {
		  max: (item.length * parseInt(item.css("width"))) - parseInt($(".viewer", $("#sliderContent")).css("width")),
          slide: function(e, ui) { 
            conveyor.css("left", "-" + ui.value + "px");
          }
        };

        //create slider
        $("#slider").slider(sliderOpts);
      });
}

function validaContato(){
	$("#nome").focus(function(){
	   if($(this).val()==$(this).attr("value")){
		   $(this).val("");
	   }
	});
    $("#nome").blur(function(){
		if($(this).val()==""){
		 $(this).val("Nome*");
	}
	});
	$("#fone").focus(function(){
	   if($(this).val()==$(this).attr("value")){
		   $(this).val("");
	   }
	});
    $("#fone").blur(function(){
		if($(this).val()==""){
		 $(this).val("Telefone*");
	}
	});
	$("#email").focus(function(){
	   if($(this).val()==$(this).attr("value")){
		   $(this).val("");
	   }
	});
    $("#email").blur(function(){
		if($(this).val()==""){
		 $(this).val("E-mail*");
	}
	});
	$("#mensagem").focus(function(){
	   if($(this).val()==$(this).attr("value")){
		   $(this).val("");
	   }
	});
    $("#mensagem").blur(function(){
		if($(this).val()==""){
		 $(this).val("Mensagem*");
	}
	});
	$("#btn").click(function(){
	contato = document.contatoForm;
	if(contato.nome.value=="" || contato.nome.value=="Nome*"){
		alert('Por favor, informe seu nome!');
		contato.nome.focus();
		return false;				
	}
	if(contato.fone.value=="" || contato.fone.value=="Telefone*"){
		alert('Por favor, digite um telefone!');
		contato.fone.focus();
		return false;				
	}
	if(contato.email.value=="" || contato.email.value=="E-mail*"){
		alert('Por favor, digite um e-mail corretamente!');
		contato.email.focus();
		return false;				
	}
	parte1 = contato.email.value.indexOf("@");
	parte2 = contato.email.value.indexOf(".");
	parte3 = contato.email.value.length;
	if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
		alert('Por favor, informe um email corretamente!');
		contato.email.focus();
		return false;
	}
	if(contato.mensagem.value=="" || contato.mensagem.value=="Mensagem*"){
		alert('O que deseja conosco?');
		contato.mensagem.focus();
		return false;				
	}
	alert('Obrigado por entrar em contato! Em breve retornaremos...');
	return true;
	});
}

function validaTelefone(e){
	var tecla=(window.event)?event.keyCode:e.which;   
    if((tecla>47 && tecla<58)) return true;
    else{
        if (tecla==8 || tecla==0) return true;
    else  return false;
    }
}

function imgFoto(){
	$("a[rel='galeria_foto']").colorbox({slideshow:true,transition:"elastic"});
	$(".galeria_video").colorbox({iframe:true, innerWidth:700, innerHeight:386});
}

function topLink(){
	jQuery.fn.topLink = function(settings) {
  settings = jQuery.extend({
    min: 1,
    fadeSpeed: 200
  }, settings);
  return this.each(function() {
    //listen for scroll
    var el = $(this);
    el.hide(); //in case the user forgot
    $(window).scroll(function() {
      if($(window).scrollTop() >= settings.min)
      {
        el.fadeIn(settings.fadeSpeed);
      }
      else
      {
        el.fadeOut(settings.fadeSpeed);
      }
    });
  });
};

//usage w/ smoothscroll
$(document).ready(function() {
  //set the link
  $('#fixBar h1 img').topLink({
    min: 140,
    fadeSpeed: 500,
  });
});
}
