(function($) {
	
	$.fn.vwFooter = function(clas) {

		return this.each(function () {
			
			var vwFooter = $(this);

			// LOAD IN XML FOOTER DATA
			$.get('/global/footer/data/footer.xml', function(data) {
			
				// LOAD LINK LIST
				$(vwFooter).html("");
				$(vwFooter).append('<ul></ul>');
				$(data).find('link').each(function() {
          var id = 'footer-' + $(this).find('title').attr('itemID');
					var html = '<li id="'+ id + '"><a href="'+$(this).find('url').text()+'">'+$(this).find('title').text()+'</a></li>';
					$('ul',vwFooter).append(html);
          // add target attribute if necessary
          var target = $(this).find('url').attr('target');
          if(target == '_blank') {
            $(vwFooter).find('#' + id + ' a').attr('target','_blank');
          }
				});
			
				// LOAD COPYRIGHT
				var $copyright = $(data).find('copyright');
				var html = '<li id="footer-'+$copyright.find('copyText').attr('itemID')+'">'+$copyright.find('copyText').text()+'</li>';
				$('ul',vwFooter).append(html);
				
				var doc = $(document);
			    doc.trigger('ajax:complete', ["footer"]);
			
			});
		});
	
	}
	
})(jQuery);
