
// '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_538_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_538_page0 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_538_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;
	
/*
 *
 * RapidWeaver Multi Language Enclosure stack by Tsooj Media
 * Version 1.0.0
 *
 * Visit http://www.tsooj.net for more information on how to use this stacks product for RapidWeaver.
 *
 */
 
 
 /**
  * Based on the Cookie plugin
  *
  * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
  * Dual licensed under the MIT and GPL licenses:
  *
  */
 
 /**
  * Create a cookie with the given name and value and other optional parameters.
  *
  * @example $.cookie('the_cookie', 'the_value');
  * @desc Set the value of a cookie.
  * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
  * @desc Create a cookie with all available options.
  * @example $.cookie('the_cookie', 'the_value');
  * @desc Create a session cookie.
  * @example $.cookie('the_cookie', null);
  * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
  *       used when the cookie was set.
  *
  * @param String name The name of the cookie.
  * @param String value The value of the cookie.
  * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
  * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
  *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
  *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
  *                             when the the browser exits.
  * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
  * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
  * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
  *                        require a secure protocol (like HTTPS).
  * @type undefined
  *
  * @name $.cookie
  * @cat Plugins/Cookie
  * @author Klaus Hartl/klaus.hartl@stilbuero.de
  */
 
 /**
  * Get the value of a cookie with the given name.
  *
  * @example $.cookie('the_cookie');
  * @desc Get the value of a cookie.
  *
  * @param String name The name of the cookie.
  * @return The value of the cookie.
  * @type String
  *
  * @name $.cookie
  * @cat Plugins/Cookie
  * @author Klaus Hartl/klaus.hartl@stilbuero.de
  */
 
 (function($){
 	$.cookie = function(key, value, options) {
 		if(arguments.length > 1) {
 			var o = $.extend({}, $.cookie.defaults, options);
 	        if (value === null || value === undefined) {
 	            value = '';
 	            o.expires = -1;
 	        }
 	        if (o.expires.constructor != Date) {
 				var today = new Date();
 				today.setDate(today.getDate() + o.expires);
 				o.expires = today;
 			}
 			// Create the cookie string
 			document.cookie = 
 				key + '=' + value +
 				'; expires=' + o.expires.toUTCString() +
 				(o.path? '; path=' + (o.path) : '') +
 				(o.domain? '; domain=' + (o.domain) : '') +
 				(o.secure? '; secure' : '');
 		} else {
 			if(result = new RegExp(key+"=(.*?)(?:;|$)").exec(document.cookie))
 				return decodeURIComponent(result[1]);
 			return false;
 		}
 	};
 	$.cookie.defaults = {
 		expires: ((90 == 0) ? -1 : 90),
 		path: '/',
 		domain: document.domain,
 		secure: ((document.location.protocol == 'https:') ? true : false),
 	}
 })(jQuery);
 

// Global Vars.
stacks.atm_gstrRwmlCurrentLanguage = '';
 
// Local Vars.
var atm_strRwmlDefaultLanguage = 'EN';
var atm_strRwmlCookieName = 'rwml_preferred_language';
var atm_strRwmlCurrentLanguage = '';
var atm_blnRwmlHanleRedirects = false;


