jQuery(function($){
	
	var $offers = $('#mylifts-offers');//we'll re use it a lot, so better save it to a var.
	$offers.serialScroll({
		items:'div',
		duration:8000,
		force:true,
		axis:'x',
		easing:'linear',
		lazy:true,// NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
		interval:1 // yeah! I now added auto-scrolling
		//step:2 // scroll 2 offers each time
	});	
	
	// You can temove the .stop() to let it finish the active animation
	$('#mylifts-offers').hover(function(){
		$(this).stop().trigger('stop');
	},function(){
		$(this).stop().trigger('start');
	});
	
	$('#mylifts-request').hover(function(){
		$(this).stop().trigger('stop');
	},function(){
		$(this).stop().trigger('start');
	});
	
	var $requests = $('#mylifts-request');//we'll re use it a lot, so better save it to a var.
	$requests.serialScroll({
		items:'div',
		duration:8000,
		force:true,
		axis:'x',
		easing:'linear',
		lazy:true,// NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
		interval:1 // yeah! I now added auto-scrolling
		//step:2 // scroll 2 offers each time
	});	

});

// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the offer_rss.xml file
	$.get("ticker/offer_rss.xml",{},function(xml){
	
		// Build an HTML string
		myHTMLOutput = '';
		
		// Run the function for each item tag in the XML file
		$('item',xml).each(function(i) {
			
			itemTitle = $(this).find("title").text();
			itemLink = $(this).find("link").text();
			
			// Build row HTML data and store in string
			mydata = BuildHTML(itemTitle,itemLink);
			myHTMLOutput = myHTMLOutput + mydata;
		});
		
		// Update the DIV called Content Area with the HTML string
		$("#mylifts-offers").append(myHTMLOutput);
	});
	
	$.get("ticker/request_rss.xml",{},function(xml){
	
		// Build an HTML string
		myHTMLOutput = '';
		
		// Run the function for each item tag in the XML file
		$('item',xml).each(function(i) {
			
			itemTitle = $(this).find("title").text();
			itemLink = $(this).find("link").text();
			
			// Build row HTML data and store in string
			mydata = BuildHTML(itemTitle,itemLink);
			myHTMLOutput = myHTMLOutput + mydata;
		});
		
		// Update the DIV called Content Area with the HTML string
		$("#mylifts-request").append(myHTMLOutput);
	});
});

function BuildHTML(itemTitle,itemLink){
	
	// Build HTML string and return
	output = '';
	output += '<div>';
	output += '<a href="' + itemLink + '">'+ itemTitle.replace(/-->/, "&raquo;")  + '</a>';
	output += '</div>';
	return output;
}
