jQuery.noConflict();

jQuery(document).ready(function($) {
	// See which font size the user wants
	$(".fontSizeResizer a").click(function() {
		switch ($(this).attr("class")) {
			case 'small'	:  setFontSize(-.15);  break;
			case 'large'	:  setFontSize(.3);  break;
			default			:  setFontSize(1);  break;
		}
		return false;
	});

	cookiesize = readCookie('fontSize');
	if (!(isNaN(cookiesize))) {
		if (cookiesize < 8) {
			cookiesize = 11;
			createCookie('fontSize',cookiesize,30);
		}
		$("#middlecol").css({fontSize: cookiesize+"px"});
	}

	// Add highlighting to form elements
	$("input, textarea, select").focus(function(){
		$(this).addClass("focus");
	});
	$("input, textarea, select").blur(function(){
		$(this).removeClass("focus");
	});

	//Add text to certain form elements
	$("#blog_search_form input").focus(function(){
		if ($(this).val() == "Search this blog...") {
			$(this).val("");
		}
	});
	$("#blog_search_form input").blur(function(){
		if ($(this).val() == "") {
			$(this).val("Search this blog...");
		}
	});

	// shows/hides the ad after the adtoggle text
	$('.adtoggle').click(function() {
		$('.adtoggle').next().slideToggle('fast');
		return false;
	});

	// hide leaderboard ad after 3 (x1000) seconds
	// setTimeout ( '$("#leaderboard").slideUp("slow");' , 3000);  

    $("#current").find('ul').show();

    $(".open:not('#current')").hover(
      function () {$(this).find('ul').show('fast');}, 
      function () { $(this).find('ul').animate({opacity: 1.0}, 200).hide('fast'); }
    );

});


// Set the font size and set a cookie
function setFontSize(size) {
	var $mainText = jQuery('#middlecol');
	var currentSize = parseFloat($mainText.css('font-size'));
	if (isNaN(currentSize)) { currentSize = 11 };
	// if size is 1, reset, otherwise, change currentSize proportionally
	if (size == 1) { newsize = 11 } else { newsize = currentSize * (1 + size) } 
	jQuery("#middlecol").animate({fontSize: newsize+"px"}, 500).fadeIn("slow");
	createCookie('fontSize',newsize,30);
	if (newsize > 9) {jQuery(".small").show();} else {jQuery(".small").hide();} ; 
	if (newsize != 11) {jQuery(".reset").show();} else {jQuery(".reset").hide();} ; 
	if (newsize < 20) {jQuery(".large").show();} else {jQuery(".large").hide();} ;
}

// Create and read coookies
// Code functions by: Peter-Paul Koch
// http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}	


function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
	if (theValue == true || theValue == false)
		eval("obj."+theProp+"="+theValue);
	else eval("obj."+theProp+"='"+theValue+"'");
  }
}