/*

	jQuery Scroller plugin
	Copyright (c) 2010 Max Vergelli

	For support and tutorials visit
	http://maxvergelli.wordpress.com/

	License: GNU Lesser General Public License (LGPL) 
	at http://opensource.org/licenses/lgpl-2.1.php

	This plugin is free software;  you can redistribute it  and/or  modify  it 
	under the terms of the GNU Lesser General Public License as  published  by 
	the Free Software Foundation;  either version 2.1 of the License,  or  (at 
	your option) any later version.
	This software is distributed in the hope  that  it  will  be  useful,  but 
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
	or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU Lesser  General  Public 
	License for more details.
	You should have received a copy of  the  GNU Lesser General Public License 
	along with this library;  if not,  write to the  Free Software Foundation, 
	Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

	THIS COMMENT AND COPYRIGHT NOTICE MUST BE RETAINED IN THE CODE AS IS FOR LEGAL USE

*/
(function(f){f.fn.PlayScroller=function(){this.children().stop();this.children().trigger("marquee",["resume"])};f.fn.PauseScroller=function(){this.children().stop()};f.fn.ResetScroller=function(c){this.children().stop();this.children().unbind("marquee");c=f.extend(this.data(),c);this.SetScroller(c)};f.fn.RemoveScroller=function(){this.children().stop();this.children().css({top:0,left:0});this.children().unbind("marquee")};f.fn.SetScroller=function(c,o){function p(){l.me.children().bind("marquee",
function(q,g){var a=f(this),b=parseInt(a.parent().height()),e=parseInt(a.height()),h=parseInt(a.position().top),i=k>0&&k<100?(100-k)*100:5E3;i=parseInt(i*e/100)+i;if(m=="pingpong")switch(d){case "bottom":typeof g=="undefined"&&a.css({top:b-e});b=h-(e+b);break;default:typeof g=="undefined"&&a.css({top:0});b+=h+e}else switch(d){case "bottom":if(typeof g=="undefined"){a.css({top:b});b=-e}else b=h-(e+b);break;default:if(typeof g=="undefined")a.css({top:-e});else b+=h+e}if(j<0||j>0){j>0&&j--;a.animate({top:b},
{duration:i,easing:"linear",complete:function(){a.trigger("marquee")},step:function(){switch(m){case "pingpong":if(d=="bottom"){if(parseInt(a.position().top)<=0){d="top";a.stop();a.trigger("marquee")}}else if(parseInt(a.position().top)+parseInt(a.height())>=parseInt(a.parent().height())){d="bottom";a.stop();a.trigger("marquee")}break;default:if(d=="bottom"){if(parseInt(a.position().top)<-parseInt(a.height())){a.stop();a.trigger("marquee")}}else if(parseInt(a.position().top)>parseInt(a.parent().height())){a.stop();
a.trigger("marquee")}}}})}}).trigger("marquee")}function r(){l.me.children().bind("marquee",function(q,g){var a=f(this),b=parseInt(a.parent().width()),e=parseInt(a.width()),h=parseInt(a.position().left),i=k>0&&k<100?(100-k)*100:5E3;i=parseInt(i*e/100)+i;if(m=="pingpong")switch(d){case "right":typeof g=="undefined"&&a.css({left:b-e});b=h-(e+b);break;default:typeof g=="undefined"&&a.css({left:0});b+=h+e}else switch(d){case "right":if(typeof g=="undefined"){a.css({left:b});b=-e}else b=h-(e+b);break;
default:if(typeof g=="undefined")a.css({left:-e});else b+=h+e}if(j<0||j>0){j>0&&j--;a.animate({left:b},{duration:i,easing:"linear",complete:function(){n&&n();a.trigger("marquee")},step:function(){switch(m){case "pingpong":if(d=="right"){if(parseInt(a.position().left)<=0){d="left";a.stop();a.trigger("marquee")}}else if(parseInt(a.position().left)+parseInt(a.width())>=parseInt(a.parent().width())){d="right";a.stop();a.trigger("marquee")}break;default:if(d=="right"){if(parseInt(a.position().left)<-parseInt(a.width())){a.stop();
a.trigger("marquee")}}else if(parseInt(a.position().left)>parseInt(a.parent().width())){a.stop();a.trigger("marquee")}}}})}}).trigger("marquee")}var n=o,l={me:this};c=f.extend({velocity:50,direction:"horizontal",startfrom:"right",loop:"infinite",movetype:"linear",onmouseover:"pause",onmouseout:"play",onstartup:"play",cursor:"pointer"},c);var k=typeof c.velocity=="number"?parseInt(c.velocity):50,s=c.direction.toLowerCase(),d=c.startfrom.toLowerCase(),j=typeof c.loop=="number"&&c.loop>0?parseInt(c.loop):
-1,m=c.movetype.toLowerCase();c.onmouseover.toLowerCase();c.onmouseout.toLowerCase();var t=c.onstartup.toLowerCase();c.cursor.toLowerCase();l.me.data(c);if(s=="horizontal"){if(d!="right"&&d!="left")d="right";r()}else{if(d!="bottom"&&d!="top")d="bottom";p()}t!="play"&&l.me.children().stop();return this}})(jQuery);
