$(document).ready(function(){
	$("#listadoProyectos").jScrollPane();
	/*$(".destacado").hover(
	function(){
		$(this).addClass("destacado_destacado");
	},
	function(){
		$(this).removeClass("destacado_destacado");
	}
	)*/
});

$(function()
{
	setInterval(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');
			});
	}, 5000 );
});

$(function()
{
	$("#usuario, #contra")
		.each(function() { if(!$(this).val().length) $(this).addClass("placeholder"); })
		.focus(function() { $(this).removeClass("placeholder"); })
		.blur(function() { if(!$(this).val().length) $(this).addClass("placeholder"); })
	;
});

function formLoginSubmit()
{
	var form = $("#formLogin");
	var divError = $("div.error_acceso", form);
	var inpUser = $("#usuario");
	var inpPass = $("#contra");
	var inpSubmit = $("#submitBoletin");
	if("usuario" == inpUser.val() || "contraseņa" == inpPass.val()) return false;
	divError.slideUp(200);
	inpSubmit.attr("disabled", true);

	$.ajax({
		type			: "POST",
		url				: form.attr("action"),
		dataType		: "json",
		data			: {
			user : inpUser.val(),
			pass : inpPass.val(),
			json : 1,
			login : 1
		},
		error			: function(request, textStatus, errorThrow)
		{
			inpSubmit.attr("disabled", false);
			divError.slideDown(200);
		},
		success			: function(data, textStatus)
		{
			inpSubmit.attr("disabled", false);
			if(data.error)
			{
				divError.slideDown(200);
				if(data.errorMessage) alert(data.errorMessage);
			}
			else if(data.url && data.url.length) document.location = data.url;
		}
	});
	return false;
}
