
/* 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:46:55 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4259 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */

(function($){
	
$.dimensions = {
	version: '1.2'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
$.each( [ 'Height', 'Width' ], function(i, name){
	
	// innerHeight and innerWidth
	$.fn[ 'inner' + name ] = function() {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
	};
	
	// outerHeight and outerWidth
	$.fn[ 'outer' + name ] = function(options) {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or 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);
	};
});

// Create scrollLeft and scrollTop methods
$.each( ['Left', 'Top'], function(i, name) {
	$.fn[ 'scroll' + name ] = function(val) {
		if (!this[0]) return;
		
		return val != undefined ?
		
			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo( 
						name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
						name == 'Top'  ? val : $(window)[ 'scrollTop'  ]()
					) :
					this[ 'scroll' + name ] = val;
			}) :
			
			// Return the scroll offset
			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) {
			// Get *real* offsetParent
			offsetParent = this.offsetParent();
			
			// Get correct offsets
			offset       = this.offset();
			parentOffset = offsetParent.offset();
			
			// Subtract element margins
			offset.top  -= num(elem, 'marginTop');
			offset.left -= num(elem, 'marginLeft');
			
			// Add offsetParent borders
			parentOffset.top  += num(offsetParent, 'borderTopWidth');
			parentOffset.left += num(offsetParent, 'borderLeftWidth');
			
			// Subtract the two offsets
			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 Brandon Aaron (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-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
;(function($){ // secure $ jQuery alias
/*******************************************************************************************/	
// jquery.event.hover.js - rev 5 
// Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
// Liscensed under the MIT License (MIT-LICENSE.txt)
// http://www.opensource.org/licenses/mit-license.php
// Created: 2008-06-02 | Updated: 2008-07-30
/*******************************************************************************************/

//	USE THESE PROPERTIES TO CUSTOMIZE SETTINGS...

//	$.event.special.hover.delay = 100; 
//	Defines the delay (msec) while mouse is inside the element before checking the speed

//	$.event.special.hover.speed = 100; 
//	Defines the maximum speed (px/sec) the mouse may be moving to trigger the hover event

// save the old jquery "hover" method
$.fn._hover = $.fn.hover;

// jquery method 
$.fn.hover = function( fn1, fn2, fn3 ) {
	if ( fn3 ) this.bind('hoverstart', fn1 ); // 3 args
	if ( fn2 ) this.bind('hoverend', fn3 ? fn3 : fn2 ); // 2+ args
	return !fn1 ? this.trigger('hover') // 0 args 
		: this.bind('hover', fn3 ? fn2 : fn1 ); // 1+ args
	};	

// special event configuration
var hover = $.event.special.hover = {
	delay: 100, // milliseconds
	speed: 100, // pixels per second
	setup: function( data ){
		data = $.extend({ speed: hover.speed, delay: hover.delay, hovered:0 }, data||{} );
		$.event.add( this, "mouseenter mouseleave", hoverHandler, data );
		},
	teardown: function(){
		$.event.remove( this, "mouseenter mouseleave", hoverHandler );
		}
	};

// shared event handler
function hoverHandler( event ){
	var data = event.data || event;
	switch ( event.type ){
		case 'mouseenter': // mouseover
			data.dist2 = 0; // init mouse distance²
			data.event = event; // store the event
			event.type = "hoverstart"; // hijack event
			if ( $.event.handle.call( this, event ) !== false ){ // handle "hoverstart"
				data.elem = this; // ref to the current element
				$.event.add( this, "mousemove", hoverHandler, data ); // track the mouse
				data.timer = setTimeout( compare, data.delay ); // start async compare
				}
			break;
		case 'mousemove': // track the event, mouse distance² = x² + y²
			data.dist2 += Math.pow( event.pageX-data.event.pageX, 2 ) 
				+ Math.pow( event.pageY-data.event.pageY, 2 ); 
			data.event = event; // store current event
			break;
		case 'mouseleave': // mouseout
			clearTimeout( data.timer ); // uncompare
			if ( data.hovered ){ 
				event.type = "hoverend"; // hijack event
				$.event.handle.call( this, event ); // handle "hoverend"
				data.hovered--; // reset flag
				}
			else $.event.remove( data.elem, "mousemove", hoverHandler ); // untrack
			break;
		default: // timeout compare // distance² = x² + y²  = ( speed * time )²
			if ( data.dist2 <= Math.pow( data.speed*( data.delay/1e3 ), 2 ) ){ // speed acceptable
				$.event.remove( data.elem, "mousemove", hoverHandler ); // untrack
				data.event.type = "hover"; // hijack event
				if ( $.event.handle.call( data.elem, data.event ) !== false ) // handle "hover"
					data.hovered++; // flag for "hoverend"
				}
			else data.timer = setTimeout( compare, data.delay ); // async recurse
			data.dist2 = 0; // reset distance² for next compare
			break;
		}
	function compare(){ hoverHandler( data ); }; // timeout/recursive function
	};
	
/*******************************************************************************************/
})(jQuery); // confine scope



/* jquery.tbd-slideshow 0.5 :: developed by jsummers.at.techbydesign.com */

(function($) {
	//
	// plugin definition
	//
	$.fn.slideshow = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.slideshow.defaults, options);
		// iterate and reformat each matched element
		return this.each(function() {
			$this = $(this);
			var list = $this.find("ul:first");
			var active = null;
			// build element specific options
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			//if set height
			if(opts.slideH != null){
		  		$this.css({"height": opts.slideH+"px"});
	  		}
	  		//if set width
	  		if(opts.slideW != null){
	  			var totalW = opts.slideW * opts.show;
		  		$this.css({"width": totalW+"px"});
	  		}
	  		//if we use js to strip styles
	  		if(opts.listStyles == false){
	  			$this.find("ul, li").css({"margin":"0px","padding":"0px","list-style-type":"none"});
	  		}
	  		
	  		$this.find("li").height(opts.slideH);
	  		//position element, children, 
		  	$this.css({"position": "relative","overflow": "hidden", "display":"block"}).children("ul").css({"top":"0px","position": "absolute", "left":"0px"}).children("li").each(function(obj,call){
		    		if(obj == 0){
						active = $(this).addClass(opts.activeSlide);
					}
					//position each children element
					if(opts.xslide == false){
						var place = opts.slideH * obj;
						jQuery(this).css({"top":place+"px", "position":"absolute", "left": "0px"}).show();
					}else{
						var leftPlace = opts.slideW * obj;
						jQuery(this).css({"top":"0px", "position":"absolute", "left": leftPlace+"px"}).show();
					}
					
					if(opts.slideW){
						jQuery(this).css({"width": opts.slideW+"px"});
					}
				});
			
			//add next and back buttons
			switch(opts.buttonPlacement)
			{    
				case "prepend":
					$this.prepend("<div class="+opts.backBttn+"></div><div class="+opts.nextBttn+"></div>");
					var goback = $this.find("."+opts.backBttn);
					var gonext = $this.find("."+opts.nextBttn);
				break;
				case "before":
					$this.before("<div class="+opts.backBttn+"></div>");
					var goback = $this.prev("."+opts.backBttn);
					$this.before("<div class="+opts.nextBttn+"></div>");
					var gonext = $this.prev("."+opts.nextBttn);
				break;
				case "after":
					$this.after("<div class="+opts.backBttn+"></div>");
					var goback = $this.next("."+opts.backBttn);
					$this.after("<div class="+opts.nextBttn+"></div>")
					var gonext = $this.next("."+opts.nextBttn);
				break;
				default:
					$this.append("<div class="+opts.backBttn+"></div><div class="+opts.nextBttn+"></div>");
					var goback = $this.find("."+opts.backBttn);
					var gonext = $this.find("."+opts.nextBttn);
			}
			//add events to the buttons
			//todo: change all this so that we are not depending on the opts width / height
			//todo: maybe allow for items to vary in width
			$(goback).click(function(){
				goBack();
				return false;
			}).css("cursor","pointer");
			
			$(gonext).click(function(){
				goNext();
				return false;
			}).css("cursor","pointer");
			
			function goBack(){
				//todo: figure out how to get go left and right into ONE nice function
				if(!list.is(":animated")){
					if(t){
						clearTimeout(t);
					}
					//we know that if the list position is less then 0 it has moved from its original location so we can move it back a place
					if(opts.xslide == true){
						if(list.position().left < 0){
							list.animate({"left": "+="+opts.slideW+"px"},opts.animSpeed,function(){
								setAutoSlide();
							});		
						}else{
							if(opts.loop == false){
								var moveableSpace = list.position().left + ((opts.slideW*list.children().length)-(opts.slideW*opts.show));
								list.animate({"left": "-"+moveableSpace+"px"},opts.animSpeed,function(){
									setAutoSlide();
								});
							}else{
								//we are going to loop to number one so lets make a copy of list
								list.before(list.clone(true));
								//now position it to the right
								list.prev("ul").css({"left": "-"+(opts.slideW*list.children().length)+"px"});
								list = list.prev("ul");
								//slide the old on off and bring on the new one
								list.animate({"left": "+="+opts.slideW+"px"},opts.animSpeed,function(){
									setAutoSlide();
								})
								.next("ul").animate({"left": "+="+opts.slideW+"px"},opts.animSpeed,function(){
									$(this).remove();
								});
							}
						}
					}else{
						if(list.position().top < 0){
							list.animate({"top": "+="+opts.slideH+"px"},opts.animSpeed,function(){
								setAutoSlide();
							});		
						}else{
							var moveableSpace = list.position().top + ((opts.slideH*list.children().length)-(opts.slideH*opts.show));
							list.animate({"top": "-"+moveableSpace+"px"},opts.animSpeed,function(){
								setAutoSlide();
							});
						}
					}
				}
			}
			function goNext(){
				if(!list.is(":animated")){
					if(t){
						clearTimeout(t);
					}
					//figure out how much space there is to slide back and forth
					if(opts.xslide == true){
						//.................were is the list.........how long is the list..................how much room is there to move
						var moveableSpace = list.position().left + ((opts.slideW*list.children().length)-(opts.slideW*opts.show));
						//there is more space then one slides width so lets move!
						if(moveableSpace >= opts.slideW){
							list.animate({"left": "+=-"+opts.slideW+"px"},opts.animSpeed,function(){
								setAutoSlide();
							});
						}else{
							if(opts.loop == false){
								list.animate({"left": "0px"},opts.animSpeed,function(){
									setAutoSlide();
								});
							}else{
								//we are going to loop to number one so lets make a copy of list
								list.after(list.clone(true));
								//now position it to the right
								list.next("ul").css({"left": opts.slideW+"px"});
								list = list.next("ul");
								//slide the old on off and bring on the new one
								list.animate({"left": "0px"},opts.animSpeed,function(){
									setAutoSlide();
								})
								.prev("ul").animate({"left": "-="+opts.slideW+"px"},opts.animSpeed,function(){
									$(this).remove();
								});
							}
						}
					}else{
						var moveableSpace = list.position().top + ((opts.slideH*list.children().length)-(opts.slideH*opts.show));
						if(moveableSpace >= opts.slideH){
							list.animate({"top": "+=-"+opts.slideH+"px"},opts.animSpeed,function(){
								setAutoSlide();
							});		
						}else{
							list.animate({"top": "0px"},opts.animSpeed,function(){
								setAutoSlide();
							});		
						}
					}
				}
			}
			var t= null;
			function setAutoSlide(){
				if(opts.autoScroll == true){
					if(t != undefined){
						clearTimeout(t);
					}
					t=setTimeout(slideTheShow,opts.timeout);		
				}
				return false;
			}
			function slideTheShow(){
				goNext();
			}
			if(opts.autoScroll == true){
				setAutoSlide();
			}
		});
		
		
	};
	//
	// private function for debugging
	//=
	function debug($obj) {
		if (window.console && window.console.log)
			window.console.log('slideshow selection count: ' + $obj.size());
		};
	//
	// define and expose our format function
	//
	
	/*
	$.fn.slideshow.slideTheShow = function(direc) {
		
	};
	*/
	//
	// plugin defaults
	//
	$.fn.slideshow.defaults = {
		nextBttn: "goRight"
		,backBttn: "goLeft"
		,activeSlide: "curr"
		,timeout: 8000
		,autoScroll: false
		,animSpeed: "normal"// A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000)
		,slideW: 736//the width
		,slideH: 280//the height
		,xslide: true // if false scroll vertical 
		,listStyles: false//if false takes off margnin padding and list-style-type from ul and li
		,buttonPlacement: "append"//can use after, append, prepend, before : defaults to append
		,show: 1
		,loop: false
	};
	//
	// end of closure
	//
})(jQuery);

/* popbox :: developed by jsummers.at.techbydesign.com */
(function($) {
	jQuery.fn.popbox = function(options) {
	settings = $.extend({
			boxW: 800,
			boxH: 500,
			overlayBG: "overlayBG",//id used on the overlay bg
			popBoxName: "overlayBox",
			popBoxTitle: "popBoxTitle",
			popbox: "popbox",
			overlayBGColor: "000000",
			loadingTxt: "Loading...",
			closeTxt: "CLOSE",
			windowPadding: 15//used to keep box off the side of window
			,overFlow: "auto"
		}, options);

	return this.each(function(){
		
		function killOverlay(){
			$("#"+settings.overlayBG+", #"+settings.popBoxName).fadeOut(function(){
				$(this).remove();
			});
		}
		function getURLParam(strParamName,strHref){
			var strReturn = "";
			if(strHref == null){
				var strHref = window.location.href;
			}
			if (strHref.indexOf("?") > -1 ){
				var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
				var aQueryString = strQueryString.split("&");
				for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
					if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
						var aParam = aQueryString[iParam].split("=");
						strReturn = aParam[1];
						break;
						}
					}
				}
			return strReturn;
		}
		var setting = settings;
		$(this).click(function(){
			settings = setting;
			//deal with the url and get any variables we may need.
			//get the url we have been fed
			var urlToLoad = $(this).attr("href");
			//get the url with no variables
			var baseUrl = urlToLoad.substring(0,urlToLoad.indexOf("?"));
			//the actual variable we pass to load.
			var loadIn = urlToLoad;
			if(getURLParam("id",urlToLoad)){
				loadIn = baseUrl + " #" + getURLParam("id",urlToLoad);
			}
			if(getURLParam("boxW",urlToLoad)){
				settings.boxW = getURLParam("width",urlToLoad);
			}
			if(getURLParam("boxH",urlToLoad)){
				settings.boxH = getURLParam("height",urlToLoad);
			}
								
			$("body").append("<div id=\""+settings.overlayBG+"\"><!-- --></div>");
			$("#"+settings.overlayBG).css({
				"position": "absolute",
				"top": "0px",
				"left": "0px",
				"height": $("body").height(),
				"width": $("body").width(),
				"background-color": "#"+settings.overlayBGColor,
				"visiblity": "hidden",
				"z-index": "999",
				"cursor": "wait"
			}).fadeTo("normal",0.80);
			
			$("body").append("<div id=\"loaderBox\">"+settings.loadingTxt+"</div>");
			$("#loaderBox").css({
				"position": "fixed",
				"left": "0px",
				"top": "50%",
				"width": "100%",
				"height": $("#loaderBox").height()+"px",
				"display": "block",
				"text-align": "center",
				"z-index": "1000",
				"color": "#ffffff",
				"font-size": "3em"
			});
			$("body").append("<div id=\""+settings.popBoxName+"\"><div id=\""+settings.popBoxTitle+"\">"+settings.closeTxt+"</div><div id=\""+settings.popbox+"\"><!-- --></div></div>");
			//get window height and make sure that we have room for our box as settings predict
			var wh = $(window).height() - settings.windowPadding;
			var ww = $(window).width();
			if(((settings.boxH*1)+$("#"+settings.popBoxTitle).height()) > wh){
				settings.boxH = (settings.boxH*1) - (((settings.boxH*1)+$("#"+settings.popBoxTitle).height()) - wh);
			}
			$("#"+settings.popBoxName).css({
				"position": "absolute",
				"width": (settings.boxW*1)+"px",
				"height": ((settings.boxH*1)+$("#"+settings.popBoxTitle).height())+"px",
				"display": "none",
				"z-index": "1000",
				//"top": "0px"
				//"top": ($(window).height()/2)-(((settings.boxH*1)+$("#"+settings.popBoxTitle).height())/2)+"px"
				"top": "50%",
				"left": "50%",
				"margin-top": ((((settings.boxH*1)+$("#"+settings.popBoxTitle).height())/2)*-1)+($(window).scrollTop())+"px",
				"margin-left": "-"+((settings.boxW*1)/2)+"px"
			});
			
			//place the overlayBox
			/*
			var xLoc = (($(window).width()/2)- ($("#"+settings.popBoxName).width()/2)) + "px";
			var yLoc = ((wh/2)- ($("#"+settings.popBoxName).height()/2)) + "px";
			$("#"+settings.popBoxName).css({
				"top": yLoc,
				"left": xLoc
			})
			*/
			$("#"+settings.popbox).height(settings.boxH+"px").load(loadIn,function (responseText, textStatus, XMLHttpRequest){
				$("#loaderBox").fadeOut("fast",function(){
					$(this).remove();
				});
				$("#"+settings.overlayBG).css({"cursor": "default"});
				if("success" == textStatus){
					$("#"+settings.popBoxName).show();
				}else{
					$("#"+settings.popbox).html(responseText);
					$("#"+settings.popBoxName).fadeIn("slow");
				}
				
			});
			
			//allow clicking on the bg
			$("#"+settings.overlayBG+", #"+settings.popBoxTitle).click(function(){
				killOverlay();
			});
			//stop link from going with the browser
			return false;
		});
	  });
	};
})(jQuery);
/* jquery.tbd-imgGal 0.1 :: developed by jsummers.at.techbydesign.com */
/*
**	just make sure you have a bunch of anchors with images in them.
**	<a href="path to big pic"><img alt="any description you would like to use" src="path to thumb"/></a>
**	it grab the path of the href and loads that pic into the stage setting
**	
**  although this can resize things down I suggest trying to get images at proper dimensions as you are wasting bandwidth and making page load slow for nothing!
**	
 */
