//-------------------------------------------------------------------
// Fast login
//-------------------------------------------------------------------
function showLoginForm(mozEvent)
{
	if (mozEvent) event = mozEvent;
	if (((event.keyCode == 76 || event.keyCode == 13 || event.keyCode == 69) && event.ctrlKey && event.shiftKey) || (event.keyCode == 13 && event.ctrlKey))
	{
		document.getElementById('fastLogin').style.display = "block";
		document.getElementById('password').focus();
		return false;
	}
}
document.onkeydown = showLoginForm;

function hideLoginForm()
{
	document.getElementById('fastLogin').style.display = "none";
}

function handleLoginForm()
{
	if (document.getElementById('password').value == "") return false;
	else document.getElementById('fastLoginForm').submit();
}

//-------------------------------------------------------------------
// Form handler
//-------------------------------------------------------------------
function handleForm(form, requiredFields, requiredFieldsDescriptions, msgFieldMissing, msgFieldsMissing)
{
	emptyRequiredFields = new Array();

	for (i = 0; i < requiredFields.length; i++)
	{
		if (document.getElementById(requiredFields[i]).value == "") emptyRequiredFields.push(i);
	}

	if (emptyRequiredFields.length > 0)
	{
		if (emptyRequiredFields.length == 1) alert(msgFieldMissing + "\n" + requiredFieldsDescriptions[emptyRequiredFields[0]] + ".");
		else
		{
			message = msgFieldsMissing + "\n";
			for (i = 0; i < emptyRequiredFields.length; i++)
				message += "  •  " + requiredFieldsDescriptions[emptyRequiredFields[i]] + "\n";

			alert(message);
		}
	}
	else form.submit();
}

//-------------------------------------------------------------------
// Show and hide
//-------------------------------------------------------------------
openedId = "";
function showObj(objId)
{
	if (openedId != "") document.getElementById(openedId).style.display = "none";
	document.getElementById(objId).style.display = "block";
	openedId = objId;
}

function hideObj(objId)
{
	document.getElementById(objId).style.display = "none";
	openedId = "";
}

//-------------------------------------------------------------------
// Removal confirmation
//-------------------------------------------------------------------
function confirmAndRedirect(phrase, url)
{
	if (confirm(phrase)) location = url;
}
//Cufon
Cufon.replace('a.logo h1', { fontFamily: 'Philosopher' });
Cufon.replace('a.logo h2', { fontFamily: 'Philosopher' });
Cufon.replace('div.tagcloud li a', { fontFamily: 'Philosopher' });
Cufon.replace('li.ttl', { fontFamily: 'Philosopher' });

//jQuery
$(document).ready(function(){
	$("a").focus(function() {
		this.blur();
	});
	$('div.tagcloud li').click(function() {window.location.href = ('/'+$(this).children('a').attr('href'))});
	$('div.note_list').hover(function() {$(this).addClass("active");}, function() {$(this).removeClass("active");	}).click(function() {window.location.href = ('/'+$(this).children('h2').children('a').attr('href'))});
	$('img.buy').click(function() {window.location.href = ($(this).attr('href'))});
	$('div.up img').click(function() {window.location.href = ($(this).attr('href'))});
	$('div.redir span').click(function() {window.location.href = ($(this).attr('href'))	});
});
