/**
 * @author Bluntworks
 */
if ($.log != 'function') {
	$.log = function(m){
		if (window && window.console && window.console.log) {
			window.console.log(arguments.length == 1 ? m : arguments);
		}
	};
};

function itrObj(o){
		for (var k in o) {
			$.log('key : '+k+ ' val : '+o[k]);
		}
 }
  
(function($) {
    $.fn.NLSlide = function(settings) {
			
		var config = { 
				'speed' 	: 1000
			,	'itemSelector' : '.Item'
			,	'navSelector' : 'li'
		};
		
		if (settings) $.extend(config, settings);
		
		var $self = $(this)
			, $items = $self.find(config.itemSelector)
			, elements = new Array()
			, index
			, count
			, max
			, $nav=$self.find(config.navSelector)
			, navLi = new Array()
			, $tray

		init(); 
		
		function init() { 
			$items.remove();

			$self.css('overflow','hidden');
			
			$self.append('<div id="Tray"></div>');
			
			$tray=$('#Tray');
			
			count=$items.length;
			
			$tray.css({ 
					'width' 	: $self.width()*count
				,	'height' 	: '245px'
				,	'position' 	: 'absolute'
				,	'top'		: 0
				,	'left'		: 0
				,	'z-index'	: 1
				,	'background': '#fff'
				,	'float': 'left'
				
			});
			
			$tray.append($items);
			
			$items.each(function(i,el) {
				$(el).css( { 
						'position' 	: 'absolute'
					,	'top' 		:  0
					,	'left'		: $self.width()*i
					
				});
			});
			
			
			$nav.each(function(i,el){
				var href = $(el).find('a').attr('href');
				
				$(el).click(function(ev){ 
					window.location = href;	
				});
				
				$(el).css('cursor','pointer');
				
				$(el).mouseover(function(ev) {
					$nav.removeClass('Active');
					$(this).addClass('Active');
					moveTo(i*$self.width());	
				});
			});
		}
		
		function moveTo(newPos) { 
			$tray.stop().animate({left : -newPos}, config.speed); 
		}

	}
})(jQuery);