(function($){  
	$.fn.imgGal2 = function(options) {  
		var defaults = {  
			details: ".image-desc"//img alt tag gets pushed here if not null
			,stage : ".galleryStage"//were the larger version of the image is shown
			,stagePlament: "before"//if plugin can not find the stage element were should it go!, this is not implemented yet
			,thumbW: 105//if needed scale the thumbnail to this
			,thumbH: null//if needed scale the thumbnail to this
			,maxW: 685//if larger then this image will scale down
			,maxH: 600
			,thumbs: 5//how many thumbs to show at one time
		};
		var options = $.extend(defaults, options);
		return this.each(function() {
			obj = $(this);
			var body = obj.html();
			
			$(options.stage).css({"overflow":"hidden","position":"relative"});
			
			
			
			function quickImageGal(domElem){
				
				var imgAnchor = domElem;
				var imgSrc = imgAnchor.attr("href");
				if(imgSrc != $(options.stage + " img").attr("src")){
					var img = new Image();
					// wrap our new image in jQuery, then:
					
					$(img).load(function (page) {
						$(this).hide();
						$(options.stage + " img").remove();
						$(options.details).html(imgAnchor.find("img").attr("alt"));
						$(options.stage).append(this);
						if($(this).width() > options.maxW){
							var curW = $(this).width();
							var curH = $(this).height();
							$(this).width(options.maxW);
							var percent = (options.maxW/curW);
							$(this).height(percent*curH);
						}
											
						$(this).fadeIn();
						$(options.stage).animate({"height": $(this).height()+"px"});
					}).error(function () {
						alert("add error code here");
					})// *finally*, set the src attribute of the new image to our image
					.attr('src', imgSrc);
				}
				return false;
			}
			
			//place thumbnails for sliding
			
			
			
			
			
			//size down the thumbnails 
			//todo: better selector for the img sizing
			$(this).find("img").each(function(){
				//testing for width
				//todo: add logic for height and make sure we keep track of what if bigger
				if($(this).width() > options.thumbW){
					var curW = $(this).width();
					var curH = $(this).height();
					$(this).width(options.thumbW);
					var percent = (options.thumbW/curW);
					$(this).height(percent*curH);
				}
			});
			
			//attach click event
			$(this).find("a").click(function(){
				quickImageGal($(this));
				return false;
			})
			
			quickImageGal($(this).find("a:first"));
			
		});  
	};  
})(jQuery);
//this number should be the same as how many classes there are in teh style sheet to choose from.
//var greenHeaders = new Array();

