/**
 * Copyright (c) 2010 Sylvain Gougouzian (sylvain@gougouzian.fr)
 * MIT (http://www.opensource.org/licenses/mit-license.php) licensed.
 * GNU GPL (http://www.gnu.org/licenses/gpl.html) licensed.
 *
 * jQuery moodular version: 2.3
 *
 * Requires: jQuery 1.3.2+ 	// http://www.jquery.com
 * Compatible : Internet Explorer 6+, Firefox 1.5+, Safari 3+, Opera 9+, Chrome 0.9+
 */
jQuery(function(c){c.fn.moodular=function(a){var b=null,d=c.extend({},c.fn.moodular.defaults,a),h=c.extend({},c.fn.moodular.controls),f=c.extend({},c.fn.moodular.effects);this.each(function(){b=new e(this,d,h,f);c(window).bind("resize",function(){b._resize()})});return d.api?b:null};c.moodular=function(a,b,d,e){this.e=c(a);if(b.random){var f=this.e.children(c("> "+b.item));f.sort(function(){return Math.round(Math.random())-0.5});this.e.remove(c("> "+b.item));for(var g=0;g<f.length;g++)this.e.append(f[g])}b.continuous&& c(a).html(c(a).html()+c(a).html());this.aItems=null;this.current=this.nbItems=0;this.locked=!1;this.dep=0;this.timerMoving=null;this.opts=b;this.controls=d;this.effects=e;this.direction=b.direction=="left"||b.direction=="top"?"next":"prev";this.pos=b.direction=="left"||b.direction=="right"?"left":"top";this.dir=b.direction=="right"||b.direction=="bottom"?-1:1;this.vertical=this.pos=="left"?!1:!0;this._init()};var e=c.moodular;e.fn=e.prototype={moodular:"2.3"};e.fn.extend=e.extend=c.extend;e.fn.extend({_init:function(){var a= this;this._resize();this.e.wrap("<div></div>");this.e.parent().css({position:"relative",overflow:"hidden",width:this.e.width(),height:this.e.height()});this.e.css({position:"absolute"});s=0;c("> "+this.opts.item,this.e).each(function(){s+=this.vertical?parseInt(c(this).outerHeight(!0)):parseInt(c(this).outerWidth(!0))});this.e.css(this.vertical?"height":"width",s+"px");this.aItems=c("> "+this.opts.item,this.e);this.nbItems=this.aItems.length;this.opts.continuous||(this.nbItems*=2);var b=this.opts.controls.split(" "), d;for(d=0;d<b.length;d++)if(c.isFunction(this.controls[b[d]]))this.controls[b[d]](this);b=this.opts.effects.split(" ");for(d=0;d<b.length;d++)if(c.isFunction(this.effects.init[b[d]]))this.effects.init[b[d]](this);if(this.opts.startOn)this.speed=this.opts.speed,this.opts.speed=1,this.moveTo(this.opts.startOn);this.opts.auto&&setTimeout(function(){a._animate("next")},a.opts.dispTimeout)},_animate:function(a){a=a==void 0?this.direction:a;if(!this.locked){this.locked=!0;clearTimeout(this.timerMoving); this.dep=this.dep==0?this.opts.scroll:this.dep;this.dir==-1&&(a=="next"?a="prev":a=="prev"&&(a="next"));a!="next"&&(this.dep*=-1);var b=!0;if(!this.opts.continuous)if(a=="next"){if(this.current>=this.nbItems/2-1)this.locked=b=!1}else if(this.current<=0)this.locked=b=!1;b&&this._beforeMoving()}},_beforeMoving:function(){var a=this.opts.effects.split(" "),b;for(b=0;b<a.length;b++)if(c.isFunction(this.effects.before[a[b]]))this.effects.before[a[b]](this,this.dep<0?-1:1);if(this.dep<0&&this.opts.continuous){for(b= a=0;b<Math.abs(this.dep);b++){var d=c("> "+this.opts.item+":last",this.e);a+=parseInt(d.css(this.vertical?"height":"width"));c("> "+this.opts.item+":last",this.e).remove();this.e.prepend(d)}this.e.css(this.pos,-a)}this._move()},_move:function(){var a=this;if(c.isFunction(this.opts.move))this.opts.move(this,function(){a._afterMoving()});else{var b=0,d;if(this.dep>0)for(d=0;d<this.dep;d++)b+=this.vertical?parseInt(this.aItems.eq(this._realpos(this.current)+d).outerHeight(!0)):parseInt(this.aItems.eq(this._realpos(this.current)+ d).outerWidth(!0));else if(this.opts.continuous||!(this.current<=0))for(d=0;d<Math.abs(this.dep);d++)b+=this.vertical?parseInt(this.aItems.eq(this._realpos(this.current)-d).outerHeight(!0)):parseInt(this.aItems.eq(this._realpos(this.current)-d).outerWidth(!0));this.e.css(this.pos)=="auto"&&this.e.css(this.pos,0);b=parseInt(this.e.css(this.pos))+(this.dep>0?-1:1)*b;this.opts.continuous||(b>0&&(b=0),this.vertical?parseInt(this.e.height())+b<parseInt(this.e.parent().height())&&(b=parseInt(this.e.parent().height())- parseInt(this.e.height())):parseInt(this.e.width())+b<parseInt(this.e.parent().width())&&(b=parseInt(this.e.parent().width())-parseInt(this.e.width())));this.vertical?this.e.stop(!0,!0).animate({top:parseInt(b)+"px"},this.opts.speed,this.opts.easing,function(){a._afterMoving()}):this.e.stop(!0,!0).animate({left:parseInt(b)+"px"},this.opts.speed,this.opts.easing,function(){a._afterMoving()})}},_afterMoving:function(){var a;if(this.dep>0&&this.opts.continuous){for(a=0;a<this.dep;a++){var b=c("> "+this.opts.item+ ":first",this.e);c("> "+this.opts.item+":first",this.e).remove();this.e.append(b)}this.e.css(this.pos,0)}var d=this;this.current+=this.dep;this.current=this.current==-1?this.opts.continuous?this.nbItems-1:0:this.current==this.nbItems?0:this._realpos(this.current);this.dep=0;this.locked=!1;b=this.opts.effects.split(" ");for(a=0;a<b.length;a++)if(c.isFunction(this.effects.after[b[a]]))this.effects.after[b[a]](this);for(a=0;a<this.opts.callbacks.length;a++)this.opts.callbacks[a](this);b=this.opts.controls.split(" "); for(a=0;a<b.length;a++)if(c.isFunction(this.controls.callback[b[a]]))this.controls.callback[b[a]](this);if(this.opts.startOn)this.opts.speed=this.speed;if(this.opts.auto)this.timerMoving=setTimeout(function(){d._animate("next")},this.opts.dispTimeout)},_realpos:function(a){a<0&&(a=this.nbItems/2-a);return a<this.nbItems/2?a:a-this.nbItems/2},_resize:function(){c("> "+this.opts.item,this.e).css(this.vertical?"height":"width");c("> "+this.opts.item,this.e).each(function(){this.vertical?c(this).height(c(this).height()): c(this).width(c(this).width())})},reanimate:function(){if(!this.opts.auto){this.locked=!1;this.opts.auto=!0;var a=this;this.timerMoving=setTimeout(function(){a._animate("next")},this.opts.dispTimeout)}},start:function(){if(!this.opts.auto)this.locked=!1,this.opts.auto=!0,this._animate("next");return!1},stop:function(){clearTimeout(this.timerMoving);return this.opts.auto=!1},next:function(){this._animate("next");return!1},prev:function(){this._animate("prev");return!1},getCurrent:function(){return this._realpos(this.current)}, moveTo:function(a){a>this.nbItems/2&&(a=this.nbItems/2-1);this.dep=parseInt(a)-parseInt(this.current);this.dep!=0&&this._animate("next");return!1}});c.fn.moodular.defaults={item:"li",controls:"",effects:"",easing:"",auto:!0,continuous:!0,speed:2E3,direction:"left",scroll:1,startOn:0,dispTimeout:1E3,callbacks:[],random:!1,api:!1};c.fn.moodular.controls={callback:{}};c.fn.moodular.effects={init:{},before:{},after:{}}});

