/**
 * When I noticed the growing popularity of JS-Slide and JS-Fade effects I have
 * decide to develop a plugin for jQuery. This plugin will help you to add thise
 * effects to the site in more simple way.
 * Note: If the mousewheel plugin has been included on the page then the slider will
 * also respond to the mouse wheel.
 *
 * @name jQuery ulSlide plugin
 * @license GPL
 * @version 1.4.8
 * @date January 31, 2011
 * @category jQuery plugin
 * @author Kotelnitskiy Evgeniy (evgennniy@gmail.com)
 * @copyright (c) 2011 Kotelnitskiy Evgeniy (http://4coder.info/en/)
 * @example Visit http://4coder.info/en/code/jquery-plugins/ulslide/ for more informations about this jQuery plugin
 */
(function(a){ulslide_last_id=0;a.fn.ulslide=function(h){var f=this;if(f.length==0){return false
}var i=f[0];if(!a(i).attr("id")){ulslide_last_id++;a(i).attr("id","ulslide-"+ulslide_last_id)
}var d=a(i).attr("id");h=a.extend({effect:{type:"slide",axis:"x",distance:20},duration:600,direction:"f",autoslide:false,current:0,width:f.width(),height:"auto",statusbar:true,lazyload:false,ajax:false,mousewheel:false,pager:false,nextButton:false,prevButton:false,printCurrentTo:false,onAnimateStart:function(l,m){},onAnimate:function(l,m){},onAjaxStart:function(l,m){},onAjaxStop:function(l,m){}},h);
if(typeof h.affect!="undefined"){h.effect["type"]=h.affect}if(typeof h.axis!="undefined"){h.effect["axis"]=h.axis
}if(typeof h.padding!="undefined"){h.effect["distance"]=h.padding}if(typeof h.navigator!="undefined"){h.pager=h.navigator
}if(typeof h.print_current!="undefined"){h.printCurrentTo=h.print_current}if(typeof h.bnext!="undefined"){h.nextButton=h.bnext
}if(typeof h.bprev!="undefined"){h.prevButton=h.bprev}if(typeof h.effect["distance"]=="undefined"){h.effect["distance"]=20
}h.fwidth=h.width+h.effect["distance"];h.prev=h.current;h.count=a("> *",f).length;
if(h.lazyload){a("img",f).each(function(m){var l=a(this);l.attr("rel",l.attr("src"));
if(m>0){l.removeAttr("src")}})}function e(o,p){if(o>=h.effect["showCount"]-p){var m=h.count-h.effect["showCount"];
var n=(o+p-h.effect["showCount"])-m;return n}else{return o+p}}a("> *",f).each(function(m){var n=a(this);
n.addClass("slide-node slide-node-"+m);n.css("position","absolute");n.css("margin","0");
n.css("distance","0");n.css("width",h.width);n.css("overflow","hidden");if(h.effect["type"]=="carousel"){var l=e(m,h.current);
n.css("top","0");n.css("left",(l*h.fwidth))}else{if(m==h.current){n.css("top","0");
n.css("left","0")}else{n.css("top","0");n.css("left",-(h.width+h.effect["distance"]))
}}});f.css("list-style","none");f.css("distance","0");f.css("position","relative");
f.css("overflow","hidden");f.css("padding",0);if(h.effect["type"]=="carousel"){f.css("width",h.fwidth*h.effect["showCount"]-h.effect["distance"])
}else{f.css("width",h.width)}if(h.height=="auto"){f.css("height",a("> *:eq("+h.current+")",f).height())
}else{f.css("height",h.height)}h.prevHeight=h.height;i.getSlide=function b(l){return a("> *:eq("+l+")",i)
};function j(){var l=i.uslCurrent();h.direction="f";if(l+1<h.count){i.uslRefresh(l+1)
}else{i.uslRefresh(0)}}function g(){var l=i.uslCurrent();h.direction="b";if(l>0){i.uslRefresh(l-1)
}else{i.uslRefresh(h.count-1)}}if(h.height=="auto"){i.currentHeight=i.getSlide(h.current).height()
}else{i.currentHeight=h.height}i.uslCurrent=function(m){if(m==undefined){return h.current
}else{var l=i.uslCurrent();var n=m;h.current=m;return m}};i.autoslideNext=function(){if(h.direction=="f"){j()
}else{g()}};i.initAutoslide=function(){if(h.TimeoutID){clearTimeout(h.TimeoutID)}h.TimeoutID=setTimeout("jQuery('#"+a(i).attr("id")+"')[0].autoslideNext()",h.autoslide)
};i.clearAutoslide=function(){if(h.TimeoutID){clearTimeout(h.TimeoutID)}};i.uslRefresh=function(q,m,s){if(!i.ready){setTimeout("$('#"+a(i).attr("id")+"')[0].uslRefresh()",400);
return}i.ready=false;if(typeof(q)!="undefined"){i.uslCurrent(q)}i.clearAutoslide();
var p=i.getSlide(h.prev);var r=i.getSlide(h.current);r.css("display","block");function o(){h.onAnimateStart(h,i);
if(h.height=="auto"){i.currentHeight=i.getSlide(h.current).height();h.prevHeight=i.getSlide(h.prev).height()
}function u(){if(h.printCurrentTo){a(h.printCurrentTo).html(h.current+1)}if((h.prev!=h.current)&&(h.effect["type"]!="carousel")){p.css("display","none")
}f.animate({height:i.currentHeight},250);if(h.autoslide){i.initAutoslide()}h.onAnimate(h,i);
h.prev=h.current;i.uslRefreshClasses();i.ready=true;if(typeof s!="undefined"){s()
}}if(h.prev==h.current){u();return}if(h.effect["type"]=="slide"){if(h.effect["axis"]=="x"){if(h.prev!=h.current){if(h.direction=="f"){p.animate({left:-(h.width+h.effect["distance"])},h.duration);
r.css("left",h.width+h.effect["distance"])}else{p.animate({left:h.width+h.effect["distance"]},h.duration);
r.css("left",-(h.width+h.effect["distance"]))}}r.animate({left:0},h.duration,function(){u()
})}else{if(h.prev!=h.current){if(h.direction=="f"){p.animate({top:i.currentHeight+h.effect["distance"]},h.duration,function(){p.css("left",-(h.width+h.effect["distance"]))
});r.css("top",-(h.prevHeight+h.effect["distance"]))}else{p.animate({top:-(i.currentHeight+h.effect["distance"])},h.duration,function(){p.css("left",-(h.width+h.effect["distance"]))
});r.css("top",h.prevHeight+h.effect["distance"])}}r.css("left",0);r.animate({top:0},h.duration,function(){u()
})}}else{if(h.effect["type"]=="fade"){r.css("display","none");r.css("left",0);r.css("top",0);
var t=h.duration;if(typeof m!="undefined"){t=0}p.fadeOut(t,function(){p.css("display","none");
r.fadeIn(t,function(){u()})})}else{if(h.effect["type"]=="carousel"){a("> *",f).each(function(w){liel=a(this);
var v=e(w,h.current);if(h.direction=="f"){var x=e(w,h.current-1)}else{var x=e(w,h.current+1)
}if((h.direction=="f")&&(v==0)){liel.css("left",(-1*h.fwidth));liel.animate({left:v*h.fwidth},h.duration)
}else{if((h.direction=="f")&&(x+1==h.effect["showCount"])){liel.animate({left:(h.effect["showCount"])*h.fwidth},h.duration)
}else{if((h.direction=="b")&&(x==0)){liel.animate({left:-1*h.fwidth},h.duration)}else{if((h.direction=="b")&&(v+1==h.effect["showCount"])){liel.css("left",(v+1)*h.fwidth);
liel.animate({left:v*h.fwidth},h.duration)}else{if((v<h.effect["showCount"])&&(v>=0)){liel.animate({left:v*h.fwidth},h.duration)
}else{liel.css("left",(v*h.fwidth))}}}}}setTimeout(function(){u()},h.duration+100)
})}}}}if(h.ajax){h.onAjaxStart(h,i);var l=i.getSlide(h.current)[0].usl_ajax_loaded;
i.uslAjaxLoadSlide(h.current,function(){h.onAjaxStop(h,i);o()})}else{if(h.lazyload){var n=a("img",r[0]);
n.each(function(u){var t=a(this);t.attr("src",t.attr("rel"))});h.z_img_count=n.length;
h.z_img_loaded=0;n.each(function(){if(this.complete){h.z_img_loaded++}else{a(this).load(function(){h.z_img_loaded++;
if(h.z_img_loaded==h.z_img_count){o()}})}});if(h.z_img_loaded==h.z_img_count){o()
}return}o()}};i.uslAjaxLoadSlide=function(m,o){var n=i.getSlide(m);if(n[0].usl_ajax_loaded){o()
}else{var l=a(h.pager).eq(m).attr("href");n[0].usl_ajax_loaded=true;n.load(l+"?ajax=1",false,o)
}};i.uslRefreshClasses=function(){if(h.count>1){if(h.nextButton){a(h.nextButton).addClass("active")
}if(h.prevButton){a(h.prevButton).addClass("active")}}if(h.pager){a(h.pager).removeClass("usl-current");
a(h.pager+".usl-pager-"+i.uslCurrent()).addClass("usl-current");a(h.pager).parent().removeClass("usl-current-parent");
a(h.pager+".usl-pager-"+i.uslCurrent()).parent().addClass("usl-current-parent")}};
if(h.nextButton){a(h.nextButton).click(function(){j();return false})}if(h.prevButton){a(h.prevButton).click(function(){g();
return false})}function c(m){var l=a(m);l.each(function(n){this.usl_navigator_index=n;
a(this).addClass("usl-pager-"+n)});l.click(function(){var n=this.usl_navigator_index;
if((n<h.count)&&(n!=i.uslCurrent())){if(n>i.uslCurrent()){h.direction="f"}else{h.direction="b"
}i.uslRefresh(n)}return false})}if(h.pager){c(h.pager)}if(h.navigator2){c(h.navigator2)
}function k(l){if(l){f.addClass("usl-loading")}else{f.removeClass("usl-loading")}}i.uslStatusbar=function(){if(h.lazyload){var l=a(">li:eq("+h.current+") img",i)
}else{var l=a("img",i)}h.img_count=l.length;if(h.img_count){k(true)}h.img_loaded=0;
l.each(function(){if(this.complete){h.img_loaded++}else{a(this).load(function(){h.img_loaded++;
if(h.img_loaded==h.img_count){k(false);i.ready=true;i.uslRefresh()}})}});if(h.img_loaded==h.img_count){k(false);
i.ready=true;i.uslRefresh()}};if(h.statusbar&&!h.ajax){i.uslStatusbar()}if(h.mousewheel){f.bind("mousewheel",function(l,m){if(i.ready){if(m<0){j()
}else{g()}}return false})}if(!h.statusbar||h.ajax){i.ready=true;i.uslRefresh()}}})(jQuery);
