		
	function gallery_itemFirstInCallback(carousel, item, idx, state) {
		parent_id = carousel.list.attr("id");
		parent_carousel = document.getElementById(parent_id);  
		perpage = $(parent_carousel).attr("perpage") ? $(parent_carousel).attr("perpage") : 5;
	    if (carousel.options.size<=perpage) return false; //1 page only

	    parent_carousel.carousel = carousel; 
	    pages = Math.ceil(carousel.options.size/perpage);
	    page = carousel.options.size==carousel.last ? pages-1 : Math.floor(idx / 5);
	    dots = carousel.container.parent().next(".carousel_dots").find("img");
	    //alert(dots.length);
	    if (dots.length<=0) return;
	    jQuery.each(dots, function() {
	        this.src = "/themes/prg/images/dot1.png";
	    });
	    dots[page].src = "/themes/prg/images/dot3.png";
	};
	
	
	$(document).ready(function(){
		$(".carousel_dots a").click(function(){
			dots_div = $(this).parent();
			page = $(this).attr("page");
			//alert($(this).parent().prev().children().find("ul").attr("id"));
			parent_id = dots_div.prev().children().find("ul").attr("id");
			parent_carousel = document.getElementById(parent_id);
			perpage = $(parent_carousel).attr("perpage") ? $(parent_carousel).attr("perpage") : 5;
			//alert("Scrolling to item #"+(page*perpage+1));
			//alert(parent_carousel.carousel);
			parent_carousel.carousel.scroll(page*perpage+1);
			return false;
		});
		
		
		$('.people_innerfade_gal').innerfade({
            speed: 'slow', 
            timeout: 3000
         }); 
		
		
		$("#morelinksa").click(function(){
			$("#morelinks").slideToggle("fast");
			return false;
		});
		
		$("#grouplinksa").click(function(){
			$("#grouplinks").slideToggle("fast");
			return false;
		});
		
		$("#search_clear").click(function(){
			$("#search_input")[0].value = '';
			$('#suggestions').fadeOut(); // Hide the suggestions box
			$('#search_loading').hide();
			$('#search_clear').hide();
			return false;
		});
		
	});
	
	
	
	
	
	
	hs.registerOverlay({
		html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		fade: 2,
		useOnHtml: true
	});
	hs.showCredits = false;
	hs.graphicsDir = '/highslide/graphics/';
	hs.align = 'center';
	hs.width = 600;
	hs.height = 500;
	hs.dimmingOpacity = 0.60;
	hs.dimmingDuration = 500;
	
	hs.outlineType = 'rounded-white';
	//hs.outlineType = null;
	hs.wrapperClassName = 'draggable-header no-footer';
	//hs.wrapperClassName = 'borderless';
	//hs.objectType = 'iframe';
		
		

		
	function search_lookup(src) {
		str = src.value;
		
		if (!str || str.length < 2) {
			$('#suggestions').fadeOut(); // Hide the suggestions box
			$('#search_loading').hide();
			$('#search_clear').hide();
		} else {
			$('#search_clear').hide();
			$('#search_loading').show();
			$.post("/files/search.php", {like :""+str+""}, 
				function(data) { // Do an AJAX call
					if (!data){
						$('#suggestions').fadeOut();
						return;
					}
					$('#search_loading').hide();
					$('#search_clear').show();
					$('#suggestions').html(data).fadeIn();
				});
		}
	}

	
	
	/**
	 * Converts the given data structure to a JSON string.
	 * Argument: arr - The data structure that must be converted to JSON
	 * Example: var json_string = array2json(['e', {pluribus: 'unum'}]);
	 * 			var json = array2json({"success":"Sweet","failure":false,"empty_array":[],"numbers":[1,2,3],"info":{"name":"Binny","site":"http:\/\/www.openjs.com\/"}});
	 * http://www.openjs.com/scripts/data/json_encode.php
	 */
	function array2json(arr) {
	    var parts = [];
	    var is_list = (Object.prototype.toString.apply(arr) === '[object Array]');

	    for(var key in arr) {
	    	var value = arr[key];
	        if(typeof value == "object") { //Custom handling for arrays
	            if(is_list) parts.push(array2json(value)); /* :RECURSION: */
	            else parts[key] = array2json(value); /* :RECURSION: */
	        } else {
	            var str = "";
	            if(!is_list) str = '"' + key + '":';

	            //Custom handling for multiple data types
	            if(typeof value == "number") str += value; //Numbers
	            else if(value === false) str += 'false'; //The booleans
	            else if(value === true) str += 'true';
	            else str += '"' + value + '"'; //All other things
	            // :TODO: Is there any more datatype we should be in the lookout for? (Functions?)

	            parts.push(str);
	        }
	    }
	    var json = parts.join(",");
	    
	    if(is_list) return '[' + json + ']';//Return numerical JSON
	    return '{' + json + '}';//Return associative JSON
	}