var taglistrevealed = false;
var taglistheight = "0px";
var searchboxrevealed = false;

$("div#searchbox").ready(function(){
	$("div#searchbox").fadeOut(1);
});

$("div#searchicon").ready(function(){
	$("div#searchicon").fadeTo(1, 0.5);
});

$("div#mainmenuCurrentText").ready(function(){
	$("img#mainmenuCurrentGlow").width($("div#mainmenuCurrentText").width()+20);
	$("img#mainmenuCurrentGlow").height($("div#mainmenuCurrentText").height()+5);
});

$("div#taglist").ready(function(){
	taglistheight = $("div#taglist").height();
	$("div#taglist").animate({height: "1px"}, 1)
});

$("div#addComment").ready(function(){
	var currentURL = location.href
	if(!currentURL.match("#addComment")){
		$("div#addComment").hide();
	}
})
$(document).ready(function(){

  //hide the center overlay when document is ready
  $("div#centerOverlay").fadeTo(1, 0);
  $("div#centerOverlay").height($(document).height()-300);
  $("div#centerOverlay").width($("div#center").width());
  $("div#centerOverlay").hide();
  
  $("div#searchicon")
	.click(function(){
		if(!searchboxrevealed){
			$("div#searchbox").fadeIn(250);
			searchboxrevealed = true;
		} else {
			$("div#searchbox").fadeOut(250);
			searchboxrevealed = false;
		}
		return false;
	});
  $("div#searchicon")
    .mouseover(function(){
    	if(!searchboxrevealed){
    		$(this).fadeTo(100, 1);
    	}
    })
    .mouseout(function(){
    	if(!searchboxrevealed){
    		$(this).stop();
    		$(this).fadeTo(100, 0.5);
    	}
    })
    .end();
  $("div.mainmenuElement")
	.mouseover(function(){
       $(this).animate({fontSize: "18pt"},200);
     })
	 .mouseout(function(){
	   $(this).stop();
       $(this).animate({fontSize: "12pt"},200);
     })
   .end();
  $("a#tagreveallink").click(function(){
  	if(taglistrevealed){
  		$("div#taglist").animate({height: "1px"}, 250);
		//$("div#footer").animate({bottom: "0px"}, 250);
  		taglistrevealed = false;
  		$("div#centerOverlay").fadeTo(250, 0, function(){$("div#centerOverlay").hide();});
  	}else{
  		$("div#taglist").animate({height: ""+taglistheight+"px"}, 250);
		//$("div#footer").animate({bottom: "0px"}, 250);
  		taglistrevealed = true;
		$("div#centerOverlay").height($(document).height()-300);
  		$("div#centerOverlay").show();
  		$("div#centerOverlay").fadeTo(250, 0.85);
  	}
  	return false;
  });
  $("a#addcommentlink").click(function(){
  	$("div#addComment").show(200);
  	return false;
  });
  
  $('a.obf').each(function(){
	var link = $(this).attr("href");
	if(link){
		link = link.replace(/mmtp:\/\// ,"mailto:");
		link = link.replace(/%%/,"@");
		$(this).attr("href", link);
	}
	});
});

