$(document).ready(function(){
	$.each($.browser, function(i, val) {
		if (i=="msie" && $.browser.version.substr(0,1)==6) {
			$("body").addClass("ie ie6");
		}
		if (i=="msie" && $.browser.version.substr(0,1)==7) {
			$("body").addClass("ie ie7");
		}
		if (i=="msie" && $.browser.version.substr(0,1)==8) {
			$("body").addClass("ie ie8");
		}
		if (i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9") {
			$("body").addClass("firefox firefox3");
		}
	});

	$("#keywords").search();

	$('span.mailme').mailme();
	$('.cap p:first').each(function() {
		var text = $(this).html();
		var first_letter = text.substr(0,1);
		if ( /[a-zA-Z]/.test(first_letter) ) {
		  $(this).html('<span class="init-cap">' + first_letter + '</span>' + text.slice(1));
		}
	});

});

jQuery.fn.mailme = function() {
	var at = / at /;
	var dot = / dot /g;
	this.each( function() {
		var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
		//var title = jQuery(this).attr('title');
		var text = addr.split("@");
		text = text[0].replace("."," ");
		//addr = text[1];
		$(this)
			//.after('<a href="mailto:'+addr+'" title="'+title+'">'+ text +'</a>');
			.after('<a href="mailto:'+addr+'">'+ text +'</a>')
			.remove();
	});
};

$.fn.search = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};



/*
$('#username').click(function(){
	if($(this).attr('value') == 'username') {
		$(this).attr('value','');
	} 
}).focus(function(){
	if($(this).attr('value') == 'username') {
		$(this).attr('value','');
	} 
})
$('#username').blur(function () {
	if($('#username').attr('value') == undefined) {
		$(this).attr('value','username');
	} 
})
*/