var colorField = null;
function showColors(colorId) {
	if(colorField == null) {
		$("#color_picker").farbtastic(updateColor);
		$("#color_picker").hover(
			function() { $.data(this, "hover", true); },
			function() { $.data(this, "hover", false); }
		).data("hover", false);
		
		$(document).bind('click', function(e) {
			colorOut(e);
		});
	}

	colorField = colorId;
	$(".farbtastic").css({
		top: ($("#" + colorId).position().top) + "px",
		left: ($("#" + colorId).position().left + 80) + "px"
	});
	$("#color_picker").show();

	$("#button_" + colorId).hover(
		function() { $.data(this, "hover", true); },
		function() { $.data(this, "hover", false); }
	).data("hover", true);
}

function updateColor(newColor, textColor) {
	$("#" + colorField).attr('value', newColor.substring(1));
	$("#" + colorField).css({
		backgroundColor: newColor,
		color: textColor
	});
}

function colorOut(e) {
	if(!$("#color_picker").data("hover") && !$("#button_" + colorField).data("hover")) {
		$("#button_" + colorField).unbind("mouseenter mouseleave");
		$("#color_picker").hide();
	}
}

function hideOff(id) {
	$('#hide_' + id).show(400);
	$('#link_on_' + id).show();
	$('#link_off_' + id).hide();
}

function hideOn(id) {
	$('#hide_' + id).hide(400);
	$('#link_on_' + id).hide();
	$('#link_off_' + id).show();
}

function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	
	return false;
}

var RecaptchaOptions = {
	theme : 'clean',
	lang : 'fr',
	custom_theme_widget : 'recaptcha'
};

$(document).ready(function() {
	jResize("img.admin_style", 250, 50);
	jResize("img.users_style", imageMaxWidth, imageMaxHeight);
});