function atm_rwmlShowLanguage(strLanguage, blnDocumentReady) {
	
	 /**	Hide all language content, note that a lot of RW Themes come with a wrong html xml declaration.
	 		For example: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">.
	 		This is wrong because the language could be something else and the RW users should be able to 
	 		set the correct Language(s) themself by using RW in our opinion.
	 
	 		So therefore we are using the specific document.body target for the Lang(uage) selection, 
	 		otherwise the entire document content could be hidden by the RWML script.
	 */
	 
	// Only perform actions when a different Language is chosen.
	if (atm_strRwmlCurrentLanguage != strLanguage) { 
	
		$('[lang]', document.body).hide();
	
		// Show Selected Language, fade in when Switching from Language.
		$('[lang]', document.body).each(function() {
			if (($(this).attr('lang') == strLanguage) && blnDocumentReady) {
				$(this).show();
			} 
			else if (($(this).attr('lang') == strLanguage) && !blnDocumentReady) {
				$(this).fadeIn(2000);
			}
			else {
				$(this).hide();
			}		
		}); 	
	
		// Show all RWML system (rwml-sys) contained Language content items.
		if (blnDocumentReady) {
			$('.rwml-sys').show();
		}
		
		// Set the Active Language;
		atm_strRwmlCurrentLanguage = strLanguage;
			
		// Make sure the Cookie is renewed.
		$.cookie(atm_strRwmlCookieName, null);

		// Set the Active Language;
		atm_strRwmlCurrentLanguage = strLanguage;

		// Store used Language in RWML Cookie.  
		$.cookie(atm_strRwmlCookieName, strLanguage);	

		// Handle Redirects when needed.
		if (atm_blnRwmlHanleRedirects) {
			setTimeout(atm_rwmlRedirect(atm_strRwmlCurrentLanguage), 500);
		}	
	}
} 


// Hide the Language Content items that belong to the RWML system (rwml-sys) during page load.
// This prevents that the Content comes available during page loading.
document.write("<style type='text/css'>.rwml-sys {display: none;}</style>"); 

$(document).ready(function() {   
 
 	// Create Switch Links based on the RWML Switch Stack(s).
	$('a[rel="rwml"]').click(function() {
		var atm_strHrefLang = $(this).attr('HREFLANG');
		atm_rwmlShowLanguage(atm_strHrefLang, false);
		return false; // Disable  default behaviour.
    });
    
    // Create Switch Links based on the Toolbar aka Menu Items.
	$('a[href*="rwml-sys"]').click(function() {
		var atm_strHrefLang = $(this).text();
		atm_rwmlShowLanguage(atm_strHrefLang, false);
		return false; // Disable  default behaviour.
	});
	
	// Handle Redirects.
	$('#rwml-redirect').each(function() {
		atm_blnRwmlHanleRedirects = true;
	});
    
    // Show the 'Selected' Language based on Autoselect.
	atm_rwmlShowLanguage(($.cookie(atm_strRwmlCookieName)) ? $.cookie(atm_strRwmlCookieName) : atm_strRwmlDefaultLanguage, true);
	
});



	return stack;
})(stacks.stacks_in_538_page0);


// Javascript for stacks_in_541_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_541_page0 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_541_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;
	
/*
 *
 * RapidWeaver Newsticker Styled stack by Tsooj Media
 * Version 1.3.0
 *
 * Visit http://www.tsooj.net for more information on how to use this stacks product for RapidWeaver.
 *
 */
 
/*
News ticker plugin (BBC news style)
Bryan Gullan,2007-2011
version 2.3.6
updated 2011-03-16
Documentation at http://www.makemineatriple.com/news-ticker-documentation/
Demo at http://www.makemineatriple.com/jquery/?newsTicker
Use and distrubute freely with this header intact.
*/

