
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - slider.js - */
// http://www.kpa-group.com/portal_javascripts/slider.js?original=1
var t;
function move_slider(x,auto){if(!auto){clearTimeout(t);loop(x-1)}
jq('.infinity').animate({marginLeft:((x-1)*-939)},1000,function(){});jq('.buttons a.active').removeClass("active");jq('.buttons a:nth-child('+x+')').addClass("active")}
jq(document).ready(function(){loop(0)});
function loop(x){x++;jq(".i").html(x);if(x>jq('.buttons a').size()){x=1}
move_slider(x,1);t=setTimeout("loop("+x+")",8000)}


/* - explorer.js - */
/*
jQuery portletNavigationTree plugin
	Collapsible/expandable navigation tree.
*/

(function($) {
	// Expands or collapses a node of which sub-items already have been loaded.
	function toggleNode(event){
		var twistie = $(this);
		
		// find ul element
		var ul = $(this).closest("li").children("ul");
		if (!ul) { return; }
		
		// toggle class names
		if (twistie.hasClass("showChildren")){
			ul.removeClass("hideChildren");
			twistie.removeClass("showChildren");
		} else {
			ul.addClass("hideChildren");
			twistie.addClass("showChildren");
		}
		
		// prevent default action of event
		event.preventDefault();
	}
	
	// Loads the sub-items of a node.
	function loadNode(event){
	
		// prevent default action of event
		event.preventDefault();
		// Find the portlet information
		var portletWrapper = $(this).closest(".portletWrapper");
		var portletHash = portletWrapper[0] ? portletWrapper[0].id.replace("portletwrapper-","") : "";
		if (!portletHash) { return; }

		// find the li element of the clicked node
		var node = $(this).closest("li");

    var ulnode = $(this).closest("ul");
    var ulnodeclass = ulnode.attr('class');
    var nestinglevel = 0;
    try {
  		nestinglevel = parseInt(/navTreeLevel(\d+)/.exec(ulnodeclass)[1],10);
    } catch (err) {
      //alert(nestinglevel);
      nestinglevel = 0;
    }
    //alert(nestinglevel);
    nestinglevel = nestinglevel+1;

		if (node.hasClass("nodeLoading")) { return; }
		
		// get node uid
		var uidClassName = node[0].className.match(/node-(\w+)/);
		var uid = uidClassName ? uidClassName[1] : null;
		if (!uid) { return; }
		
		// data to send with request
		var data = {
			portlethash : portletHash,
			uid : uid,
      nl : nestinglevel
		};
		
		// add nodeLoading class
		node.addClass("nodeLoading");
		
		// send request
		$.post("expandNode", data, function(html){
			node.replaceWith(html);
		});
	}

	// observe clicks on toggle buttons
	$(".portletNavigationTree span.toggleNode").live("click", loadNode);
	$(".portletNavigationTree span.expandedNode").live("click", toggleNode);
})(jQuery);


