function emailReplace() {
	
	$('a.mail').each(function() {
		$(this).attr('href', 'mailto:'+$(this).attr('href').replace('--at--', '@'));
		$(this).html($(this).html().replace('--at--', '@'));
	});
	
}

function htmlencode(s, quotes){
	if ( !quotes ) {
		return $("<div/>").text(s).html();
	} else {
		return $("<div/>").text(s).html().replace(/"/g, '&quot;').replace(/'/, '&#039;');
	}
}
function htmldecode(s){
	return $("<div/>").html(s).text();
}

function cufonReplace() {

	Cufon.replace('#navigation a', {
		fontFamily: 'coolvetica', fontSize: '24px', hover: true
	});
	
	Cufon.replace('h1', {
		fontFamily: 'coolvetica', fontSize: '24px', hover: false
	});
	
}

function formChangeEvent(ev) {
	
	switch (ev.type) {
		case 'focus':
			if ($(this).val() == $(this).parent('label').text()) {
				$(this).val('');
			}
			break;
		case 'blur':
			if ($(this).val() == '') {
				$(this).val($(this).parent('label').text());
			}
			break;
	}
}

function formLabels() {
	$('label input[type="text"],label textarea').each(function() {
		if ($(this).val() == '') {
			$(this).val($(this).parent('label').text());
		}
		$(this).focus(formChangeEvent).blur(formChangeEvent);
	});
}



if (typeof jQuery !== 'undefined') {
	$(document).ready(emailReplace);
	if (typeof Cufon !== 'undefined') {
		$(document).ready(cufonReplace);
	}
	$(document).ready(function() { var rbt = $('ul#myRoundabout'); if (rbt.length) rbt.roundabout(); });
	$(document).ready(formLabels);
}