(function($) {
	
	var name='newsTicker';
	var debugMode = false; // enabling this turns on console logging for interactions
	
	function runTicker(settings) {
		
		tickerData = $(settings.newsList).data('newsTicker');
		
		if(tickerData.currentItem > tickerData.newsItemCounter){
			// if we've looped to beyond the last item in the list, start over
			tickerData.currentItem = 0;
		}
		else if (tickerData.currentItem < 0) {
			// if we've looped back before the first item, move to the last one
			tickerData.currentItem = tickerData.newsItemCounter;
		}
		
		if(tickerData.currentPosition == 0) {
			if(tickerData.newsLinks[tickerData.currentItem].length > 0) {
				$(tickerData.newsList).empty().append('<li><a '+ tickerData.newsAttributes[tickerData.currentItem] +'></a></li>');
			}
			else {
				$(tickerData.newsList).empty().append('<li></li>');
			}
		}
		
		//only start the ticker itself if it's defined as animating: otherwise it's paused or under manual advance
		if (tickerData.animating) {
			
			if( tickerData.currentPosition % 2 == 0) {
					var placeHolder = tickerData.placeHolder1;
			}
			else {
				var placeHolder = tickerData.placeHolder2;
			}
			
			if( tickerData.currentPosition < tickerData.newsItems[tickerData.currentItem].length) {
				// we haven't completed ticking out the current item
				
				var tickerText = tickerData.newsItems[tickerData.currentItem].substring(0,tickerData.currentPosition);
				if(tickerData.newsLinks[tickerData.currentItem].length > 0) {
					$(tickerData.newsList + ' li a').text(tickerText + placeHolder);
				}
				else {
					$(tickerData.newsList + ' li').text(tickerText + placeHolder);
				}
				tickerData.currentPosition ++;
				setTimeout(function(){runTicker(settings); settings = null;},tickerData.tickerRate);
			}
			
			else {
				// we're on the last letter of the current item
				
				if(tickerData.newsLinks[tickerData.currentItem].length > 0) {
					$(tickerData.newsList + ' li a').text(tickerData.newsItems[tickerData.currentItem]);
				}
				else {
					$(tickerData.newsList + ' li').text(tickerData.newsItems[tickerData.currentItem]);
				}
				
				setTimeout(function(){
					if (tickerData.animating) {
						tickerData.currentPosition = 0;
						tickerData.currentItem ++;
						runTicker(settings); settings = null;
					}
				},tickerData.loopDelay);
				
			}
		}
		
		else {// settings.animating == false 
			
			// display the full text of the current item
			var tickerText = tickerData.newsItems[tickerData.currentItem];
			
			if(tickerData.newsLinks[tickerData.currentItem].length > 0) {
				$(tickerData.newsList + ' li a').text(tickerText);
			}
			else {
				$(tickerData.newsList + ' li').text(tickerText);
			}
					
		}
		
	}

	
	// Core plugin setup and config
	jQuery.fn[name] = function(options) {
 
	  // Add or overwrite options onto defaults
	  var settings = jQuery.extend({}, jQuery.fn.newsTicker.defaults, options);
	 
    var newsItems = new Array();
		var newsLinks = new Array();
		var newsAttributes = new Array();
		var newsItemCounter = 0;
		
		// Hide the static list items
		$(settings.newsList + ' li').hide();
		
		// Store the items and links in arrays for output
		$(settings.newsList + ' li').each(function(){
			if($(this).children('a').length) {
				newsItems[newsItemCounter] = $(this).children('a').text();
				newsLinks[newsItemCounter] = $(this).children('a').attr('href');
				
				var linkAttributes = new Object();
			  	var attrs = $(this).children('a')[0].attributes;
					for (var i=0;i<attrs.length;i++) {
					linkAttributes[attrs[i].nodeName] = attrs[i].nodeValue;
				}
				if (debugMode){ 
					console.log(linkAttributes);
				}
				
		    var linkAttributesProcessed = '';
 				for (var prop in linkAttributes) {
 					// print out the attributes as a string ready for output within the anchor tag
    			linkAttributesProcessed = linkAttributesProcessed + prop + '="' + linkAttributes[prop] + '" ';
 				}
 				if (debugMode){ 
					console.log(linkAttributesProcessed);
				}
 				
				newsAttributes[newsItemCounter] = linkAttributesProcessed;
				
			}
			else {
				newsItems[newsItemCounter] = $(this).text();
				newsLinks[newsItemCounter] = '';
				newsAttributes[newsItemCounter] = '';
			}
			newsItemCounter ++;
		});
        
        var tickerElement = $(settings.newsList); // for quick reference below
        
        tickerElement.data(name, {
        	newsList: settings.newsList,
					tickerRate: settings.tickerRate,
					startDelay: settings.startDelay,
					loopDelay: settings.loopDelay,
					placeHolder1: settings.placeHolder1,
					placeHolder2: settings.placeHolder2,
					controls: settings.controls,
					ownControls: settings.ownControls,
					stopOnHover: settings.stopOnHover,
					resumeOffHover: settings.resumeOffHover,
          newsItems: newsItems,
					newsLinks: newsLinks,
					newsAttributes: newsAttributes,
					newsItemCounter: newsItemCounter - 1, // -1 because we've incremented even after the last item (above)
					currentItem: 0,
					currentPosition: 0,
					firstRun:1
        })
        .bind({
			stop: function(event) {
				// show remainder of the current item immediately
		    	tickerData = tickerElement.data(name);
		    	if (tickerData.animating) { // only stop if not already stopped
            		tickerData.animating = false;
            		if (debugMode){ 
            			console.log('stop'+tickerData.currentItem + ' ' + tickerData.animating);
            		}
               	}
		  	},
		  	play: function(event) {
		  		// show 1st item with startdelay
		    	tickerData = tickerElement.data(name);
		    	if (!tickerData.animating) { // if already animating, don't start animating again
	            	tickerData.animating = true;
	            	if (debugMode){ 
            			console.log('play'+tickerData.currentItem + ' ' + tickerData.animating);
            		}
	            	setTimeout(function(){runTicker(tickerData); tickerData = null;},tickerData.startDelay);
	            }
		  	},
		  	resume: function(event) {
		  		// start from next item, with no delay
		    	tickerData = tickerElement.data(name);
		    	if (!tickerData.animating) { // if already animating, don't start animating again
	            	tickerData.animating = true;
	            	// set the character position as 0 to ensure on resume we start at the right point
					tickerData.currentPosition = 0;
	            	tickerData.currentItem ++;
	            	if (debugMode){ 
            			console.log('resume'+tickerData.currentItem + ' ' + tickerData.animating);
            		}
		            runTicker(tickerData); // no delay when resuming.
		        }
		  	},
		  	next: function(event) {
		  		// show whole of next item
		  		tickerData = tickerElement.data(name);
		  		// stop (which sets as non-animating), and call runticker
		  		$(tickerData.newsList).trigger("stop");
		  		// set the character position as 0 to ensure on resume we start at the right point
				tickerData.currentPosition = 0;
	            tickerData.currentItem ++;
	            if (debugMode){ 
            			console.log('next'+tickerData.currentItem + ' ' + tickerData.animating);
            		}
		  		runTicker(tickerData);
		  	},
		  	previous: function(event) {
				// show whole of previous item
				tickerData = tickerElement.data(name);
		  		// stop (which sets as non-animating), and call runticker
		  		$(tickerData.newsList).trigger("stop");
		  		// set the character position as 0 to ensure on resume we start at the right point
				tickerData.currentPosition = 0;
	            tickerData.currentItem --;
	            if (debugMode){ 
            			console.log('previous'+tickerData.currentItem + ' ' + tickerData.animating);
            		}
		  		runTicker(tickerData);
			}
		}); 	
		if (settings.stopOnHover) {
	    	tickerElement.bind({			    	
			  	mouseover: function(event) {
			  		tickerData = tickerElement.data(name);
			    	if (tickerData.animating) { // stop if not already stopped
				  		$(tickerData.newsList).trigger("stop");
				  		if (tickerData.controls) { // ensure that the ticker can be resumed if controls are enabled
				  			$('.stop').hide();
			        		$('.resume').show();
				  		}
			  		}
			  	}
			});
			if (settings.resumeOffHover) { // only allowed if stopOnHover enabled
		    	tickerElement.bind({			    	
				  	mouseout: function(event) {
				  		tickerData = tickerElement.data(name);
				    	if (!tickerData.animating) { // if already animating, don't start animating again
			            	$(tickerData.newsList).trigger("resume");
			            	if (debugMode){ 
		            			console.log('resumeoffhover'+tickerData.currentItem + ' ' + tickerData.animating);
		            		}
				        }
				  	}
				});
    		}
    	}
    	
    	tickerData = tickerElement.data(name);
    	
    	// set up control buttons if the option is on
		if (tickerData.controls || tickerData.ownControls) {
			if (!tickerData.ownControls) {
				$('<ul class="ticker-controls"><li class="play"><a href="#play">Play</a></li><li class="resume"><a href="#resume">Resume</a></li><li class="stop"><a href="#stop">Stop</a></li><li class="previous"><a href="#previous">Previous</a></li><li class="next"><a href="#next">Next</a></li></ul>').insertAfter($(tickerData.newsList));
			}
			$('.play').hide();
		    $('.resume').hide();
			
		    $('.play').click(function(event){
		        $(tickerData.newsList).trigger("play");
		        $('.play').hide();
		        $('.resume').hide();
		        $('.stop').show();
		        event.preventDefault();
		    });
		    $('.resume').click(function(event){
		        $(tickerData.newsList).trigger("resume");
		        $('.play').hide();
		        $('.resume').hide();
		        $('.stop').show();
		        event.preventDefault();
		    });
			$('.stop').click(function(event){
		        $(tickerData.newsList).trigger("stop");
		        $('.stop').hide();
		        $('.resume').show();
		        event.preventDefault();
		    });
		    $('.previous').click(function(event){
		        $(tickerData.newsList).trigger("previous");
		        $('.stop').hide();
			    $('.resume').show();
		        event.preventDefault();
		    });
		    $('.next').click(function(event){
		        $(tickerData.newsList).trigger("next");
		        $('.stop').hide();
			    $('.resume').show();
		        event.preventDefault();
		    });

	    };
    	
    	// tell it to play
    	$(tickerData.newsList).trigger("play");
	};

	// News ticker defaults 
	jQuery.fn[name].defaults = {
		newsList: ".atm-Newsticker ul",
		tickerRate: 80,
		startDelay: 100,
		loopDelay: 3000,
		placeHolder1: "",
		placeHolder2: "",
		controls: false,
		ownControls: false,
		stopOnHover: true,
		resumeOffHover: true
	}

})(jQuery);


