// For 1 pixel background shift in Safari
	window.onload = resizeIfOdd;
		window.onresize = forceSafariEven;

		function resizeIfOdd(){
		if(navigator.userAgent.indexOf('Safari') != -1)
		 if(document.documentElement.clientWidth % 2 == 1)
		  window.resizeBy(-1,0);
		};

		function forceSafariEven(){
		 window.setTimeout('resizeIfOdd()',5);
		};

// For IE hover flicker bug
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


$(function() {
    styleSwitcher();
    hoverBox();

    // Gallery Nav Hover
    $("#nav_drop_locations").mouseover(function() { $(this).addClass("sfhover") });
    $("#nav_drop_locations").mouseout(function() { $(this).removeClass("sfhover") });

    // Tool Tip hover
    $(".tool_tip").mouseover(function() { $(this).addClass("sfhover") });
    $(".tool_tip").mouseout(function() { $(this).removeClass("sfhover") });

    // Nested List show/hide
    $("li.nested_list ul").hide()
    $("li.nested_list ul ul").show()
    $("li.nested_list .show_hide").click(function() {
        $(this).parent().toggleClass("active");
        $(this).parent().children("ul").toggle();
        return false
    });

    // Healthy Is "Fill in YOUR blank" show/hide form ------------------------------

    //	First, set the height of each hidden section so IE can show/hide it properly.
    $("#fillIn div .healthyForm").each(function() {
        var myHeight = $(this).height()
        $(this).css({ height: myHeight + 100 });
    });

    //	Hide all nested ULs with js (so users with js turned off can see everything)
    $("#fillIn div.first .healthyForm").hide();//Hide on load
    $("#fillIn div.validation-error .healthyForm").slideDown(300);//Slide open if returned with validation error

    //	Hover state for headlines
    $("#fillIn .trigger").hover(
      function() { $(this).addClass("over"); },
      function() { $(this).removeClass("over"); }
    );

    //	Accordion actions
    $("#fillIn .trigger").click(function() {
        //	If clicking on an active section, just close it and remove the active state.
        if ($(this).parent().hasClass("active")) {
            $("div.active .healthyForm").slideUp(300)
            $("#fillIn div").removeClass("active")
        }
        //	Otherwise, the click triggers two actions: close the 'active' section
        //  remove the validation-error class
        else if ($(this).parent().hasClass("validation-error")) {
            $("#fillIn div.active .healthyForm").slideUp(300)
            $("#fillIn div").removeClass("validation-error")
        }
        //	Otherwise, the click triggers three actions: close the active section, open
        //	the section that's clicked on, and mark it active.
        else if ($(this).hasClass("trigger")) {
            $("#fillIn div.active .healthyForm").slideUp(300)
            $("#fillIn div").removeClass("active")
            $(this).parent().addClass("active")
            $("#fillIn div.active .healthyForm").slideDown(300)
        }
    });





    // zebra tables
    $("#content table").each(function() {
        $("tr:nth-child(odd)").addClass("odd");
    });

    // Interactive Map Directory / Search Toggle
    $(document).ready(function() {
        $.jtabber({
            mainLinkTag: "#directory_search a", // much like a css selector, you must have a 'title' attribute that links to the div id name
            activeLinkClass: "selected", // class that is applied to the tab once it's clicked
            hiddenContentClass: "hiddencontent", // the class of the content you are hiding until the tab is clicked
            showDefaultTab: 1, // 1 will open the first tab, 2 will open the second etc. null will open nothing by default
            showErrors: false, // true/false - if you want errors to be alerted to you
            effect: 'slide', // null, 'slide' or 'fade' - do you want your content to fade in or slide in?
            effectSpeed: 'fast' // 'slow', 'medium' or 'fast' - the speed of the effect
        });
    });

    // Interactive Map Passing URL to Flash
    function thisMovie(movieName) {
        var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? document.getElementById(movieName) : document[movieName];
    }

    function makeCall(str) {
        thisMovie("BIDMC_CampusMap").asFunc(str);
    }
    $(function() {
        $(".map_callout li a, a.button_show_map").click(function() {
            var title = $(this).attr("title").toLowerCase()
            var href = $(this).attr("href")
            var mov = thisMovie("BIDMC_CampusMap")
            alert(mov);
            mov.asFunc(title + "," + href);
            return false;
        });
    });


    // select first li
    $(".podcast_list").each(function() {
        $(".podcast_list li:first").addClass("first");
    });
    // first td in UserMessage tables
    $("#content .cutechat .UserMessage tr").each(function() {
        if (!$(this).hasClass("nostyle")) {
            $("#content .cutechat .UserMessage tr td:nth-child(odd)").addClass("user_id");
        }
    });

    // select first cutechat table
    $(".cutechat table, #td_channel_container div.HtmlPanel").each(function() {
        $(".cutechat table:first, #td_channel_container div.HtmlPanel:first").addClass("first");
    });

    // select first tr
    $(".table").each(function() {
        $(".table tr:first").addClass("first");
    });
    // select last tr in .poll
    $("#extra .flexible .poll table").each(function() {
        $("#extra .flexible .poll table tr:last").addClass("last");
    });
    // select last li
    $("#content ul.anchor_index li").each(function() {
        $("#content ul.anchor_index li:last").addClass("last");
    });
    // select last li
    $("#content .small_news_items li").each(function() {
        $("#content .small_news_items li:last").addClass("last");
    });
    // add image caption
    $(function() {
        $("img.image_with_caption").each(function() {
            $(this).wrap("<div class='image_and_caption'></div>")
            $(this).parent().css("width", $(this).attr("width") + "px")
            $(this).after("<p>" + $(this).attr("alt") + "</p>")
        });
    });
    thickboxLinks();

});

