﻿$(document).ready(function() {
	$("table.submenu").each(function(i)
	{
		var sibRow = $(this).parent().parent()[0].previousSibling;
		$(sibRow).find("table").addClass("parentmenu");
	}
	);
   // These functions control the behavior of the site's truncated breadcrumb menu.
   $("li.breadcrumb-truncated").hide();
   $("#breadcrumbs ul li.hidden").removeClass("hidden");
   $("li.breadcrumb-expand").click(function() {
     $("li.breadcrumb-truncated").show();
     $("li.breadcrumb-expand").hide();
   });
   // These functions control the behavior of the site's search form.
   $("input.search").attr({ value: "Search"});
   $("input.search").blur(function(){
 	 $(this).attr({ value: "Search"}).addClass("prefocus").removeClass("focus");
   });
   $("input.search").focus(function(){
 	 $(this).attr({ value: ""}).removeClass("prefocus").addClass("focus");
   });
   $("#search label").hover(function(){
  	 $(this).addClass("current-scope");
	 },function(){
     $(this).removeClass("current-scope");
   }); 
   // looks for 'pullquote' class and styles that text as an offset blockquote.
   $(".pullquote").each(function(){ 
     $(this.parentNode).after('<blockquote><p>' + $(this).html() + '</p></blockquote>'); 
   });
   // these functions wrap links to Word, Excel and PDF documents in a span that adds appropriate document icons.
   $("#main-content a[@href$=pdf]").wrap("<span class='pdf'></span>");
   $("#main-content a[@href$=doc]").wrap("<span class='word'></span>");
   $("#main-content a[@href$=xls]").wrap("<span class='excel'></span>");
	// these functions create scalable CSS button
	$('.btn').each(function(){
		var b = $(this);
		var tt = b.text() || b.val();
		if ($(':submit,:button',this)) {
			b = $('<a>').insertAfter(this).addClass(this.className).attr('id',this.id);
			$(this).remove();
		}
		b.text('').css({cursor:'pointer'}).prepend('<i></i>').append($('<span>').
		text(tt).append('<i></i><span></span>'));
	});
	// Zoombox
	$(".zoombox").addClass("hide");
	$(".zoombox-large").addClass("hide");
	$("a#attend-btn").click(function(){
	 $("div#attend").removeClass("hide");
 	 $("div#attend").fadeIn("300");
   });
   $("a#future-btn").click(function(){
   	 $("div#future").removeClass("hide");
 	 $("div#future").fadeIn("300");
   });
	$("a#watch-btn").click(function(){
	 $("div#watch").removeClass("hide");
 	 $("div#watch").fadeIn("300");
   });
	$("img.close").click(function(){
 	 $(this).parent().fadeOut("300");
   });
});