$(document).ready(function() {
	$().newsTicker();
});

	return stack;
})(stacks.stacks_in_541_page0);


// Javascript for stacks_in_561_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_561_page0 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_561_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;
	

//-- RSS Stream Stack v1.5 by Joe Workman --//

/****** Start liScroll JQuery plugin
 * liScroll 1.0
 * Examples and documentation at: 
 * http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
 * 2007-2010 Gian Carlo Mingati
 * Version: 1.0.2 (30-MARCH-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * I have modified this plugin slightly to support TipTip Integration */
(function($) {
	$.fn.liScroll = function(settings) {
		settings = $.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = $(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += $(this, i).outerWidth(true); // thanks to Michael Haszprunar
				});
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				$(this).stop();
				if ($().tipTip) { $(".tiptip").tipTip(); } //JW - Added this line to integrate with TipTip
				},
				function(){
				var offset = $(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
	}; 
})(jQuery);

//---------------------------
// Start Common RSS Code
//---------------------------
formatString = function(str) {
	str = str.replace(/<[^>]+>/ig,'');
	str=' '+str;
	return $.trim(str);
}

enrichString = function(str) {
	str = str.replace(/((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/gm,'<a href="$1" target="_blank">$1</a>');
	str = str.replace(/([^\w])\@([\w\-]+)/gm,'$1@<a href="http://twitter.com/$2" target="_blank">$2</a>');
	str = str.replace(/([^\w])\#([\w\-]+)/gm,'$1<a href="http://twitter.com/search?q=%23$2" target="_blank">#$2</a>');
	return $.trim(str);
}

parse_date = function(str) {
    if (str.match(/^\d+\-\d+\-\d+T/)) {
        str = str.replace(/T.+$/,'');
    }
	var d = new Date(str);
	var m = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
	if (d.getUTCDate()) {
		return d.getUTCDate() + ' ' + m[d.getUTCMonth()] + ' ' + d.getFullYear();
    }
    return str;
};

find_link = function(obj) {
    var default_string = '#';
    if (obj == null || obj == undefined) {
        return default_string;
    }	
    else if (typeof obj.origLink == 'string') {
        return obj.origLink;
    }
    else if ($.isArray(obj.link)) {
        var mylink = obj.link[0].href;
        $.each(obj.link,function(index, value){
            if (value.rel === 'alternate') {
                mylink = value.href;
            }
		})
        return mylink;
    }
    else if (typeof obj.link == 'object') {
        return obj.link.href;
    }
    else if (typeof obj.link == 'string') {
        return obj.link;
    }
    else if (typeof obj.enclosure == 'object' && typeof obj.enclosure.url == 'string') {
        return obj.enclosure.url;
    }
    return default_string;
};

find_title = function(obj) {
    var default_string = 'No Items in RSS Feed';
    if (obj == null || obj == undefined) {
        return default_string;
    }	
    else if (typeof obj.title.content == 'string') {
        return formatString(obj.title.content);
    }
    else if (typeof obj.title == 'string') {
        return formatString(obj.title);
    }
    return default_string;
};

find_date = function(obj) {
    var default_string = 'Date Unknown';
    if (obj == null || obj == undefined) {
        return default_string;
    }	
    else if (typeof obj.pubDate == 'string') {
		return parse_date(obj.pubDate);
    }
    else if (typeof obj.date == 'string') {
		return parse_date(obj.date);
    }
    else if (typeof obj.published == 'string') {
		return parse_date(obj.published);
    }
    else if (typeof obj.updated == 'string') {
		return parse_date(obj.updated);
    }
    return default_string;
};

find_descr = function(obj) {
    var default_string = 'RSS Feed Invalid. No Description Found.';
    if (obj == null || obj == undefined) {
        return default_string;
    }	
    else if (typeof obj.description == 'string') {
		return formatString(obj.description);
    }
    else if (typeof obj.encoded == 'string') {
		return formatString(obj.encoded);
    }
    else if (typeof obj.content == 'object' && typeof obj.content.content == 'string') {
		return formatString(obj.content.content);
    }
    return default_string;
};

find_author = function(obj) {
    var default_string = 'Unknown Author';
    if (obj == null || obj == undefined) {
        return default_string;
    }	
    else if (typeof obj.creator == 'string') {
		return obj.creator;
    }
    else if ($.isArray(obj.author)) {
        return obj.author[0];
    }
    else if (typeof obj.author == 'object' && typeof obj.author.email == 'string') {
		return obj.author.email;
    }
    else if (typeof obj.author == 'string') {
		return obj.author;
    }
    return default_string;
};

$(document).ready(function() {
	/* Forming the query: */
	var feed = "feed://smoothyclub.ning.com/activity/log/list?fmt=rss";
	feed = feed.replace(/feed:\/\//,'http://'); // Replace feed:// with http://
	var query = 'select * from feed where url="' + feed + '" LIMIT 15';

	/* Forming the URL to YQL: */
	var url = "http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(query)+"&format=json&callback=?";

	$.getJSON(url,function(data){
		if (data.query == null || data.query == undefined || data.query.results == null || data.query.results == undefined) {
			// Invalid or Empty RSS Feed - Add Blank/Default Entries
			add_feed_item();
	 	}
	 	else if ($.isArray(data.query.results.item || data.query.results.entry) ) {  //item exists in RSS and entry in ATOM feeds
			$.each(data.query.results.item || data.query.results.entry,function(){
	       		//Normal RSS Feed
	       		add_feed_item(this);
			})
		}
		else {
		    // RSS Feed with only one item in it
			add_feed_item(data.query.results.item || data.query.results.entry || null);
		}
		post_process_feed(this);
	});
});
//---------------------------
// End Common RSS Code
//---------------------------

function add_feed_item(obj) {
    var maxLength = 150;
	$('#rss-stream-list-stacks_in_561_page0').append('<li><span class="tickerdate">' + find_date(obj) + 
		'</span><a class="tiptip" title="'+ find_date(obj) +  
		' - ' + find_descr(obj).substring(0, maxLength) + 
		'" href="' + find_link(null) + 
		'" target="_blank">' + find_title(obj) + '</a></li>'
	);
	return;    	        
};
function post_process_feed(obj) {
	$('#rss-stream-list-stacks_in_561_page0').liScroll({travelocity: 0.05});
	return;    	        
};
//-- End RSS Stream Stack --//


	return stack;
})(stacks.stacks_in_561_page0);