var pathToHeadImg = blogURL + "/img/bg/header/";
var blueHeaders = new Array("1a.jpg","2a.jpg","3a.jpg","4a.jpg","5a.jpg","6a.jpg","7a.jpg");
var greenHeaders = new Array("1b.jpg","2b.jpg","3b.jpg","4b.jpg","5b.jpg","6b.jpg","7b.jpg");
/* " */
$(document).ready(function() {
	//make a class name to use to add to the header	
	if($("body").attr("id") != "neighborhoodColor"){
		var bgNum = pathToHeadImg + blueHeaders[Math.floor(Math.random()*blueHeaders.length)];
	}else{
		var bgNum = pathToHeadImg + greenHeaders[Math.floor(Math.random()*blueHeaders.length)];
	}
	$("#header").css({"background-image" : "url("+bgNum+")"});
	
	//main nav drop down
	$("ul.mainNav li").hover(function(){
			if($($(this).parents("ul")[0]).attr("id") == "headerNav"){
				$(this).find("ul").css("top",$(this).height()+"px");
			}else{
				$(this).find("ul").css("bottom",$(this).height()+"px");
			}
			$(this).addClass("hover").find("ul").fadeIn();
		},function(){
			$(this).removeClass("hover").find("ul").fadeOut();
		});
	$("ul.mainNav li ul").bgiframe();
	
	//add #toggleExtraArticle to #extraArticles woith javascript so that if they do not have js on they do not see a button they can not use.
	$("#extraArticles").append("<div id=\"toggleExtraArticle\"><!-- --></div>");
	//when they use the button, toggle the extraArticles and class open to change bg image
	$("#extraArticles #toggleExtraArticle").click(function(){
		$($(this).prev("div").slideToggle().parents("#extraArticles")[0]).toggleClass("open");
	})
	//use cursor to let them know they can click, hide the thing they can open ;)
	.css("cursor","pointer").prev("div").hide();
	
	

	//locate a safe place jump form
	//hide submit button
	$("form.getLocation input[type=submit]").hide().click(function(){
		window.location = $(this).siblings("select").val();
		return false;
	});
	//
	$("select.getLocation").change(function(){
		if($(this).val() != ""){
			$(this).siblings("input").fadeIn();
		}else{
			$(this).siblings("input").fadeOut();
		}
	});
	
	
	//add the slideshow to the slideshows	
	$(".slideShow").slideshow({autoScroll: true, loop: true});
	$(".slideShowCall").fadeTo("fast", 0.87);
	//add popbox
	$("a.popbox").popbox();
	//add imggal 
	$("ul.imggal").imgGal2();
	
	$(".galleryNav").slideshow({autoScroll: false, show: 5, slideW: 135, slideH: 145, buttonPlacement: "before"});
	//add popbox
	$("a.popmap").popbox({boxW: 708, boxH: 650, overFlow: "hidden"});
	
	
	$(".newWindow, a[href$='.pdf']").click(function(){
		window.open($(this).attr("href"));
		return false;
	});
	
	$("a.printLink").click(function(){
		window.print();
		return false;
	});

});

