
// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will 
// be attatched to it.
var stacks = {};


// this call to jQuery gives us access to the globaal
// jQuery object. 
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other 
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);

// Javascript for stacks_in_2_page0
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_2_page0 = {};

// A closure is defined and assigned to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_2_page0 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
/*
 * SymfoniP Slide MP3 player HTML5 and Flash (c) 2010
 + Params available (with defaults):
 + width:1,
 + open: false,
 + animateInterval: 500,
 + mp3: 'http://www.miaowmusic.com/audio/mp3/Miaow-05-The-separation.mp3',
 + ogg: 'http://www.miaowmusic.com/audio/ogg/Miaow-05-The-separation.ogg',  Not in use
 + preload: 'metadata',
 + swf: 'path to swf/',
 + continuousPlay: true
 + autoPlay: false
 */

//$(document).ready(function() {
//	$("#player_containerstacks_in_2_page0").symJPlayer({continuousPlay:false, open: true, mp3:'http://www.tamana.de/assets/Audio/Diaa-Ws-Mansa-Snippet.mp3', preload:'metadata',autoPlay:true,swf:'index_files/symslidemp3/'});
//});
//Everything happens in the template 

	return stack;
})(stacks.stacks_in_2_page0);


// Javascript for stacks_in_6_page0
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_6_page0 = {};

// A closure is defined and assigned to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_6_page0 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
/*!
 * RWT Stretch Script
 * Copyright (c) 2009-2010 G. Byrd
 * Version: 2.0.0 (22-JULY-2010)
 * Requires: jQuery v1.2.6 or later
 */
jQuery(document).ready(function($){
	
		jQuery("#stacks_in_6_page0 .toggle_container").hide();

		jQuery("#stacks_in_6_page0 .trigger").toggle(function(){
			jQuery(this).addClass("active"); 
			}, function () {
			jQuery(this).removeClass("active");
		});

		jQuery("#stacks_in_6_page0 .trigger").click(function(){
			jQuery(this).next(".toggle_container").slideToggle("slow,");
		});
});
	

	return stack;
})(stacks.stacks_in_6_page0);


// Javascript for stacks_in_39_page0
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_39_page0 = {};

// A closure is defined and assigned to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_39_page0 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
/*
	Background Stretcher jQuery Plugin
	� 2009 ajaxBlender.com
	For any questions please visit www.ajaxblender.com 
	or email us at support@ajaxblender.com
	
	Version: 1.2 (modified by MS)
*/

	/*  Variables  */
	var container = null;
	var allImgs = '', allLIs = '', containerStr = '';	
	var element = this;
	var _bgStretcherPause = false;
	var _bgStretcherTm = null;
	
	jQuery.fn.bgStretcher = function(settings){
		settings = jQuery.extend({}, jQuery.fn.bgStretcher.defaults, settings);
		jQuery.fn.bgStretcher.settings = settings;
		
		function _build(){
			if(!settings.images.length){ return; }
			
			_genHtml();
			
			containerStr = '#' + settings.imageContainer;
			container = jQuery(containerStr);
			allImgs = '#' + settings.imageContainer + ' IMG';
			allLIs = '#' + settings.imageContainer + ' LI';

			jQuery(allLIs).hide();
			var bgrandom = Math.round(Math.random() * jQuery(allLIs).length);
			if(settings.randomFirst) {
			jQuery(allLIs + ':eq(' + bgrandom + ')').fadeIn(1000).addClass('bgs-current');
			} else {
			jQuery(allLIs + ':first').fadeIn(1000).addClass('bgs-current');}
			
			if(!container.length){ return; }
			jQuery(window).resize(_resize);
			
			if(settings.slideShow && jQuery(allImgs).length > 1){
				_bgStretcherTm = setTimeout( bgSlideshow , settings.nextSlideDelay);
			}
			_resize();
		};
		
		function _resize(){
			var winW = jQuery(window).width();
			var winH = jQuery(window).height();
			var imgW = 0, imgH = 0;

			//	Update container's height
			container.width(winW);
			container.height(winH);
			
			//	Non-proportional resize
			if(!settings.resizeProportionally){
				imgW = winW;
				imgH = winH;
			} else {
				var initW = settings.imageWidth, initH = settings.imageHeight;
				var ratio = initH / initW;
				
				imgW = winW;
				imgH = winW * ratio;
				
				if(imgH < winH){
				imgH = winH;
				imgW = imgH / ratio;
				}
			}
			
			//	Apply new size for images
			if(!settings.resizeAnimate){
				jQuery(allImgs).width(imgW).height(imgH);
			} else {
				jQuery(allImgs).animate({width: imgW, height: imgH}, 'normal');
			}
		};
		
		function _genHtml(){
			var code = '<div id="' + settings.imageContainer + '" class="bgstretcher"><ul>';
			for(i = 0; i < settings.images.length; i++){
				code += '<li><img src="' + settings.images[i] + '" alt="" /></li>';
			}
			code += '</ul></div>';
			jQuery(settings.codeLocation).prepend(code);
		};

		function bgSlideshow (){
			var current = jQuery(containerStr + ' LI.bgs-current');
			var next = current.next();
			if(!next.length){
			if(settings.stopEnd)	
			{ return false; }
			else { next = jQuery(containerStr + ' LI:first'); }
			}

			jQuery(containerStr + ' LI').removeClass('bgs-current');
			next.addClass('bgs-current');

			next.fadeIn( jQuery.fn.bgStretcher.settings.slideShowSpeed );
			current.fadeOut( jQuery.fn.bgStretcher.settings.slideShowSpeed );
			_bgStretcherTm = setTimeout( bgSlideshow, jQuery.fn.bgStretcher.settings.nextSlideDelay);
		};
		
		/*  Start bgStretcher  */
		_build();
	};

	/*  Default Settings  */
	jQuery.fn.bgStretcher.defaults = {
		imageContainer:             'bgstretcher',
		resizeProportionally:       true,
		resizeAnimate:              false,
		images:                     [],
		imageWidth:                 1024,
		imageHeight:                768,
		nextSlideDelay:             3000,
		slideShowSpeed:             'slow',
		codeLocation: 				'body',
		randomFirst: 				false,
		slideShow:                  true
	};
	jQuery.fn.bgStretcher.settings = {};

jQuery(document).ready(function(){
	var bg_images = [];
	jQuery('div#inputimages ol li').each(function() {
		bg_images.push(jQuery(this).html())
	});

		jQuery(document).bgStretcher({
			images: bg_images,
			imageWidth: 1024,
			imageHeight: 768,
			imageContainer: 'stretcher',
			nextSlideDelay: 3000,
			slideShowSpeed: 'slow',
			resizeAnimate: false,
			codeLocation: 'body',
			randomFirst: false,
			slideShow: true,
			stopEnd: false
		});
});
	return stack;
})(stacks.stacks_in_39_page0);



