// JavaScript Document
/*! Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.2
 * 
 * Requires: 1.2.2+
 */
(function(b){function d(a){var f=[].slice.call(arguments,1),e=0;a=b.event.fix(a||window.event);a.type="mousewheel";if(a.wheelDelta)e=a.wheelDelta/120;if(a.detail)e=-a.detail/3;f.unshift(a,e);return b.event.handle.apply(this,f)}var c=["DOMMouseScroll","mousewheel"];b.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=c.length;a;)this.addEventListener(c[--a],d,false);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=c.length;a;)this.removeEventListener(c[--a],
d,false);else this.onmousewheel=null}};b.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);

/**
 * @version		$Id:  $Revision
 * @package		jquery
 * @subpackage	lofslidernews
 * @copyright	Copyright (C) JAN 2010 LandOfCoder.com <@emai:landofcoder@gmail.com>. All rights reserved.
 * @website     http://landofcoder.com
 * @license		This plugin is dual-licensed under the GNU General Public License and the MIT License 
 */
(function(c){c.fn.lofJSidernews=function(a){return this.each(function(){new c.lofSidernews(this,a)})};c.lofSidernews=function(a,b){this.settings={direction:"",mainItemSelector:"li",navInnerSelector:"ul",navSelector:"li",navigatorEvent:"click",wapperSelector:".lof-main-wapper",interval:4E3,auto:true,maxItemDisplay:3,startItem:0,navPosition:"vertical",navigatorHeight:75,navigatorWidth:280,duration:600,navItemsSelector:".lof-navigator li",navOuterSelector:".lof-navigator-outer",isPreloaded:true,easing:"easeInOutQuad"};
c.extend(this.settings,b||{});this.previousNo=this.nextNo=null;this.maxWidth=this.settings.mainWidth||647;this.wrapper=c(a).find(this.settings.wapperSelector);this.slides=this.wrapper.find(this.settings.mainItemSelector);if(this.wrapper.length&&this.slides.length){if(this.settings.maxItemDisplay>this.slides.length)this.settings.maxItemDisplay=this.slides.length;this.currentNo=isNaN(this.settings.startItem)||this.settings.startItem>this.slides.length?0:this.settings.startItem;this.navigatorOuter=c(a).find(this.settings.navOuterSelector);
this.navigatorItems=c(a).find(this.settings.navItemsSelector);this.navigatorInner=this.navigatorOuter.find(this.settings.navInnerSelector);if(this.settings.navPosition=="horizontal"){this.navigatorInner.width(this.slides.length*this.settings.navigatorWidth);this.navigatorOuter.width(this.settings.maxItemDisplay*this.settings.navigatorWidth);this.navigatorOuter.height(this.settings.navigatorHeight)}else{this.navigatorInner.height(this.slides.length*this.settings.navigatorHeight);this.navigatorOuter.height(this.settings.maxItemDisplay*
this.settings.navigatorHeight);this.navigatorOuter.width(this.settings.navigatorWidth)}this.navigratorStep=this.__getPositionMode(this.settings.navPosition);this.directionMode=this.__getDirectionMode();if(this.settings.direction=="opacity"){this.wrapper.addClass("lof-opacity");c(this.slides).css("opacity",0).eq(this.currentNo).css("opacity",1).addClass("active-slide");this.caption=c(a).find(".lof-main-item-desc");c(a).find(".lof-main-item-desc").hide().eq(0).show()}else this.wrapper.css({left:"-"+
this.currentNo*this.maxSize+"px",width:this.maxWidth*this.slides.length});this.settings.isPreloaded?this.preLoadImage(this.onComplete):this.onComplete()}};c.lofSidernews.fn=c.lofSidernews.prototype;c.lofSidernews.fn.extend=c.lofSidernews.extend=c.extend;c.lofSidernews.fn.extend({startUp:function(){seft=this;this.navigatorItems.each(function(a,b){c(b).click(function(){seft.jumping(a,true);seft.setNavActive(a,b)});c(b).css({height:seft.settings.navigatorHeight,width:seft.settings.navigatorWidth})});
this.registerWheelHandler(this.navigatorOuter,this);this.setNavActive(this.currentNo);this.settings.buttons&&typeof this.settings.buttons=="object"&&this.registerButtonsControl("click",this.settings.buttons,this);this.settings.auto&&this.play(this.settings.interval,"next",true);return this},onComplete:function(){setTimeout(function(){c(".preload").fadeOut(900)},400);this.startUp()},preLoadImage:function(){var a=this,b=this.wrapper.find("img"),d=0;b.each(function(e,f){if(f.complete){d++;d>=b.length&&
a.onComplete()}else{f.onload=function(){d++;d>=b.length&&a.onComplete()};f.onerror=function(){d++;d>=b.length&&a.onComplete()}}})},navivationAnimate:function(a){if(a<=this.settings.startItem||a-this.settings.startItem>=this.settings.maxItemDisplay-1){this.settings.startItem=a-this.settings.maxItemDisplay+2;if(this.settings.startItem<0)this.settings.startItem=0;if(this.settings.startItem>this.slides.length-this.settings.maxItemDisplay)this.settings.startItem=this.slides.length-this.settings.maxItemDisplay}this.navigatorInner.stop().animate(eval("({"+
this.navigratorStep[0]+":-"+this.settings.startItem*this.navigratorStep[1]+"})"),{duration:500,easing:"easeInOutQuad"})},setNavActive:function(a){if(this.navigatorItems){this.navigatorItems.removeClass("active");c(this.navigatorItems.get(a)).addClass("active");this.navivationAnimate(this.currentNo)}},__getPositionMode:function(a){if(a=="horizontal")return["left",this.settings.navigatorWidth];return["top",this.settings.navigatorHeight]},__getDirectionMode:function(){switch(this.settings.direction){case "opacity":this.maxSize=
0;return["opacity","opacity"];default:this.maxSize=this.maxWidth;return["left","width"]}},registerWheelHandler:function(a,b){a.bind("mousewheel",function(d,e){e>0?b.previous(true):b.next(true);return false})},registerButtonsControl:function(a,b,d){for(var e in b)switch(e.toString()){case "next":b[e].click(function(){d.next(true)});break;case "previous":b[e].click(function(){d.previous(true)})}return this},onProcessing:function(){this.previousNo=this.currentNo+(this.currentNo>0?-1:this.slides.length-
1);this.nextNo=this.currentNo+(this.currentNo<this.slides.length-1?1:1-this.slides.length);return this},finishFx:function(a){a&&this.stop();a&&this.settings.auto&&this.play(this.settings.interval,"next",true);this.setNavActive(this.currentNo)},getObjectDirection:function(a){return eval("({'"+this.directionMode[0]+"':-"+this.currentNo*a+"})")},fxStart:function(a,b,d){if(this.settings.direction=="opacity"){c(this.slides).stop().animate({opacity:0},{duration:this.settings.duration,easing:this.settings.easing}).removeClass("active-slide");
c(this.slides).eq(a).stop().animate({opacity:1},this.settings.duration,this.settings.easing,function(){c(d.caption.slideUp().eq(a)).slideDown()}).addClass("active-slide")}else this.wrapper.stop().animate(b,{duration:this.settings.duration,easing:this.settings.easing});return this},jumping:function(a,b){this.stop();if(this.currentNo!=a){var d=eval("({'"+this.directionMode[0]+"':-"+this.maxSize*a+"})");this.onProcessing(null,b,0,this.maxSize).fxStart(a,d,this).finishFx(b);this.currentNo=a}},next:function(a,
b){this.currentNo+=this.currentNo<this.slides.length-1?1:1-this.slides.length;this.onProcessing(b,a,0,this.maxSize).fxStart(this.currentNo,this.getObjectDirection(this.maxSize),this).finishFx(a)},previous:function(a,b){this.currentNo+=this.currentNo>0?-1:this.slides.length-1;this.onProcessing(b,a).fxStart(this.currentNo,this.getObjectDirection(this.maxSize),this).finishFx(a)},play:function(a,b,d){this.stop();d||this[b](false);var e=this;this.isRun=setTimeout(function(){e[b](true)},a)},stop:function(){if(this.isRun!=
null){clearTimeout(this.isRun);this.isRun=null}}})})(jQuery);