function thickboxLinks() {
	var output = "";

	$(".profile .thickbox").each(function() {
		var curHref = $(this).attr("href");
		if(curHref.indexOf("?") == -1) {
			output = "?";
		}
		else {
			output = "&amp;";
		}
		output += "device=thickbox&amp;TB_iframe=true&amp;height=488&amp;width=520";
		$(this).attr("href", curHref + output)
	});
	
	$(".page_feedback .thickbox, .page_email .thickbox").each(function() {
		var curHref = $(this).attr("href");
		if(curHref.indexOf("?") == -1) {
			output = "?";
		}
		else {
			output = "&amp;";
		}
		output += "device=thickbox&amp;TB_iframe=true&amp;height=380&amp;width=450";
		$(this).attr("href", curHref + output)
	});
}

function hoverBox() {	
	$(".hoverbox a").each(function(){
		$(this).parent().mouseover(function() {$(this).addClass("hoverlink")});
		$(this).parent().mouseout(function() {$(this).removeClass("hoverlink")});
		
		//if this is a normal hoverbox
		if($(this).parent().children(".thickbox").length < 1) {
			$(this).parent().mouseup(function() {window.location = $("a", $(this)).attr("href")});
		}
		// if this is a hoverbox with thickbox
		else {
			$(this).parent().click(function() {	
				var t = $(this).children(".thickbox a").attr("title") || $(this).children(".thickbox a").attr("name") || null;
				var a = $(this).children(".thickbox a").attr("href") || $(this).children(".thickbox a").attr("alt");
				var g = $(this).children(".thickbox a").attr("rel") || false;
				var c = $(this).children(".thickbox a").attr("class").replace("thickbox", "");
				tb_show(t, a, g, c);
				return false;
			});
		}
	});

};

/************************************************************************

		Text Resize
		
************************************************************************/
/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/
function styleSwitcher() {
	
	var textSizes = new Array();
	var textSize = null;
	var options = new Array();
	
	var c = readCookie('font-size');
	if (c) {switchStyle(c);}
		
	$('link[@rel*=style][@title]').each(function(i) {
		
		var href = this.getAttribute('href');
		var parts = (href.split("/"));
		var last = parts[parts.length-1];
		var num = (last.split("."))[0];
		
		if(!this.disabled && textSize == null) {
			textSize = parseInt(num);
		}
		textSizes.push(parseInt(num));
		
		options[num] = this.getAttribute('title');
	});

	textSizes.sort(sortfunction);

	var textIndex;
	


	for (var i=0; i < textSizes.length; i++) {
		if (parseInt(textSizes[i]) === textSize) {
			textIndex = i;
		}
	}

	$('.page_text-size .increase').click(function() {
		if(textSizes[textIndex+1]) {
			textIndex++;
			switchStyle(options[textSizes[textIndex]])
		}
		
		return false;
	});

	$('.page_text-size .decrease').click(function() {
		if(textSizes[textIndex-1]) {
			textIndex--;
			switchStyle(options[textSizes[textIndex]])
		}
		
		return false;
	});
}

function switchStyle(src) {
	$('link[@rel*=style][@title]').each(function(i) {
		this.disabled = true;
		if (this.getAttribute('title') == src) this.disabled = false;
	});
	createCookie('font-size', src, 365);
}

function sortfunction(a, b) {
	return (a - b) //causes an array to be sorted numerically and ascending
}

/* end style switcher */

/*
 * cookie functions 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 eraseCookie(name)
{
	createCookie(name,"",-1);
}
/* end cookie functions */


// Flash loader
function writeFlash(flashSrc, flashWidth, flashHeight){
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="' + flashHeight + '" width="' + flashWidth + '" align="top"><param name="movie" value="' + flashSrc + '"><param name="wmode" value="opaque"><param name="play" value="true"><embed align="top" height="' + flashHeight + '" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + flashSrc + '" type="application/x-shockwave-flash" width="' + flashWidth + '" quality="best" wmode="opaque" play="true"><\/embed><\/object>' );
}

// Flash loader Patient & Visitors Guide
function writeVisitorFlash(flashSrc, flashWidth, flashHeight, flashVar){
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="' + flashHeight + '" width="' + flashWidth + '" align="top"><param name="movie" value="' + flashSrc + '"><param name="wmode" value="opaque"><param name="play" value="true"><param name="flashvars" value="var1=' + flashVar + '" /><embed align="top" height="' + flashHeight + '" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + flashSrc + '" type="application/x-shockwave-flash" width="' + flashWidth + '" quality="best" flashvars="var1=' + flashVar + '" wmode="opaque" play="true"><\/embed><\/object>' );
}

