jQuery(document).ready(function($){ 
	$(function() {
	if(!$.support.placeholder) { 
		var active = document.activeElement;
		$(':text').focus(function () {
			if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
				$(this).val('').removeClass('hasPlaceholder');
			}
		}).blur(function () {
			if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
				$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
			}
		});
		$(':text').blur();
		$(active).focus();
		$('form').submit(function () {
			$(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
		});
	}
});
		
// Open an external link in a new window
    $('a[href^="http://"]').filter(function () {
        return this.hostname && this.hostname !== location.hostname;
    }).attr('target', '_blank');

// outline fix
	$("a, button, input").each(function() {
		$(this).attr("hideFocus", "true").css("outline", "none");
	});

// messages close animation
$(".message.closeable, .message.closeable .close").live("click", function(){
	var message = $(this).parent();
	if($(this).is(".closeable")) message = $(this);
	message.animate({opacity: 0}, 250, function(){
	$(this).slideUp(100, function(){$(this).remove()})
	});
});
	$(".message.closeable").append($('<div/>', {'class': 'close',html: '&#215;'}));
	
	$('.areatabs > .tabs').delegate('li:not(.current)', 'click', function() {
	$(this).addClass('current').siblings().removeClass('current').parent().parent().children(".panes").children('.pane').hide().eq($(this).index()).show();
	return false;
});

	// Collapse and expand the blocks
	$("div.block.collapsible > h3").click(function(){
		if($(this).parent().hasClass("closed")){
			$(this).next(".bcontent").slideDown("fast").parent().removeClass("closed");
		}else{
			$(this).next(".bcontent").slideUp("fast").parent().addClass("closed");
		}
	});
});
