$(document).ready( function() {
$('.blink').focus(function () {
			if ($(this).val() == $(this).attr('title')) {
				$(this).val('');
			}
		})
	$('.blink').blur(function () {
			if ($(this).val() == '') {
				$(this).val($(this).attr('title'));
			}
		})	
	//
 //$("#page").center();
 $("ul.tabslink li a").not('.active, .hl').click(function(){
 	var href = $(this).attr("href");
 	//var offset = $(this).offset();
 	//$(href).find(".folder-label").css({"top":offset.top});
	$('.folder').hide();
	$('.mainbody').hide();
	$("ul.tabslink li a").removeClass("active");
	if(href != "#"){
		$('ul.tabslink li a[href="'+href+'"]').addClass("active");
		$(href).slide();
		$(href+' .mainbody').fadeIn(1000);
	}
	else{
		$('#right-nav a.hl').addClass("active");
	}
 	return false;
 });
 $('a#backtoprofiles').click(function(){
 	var href = "#attorney";
	$('.folder').hide();
	$('.mainbody').hide();
	$("ul.tabslink li a").removeClass("active");
	$('ul.tabslink li a[href="'+href+'"]').addClass("active");
	$(href).slide();
	$(href+' .mainbody').fadeIn(1000);
 });
 
 $("#folders-content .folder-label").click(function(){
 	$('.mainbody').hide();
	$("#folders-content .folder").slideHide();
 	$(".folder-titles ul li a").removeClass("active");
 	return false;
 });
});
jQuery.fn.center = function(loaded) {
    var obj = this;
    body_width = parseInt($("body").width());
    body_height = parseInt($("body").height());
    block_width = parseInt(obj.width());
    block_height = parseInt(obj.height());
    
    left_position = parseInt((body_width/2) - (block_width/2)  + $(window).scrollLeft());
    if (body_width<block_width) { left_position = 0 + $(window).scrollLeft(); };
    top_position = parseInt((body_height/2) - (block_height/2) + $(window).scrollTop());
    if (body_height<block_height) { top_position = 0 + $(window).scrollTop(); };
    
    if(!loaded) {
        
        obj.css({'position': 'absolute'});
        obj.css({'left': left_position, 'top': top_position});
        $(window).bind('resize', function() { 
            obj.center(!loaded);
        });
        
    } else {
        obj.stop();
        obj.css({'position': 'absolute'});
        obj.animate({'left': left_position, 'top': top_position}, 200, 'linear');
    }
}
jQuery.fn.slide = function(){
	var obj = this;
	$(obj).animate({width: "toggle"});
}
jQuery.fn.slideHide = function(){
	var obj = this;
	$(obj).animate({width: "hide"});
}

