function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function instrumentSwitch() {
    var $active = $('#instruments a.active');

    if ( $active.length == 0 ) $active = $('#instruments a:last');
	
    var $next =  $active.next().length ? $active.next()
        : $('#instruments a:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


$(document).ready(function() {
						   
	$(function() {
    	setInterval( "slideSwitch()", 5000 );
		setInterval( "instrumentSwitch()", 5000 );
	});
	
	$("#moreInfo, .moreInfo, #btn_lermenos").hide();
	$("#bio, #current").append("<span id='reticencias'>...</span>");
	
	$("#btn_lermais").click(function () { 
		$("#moreInfo, .moreInfo").fadeIn(1000);
		$("#reticencias").hide();
		$("#btn_lermais").hide();
		$("#btn_lermenos").show();
		//parent.document.getElementById("conteudo").height = document.getElementById("right").scrollHeight + 250;
    });
	
	$("#btn_lermenos").click(function () { 
		$("#moreInfo, .moreInfo").slideUp(1000, function() { $("#reticencias").show(); });
		$("#btn_lermais").show();
		$("#btn_lermenos").hide();
		//parent.document.getElementById("conteudo").height = document.getElementById("master").scrollHeight - 350;
    });
	
	$("#btn_setas_close").hide();
	$("#btn_setas").click(function () {
		$("#mPlayer").animate( { left:"-90px" }, 300);
		$(this).fadeOut(150);
		$("#btn_setas_close").fadeIn(150);
		$("#mPlayer img").fadeOut(300);
    });
	
	$("#btn_setas_close").click(function () { 
		$("#mPlayer").animate( { left:"-25px" }, 300);
		$(this).fadeOut(150);
		$("#btn_setas").fadeIn(150);
		$("#mPlayer img").fadeIn(300);
    });
});


function validate_required(field,alerttxt){
with (field){
if (value==null||value==""){alert(alerttxt);return false;}
else {return true}}
}


function validateContacto(thisform)
{
	with (thisform)
	{
		if (validate_required(nome,"Introduza o seu nome")==false)
		{
			nome.focus();
			return false;
		}
		else if (validate_required(email,"Introduza o seu email")==false)
		{
			email.focus();
			return false;
		}
		else if (validate_required(mensagem,"Introduza a sua mensagem")==false)
		{
			mensagem.focus();
			return false;
		}
	}
}