

/*  
	MultiSlide, version 1.0
	(c) 2009 Intereactive, LLC - Ryan Hargrave
	http://blueprint.intereactive.net/multislide-for-mootools
	
	Compatible with Mootools v1.2 - http://mootools.net
	Extends the capability of the Fx.Slide Class  - http://mootools.net/docs/Plugins/Fx.Slide
	
	This code is freely distributable under the terms of an MIT-style license.
*/

window.addEvent('domready', function() {
			multislide = new multislide('moreInfoWrapper');
		
		  // Hold value from the home page is a 3rd Party Integration Link is clicked
    linkToShow = ""

    if (document.getElementById("ctl00_MainContentHolder_txtHomePageLinkID") != null)
    {
    linkToShow = document.getElementById("ctl00_MainContentHolder_txtHomePageLinkID").value;
    }

    // Show the coresponding content for the link that was clicked on the home page
    if (linkToShow != "")
    {
    linkID = linkToShow.replace('Content', '');
    document.getElementById(linkID).className = "divToggle SystemOpen";
    var mySlide = new Fx.Slide(linkToShow).slideIn();
    listItem = linkID.replace("nk", "");
    document.getElementById(listItem).className = "current";
    }
		
		});		

var multislide = new Class({
	
	Implements: [Events, Options],

	options: {
		/*
		onExpand: $empty,
		onCollapse: $empty, 
		onExpand_all: $empty, 
		onCollapse_all: $empty, 
		*/  
		slide_duration:			300,
		slide_transition: 		'sine:in:out',
		class_expand_all: 		'expand_all',
		class_collapse_all: 	'collapse_all',
		class_toggler: 			'divToggle',
		class_expander: 		'moreInfo'
	},
	
	//sets up the animations for the team layout
	initialize: function(container_class, options) {
		this.setOptions(options);
		
		//set empty array to hold all the sliders
		this.person_slide = [];
		this.togglerArray = [];
		
		//create the sliders and set up event listeners
		$$('.'+container_class).each(function(container, i){
			
			var toggler = container.getElement('.'+this.options.class_toggler);
			
			this.togglerArray[i] = container.getElement('.'+this.options.class_toggler).id;
			
			//set up the slide instance for each element and hide all the sliders								  
			this.person_slide[i] = new Fx.Slide(container.getElement('.'+this.options.class_expander), {
					duration: this.options.slide_duration, 
					transition: this.options.slide_transition, 
					link : 'ignore',
					onStart : function(){
						if(this.person_slide[i].open){
							this.fireEvent('collapse', toggler);
						} else {
							this.fireEvent('expand', toggler);
						}
					}.bind(this)
			}).hide();
			
			//add the toggle slide event		
			toggler.addEvent('click', function(e){
					e.stop();
					this.person_slide[i].toggle();
			}.bind(this));
		}.bind(this));
		
		
		$$('.'+this.options.class_expand_all).addEvent('click', function(e){
			e.stop();
			this.expand_all();
		}.bind(this));
		
		
		$$('.'+this.options.class_collapse_all).addEvent('click', function(e){
			e.stop();
			this.collapse_all();
		}.bind(this));
	},
	
	expand_all: function() {
		//run the effect on the entire array
		this.person_slide.each(function(sl){
//			if(!sl.open){
//				sl.slideIn();
//			}
			sl.slideIn();
		});
		
		for (i = 0; i < this.togglerArray.length; i++)
		{
		  document.getElementById(this.togglerArray[i]).className = "divToggle SystemOpen";
		  listItem = this.togglerArray[i];
		  listItem = listItem.replace("nk", "");
		  if (document.getElementById(listItem) != null)
		  {
		    document.getElementById(listItem).className = "current";
		  }
		  
		} 
		
		this.fireEvent('expand_all');
	},
	
	collapse_all: function() {
		//run the effect on the entire array
		this.person_slide.each(function(sl){
//			if(sl.open){
//				sl.slideOut();
//			}
			sl.slideOut();
		});
		
		for (i = 0; i < this.togglerArray.length; i++)
		{
		  document.getElementById(this.togglerArray[i]).className = "divToggle SystemClosed";
		  listItem = this.togglerArray[i];
		  listItem = listItem.replace("nk", "");
		  if (document.getElementById(listItem) != null)
		  {
		    document.getElementById(listItem).className = "";
		  }
		} 
		
		this.fireEvent('collapse_all');
	}
});
