var INACTIVITY_TIMEOUT = 2500;

$(function(){
var reskin_timeout;
var hovered = 0;
function onhov(){
	hovered = 1;
	lnd2.kinetic('stop');
	clearTimeout(reskin_timeout);
}
function reskin(){
	hovered = 0;
	clearTimeout(reskin_timeout);
	if (!lnd2.hasClass('kinetic-decelerating-right')){
		lnd2.kinetic('start', {velocity: 1});
	}
}

var lnd2;

get_featured();


function get_featured(){
	$.get("/pads/recent-cred/", got_featured);
}


function got_featured(ob){

	var ass = $("#lnd2 #assets").removeClass("loading");
		$("<div/>").hide().append(ob).appendTo(document.body).find("img").load(function(){
		$(this).closest("div").hide().appendTo(ass).fadeIn('fast');
		ass.width(185*(4 + ass.children().size()) - 16);
	});

	setTimeout(get_featured, 19000);
	
	if (!lnd2){
	lnd2 = $("#lnd2").kinetic({
moved: function(){

},
stopped: function(){
	if (!hovered){
		clearTimeout(reskin_timeout);
		reskin_timeout = setTimeout(reskin, INACTIVITY_TIMEOUT);
	}
}, y: false, triggerHardware: true}).hover(onhov, reskin).mousedown(onhov);
reskin();
}
}

$(".loginlnk").click(function(e){
$(this).addClass("hide");
e.preventDefault();e.stopPropagation();
var o = $("#topsect");
o.animate({scrollTop: o.height() });
});

$("#compactlgn form").attr("action", "https://" + location.href.match(/https?:\/\/(.*)/)[1]);
});
