
	jQuery.fn.slider = function(par){
			
		/*------VARIABLES--------*/
				
			var parDefault = {
				start : 0,				
				height : 0,
				width : 0,
				delay : 6000,
				scrollSpeed : 45, 
				fadeDuration : 1500
			}
			
			var param = $.extend(parDefault, par);
			
			
			this.append('<div style="overflow:hidden; position:absolute; height:'+param.height+'px; width:'+param.width+'px;"><img border="0" /></div>');
			this.append('<div style="overflow:hidden; position:absolute; height:'+param.height+'px; width:'+param.width+'px;"><img border="0" /></div>');	
			
			var photoB = $(":nth-child(1)",this);
			var photoA = $(":nth-child(2)",this);
			
			var scrollA;
			var scrollB;
			
			var scrollA_x, scrollA_y, scrollB_x, scrollB_y;
			
			var pshowN = param.start;
			var toggle = 0;
			
			
		/*------START-----*/
			

			
			photoA.hide();
			photoB.hide();			

			prepareDiv(photoA, pshowN);			
			
			setTimeout( function () {

				photoB.show();
				photoA.fadeTo(750, 1.0, function () {
												   
					prepareDiv(photoB, nextN());
					
				});
				
				scrollA = setInterval(function () { scrollDiv(photoA, param.start); }, param.scrollSpeed);				

			}, 100);
			
			
			
			wait();	
			
	
			
			
			
		/*------FUNCTIONS--------*/
			
			function toggleDiv() {
				
				var currentN = pshowN;
					
				if (!toggle) {
					
					toggle = 1;
					
					scrollB = setInterval(function () { scrollDiv(photoB, currentN); }, param.scrollSpeed);
					
					photoA.fadeTo(param.fadeDuration, 0.0, function () {
						clearInterval(scrollA);
						prepareDiv(photoA, nextN());	
						wait();						
					});

				} else {
					
					toggle = 0;
					
					scrollA = setInterval(function () { scrollDiv(photoA, currentN); }, param.scrollSpeed);	
					
					photoA.fadeTo(param.fadeDuration, 1.0, function () {
						clearInterval(scrollB);
						prepareDiv(photoB, nextN());	
						wait();
					});
					
				}
			}
			
			function prepareDiv(div, n) {
				$('img', div).attr('src', param.list[n].src);
				div.scrollLeft(param.list[n].offset[0]);	
				div.scrollTop(param.list[n].offset[1]);						

				div.moveDecimalX = parseFloat(param.list[n].offset[0]);
				div.moveDecimalY = parseFloat(param.list[n].offset[1]);

			}
			
			function scrollDiv(div, n) {
				
				
				var speed = 1;
				if (param.list[n].speed) {
					speed = param.list[n].speed;
				}
				
				var radian = (param.list[n].angle * Math.PI) / 180;
				var x = Math.cos(radian) * speed;
				var y = -Math.sin(radian) * speed;
				
				div.moveDecimalX = div.moveDecimalX + x;
				div.moveDecimalY = div.moveDecimalY + y;
				
				
				div.scrollLeft(Math.floor(div.moveDecimalX));				
				div.scrollTop(Math.floor(div.moveDecimalY));

			}				
			
			function wait() {
				
				var delay = param.delay;
				if (param.list[pshowN].delay) {
					delay = param.list[pshowN].delay;
				}
				
				pshowN = nextN();
				var timeout = setTimeout(function () { toggleDiv(); }, delay);
			}
			
			
			function nextN() {
				if ( parseInt(pshowN+1) >= (param.list.length)) {
					return 0;	
				} else {							
					return pshowN+1;
				}
			}		



	}
