function trim (str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}

$(function() {
	// External URL
	$('a[rel^="external"]').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
	
	// swip inputs
	$('input.swip').each(function() {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
			$(this).addClass('swipped');
		}
	});
	$('input.swip').focus(function() {
		if ($(this).hasClass('swipped')) {
			$(this).val('');
			$(this).removeClass('swipped');
		}
	}).blur(function() {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
			$(this).addClass('swipped');
		}
	});
	$('form.swip').submit(function() {
		$(this).find('input.swip').each(function() {
			if ($(this).val() == $(this).attr('title'))
				$(this).val('');
		});
	});
});