/**
 * Copyright (c) 2009 Sylvain Gougouzian (sylvain@gougouzian.fr)
 * MIT (http://www.opensource.org/licenses/mit-license.php) licensed.
 * GNU GPL (http://www.gnu.org/licenses/gpl.html) licensed.
 *
 * jQuery moodular effects by Sylvain Gougouzian http://sylvain.gougouzian.fr
 *
 * Requires: jQuery 1.3.2+ 	// http://www.jquery.com
 *			jQuery corner plugin 2.01 // http://jquery.malsup.com/corner/
 *
 * Compatible : Internet Explorer 6+, Firefox 1.5+, Safari 3+, Opera 9+, Chrome 0.9+
 */
jQuery(function(b){b.extend(b.fn.moodular.effects.init,{corner:function(a){b.fn.corner.defaults.useNative=!1;b("> "+a.opts.item,a.e).corner("10px")},reflection:function(a){a.e.parent().height(parseInt(a.e.parent().height())*1.33);b(a.opts.item+" > img",a.e).load(function(){a:{var a=b(this),f=parseInt(a.width()),c=parseInt(a.height()),e;if(b.browser.msie)e=b("<img />").attr("src",a.attr("src")).css({width:f,height:c,"margin-bottom":c-Math.floor(c*0.33),filter:"flipv progid:DXImageTransform.Microsoft.Alpha(opacity=50, style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy=33)"})[0]; else{e=b("<canvas />")[0];if(!e.getContext)break a;var d=e.getContext("2d");try{b(e).attr({width:f,height:Math.floor(c*0.33)});d.save();d.translate(0,c-1);d.scale(1,-1);d.drawImage(this,0,0,f,c);d.restore();d.globalCompositeOperation="destination-out";var g=d.createLinearGradient(0,0,0,Math.floor(c*0.33));g.addColorStop(0,"rgba(255, 255, 255, 0.5)");g.addColorStop(1,"rgba(255, 255, 255, 1.0)");d.fillStyle=g;d.rect(0,0,f,Math.floor(c*0.33));d.fill()}catch(i){break a}}b(e).css("display","block");a.parent().css({width:f, height:c+Math.floor(c*0.33),overflow:"hidden"}).append(b(e))}b(this).parent().height(parseInt(b(this).parent().height())*1.33)})},fade:function(a){b("> "+a.opts.item,a.e).each(function(h){h>a.nbItems/2&&b(this).remove()});a.opts.scroll=1;a.opts.move=function(a,f){a.e.css({top:0,left:0});setTimeout(function(){clearTimeout(a.timerMoving);b(".position_"+a.current,a.e).fadeOut(a.opts.speed);b(".position_"+a._realpos(a.current+a.dep),a.e).fadeIn(a.opts.speed,function(){f()})},a.opts.dispTimeout)};b("> "+ a.opts.item,a.e).each(function(a){b(this).css("position","absolute").addClass("position_"+a)});b("> "+a.opts.item,a.e).not(":first").hide()},zoom:function(a){b("> "+a.opts.item,a.e).each(function(h){h>a.nbItems/2&&b(this).remove()});a.opts.scroll=1;a.opts.move=function(a,f){a.e.css({top:0,left:0});setTimeout(function(){clearTimeout(a.timerMoving);var c=b(".position_"+a.current,a.e);c.show();var e=c.width(),d=b("> img",c).width(),g=c.height(),i=b("> img",c).height();c.hide();c.fadeOut(a.opts.speed).animate({width:2* parseInt(e)+"px",height:2*parseInt(g)+"px",top:0-parseInt(g)/2+"px",left:0-parseInt(e)/2+"px"},a.opts.speed,function(){b(this).css({top:0,left:0,width:e,height:g}).hide()});b("> img",c).animate({width:2*parseInt(d)+"px",height:2*parseInt(i)+"px"},a.opts.speed,function(){b(this).css({width:d,height:i})});b(".position_"+a._realpos(a.current+a.dep),a.e).fadeIn(a.opts.speed,function(){f()})},a.opts.dispTimeout)};b("> "+a.opts.item,a.e).each(function(a){b(this).css("position","absolute").addClass("position_"+ a)});b("> "+a.opts.item,a.e).not(":first").hide()}});b.extend(b.fn.moodular.effects.after,{fade:function(a){a.e.css({top:0,left:0});b("> "+a.opts.item,a.e).css({top:0,left:0})},zoom:function(a){a.e.css({top:0,left:0});b("> "+a.opts.item,a.e).css({top:0,left:0})}});b.extend(b.fn.moodular.effects.before,{fade:function(a){a.e.css({top:0,left:0});b("> "+a.opts.item,a.e).css({top:0,left:0})},zoom:function(a){a.e.css({top:0,left:0});b("> "+a.opts.item,a.e).css({top:0,left:0})}})});

