$(function() {
	$('body').addClass('js'); // For advanced CSS
	setBodyClass();
	$('#signup fieldset div').labelHolder();
	$('.email').defuscate();
});

//-------------------------------
// Adds class name to body based on URL
//-------------------------------
function setBodyClass() {
	var urlroot = '/', // Set to the root URL of the site
		url = window.location.pathname,
		dir = url.split(urlroot);
	dir = dir[1].toLowerCase();
	if (dir) {
		var file = dir.split('.'); // removes file extentions
		if (file[0]) {
			dir = file[0];
		}
	} else {
		dir = 'home';
	}
	$('body').addClass(dir);
}

//-------------------------------
// Moves form label to the input
//-------------------------------
$.fn.labelHolder = function() {
	return this.each(function() {
		var holder = $(this).find('label').hide().text(),
			field = $(this).find('input');
		field.blur(function() {
			if ( $(this).val() == '' || $(this).val() == holder ) {
				$(this).val(holder).addClass('holder');
			}
		}).blur();
		field.focus(function() {
			if ( $(this).val() == holder ) {
				$(this).val('').removeClass('holder');
			}
		});
	});
};
