/*
$(document).ready(function() {
	$("table td div").each(function() {
		var img = $(this).find("img");
		var p = $(this).find("p");
		var h2 = $(this).find("h2");
		var div = $(this).find("div");

		p.css("width", img.width()+"px");
		h2.css("width", img.width()+"px");
		if($(this).height() < div.height()) {
			$(".thumbnail").css("height", div.height()+"px");
		}
	});
});*/
function logIn() {
	if(document.forms['login'].email.value == '' || document.forms['login'].password.value == '') {
		$("#error").html('Vous devez remplir votre email et votre mot de passe pour accéder a ce service.');
		$("#error").css("visibility", "visible");
		return false;
	} else {
		return true;
	}
}
function badLogIn() {
	$("#error").html("Votre email ou mot de passe n'est pas reconnu. Veuillez recommencer.");
	$("#error").css("visibility", "visible");
}
function lostPassword() {
	$("#error").html('Remplissez le champ Email et <a href="#" onclick="$(\'#lpEmail\').val($(\'#email\').val());$(\'#lostPassword\').submit();">cliquez ici pour recevoir votre mot de passe.</a>');
	$("#error").css("visibility", "visible");
}
function PasswordSent() {
	$("#error").html("Votre mot de passe vous a été envoyé à l'adresse que vous<br/>nous avez indiqué.");
	$("#error").css("visibility", "visible");
}
function PasswordNotSent() {
	$("#error").html('L\'adresse email ne correspond pas à un compte. <a href="#" onclick="$(\'#lpEmail\').val($(\'#email\').val());$(\'#lostPassword\').submit();">Cliquez ici pour recommencez.</a>');
	$("#error").css("visibility", "visible");
}
function checkSearch() {
	if($("#quicksearch_content").val() == '' || $("#quicksearch_content").val() == 'Recherchez une oeuvre, un objet, un auteur...') {
		alert('Vous devez taper une oeuvre, un objet, un auteur pour lancer la recherche !');
		return false;
	}
	if($("#quicksearch_content").val() == 'Search for an artist, a work of art or an author...') {
		alert('You have to type a keyword for the search !');
		return false;
	}
}
function popupImage(img) {
    titre="Agrandissement";
    var top = (screen.height-400)/2;
    var left = (screen.width-400)/2;
    w = open('','image','top='+top+',left='+left+',width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');
    w.document.write('<html><head><title>'+titre+'</title><style>body { text-align: center; } p{ font: 12px arial; text-align: center; }</style></head>');
    w.document.write('<script language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+50); window.focus();} else { setTimeout("checksize()",250) } }</'+'SCRIPT>');
    w.document.write('<script language=javascript>function fitsize() { document.images[0].height = document.body.clientHeight; if(document.images[0].width > document.body.clientWidth) { document.images[0].width = document.body.clientWidth; } }</'+'SCRIPT>');
    w.document.write('<body onload="checksize()" onresize="fitsize()" onblur="window.close()" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">');
    w.document.write('<IMG src="'+img+'" border="0" title="Redimensionner la fenêtre pour changer la taille de l\'image">');
    w.document.write('</body></html>');
    w.document.close();
}
function popup(src, width, height, options) {
	var top=(screen.height-height)/2;
	var left=(screen.width-width)/2;
	window.open(src,"","top="+top+",left="+left+",width="+width+",height="+height+","+options);
}
