var intPinned = false;
var skiPinned = false;
$(document).ready(function () {
	if($("#about-interests").size() == 1 && $("#about-skills").size() == 1) {
		//"Roll-over to read more" functionality for the interests section
		var p = $("<p/>").attr("id", "about-interests-display").html("&nbsp;");
		$("#about-interests").nextUntil("h2").filter(":last").after(p);
		$("#about-interests").nextUntil("h2").filter("h3").each(function() {
			$(this).text(" [ " + $(this).text() + " ] ");
			$(this).css("float", "left").css("clear", "none").css("padding-right", "2px").css("padding-left", "2px").next().hide();
			$(this).hover(function() {
				if(intPinned == false) {
					$(this).css("background-color", "#cccccc");
					$("#about-interests-display").stop(true, true);
					$("#about-interests-display").html($(this).next().html());
				}
			}, function() {
				if(intPinned == false) {
					$(this).css("background-color", "transparent");
					$("#about-interests-display").html("&nbsp;");
				}
			});
			$(this).click(function() {
				if(intPinned == false) {
					intPinned = $(this).text();
					$(this).css("background-color", "#b0b0b0");
				} else {
					if(intPinned == $(this).text()) {
						intPinned = false;
						$(this).css("background-color", "#cccccc");
					}
				}
			});
		});
		p = $("<p/>").attr("class", "rollover-instruction").text("(Roll-over to read more, click to pin open...)");
		$("#about-interests").after(p);
		
		//For the skills section
		p = $("<p/>").attr("id", "about-skills-display").html("&nbsp;");
		$("#about-skills").nextUntil("h2").filter(":last").after(p);
		$("#about-skills").nextUntil("h2").filter("h3").each(function() {
			$(this).text(" [ " + $(this).text() + " ] ");
			$(this).css("float", "left").css("clear", "none").css("padding-right", "2px").css("padding-left", "2px").next().hide();
			$(this).hover(function() {
				if(skiPinned == false) {
					$(this).css("background-color", "#cccccc");
					$("#about-skills-display").stop(true, true);
					$("#about-skills-display").html($(this).next().html());
				}
			}, function() {
				if(skiPinned == false) {
					$(this).css("background-color", "transparent");
					$("#about-skills-display").html("&nbsp;");
				}
			});
			$(this).click(function() {
				if(skiPinned == false) {
					skiPinned = $(this).text();
					$(this).css("background-color", "#b0b0b0");
				} else {
					if(skiPinned == $(this).text()) {
						skiPinned = false;
						$(this).css("background-color", "#cccccc");
					}
				}
			});
		});
		p = $("<p/>").attr("class", "rollover-instruction").text("(Roll-over to read more, click to pin open...)");
		$("#about-skills").after(p);
	}
});

