function popin(left, top, milliseconds) {
	var popin = $("#ebookForm");
	if (popin) popin.hide();
	if (!shouldShowPopin()) return;
	popin.css('top', -popin.height()+'px');
	popin.css('left', left+'px');
	popin.show();
	popin.animate({ top: top, position: 'absolute'}, milliseconds);
}

function popout(milliseconds) {
	var popin = $("#ebookForm");
	popin.hide();
}

function shouldShowPopin() {
	if ($.cookie('showPopin')=='false') {
		return false;
	}
	$.cookie('showPopin','false');
	return true;
}

function ebookDownload() {
	var messages = "";
	if (document.ebook.category2.value=="") {
		messages += "Nome obbligatorio\n";
	}
	if (document.ebook.category3.value=="") {
		messages += "Email obbligatoria\n";
	}
	if (document.ebook.custom_telefono.value=="") {
		messages += "Telefono obbligatorio\n";
	}
	if (messages!="") {
		alert(messages);
	} else {
		document.ebook.submit();
	}
}