$(document).ready(function(){

	$("#slots .slots:first-child").addClass("first");
	$("#breadcrumb a:last-child").addClass("last");



	// Show/hide unsubscribe form

	$("#unsubscribe").hide();
	$("#subscribe div").append("<a href='#unsubscribe' id='unsublink' class='morelink'>Unsubscribe?<\/a>")
	$("#unsublink").click(function() {
		$("#unsubscribe").show();
		$("#subscribe").hide();
	});


	/**
	 * Equal Heights Plugin
	 * Equalize the heights of elements. Great for columns or any elements
	 * that need to be the same size (floats, etc).
	 * 
	 * Version 1.0
	 * Updated 12/10/2008
	 *
	 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
	 *
	 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
	 * 
	 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
	 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
	 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
	 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
	 * 
	 */

	(function($) {
		$.fn.equalHeights = function(minHeight, maxHeight) {
			tallest = (minHeight) ? minHeight : 0;
			this.each(function() {
				if($(this).height() > tallest) {
					tallest = $(this).height();
				}
			});
			if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
			return this.each(function() {

				//If browser is Microsoft Internet explorer, then use css "height: yypx"
				if ($.browser.msie && $.browser.version == 6.0) { $(this).height(tallest).css("overflow","auto");
				}

				//use css "min-height: yypx"
				$(this).css({"min-height": tallest});
			});
		}
	})(jQuery);


	// Show/hide default text on form inputs if needed

	var searchBoxes = $(".forminput");

	searchBoxes.each(function(){
	if($(this).attr("value") == ""){
		$(this).attr("value", $(this).attr("title"));
		$(this).css("color","#7F7777");
		}
	if($(this).attr("value") == $(this).attr("title")){
		$(this).css("color","#7F7777");
	}
	});

	searchBoxes.focus(function(){
		if($(this).attr("value") == $(this).attr("title")){
		$(this).attr("value", "");
		$(this).css("color","#1F1D1D");
		$(this).addClass("active");
		}
	});
	searchBoxes.blur(function(){
		if($(this).attr("value") == "") {
		$(this).attr("value", $(this).attr("title"))
		$(this).css("color","#7F7777");
		$(this).removeClass("active");
		};
	});


	// Show/hide back to top link if needed

	$(function() {
		var height = $("#content").height();
		if (height > 600) {
			$("a#toplnk").show();
		} else {
			$("a#toplnk").hide();
		}
		$('a#toplnk').click(function(){
			 $('html, body').animate({scrollTop: '0px'}, 300);
			 return false;
		});
	});
	
	
	// Show/hide back to top link if needed
	
	$('#lhs a:not(.noAutoLink), #rhs a:not(.noAutoLink), #rhsfull a:not(.noAutoLink)').filter(function() {
		var theHref = this;
		if (theHref.hostname && theHref.hostname !== location.hostname) {
			$(theHref).not(".noAutoIcon").addClass("offSite autoIcon");
			$(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) {
				var code=event.charCode || event.keyCode;
				if (!code || (code && code == 13)) {
					if(pageTracker){
						var fixedLink = this.href;
						fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
						fixedLink = '/outgoing/' + fixedLink;
						pageTracker._trackPageview(fixedLink);
					};
				};
			});
		};
		$("a[href$=pdf]").addClass("pdf autoIcon");
		$("a[href$=zip], a[href$=.gzip], a[href$=.rar]").addClass("zip autoIcon");
		$("a[href$=psd]").addClass("psd autoIcon");
		$("a[href$=.xls], a[href$=.csv], a[href$=.xlt], a[href$=.xlw]").addClass("xls autoIcon");
		$("a[href$=.ppt], a[href$=.pps]").addClass("ppt autoIcon");
		$("a[href$=.doc], a[href$=.docx], a[href$=.rtf], a[href$=.txt], a[href$=.wps]").addClass("doc autoIcon");
		$("a[href^='mailto:']").addClass("emailLink autoIcon");
	});



	// Equal heights last, otherwise changes to display may result in scrollbars
		
});

$(window).load(function(){
	// Repeat equal heights call here to ensure, images don't throw things out
});