// Flash loader Interactive Campus Map
function writeMapFlash(flashSrc, flashWidth, flashHeight, flashId, flashName){
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="' + flashHeight + '" width="' + flashWidth + '" id="' + flashId + '"><param name="movie" value="' + flashSrc + '"><param name="wmode" value="opaque"><param name="play" value="true"><embed src="' + flashSrc + '" height="' + flashHeight + '" width="' + flashWidth + '" name="' + flashName + '" allowScriptAccess="sameDomain" allowFullScreen="false" quality="best" bgcolor="#ffffff" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"><\/embed><\/object>' );
}


/************************************************************************

		Thickbox
		
************************************************************************/

/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
		  
var tb_pathToImage = "../images/structure/loadingAnimation.gif";

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

//on page load call tb_init
$(document).ready(function(){   
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;});

//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
		$(domChunk).click(function(){
			if($(this).parent(".hoverbox").length <= 0) {
				var t = this.title || this.name || null;
				var a = this.href || this.alt;
				var g = this.rel || false;
				var c = $(this).attr("class").replace("thickbox", "");
				tb_show(t,a,g, c);
				this.blur();
				return false;
			}
		});
}

function tb_show(caption, url, imageGroup, newClass) {//function called when the user clicks on a thickbox link

	try {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe class='"+newClass+"' id='TB_HideSelect'></iframe><div class='"+newClass+"' id='TB_overlay'></div><div class='"+newClass+"' id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div class='"+newClass+"' id='TB_overlay'></div><div class='"+newClass+"' id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}
		
		if(tb_detectMacXFF()){
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		
		if(caption===null){caption="";}
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
		$('#TB_load').show();//show loader
		
		var baseURL;
	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
	   }else{ 
	   		baseURL = url;
	   }
	   
	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   var urlType = baseURL.toLowerCase().match(urlString);

		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
				
			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if(imageGroup){
				TB_TempArray = $("a[@rel="+imageGroup+"]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
						if (!(TB_TempArray[TB_Counter].href == url)) {						
							if (TB_FoundURL) {
								TB_NextCaption = TB_TempArray[TB_Counter].title;
								TB_NextURL = TB_TempArray[TB_Counter].href;
								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
							} else {
								TB_PrevCaption = TB_TempArray[TB_Counter].title;
								TB_PrevURL = TB_TempArray[TB_Counter].href;
								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
							}
						} else {
							TB_FoundURL = true;
							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);											
						}
				}
			}

			imgPreloader = new Image();
			imgPreloader.onload = function(){		
			imgPreloader.onload = null;
				
			// Resizing large images - orginal by Christian Montoya edited by me.
			var pagesize = tb_getPageSize();
			var x = pagesize[0] - 150;
			var y = pagesize[1] - 150;
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (imageWidth > x) {
				imageHeight = imageHeight * (x / imageWidth); 
				imageWidth = x; 
				if (imageHeight > y) { 
					imageWidth = imageWidth * (y / imageHeight); 
					imageHeight = y; 
				}
			} else if (imageHeight > y) { 
				imageWidth = imageWidth * (y / imageHeight); 
				imageHeight = y; 
				if (imageWidth > x) { 
					imageHeight = imageHeight * (x / imageWidth); 
					imageWidth = x;
				}
			}
			// End Resizing
			
			TB_WIDTH = imageWidth + 30;
			TB_HEIGHT = imageHeight + 60;
			$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> <!--// or Esc Key //--></div>"); 		
			
			$("#TB_closeWindowButton").click(tb_remove);
			
			if (!(TB_PrevHTML === "")) {
				function goPrev(){
					if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
					$("#TB_window").remove();
					$("body").append("<div id='TB_window'></div>");
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
					return false;	
				}
				$("#TB_prev").click(goPrev);
			}
			
			if (!(TB_NextHTML === "")) {		
				function goNext(){
					$("#TB_window").remove();
					$("body").append("<div id='TB_window'></div>");
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
					return false;	
				}
				$("#TB_next").click(goNext);
				
			}

			document.onkeydown = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				} else if(keycode == 190){ // display previous image
					if(!(TB_NextHTML == "")){
						document.onkeydown = "";
						goNext();
					}
				} else if(keycode == 188){ // display next image
					if(!(TB_PrevHTML == "")){
						document.onkeydown = "";
						goPrev();
					}
				}	
			};
			
			tb_position();
			$("#TB_load").remove();
			$("#TB_ImageOff").click(tb_remove);
			$("#TB_window").css({display:"block"}); //for safari using css instead of show
			};
			
			imgPreloader.src = url;
		}else{//code to show html
			
			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );

			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;
			
			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
					urlNoQuery = url.split('TB_');
					$("#TB_iframeContent").remove();
					if(params['modal'] != "true"){//iframe no modal
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='/images/buttons/close_email.gif' alt='close' /></a> <!--//  oror Esc Key //--></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
					}else{//iframe modal
					$("#TB_overlay").unbind();
						$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
					}
			}else{// not an iframe, ajax
					if($("#TB_window").css("display") != "block"){
						if(params['modal'] != "true"){//ajax no modal
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a><!--// or Esc Key //--></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
						}else{//ajax modal
						$("#TB_overlay").unbind();
						$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");	
						}
					}else{//this means the window is already up, we are just loading new content via ajax
						$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
						$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
						$("#TB_ajaxContent")[0].scrollTop = 0;
						$("#TB_ajaxWindowTitle").html(caption);
					}
			}
					
			$("#TB_closeWindowButton").click(tb_remove);
			
				if(url.indexOf('TB_inline') != -1){	
					$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
					$("#TB_window").unload(function () {
						$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished
					});
					tb_position();
					$("#TB_load").remove();
					$("#TB_window").css({display:"block"}); 
				}else if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($.browser.safari){//safari needs help because it will not fire iframe onload
						$("#TB_load").remove();
						$("#TB_window").css({display:"block"});
					}
				}else{
					$("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
						tb_position();
						$("#TB_load").remove();
						tb_init("#TB_ajaxContent a.thickbox");
						$("#TB_window").css({display:"block"});
					});
				}
			
		}

		if(!params['modal']){
			document.onkeyup = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				}	
			};
		}
		
	} catch(e) {
		//nothing here
	}
}

