var boxWidth=480,brake=100,t;
$(document).ready(function(){var b=$(".galleryWrapper"),c=$(".galleryWrapper5"),d=$(".galleryWrapper4"),f=$(".galleryWrapper3"),g=$(".galleryWrapper2"),e=$(".galleryWrapper1"),x=$(".button_left"),j=$(".button_right"),y=$(".button_left1"),h=$(".button_right1"),z=$(".button_left2"),k=$(".button_right2"),A=$(".button_left3"),l=$(".button_right3"),B=$(".button_left4"),C=$(".button_right4"),D=$(".button_left5"),E=$(".button_right5"),F=b.width(),m=d.width(),n=d.width(),o=f.width(),p=g.width(),i=e.width(),
G=$(".galleryItems").children().length,q=$(".galleryItems").children(":first-child").outerWidth()*G-F+20;G=$(".galleryItems1").children().length;var r=$(".galleryItems1").children(":first-child").outerWidth()*G-i+20,s=$(".galleryItems2").children(":first-child").outerWidth()*6-p+20,u=$(".galleryItems3").children(":first-child").outerWidth()*4-o+20,v=$(".galleryItems4").children(":first-child").outerWidth()*6-n+20,w=$(".galleryItems5").children(":first-child").outerWidth()*4-m+20;y.mouseover(function(a){if(e.scrollLeft()>=
0&&e.scrollLeft()<=r)moveIt(a,i,e,y,"");else if(r<=e.scrollLeft()){e.scrollLeft(e.scrollLeft()-r);moveIt(a,i,e,"",h)}});h.mouseover(function(a){e.scrollLeft()>=0&&e.scrollLeft()<=r&&moveIt(a,i,e,"",h)});y.mouseout(function(){clearInterval(t)});h.mouseout(function(){clearInterval(t)});z.mouseover(function(a){if(g.scrollLeft()>=0&&g.scrollLeft()<=s)moveIt(a,p,g,z,"");else if(s<=g.scrollLeft()){g.scrollLeft(g.scrollLeft()-s);moveIt(a,p,g,"",k)}});k.mouseover(function(a){g.scrollLeft()>=0&&g.scrollLeft()<=
s&&moveIt(a,p,g,"",k)});z.mouseout(function(){clearInterval(t)});k.mouseout(function(){clearInterval(t)});A.mouseover(function(a){if(f.scrollLeft()>=0&&f.scrollLeft()<=u)moveIt(a,o,f,A,"");else if(u<=f.scrollLeft()){f.scrollLeft(f.scrollLeft()-u);moveIt(a,o,f,"",l)}});l.mouseover(function(a){f.scrollLeft()>=0&&f.scrollLeft()<=u&&moveIt(a,o,f,"",l)});A.mouseout(function(){clearInterval(t)});l.mouseout(function(){clearInterval(t)});B.mouseover(function(a){if(d.scrollLeft()>=0&&d.scrollLeft()<=v)moveIt(a,
n,d,B,"");else if(v<=d.scrollLeft()){d.scrollLeft(d.scrollLeft()-v);moveIt(a,n,d,"",h)}});C.mouseover(function(a){d.scrollLeft()>=0&&d.scrollLeft()<=v&&moveIt(a,n,d,"",C)});B.mouseout(function(){clearInterval(t)});C.mouseout(function(){clearInterval(t)});D.mouseover(function(a){if(c.scrollLeft()>=0&&c.scrollLeft()<=w)moveIt(a,m,c,D,"");else if(w<=c.scrollLeft()){c.scrollLeft(c.scrollLeft()-w);moveIt(a,m,c,"",h)}});E.mouseover(function(a){c.scrollLeft()>=0&&c.scrollLeft()<=w&&moveIt(a,m,c,"",E)});
D.mouseout(function(){clearInterval(t)});E.mouseout(function(){clearInterval(t)});x.mouseover(function(a){if(b.scrollLeft()>=0&&b.scrollLeft()<=q)moveIt(a,F,b,x,"");else if(q<=b.scrollLeft()){b.scrollLeft(b.scrollLeft()-q);moveIt(a,i,b,"",j)}});j.mouseover(function(a){b.scrollLeft()>=0&&b.scrollLeft()<=q&&moveIt(a,F,b,"",j)});x.mouseout(function(){clearInterval(t)});j.mouseout(function(){clearInterval(t)})});
function moveIt(b,c,d,f,g){clearInterval(t);b=b.pageX-d.position().left;if(b>c-boxWidth&&g){var e=(b-(boxWidth+100))/brake^2;t=setInterval(function(){goRight(e,d)},13)}else if(b<boxWidth&&f){e=(c-b-(boxWidth+100))/brake^2;t=setInterval(function(){goLeft(e,d)},13)}}function goLeft(b,c){c.scrollLeft(c.scrollLeft()-b)}function goRight(b,c){c.scrollLeft(c.scrollLeft()+b)};

