/**
 * JS
 * @author Darío Ruellan <druellan@ecimtech.com>
 * @copyright ecimTech 2009
 */

$(function()
{	

	// Login: inicializamos
	$("#header_login input[value=]").addClass("label");
		
	$("#header_login input").focus(function()
	{
		var value = $(this).attr("value");
		if ( !$(this).data("text") ) 
		{
			$(this).removeClass("label");
		}
	});
	$("#header_login input").blur(function()
	{
		if ($(this).attr("value").length == 0) 
		{
			$(this).addClass("label");
		}
	});
	$("#header_login form").submit(function()
	{
		$("button", this).attr('disabled', 'disabled');
		$("button", this).addClass("loading");
	});
	
	/* Search 
	$("#header_search div input")
	.focus(function() {
		$("#header_search").animate({ height: 100 });
		$("#header_search div").addClass("focus");
	});
	$("#header_search").hover(function (){},  function() {
		$("#header_search").animate({ height: 24 });
		$("#header_search div").removeClass("focus");
	})
	*/
	
	// Minisearchbox
	$("#search-box .search-mini").click(function()
	
	{
		$(this).parent().animate({ marginTop: 0, marginBottom: 8 });
		$(this).animate({ height: 22, width: 600, opacity: 0 });
		$("#search-box .search").show("normal");
		return false;
	});
	
	// Back button
	$("#body .back").attr("href", "#").click(function()
	{
		history.back();
		return false;
	});
	
	// odd universal para listados
	$("#body .zebra > li:odd").addClass("odd");
	
	// Resaltamos diálogos de alert
	$("#body .notice.alert")
	.css({ position: 'relative' })
	.delay(500)
	.animate({ top: -10 }, "normal")
	.delay(500)
	.animate({ top: 0 }, "slow", "easeOutBounce");
	
});


/* ----------------------------------------------------------------- */

function fbStreamPublishInviteOthers()
{
	FB.ui
	(
		{
			method: 'stream.publish',
			message: 'Recomiendo que entren a desarrollarme.com y me cuenten qué les pareció. A mí me gustó mucho.',
			attachment: 
			{
				name: 'Desarrollarme.com - Facilitamos tu desarrollo profesional',
				caption: 'Tests, ejercicios, trabajo, orientación vocacional, carreras, universidades, entrevistas...',
				description: 
				(
					''
				),
				href: window.location.href
			},
			action_links: 
			[
				{
					text: 'Desarrollo y Tecnología : EcimTech', href: 'http://www.ecimtech.com' 
				}
			],
			user_prompt_message: 'Compartí tu opinión acerca de Desarrollarme.com'
		},
		function(response) 
		{
/*
			if (response && response.post_id) 
			{
				alert('El post fue publicado.');
			} else {
				alert('El post no fue publicado.');
			}
*/
		}
	);
}


// ** Easing ************************************


jQuery.extend( jQuery.easing,
{
	easeInBounce: function (x, t, b, c, d) {
	return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});














