	//CONFIG SECTION
	//check to see if site root was initialized by php(refer to /includes/header.php for this code)
	if ( typeof( siteRoot ) == 'undefined' || siteRoot == ""){
		var siteRoot = "./";
	}

	/** setOpacity
	 *	safely sets opacity by stopping the animation and specifying an opacity level 
	**/
	$.fn.setOpacity = function(opacity) {
		return this.each( function(){
			$(this).stop().fadeTo( "200", opacity );
		});
	};
	
	/**
	 * loadingFade
	 * @param time - about of time before the element fades in
	 **/
	$.fn.loadingFade = function(time) {
		return this.each( function(){
			var $item = $(this);
			$item.stop().hide(); 

			setTimeout( function(){
				$item.setOpacity(0.75);
			}, time)
		});
	};

	//for each in the collection, find the maximum height and set all elements to that height
	$.fn.equalHeight = function() {		
		var tallest = 0;		
		$(this).each(function() {
			var thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});		
		$(this).height(tallest);
	}

	/* create flash elements via swfObject*/
	function initFlashElements(){
		var flashvars = {};
		var params = {
				menu: "false",
				wmode: "transparent",
				base: siteRoot+"flash/"
			};
		var attributes = false;
		var expressInstall = siteRoot+"flash/expressInstall.swf";
		
		if($("#homeFlash").length){
			swfobject.embedSWF(siteRoot+"flash/homeFlash.swf", "homeFlash", "964", "250", "8.0.0", expressInstall, flashvars, params, attributes);
		}
		if($("#aboutFlash1").length){
			swfobject.embedSWF(siteRoot+"flash/aboutFlash1.swf", "aboutFlash1", "480", "272", "8.0.0", expressInstall, flashvars, params, attributes);
		}
		if($("#aboutFlash2").length){
			swfobject.embedSWF(siteRoot+"flash/aboutFlash2.swf", "aboutFlash2", "480", "272", "8.0.0", expressInstall, flashvars, params, attributes);
		}
	}
	
	/* regular expression to get the basename of a file */
	function basename(path) {
		return path.replace(/\\/g,'/').replace( /.*\//, '' )
	}
	
	/* Random images loader for site template (in header) */
	function randomImage() {
		var imgArr = ['donateKids-01.png','donateKids-02.png','donateKids-03.png','donateKids-04.png','donateKids-05.png','donateKids-06.png','donateKids-07.png','donateKids-08.png','donateKids-09.png','donateKids-10.png','donateKids-11.png','donateKids-12.png','donateKids-13.png','donateKids-14.png','donateKids-15.png'];
		var rndNum = Math.floor( Math.random() * imgArr.length );
		$("#donateKids").fadeOut("fast", function () {
			$("#donateKids").css("background-image","url(img/" + imgArr[rndNum] + ")");
			$("#donateKids").fadeIn(0);
			$("body#home #donateKids, body.donateForm #donateKids").css("display","none");
		});
	}
	
	
	/* actions to be attached each time a new gallery page is loaded */
	function attachThumbClick( links ){
		return links.lightBox({
			imageLoading: siteRoot+'img/loading.gif',
			imageBtnClose: siteRoot+'img/lightbox-btn-close.gif',
			imageBtnPrev:  siteRoot+'img/lightbox-btn-prev.gif',
			imageBtnNext:  siteRoot+'img/lightbox-btn-next.gif'
		});
	}
	
	/** updateGalleryPages
	 * 
	 *	imageGallery call-back function
	 */
	function updateGalleryPages( container, pageIndex, pageMult ) {
		var galItem = container.find('li');
		var currentArrayItem = pageIndex * pageMult;

		/* check if the galleryImages var is generated by php */
		if( typeof( galleryImages ) != 'undefined' || galleryImages.length > 0 ){
			
			//loop through the page's dom elements and replace them one by one
			//starting at currentItem
			for(i=0; i <= pageMult-1; i++) {
				var item = container.find('li:eq('+i+')');
				var img = item.find('img');
				var link = item.find('a');
				var mytimeout = 2000+(i*150);
				
				var path = galleryImages[currentArrayItem];
				var filename = basename( link.attr("href") );
				filename = filename.substr(0, filename.lastIndexOf('.')) || filename;
				
				if( link.length ){
					//replace link
					link
						.attr( "href", path  )
						.find( "span" ).text( filename );
					
					//replace image
					img.attr({src: path , alt: filename, title: filename} );
				} else {
					//replace link
					link
						.attr( "href", "#"  )
						.find( "span" ).text( "" );
					
					//replace image
					img.attr({src: "#" , alt: "no image", title: "no image"} );
				}
				img.loadingFade(mytimeout);
				currentArrayItem++;
			}		
		}
	}

	function imageGallery() {
	//set the category clicks 
		var page = 'cat'
		if( $('#gallery-img-list').length ){
			page = 'img';
		}
		var container = $('#gallery-'+page+'-list');
	//cache elements and vars
		var links = container.find( 'a' ); 	//all links in galleryList
		var imgs = container.find( 'img' ); //all images in galleryList
		var pageIndex = 0; 					//where we are in the pagination of images
		var itemMult = 21; 					//how many images are show on a page
		
	//style the images
		imgs.setOpacity( 0.75 );
		container.css("display", "block").height( container.height() );
		
	//special operations for image list
		if( $('#gallery-img-list').length ){
			attachThumbClick(links);
		}
		
	///link hovers
		links
			.mouseenter( function(){ $(this).next("img").setOpacity( 1.00 ); })
			.mouseleave( function(){ $(this).next("img").setOpacity( 0.75 ); });

		
	//check if the galleryImages var is generated by php 
		if( typeof( galleryImages ) != 'undefined' || galleryImages != "" ){
			
			totalPages = Math.ceil( galleryImages / itemMult ); // TODO: make this dynamic so we can figure out how many pages there are
			container.append("<a href='#next' class='next'>Next</a>");
			container.append("<a href='#prev' class='prev'>Previous</a>");
			
			container.find(".next, .prev").click( function(){
				
			//get the new current page
				pageIndex = ( $(this).hasClass("next") ) ? (pageIndex+1) : (pageIndex-1);
				
			//make sure we're not out of bounds
				if(pageIndex <= 0){ 
					pageIndex = 0; 
				}else if( pageIndex >= totalPages-1){
					pageIndex = totalPages
				}
				
			//call-back function
				updateGalleryPages( container, pageIndex, itemMult );
				
			//override default actions
				return false;
			});
		}
		
	}

	//for error reporting on ajax functions
	$(document).ajaxError( function(){
	  if (window.console && window.console.error) {
	      console.error(arguments);
		}
	});

	$(document).ready(function(){
		
	//dictionary
		$("ul#faqList li>a").live("click", function(){
			$("ul#faqList li div").hide();
			$(this).next("div").show();
			return false;
		});
		$("ul#sponsorMenu li a").live("click", function(){
			$("ul#sponsorMenu li ul.bulletList").hide();
			$(this).next("ul.bulletList").show();
			return false;
		});

	//ImageGallery
		if( $("#gallery-cat-list").length ||  $("#gallery-img-list").length ){
			imageGallery();
		}
		 
	//hide email addresses with javascript
		$('.obfuscated').defuscate();

	//random image
		randomImage();	

	//tooltips on news section
		$(".storyImg").tooltip({
		showURL: false
		});
	//tooltips on about-programs section
		$('#programlist a').tooltip({ 
			track: true, 
			delay: 0, 
			showURL: false,
			bodyHandler: function() { 
				return $(this).next("div").text(); 
			}
		});
		$('#programlist a').click( function(){ return false; });

	//generate screenshot preview
		screenshotPreview();

	// swfObject for all flash elements
		initFlashElements();
		
	//dropshadows
		$("#nav a, .fancyText").each( function() {
			var str_text = $(this).text();
			$(this)
				.addClass("fancyText")
				.html('<span>'+str_text+'</span><span class="shadow">'+str_text+'</span><span class="shadow2">'+str_text+'</span><span class="shadow3">'+str_text+'</span>');
		});

		$(".fancyHead").each( function() {
			var str_text = $(this).text();
			$(this)
				.addClass("fancyHead")
				.html('<h3>'+str_text+'</h3><h3 class="shadow">'+str_text+'</h3><h3 class="shadow2">'+str_text+'</h3><h3 class="shadow3">'+str_text+'</h3><h3 class="shadow4">'+str_text+'</h3>');
		});
		$(".fancyHead2").each( function() {
			var str_text = $(this).text();
			$(this)
				.addClass("fancyHead2")
				.html('<h3>'+str_text+'</h3><h3 class="shadow">'+str_text+'</h3><h3 class="shadow2">'+str_text+'</h3><h3 class="shadow3">'+str_text+'</h3>');
		});
		
	//Card image cycler
		if( $('#cardRotation').length ){
			$('#cardRotation').cycle();
		}
		
	//Blog image cycler
		if( $('#blogRotation').length ){
			$('#blogRotation').cycle();
		}
		
	//Sponsor cycler
		if( $('#sponsorRotator').length ){
			$('#sponsorRotator > div').equalHeight();
			$('#sponsorRotator').height( $('#sponsorRotator > div').height() );
			$('#sponsorRotator').cycle({
				timeout: 10000
			});		
		}
		
	// complex mouseover for the navigation
		$('#nav a,').hover(function(){
			var nav = $("#nav");
			switch($(this).attr('id')){
				case 'home':
					nav.css({backgroundPosition: '0 0'});
					break;
				case 'about':
					nav.css({backgroundPosition: '0 -60px'});
					break;
				case 'help':
					nav.css({backgroundPosition: '0 -120px'});
					break;
				case 'news':
					nav.css({backgroundPosition: '0 -180px'});
					break;
				case 'events':
					nav.css({backgroundPosition: '0 -240px'});
					break;
				case 'contact':
				default:
					nav.css({backgroundPosition: '0 -300px'});
					break;
			}
		},function(){
			$("#nav").removeAttr("style");
		});

		$('.dropmenudiv').mouseenter(function(){
			var nav = $("#nav");
			switch($(this).attr('id')){
				case 'dropmenu1':
					nav.css({backgroundPosition: '0 -60px'});
					break;
				case 'dropmenu2':
					nav.css({backgroundPosition: '0 -120px'});
					break;
				case 'dropmenu3':
					nav.css({backgroundPosition: '0 -180px'});
					break;
				case 'dropmenu4':
					nav.css({backgroundPosition: '0 -240px'});
					break;
				default:
					nav.css({backgroundPosition: '0 0'});
					break;
			}
		});
		
		$('.dropmenudiv').mouseleave(function(){
			$("#nav").removeAttr("style");
		});
		
	});

