var hl_folder;
var hl_url;
var hlimg_folder;

(function($){
get_highlights = function(hl_folder,url) {

hlimg_folder = hl_folder +"/highlights_"+url;

url = 'highlights_'+url+'.xml'; //highlight_home.xml and url is home
// hl_folder is feature
hl_url = hl_folder +"/"+ url; //feature/highlight_home.xml

$.ajax({
                 type: "GET",
                 url: hl_url,
                 dataType: "xml",
                 cache: false,
                 success: function(xml) {
			var htmlvar = '';
			var profileid;
			var venue_name;
			var hl_img;
			var hl_caption;
			var hl_section;
			var hl_type;

			$(xml).find('item').each(function(){			
				profileid = $(this).find('id').text();
				venue_name = $(this).find('name').text();
				hl_img = $(this).find('img').text();
				hl_caption = $(this).find('caption').text();
				hl_section = $(this).find('section').text();
				hl_type = $(this).find('type').text();
				hl_date = $(this).find('date').text();


//split into array - see if date is < today's date
var dateparts = new Array(); 
dateparts = hl_date.split('/'); 		
var listdate = dateparts[2]+"/"+dateparts[1]+"/"+dateparts[0];
//is date less than today - format Ymd
if (Date.parse(listdate) < Date.parse(currentDate) ) {
hl_date = "";
}

				
if (hl_date !=""){
			hl_date	= hl_date.replace(/\//g,'-');
				htmlvar = htmlvar + '<div class="itemk"><a href="index.php?p='+hl_section+'&type='+hl_type+'&id='+profileid+'&date='+hl_date+'"><img  class = "hlimg" width="480"  src="'+hlimg_folder+'\/'+hl_img+'"><\/a><div class="hltext"><a href="index.php?p='+hl_section+'&type='+hl_type+'&id='+profileid+'&date='+hl_date+'"><h3>'+ venue_name +'<\/h3><\/a><p>'+ hl_caption +'<\/p><\/div><\/div>';
} else {

				htmlvar = htmlvar + '<div class="itemk"><a href="index.php?p='+hl_section+'&type='+hl_type+'&id='+profileid+'"><img  class = "hlimg" width="480"  src="'+hlimg_folder+'\/'+hl_img+'"><\/a><div class="hltext"><a href="index.php?p='+hl_section+'&type='+hl_type+'&id='+profileid+'"><h3>'+ venue_name +'<\/h3><\/a><p>'+ hl_caption +'<\/p><\/div><\/div>';	
}			
				
				
				
				});
				
				$('#scroller .items_big').empty();				
				$('#scroller .items_big').html(htmlvar);
					
			var root = $("#scroller").scrollable({circular: true}).autoscroll({interval: 15000, autoplay: true }).navigator();
			
		}
       	});     


          }           
})(jQuery);
