(function($){
	$.fn.rotator=function(options){
		var settings = $.extend({
			cont: 	'.cont',
			list:	'.listtext',
			timer:	4500,
			here: 	0,
			told: 	0,
			load:	'',
			action:	'f',
			lab:	new Array(),
			total:	0,
			width:	180,
			inter:	'',
			arrows: false
		}, options);
		return this.each(function() {
			var $this = $(this);
			var $set = settings;
			var getcont = function(){
				var $i=0;
				$this.find($set.list).children('.loadme').each(
					function(){
						$set.lab[$i] = $(this).html();
						$i++;
					}
				);
			}
			var scrollit = function(){
				$i=0;
				$set.load='';
				if($set.action=='r'){
					$set.told=($set.here-1);
					$set.action='f'
				}
				$($set.lab).each(
					function(){
						if($i==$set.told){
							$set.load=$set.lab[$i];
							$set.here=$i;
						}
						$i++;
					}
				);
				$set.told=($set.here+1);
				if($set.arrows == true){
					($set.here == 0) ? $this.find('.nextrew').hide() : $this.find('.nextrew').show();
					if ($set.told == $i){
						$this.find('.nextfwd').hide();
						$set.told=0;
					}
					else{
						$this.find('.nextfwd').show();
					}
				}
				else{
					if($set.told==$i){
						$set.told=0;
					}
				}
				
				$this.find('.nxt_img_list').fadeOut('fast',function(){
					$(this).css({left:'-'+($set.here*$set.width)+'px'});
					$this.find('.label').fadeOut('fast').html($set.load).fadeIn('fast');
					$(this).fadeIn('fast');}
				);
			};
			if($this.find('.curcont').html()!=''){
				getcont();
				scrollit();
				if($set.lab.length > 1){
					$this
						.bind('mouseover',function(e){
							clearInterval($this.inter);
						})
						.bind('mousemove',function(){
							clearInterval($this.inter);
						})
						.bind('mouseout',function(){
							$this.inter = setInterval(function() { scrollit(); }, $set.timer);
						});
					$this.find('.nextrew').click(function(){$set.action='r'; scrollit();})
					$this.find('.nextfwd').click(function(){scrollit();})
					$this.inter = setInterval(function() { scrollit(); }, $set.timer);
				}
			}
			else{
				$this.remove();
			}
		});
	};
})(jQuery);

(function($){
	$.fn.homeslider=function(options){
		var settings = $.extend({
			total:	0,
			width:	180,
			timer:	3000,
			here: 	0,
			inter: 	''
		}, options);
		return this.each(function() {
			var $this = $(this);
			var $set = settings;
			
			var initialize = function(){
				$this.find('img').each(
					function(){
						$set.total++;
					}
				);
			}
			var move = function(){
				$this.children('div').animate({'left':'-'+($set.here*$set.width)+'px'},'slow','linear',function(){
					$set.here++;
					if ($set.here == $set.total){
						$(this).css({left:'-0px'});
						$set.here = 1;
					}
				});				
			};
			
			
			
			if($this.find('img').attr('src')!=''){
				initialize();
				move();
				if($set.total > 2){
					$this
						.bind('mouseover',function(e){
							clearInterval($this.inter);
						})
						.bind('mousemove',function(){
							clearInterval($this.inter);
						})
						.bind('mouseout',function(){
							$this.inter = setInterval(function() { move(); }, $set.timer);
						});
					$this.inter = setInterval(function() { move(); }, $set.timer);
				}
			}
			else{
				$this.remove();
			}
		});
	};
})(jQuery);