//helper functions below
function tb_showIframe(){
	$("#TB_load").remove();
	$("#TB_window").css({display:"block"});
}

function tb_remove() {
 	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position() {
$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}

function tb_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}



/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
(function($){$.dimensions={version:'1.2'};$.each(['Height','Width'],function(i,name){$.fn['inner'+name]=function(){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';return this.is(':visible')?this[0]['client'+name]:num(this,name.toLowerCase())+num(this,'padding'+torl)+num(this,'padding'+borr);};$.fn['outer'+name]=function(options){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';options=$.extend({margin:false},options||{});var val=this.is(':visible')?this[0]['offset'+name]:num(this,name.toLowerCase())+num(this,'border'+torl+'Width')+num(this,'border'+borr+'Width')+num(this,'padding'+torl)+num(this,'padding'+borr);return val+(options.margin?(num(this,'margin'+torl)+num(this,'margin'+borr)):0);};});$.each(['Left','Top'],function(i,name){$.fn['scroll'+name]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(name=='Left'?val:$(window)['scrollLeft'](),name=='Top'?val:$(window)['scrollTop']()):this['scroll'+name]=val;}):this[0]==window||this[0]==document?self[(name=='Left'?'pageXOffset':'pageYOffset')]||$.boxModel&&document.documentElement['scroll'+name]||document.body['scroll'+name]:this[0]['scroll'+name];};});$.fn.extend({position:function(){var left=0,top=0,elem=this[0],offset,parentOffset,offsetParent,results;if(elem){offsetParent=this.offsetParent();offset=this.offset();parentOffset=offsetParent.offset();offset.top-=num(elem,'marginTop');offset.left-=num(elem,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return $(offsetParent);}});function num(el,prop){return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;};})(jQuery);

/* Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.min.js 3579 2007-10-06 17:17:09Z kelvin.luck $
 */

