/*****************************
**Company: Indivirtual
**Date: 06-07-2011
**Version: 1.0.2
**M.V.
******************************/
(function(b){function u(e){for(var d="",c=0;c<e.length;c++)d+="<a class='' href='#"+c+"'></a>";b(a.navWrapper).html(d);return naviElems=b(a.navWrapper+" a")}function v(e){try{var d='<li class="firstitem cloned">'+b(e[0]).html()+"</li>",c='<li class="cloned">'+b(e[e.length-1]).html()+"</li>";b(a.imagesUl).html(function(a,b){return c+b+d});return!0}catch(f){return b.error("error during cloning: "+f),!1}}function s(e,d,c,f,h){c>d?(e=(c-d)*a.imageWidth,b(a.imagesUl).animate({left:"-="+e+"px",queue:!0},
a.multipleSpeed,function(){c<f.length&&a.infoboxOn&&b(f[h]).animate({height:"show",opacity:1,queue:!0},a.multipleSpeed/2,function(){b(this).removeAttr("style")})})):c<d&&(e=(d-c)*a.imageWidth,b(a.imagesUl).animate({left:"+="+e+"px"},a.multipleSpeed,function(){c<f.length&&a.infoboxOn&&b(f[h]).animate({height:"show",opacity:1,queue:!0},a.multipleSpeed/2,function(){b(this).removeAttr("style")})}))}function t(e,d,c,f){if(parseInt(c)==0&&parseInt(d)==e.length-1)b(a.imagesUl).animate({left:"-="+a.imageWidth+
"px"},a.multipleSpeed,function(){b(a.imagesUl).attr("style","left:-"+a.imageWidth+"px");parseInt(c)<f.length&&a.infoboxOn?b(f[1]).animate({height:"show",opacity:1,queue:!0},a.multipleSpeed/2,function(){b(this).removeAttr("style");b(a.browseLeft).click(function(){g("normal")});b(a.browseRight).click(function(){i("normal")})}):a.infoboxOn||(b(a.browseLeft).click(function(){g("normal")}),b(a.browseRight).click(function(){i("normal")}))}),j=0,k=e.length-1,h=1;else if(parseInt(c)==parseInt(d)-1||parseInt(c)==
parseInt(d)+1)parseInt(c)<parseInt(d)?b(a.imagesUl).animate({left:"+="+a.imageWidth+"px"},a.singleSpeed,function(){parseInt(c)<f.length&&a.infoboxOn?b(f[parseInt(c)+1]).animate({height:"show",opacity:1,queue:!0},a.singleSpeed/2,function(){b(this).removeAttr("style");b(a.browseLeft).click(function(){g("normal")});b(a.browseRight).click(function(){i("normal")})}):a.infoboxOn||(b(a.browseLeft).click(function(){g("normal")}),b(a.browseRight).click(function(){i("normal")}))}):b(a.imagesUl).animate({left:"-="+
a.imageWidth+"px"},a.singleSpeed,function(){parseInt(c)<f.length&&a.infoboxOn?b(f[parseInt(c)+1]).animate({height:"show",opacity:1,queue:!0},a.singleSpeed/2,function(){b(this).removeAttr("style");b(a.browseLeft).click(function(){g("normal")});b(a.browseRight).click(function(){i("normal")})}):a.infoboxOn||(b(a.browseLeft).click(function(){g("normal")}),b(a.browseRight).click(function(){i("normal")}))});else if(parseInt(c)<parseInt(d))e=parseInt(d)-parseInt(c),e*=a.imageWidth,b(a.imagesUl).animate({left:"+="+
e+"px"},a.multipleSpeed,function(){parseInt(c)<f.length&&a.infoboxOn?b(f[parseInt(c)+1]).animate({height:"show",opacity:1,queue:!0},a.multipleSpeed/2,function(){b(this).removeAttr("style");b(a.browseLeft).click(function(){g("normal")});b(a.browseRight).click(function(){i("normal")})}):a.infoboxOn||(b(a.browseLeft).click(function(){g("normal")}),b(a.browseRight).click(function(){i("normal")}))});else if(d==0&&c==e.length-1){var e=parseInt(c)-parseInt(d),p=(e+1)*a.imageWidth;b(a.imagesUl).animate({left:"+="+
a.imageWidth+"px"},a.multipleSpeed,function(){b(a.imagesUl).attr("style","left:-"+p+"px");parseInt(c)<f.length&&a.infoboxOn?b(f[f.length-2]).animate({height:"show",opacity:1,queue:!0},a.multipleSpeed/2,function(){b(this).removeAttr("style");b(a.browseLeft).click(function(){g("normal")});b(a.browseRight).click(function(){i("normal")})}):a.infoboxOn||(b(a.browseLeft).click(function(){g("normal")}),b(a.browseRight).click(function(){i("normal")}))})}else e=parseInt(c)-parseInt(d),p=e*a.imageWidth,b(a.imagesUl).animate({left:"-="+
p+"px"},a.multipleSpeed,function(){parseInt(c)<parseInt(f.length)&&a.infoboxOn?b(f[parseInt(c)+1]).animate({height:"show",opacity:1,queue:!0},a.multipleSpeed/2,function(){b(this).removeAttr("style");b(a.browseLeft).click(function(){g("normal")});b(a.browseRight).click(function(){i("normal")})}):a.infoboxOn||(b(a.browseLeft).click(function(){g("normal")}),b(a.browseRight).click(function(){i("normal")}))})}function q(e,d,c,f){b(a.browseRight).unbind("click");b(a.browseLeft).unbind("click");parseInt(d)<
f.length&&a.infoboxOn?b(f[parseInt(d)+1]).animate({height:"hide",opacity:0,queue:!0},a.multipleSpeed/2,t(e,d,c,f,!1)):a.infoboxOn||t(e,d,c,f,!1);j=parseInt(c);k=parseInt(c)-1;for(h=0;h<=j;)h++;b(l[parseInt(d)]).removeClass("active");b(l[parseInt(c)]).addClass("active")}function g(){k<0&&(k=m.length-1);q(m,j,k,n)}function r(e,d,c,f){b(document).everyTime(d,a.timerName,function(){h>e.length-1&&(h=0);q(e,j,h,c)},f)}function i(){h>m.length-1&&(h=0);q(m,j,h,n)}var j=0,m=null,n=null,h=1,k=0,l=null,a=null,
o={init:function(a){return this.each(function(){if(!b(this).data("carrousel"))var d={secondsInterval:"10s",timerName:"scrollable",singleSpeed:1E3,multipleSpeed:1E3,navWrapper:"#navi",browseLeft:".browseLeft",browseRight:".browseRight",imageGallery:".imageGallery",imagesUl:"#scrollBanner",infoboxOn:!0,infoboxWrapper:".innerPushbox",stopOnMouse:!0,imageWidth:970};a&&b.extend(d,a);b(this).data("carrousel",d)})},start:function(){(a=b(this).data("carrousel"))||o.init.apply(this,arguments);return this.each(function(){if(a=
b(this).data("carrousel"))if(b(a.imagesUl).length<=0)b.error("plugin couldn't find the carrousel");else{var e=!1,d=!1;navigator.userAgent.indexOf("MSIE 6.0")!=-1&&(e=!0);navigator.userAgent.indexOf("MSIE 7.0")!=-1&&(d=!0);b(this).removeClass("noNavigation");var c=b(a.imagesUl).find("li");l=u(c);v(c);var f=[0,0];n=f;a.infoboxOn&&(n=f=b(a.infoboxWrapper),b(a.infoboxWrapper).animate({height:"hide",opacity:0,queue:!0},100,function(){}));m=c;b(a.imagesUl).attr("style","left: -"+a.imageWidth+"px");a.infoboxOn&&
b(f[1]).delay(500).animate({height:"show",opacity:1,queue:!0},a.singleSpeed/2,function(){});k=c.length-1;c.length>1?(b(a.browseLeft).click(function(){g();return!1}),b(a.browseRight).click(function(){i();return!1}),a.stopOnMouse&&(b(a.imageGallery).mouseenter(function(){b(document).stopTime(a.timerName)}),b(a.imageGallery).mouseleave(function(){b(document).stopTime(a.timerName);r(c,a.secondsInterval,f,0)})),window.onblur=function(){b(document).stopTime(a.timerName)},window.onfocus=function(){b(document).stopTime(a.timerName);
r(c,a.secondsInterval,f,0)},document.onblur=window.onblur,document.focus=window.focus,b(l[0]).addClass("active"),!e&&!d?b(l).click(function(){var e=b(this),d=f,g=b(e).attr("href"),g=g.replace("#",""),e=j,i=parseInt(g)+1;e<d.length&&a.infoboxOn?b(d[e+1]).animate({height:"hide",opacity:0,queue:!0},a.multipleSpeed/2,s(c,e,g,d,i)):a.infoboxOn||s(c,e,g,d,i);if(g==c.length-1)j=parseInt(g),k=parseInt(g)-1,h=0;else if(g==0)j=parseInt(g),k=c.length-1,h=1;else{j=parseInt(g);k=parseInt(g)-1;for(h=0;h<=j;)h++}b(l[e]).removeClass("active");
b(l[g]).addClass("active");return!1}):(b(l).css("cursor","default"),b(l).click(function(){return!1})),r(c,a.secondsInterval,f,0)):(b(a.browseLeft).hide(),b(a.browseRight).hide())}else b.error("plugin not yet initialized")})},stop:function(){return this.each(function(){(a=b(this).data("carrousel"))||b.error("the plugin hasn't even started yet, how do you expect to stop it?");b(document).stopTime(a.timerName)})},destroy:function(){return this.each(function(){var a=b(this),d=a.data("carrousel");b(window).unbind(".carrousel");
d.carrousel.remove();a.removeData("carrousel")})}};b.fn.carrousel=function(a){if(o[a])return o[a].apply(this,Array.prototype.slice.call(arguments,1));else if(typeof a==="object"||!a)return o.init.apply(this,arguments);else b.error("Method "+a+" does not exist on jQuery.carrousel")}})(jQuery);