jQuery.jScrollPane={active:[]};jQuery.fn.jScrollPane=function(settings){settings=jQuery.extend({scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:true,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:20,animateInterval:100,animateStep:3,maintainPosition:true},settings);return this.each(function(){var $this=jQuery(this);if(jQuery(this).parent().is('.jScrollPaneContainer')){var currentScrollPosition=settings.maintainPosition?$this.offset({relativeTo:jQuery(this).parent()[0]}).top:0;var $c=jQuery(this).parent();var paneWidth=$c.innerWidth();var paneHeight=$c.outerHeight();var trackHeight=paneHeight;if($c.unmousewheel){$c.unmousewheel()}jQuery('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown',$c).remove();$this.css({'top':0})}else{var currentScrollPosition=0;this.originalPadding=$this.css('paddingTop')+' '+$this.css('paddingRight')+' '+$this.css('paddingBottom')+' '+$this.css('paddingLeft');this.originalSidePaddingTotal=(parseInt($this.css('paddingLeft'))||0)+(parseInt($this.css('paddingRight'))||0);var paneWidth=$this.innerWidth();var paneHeight=$this.innerHeight();var trackHeight=paneHeight;$this.wrap(jQuery('<div></div>').attr({'className':'jScrollPaneContainer'}).css({'height':paneHeight+'px','width':paneWidth+'px'}));jQuery(document).bind('emchange',function(e,cur,prev){$this.jScrollPane(settings)})}var p=this.originalSidePaddingTotal;$this.css({'height':'auto','width':paneWidth-settings.scrollbarWidth-settings.scrollbarMargin-p+'px','paddingRight':settings.scrollbarMargin+'px'});var contentHeight=$this.outerHeight();var percentInView=paneHeight/contentHeight;if(percentInView<.99){var $container=$this.parent();$container.append(jQuery('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(jQuery('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(jQuery('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),jQuery('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'}))));var $track=jQuery('>.jScrollPaneTrack',$container);var $drag=jQuery('>.jScrollPaneTrack .jScrollPaneDrag',$container);if(settings.showArrows){var currentArrowButton;var currentArrowDirection;var currentArrowInterval;var currentArrowInc;var whileArrowButtonDown=function(){if(currentArrowInc>4||currentArrowInc%4==0){positionDrag(dragPosition+currentArrowDirection*mouseWheelMultiplier)}currentArrowInc++};var onArrowMouseUp=function(event){jQuery('body').unbind('mouseup',onArrowMouseUp);currentArrowButton.removeClass('jScrollActiveArrowButton');clearInterval(currentArrowInterval)};var onArrowMouseDown=function(){jQuery('body').bind('mouseup',onArrowMouseUp);currentArrowButton.addClass('jScrollActiveArrowButton');currentArrowInc=0;whileArrowButtonDown();currentArrowInterval=setInterval(whileArrowButtonDown,100)};$container.append(jQuery('<a></a>').attr({'href':'javascript:;','className':'jScrollArrowUp'}).css({'width':settings.scrollbarWidth+'px'}).html('Scroll up').bind('mousedown',function(){currentArrowButton=jQuery(this);currentArrowDirection=-1;onArrowMouseDown();this.blur();return false}),jQuery('<a></a>').attr({'href':'javascript:;','className':'jScrollArrowDown'}).css({'width':settings.scrollbarWidth+'px'}).html('Scroll down').bind('mousedown',function(){currentArrowButton=jQuery(this);currentArrowDirection=1;onArrowMouseDown();this.blur();return false}));if(settings.arrowSize){trackHeight=paneHeight-settings.arrowSize-settings.arrowSize;$track.css({'height':trackHeight+'px',top:settings.arrowSize+'px'})}else{var topArrowHeight=jQuery('>.jScrollArrowUp',$container).height();settings.arrowSize=topArrowHeight;trackHeight=paneHeight-topArrowHeight-jQuery('>.jScrollArrowDown',$container).height();$track.css({'height':trackHeight+'px',top:topArrowHeight+'px'})}}var $pane=jQuery(this).css({'position':'absolute','overflow':'visible'});var currentOffset;var maxY;var mouseWheelMultiplier;var dragPosition=0;var dragMiddle=percentInView*paneHeight/2;var getPos=function(event,c){var p=c=='X'?'Left':'Top';return event['page'+c]||(event['client'+c]+(document.documentElement['scroll'+p]||document.body['scroll'+p]))||0};var ignoreNativeDrag=function(){return false};var initDrag=function(){ceaseAnimation();currentOffset=$drag.offset(false);currentOffset.top-=dragPosition;maxY=trackHeight-$drag[0].offsetHeight;mouseWheelMultiplier=2*settings.wheelSpeed*maxY/contentHeight};var onStartDrag=function(event){initDrag();dragMiddle=getPos(event,'Y')-dragPosition-currentOffset.top;jQuery('body').bind('mouseup',onStopDrag).bind('mousemove',updateScroll);if(jQuery.browser.msie){jQuery('body').bind('dragstart',ignoreNativeDrag).bind('selectstart',ignoreNativeDrag)}return false};var onStopDrag=function(){jQuery('body').unbind('mouseup',onStopDrag).unbind('mousemove',updateScroll);dragMiddle=percentInView*paneHeight/2;if(jQuery.browser.msie){jQuery('body').unbind('dragstart',ignoreNativeDrag).unbind('selectstart',ignoreNativeDrag)}};var positionDrag=function(destY){destY=destY<0?0:(destY>maxY?maxY:destY);dragPosition=destY;$drag.css({'top':destY+'px'});var p=destY/maxY;$pane.css({'top':((paneHeight-contentHeight)*p)+'px'});$this.trigger('scroll')};var updateScroll=function(e){positionDrag(getPos(e,'Y')-currentOffset.top-dragMiddle)};var dragH=Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2),settings.dragMaxHeight),settings.dragMinHeight);$drag.css({'height':dragH+'px'}).bind('mousedown',onStartDrag);var trackScrollInterval;var trackScrollInc;var trackScrollMousePos;var doTrackScroll=function(){if(trackScrollInc>8||trackScrollInc%4==0){positionDrag((dragPosition-((dragPosition-trackScrollMousePos)/2)))}trackScrollInc++};var onStopTrackClick=function(){clearInterval(trackScrollInterval);jQuery('body').unbind('mouseup',onStopTrackClick).unbind('mousemove',onTrackMouseMove)};var onTrackMouseMove=function(event){trackScrollMousePos=getPos(event,'Y')-currentOffset.top-dragMiddle};var onTrackClick=function(event){initDrag();onTrackMouseMove(event);trackScrollInc=0;jQuery('body').bind('mouseup',onStopTrackClick).bind('mousemove',onTrackMouseMove);trackScrollInterval=setInterval(doTrackScroll,100);doTrackScroll()};$track.bind('mousedown',onTrackClick);if($container.mousewheel){$container.mousewheel(function(event,delta){initDrag();ceaseAnimation();var d=dragPosition;positionDrag(dragPosition-delta*mouseWheelMultiplier);var dragOccured=d!=dragPosition;return!dragOccured},false)}var _animateToPosition;var _animateToInterval;function animateToPosition(){var diff=(_animateToPosition-dragPosition)/settings.animateStep;if(diff>1||diff<-1){positionDrag(dragPosition+diff)}else{positionDrag(_animateToPosition);ceaseAnimation()}}var ceaseAnimation=function(){if(_animateToInterval){clearInterval(_animateToInterval);delete _animateToPosition}};var scrollTo=function(pos,preventAni){if(typeof pos=="string"){$e=jQuery(pos,this);if(!$e.length)return;pos=$e.offset({relativeTo:this}).top}ceaseAnimation();var destDragPosition=-pos/(paneHeight-contentHeight)*maxY;if(!preventAni||settings.animateTo){_animateToPosition=destDragPosition;_animateToInterval=setInterval(animateToPosition,settings.animateInterval)}else{positionDrag(destDragPosition)}};$this[0].scrollTo=scrollTo;$this[0].scrollBy=function(delta){var currentPos=-parseInt($pane.css('top'))||0;scrollTo(currentPos+delta)};initDrag();scrollTo(-currentScrollPosition,true);jQuery.jScrollPane.active.push($this[0])}else{$this.css({'height':paneHeight+'px','width':paneWidth-this.originalSidePaddingTotal+'px','padding':this.originalPadding})}})};jQuery(window).bind('unload',function(){var els=jQuery.jScrollPane.active;for(var i=0;i<els.length;i++){els[i].scrollTo=els[i].scrollBy=null}});





$(document).ready(function()  {
	$('#pane').jScrollPane();
});



/* photo gallery  */
function gallery(increment, visibleItems) {
	if ($("#gallery").length == 1)
	{

	$("body").addClass("jsEnabled");
	//Add buttons to scroll the gallery
	$("#thumbs").prepend("<a href='#next' id='scroll-left'>Scroll Up</a>");
	$("#thumbs").append("<a href='#previous' id='scroll-right'>Scroll Down</a>");

	//Add Container for media and text
	$("#gallery").prepend("<div id='showcase'></div><p id='counter'></p>");	
	$("#showcase").prepend("<div id='media'><div id='image_wrapper'></div></div>");
	$("#showcase").append("<p></p>");

	//Wrap the ul in a holder tag
	$("#thumbs ul").wrap("<div id='slide-holder'></div>");
	var totalImages = $("#thumbs li").length;
	var galleryItem = $("#thumbs li:first");
	
	//Get the size of each item and any margin, padding, or border
	var totalDimensions;
	var itemSize = galleryItem.width();
	totalDimensions = new Array("margin-left", "margin-right", "padding-left", "padding-right");

	for (var n = 0; n < totalDimensions.length; n++) {
		itemSize += Number(galleryItem.css(totalDimensions[n]).replace("px", ""));
	}

	var incrementAmount = increment * itemSize;
	var visibleItemsSize = visibleItems * itemSize;
	var maxOffset = (totalImages * itemSize) - visibleItemsSize;


	//Add events to the scroll buttons
	var target = $("#thumbs ul");
	var imageSet = 1;
	var curImage = 0
	$("#scroll-left").click(function() {
		scroll(target, "left", incrementAmount, maxOffset);
		imageSet --;
		curImage = curImage - 5
			if (curImage < 0)
			{
			curImage = 0
			}
			$("#counter_smpl").html("Displaying " +(curImage + 1)+ " - " +(curImage + 5)+ " <span>(of " +totalImages+ ")</span>")
		return false;
	});
	$("#scroll-right").click(function() {
		scroll(target, "right", incrementAmount, maxOffset);
		imageSet ++;
		curImage = curImage + 5
		if (curImage >= totalImages - 5)
		{
			curImage = totalImages - 5
		}	
			$("#counter_smpl").html("Displaying " +(curImage + 1)+ " - " +(curImage + 5)+ " <span>(of " +totalImages+ ")</span>")
		return false;
	});

	var totalItems = $("#thumbs li").length;
	var counter = 0;

	// Make first gallery item active by default
	$("#thumbs li:first").each(function() {
		var link = $(this).children("a").attr("href");
		var thumbSrc = $(this).children("a").children("span").children("img").attr("src");
		var altText = $(this).children("a").children("img").attr("alt");
		var text = $(this).children("a").children("em").text();
		if(thumbSrc != null) var newThumbSrc = link;

		$("#counter_smpl").html("Displaying " +1+ " - " +5+ " <span>(of " +totalImages+ ")</span>")
		$(this).siblings().removeClass("active");
		$(this).addClass("active");
		$("#image_wrapper").prepend('<img alt="' + altText + '" class="item"" src="' + newThumbSrc + '" />');
		$("#showcase p").text(text);
		
		var wallpaper = $(this).children(".wallpaper").attr("href");
		if(wallpaper != undefined) {
			$("#showcase").append("<a class='wallpaper' href='" + wallpaper + "'>Save As Desktop Wallpaper</a>");
		}
	});

	var $thumbs = $("#thumbs li")
	$thumbs.each(function() {
		counter ++;
		var link = $(this).children("a").attr("href");
		var altText = $(this).children("a").children("img").attr("alt");
		
		var splitLink = link.split("?");
		var end = splitLink[0].lastIndexOf(".");
		var mediaType = splitLink[0].substring(end+1);
		
		var text = $(this).children("a").children("em").text();
		var wallpaper = $(this).children(".wallpaper").attr("href");
		var itemNumber = counter;
		
		var mediaContent;
		var height, width;
		//Generate code based on the type of media to be displayed
		switch(mediaType) {

			//Audio
			case "mp3":
				//hard code the dimensions of mp3 files so that just the controls are visible
				width = 300;
				height = 16;

				/* Begin creating the OBJECT tag */
				mediaContent = '<object class="item" width="'+ width +'" height="'+ height +'" id="gallery-media" name="gallery-media"';
			
				if(navigator.plugins && navigator.plugins.length){
					mediaContent += 'data="'+ link +'" type="video/quicktime">';
				}else{ // IE
					mediaContent +=  'classid= "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0">';
				}

				mediaContent += '<param value="'+ link +'" name="src"/>'+
				'<param value="aspect" name="scale"/>'+
				'<param value="true" name="controller"/>'+
				'<param value="true" name="autoplay"/>'+
				'</object>';
				//End OBJECT tag
				break;

			//Flash
			case "swf":
				//Get all the parameters for the flash movie
				var urlParams = link.split("?");
				link = urlParams[0];
				var properties = getQueryString(urlParams[1]);
				
				width = properties['width'];
				height = properties['height'];
				
				//If dimensions not defined or too large then set to max size
				if(!height || height > 309) height = 309;
				if(!width || width > 472) width = 472;
				
				flashVars = '&MM_ComponentVersion='+ properties['MM_ComponentVersion'] +'&skinName='+ properties['skinName'] +'&streamName='+ properties['streamName'] +'&autoPlay='+ properties['autoPlay'] +'&autoRewind='+ properties['autoRewind'];

				mediaContent = '<object class="item" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="' + height + '" width="' + width + '" align="top">'+
				'<param value="lt" name="salign"/>'+
  				'<param value="noscale" name="scale"/>'+
				'<param name="movie" value="'+ link +'">'+
				'<param name="quality" value="high">'+
				'<param value="'+ flashVars +'" name="FlashVars"/>'+
				'<embed flashvars="'+ flashVars +'" height="' + height + '" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + link + '" type="application/x-shockwave-flash" width="' + width + '" quality="high" salign="LT" scale="noscale">'+
				'<\/embed><\/object>';
				break;

			//Images
			case "ashx":
			case "jpg":
			case "jpeg":
			case "gif":
			case "png":
			case "bmp":
				mediaContent = '<img alt="' +  altText + '" class="item" src="' + link + '" />';
				break;

			//Video
			case "mov":
				var urlParams = link.split("?");
				link = urlParams[0];
				var properties = getQueryString(urlParams[1]);
				width = properties['width'];
				height = properties['height'];
				
				/* Begin creating the OBJECT tag */
				mediaContent = '<object class="item" width="'+ width +'" height="'+ height +'" id="gallery-media" name="gallery-media"';
			
				if(navigator.plugins && navigator.plugins.length){
					mediaContent += 'data="'+ link +'" type="video/quicktime">';
				}else{ // IE
					mediaContent +=  'classid= "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0">';
				}
			
				mediaContent += '<param value="'+ link +'" name="src"/>'+
				'<param value="aspect" name="scale"/>'+
				'<param value="true" name="controller"/>'+
				'<param value="true" name="autoplay"/>'+
				'</object>';
				//End OBJECT tag
				break;
		}

		//When thumbnail clicked, set as active item and load content into main display area
		$(this).click(function() {
			addMediaToPage($(this), itemNumber, totalItems, mediaContent, text, wallpaper);
			return false;
		});

		//Add hover effect to gallery items
		$(this).mouseover(function() {
			$(this).addClass("jsHover");
		});
		$(this).mouseout(function() {
			$(this).removeClass("jsHover");
		});
		this.onclick = function() { return false; };
	});
}
}
/*
 * After all the work has been done, this will add the html to the page
 * It also removes any existing media in the showcase
 */
function addMediaToPage(el, itemNumber, totalItems, mediaContent, text, wallpaper) {
	//Display Counter
	$("#showcase").empty();
	$("#showcase").prepend("<div id='media'><div id='image_wrapper'></div></div>");
	$("#showcase").append("<p></p>");

	//Set current item as active
	el.siblings().removeClass("active");
	el.siblings().removeClass("jsHover");
	el.addClass("active");

	//Remove existing content
	try {
		document.gallery-media.Stop();
	}
	catch(e){}
	$("#image_wrapper .item").css("display", "none");
	$("#image_wrapper").empty();
	
	//Add new content
	document.getElementById("image_wrapper").innerHTML = mediaContent;
	$("#showcase p").text(text);
	
	//Remove existing content
	try {
		document.gallery-media.Stop();
	}
	catch(e){}
	$("#image_wrapper .item").css("display", "none");
	$("#image_wrapper").empty();
	//Add new content
	document.getElementById("image_wrapper").innerHTML = mediaContent;
	$("#showcase p").text(text);
	
	if(wallpaper != undefined) {
		$("#showcase").append("<a class='wallpaper' href='" + wallpaper + "'>Save As Desktop Wallpaper</a>");
	}
}

/*
 * Get the dimensions of the media content from a query string
 * Returns an array containing width and height
 */
function getDimensions(params) {
	var dim = new Array();
	params = params.split("&");
	dim[0] = params[1].substring(6);
	dim[1] = Number(params[0].substring(7)) + 16;
	return dim;
}

function getQueryString(params) {
	var props = new Array();
	
	$(params.split("&")).each(function(i) {
		var param = this.split("=");
		props[param[0]] = param[1];
	});

	return props;
}

/*
 * Scroll the gallery the required amount in the specified direction
 */
function scroll(container, direction, amount, maxOffest) {
	var cur = container.css("left");

	if(cur == "auto") cur = 0;
	else cur = Number(cur.replace("px", ""));

	switch(direction) {
		case "left":
			cur = cur + amount;
			if(cur > 0) cur = 0;
			break;
		case "right":
			cur = cur - amount;
			if(cur < - maxOffest) cur = - maxOffest;
			break;
	}

	container.css("left", cur+"px");
}
$(function() {
			gallery(5, 5);
		});
// Hello jQuery!
$(document).ready(function() {
// First, let's tell tag the page when javascript is on.
	$("body").addClass("jsOn");


// Accordion ------------------------------

//	First, set the height of each hidden section so IE can show/hide it properly.
	$(".accordion li ul").each(function() {
		var myHeight = $(this).height()
		$(this).css({ height:myHeight+20 });
	});

//	Hide all nested ULs with js (so users with js turned off can see everything)
	$(".accordion ul").hide();

//	Hover state for headlines
    $(".accordion h3.handle").hover(
      function () { $(this).addClass("over"); }, 
      function () { $(this).removeClass("over"); }
    );

//	Accordion actions
	$(".accordion h3.handle").click(function() {
	//	If clicking on an active section, just close it and remove the active state.
		if($(this).parent().hasClass("active")) {
			$("li.active ul").slideUp(300)
			$(".accordion li").removeClass("active")
		}
	//	Otherwise, the click triggers three actions: close the active section, open
	//	the section that's clicked on, and mark it active.
		else if($(this).hasClass("handle")) {
			$(".accordion li.active ul").slideUp(300)
			$(".accordion li").removeClass("active")
			$(this).parent().addClass("active")
			$(".accordion li.active ul").slideDown(300)
		}
	});



});// Bye-bye jQuery! ------------------------------

/***************************************/
// jQuery Tabber
// By Jordan Boesch
// www.boedesign.com
// Dec 25, 2007 (Merry Christmas!)
/***************************************/

	$.extend($, {
		jtabber: function(params){
				
				// parameters
				var directory_searchDiv = params.mainLinkTag;
				var selectedClass = params.activeLinkClass;
				var hiddenContentDiv = params.hiddenContentClass;
				var showDefaultTab = params.showDefaultTab;
				var showErrors = params.showErrors;
				var effect = params.effect;
				var effectSpeed = params.effectSpeed;
				
				// If error checking is enabled
				if(showErrors){
					if(!$(directory_searchDiv).attr('title')){
						alert("ERROR: The elements in your mainLinkTag paramater need a 'title' attribute.\n ("+directory_searchDiv+")");	
						return false;
					}
					else if(!$("."+hiddenContentDiv).attr('id')){
						alert("ERROR: The elements in your hiddenContentClass paramater need to have an id.\n (."+hiddenContentDiv+")");	
						return false;
					}
				}
				
				// If we want to show the first block of content when the page loads
				if(!isNaN(showDefaultTab)){
					showDefaultTab--;
					$("."+hiddenContentDiv+":eq("+showDefaultTab+")").css('display','block');
					$(directory_searchDiv+":eq("+showDefaultTab+")").addClass(selectedClass);	
				}
				
				// each anchor
				$(directory_searchDiv).each(function(){
										
					$(this).click(function(){
						// once clicked, remove all classes
						$(directory_searchDiv).each(function(){
							$(this).removeClass();
						})
						// hide all content
						$("."+hiddenContentDiv).css('display','none');
						
						// now lets show the desired information
						$(this).addClass(selectedClass);
						var contentDivId = $(this).attr('title');
						
						if(effect != null){
							
							switch(effect){
								
								case 'slide':
								$("#"+contentDivId).slideDown(effectSpeed = 500);
								break;
								case 'fade':
								$("#"+contentDivId).fadeIn(effectSpeed);
								break;
								
							}
								
						}
						else {
							$("#"+contentDivId).css('display','block');
						}
						return false;
					})
				})
			
			}
	})
	