Implemented a JQuery Slider on my own - Not very impressed
<p>I'm new to both Javascript and JQuery though I have prior experience in J2ee/C/C++. I created a JQuery slider on my own. Here is the entire source code -</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Experimentation&lt;/title&gt;
    &lt;style type="text/css"&gt;

#container {
overflow:hidden;
position: relative;
height: 200px;
width: 800px;
background-color: white;
float: left;
}   

#slider {
width: 876px;
height: 200px;
background-color:black;
margin: 0 auto;
}

.box1, .box2, .box3, .box4, .box5, .box6, .box7, .box8 {
  width: 200px;
  height: 200px;
  background-color: gray;
  z-index: 10000;
  position: relative;
  float: left;
  overflow:hidden;
  }


.information1, .information2, .information3, .information4, .information5, .information6, .information7, .information8 {
  position: absolute;
  width: 200px;
  height:200px;
  background-color: black;
  opacity: 0.2;
  filter:alpha(opacity=40);
  top: 170px;
  color: #FFF;
}

.information1 h3, .information2 h3,.information3 h3, .information4 h3, .information5 h3, .information6 h3, .information7 h3, .information8 h3   {
 margin: 3px 3px; 
 text-align: center;
}

.leftbutton img {
cursor:pointer;
float:left;
}

.rightbutton img {
cursor:pointer;
float: right;
}

    &lt;/style&gt;
    &lt;script type="text/javascript" src="jquery-1.4.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      var topInitial = "0";
      var topAfter = "170px";
      var sliderPos=1;
      var timeDuration= 1;

      $(function() {

      $(".box1").mouseenter(function() {    
      $(".information1").animate({
      top: topInitial }, "normal"); });

      $(".box1").mouseleave(function() {
      $(".information1").animate({
      top: topAfter }, "normal"); });


      $(".box2").mouseenter(function() {    
      $(".information2").animate({
      top: topInitial }, "normal"); });

      $(".box2").mouseleave(function() {
      $(".information2").animate({
      top: topAfter }, "normal"); });

       $(".box3").mouseenter(function() {   
      $(".information3").animate({
      top: topInitial }, "normal"); });

      $(".box3").mouseleave(function() {
      $(".information3").animate({
      top: topAfter }, "normal"); });

       $(".box4").mouseenter(function() {   
      $(".information4").animate({
      top: topInitial }, "normal"); });

      $(".box4").mouseleave(function() {
      $(".information4").animate({
      top: topAfter }, "normal"); });

      $(".box5").mouseenter(function() {    
      $(".information5").animate({
      top: topInitial }, "normal"); });

      $(".box5").mouseleave(function() {
      $(".information5").animate({
      top: topAfter }, "normal"); });

      $(".box6").mouseenter(function() {    
      $(".information6").animate({
      top: topInitial }, "normal"); });

      $(".box6").mouseleave(function() {
      $(".information6").animate({
      top: topAfter }, "normal"); });

      $(".box7").mouseenter(function() {    
      $(".information7").animate({
      top: topInitial }, "normal"); });

      $(".box7").mouseleave(function() {
      $(".information7").animate({
      top: topAfter }, "normal"); });

      $(".box8").mouseenter(function() {    
      $(".information8").animate({
      top: topInitial }, "normal"); });

      $(".box8").mouseleave(function() {
      $(".information8").animate({
      top: topAfter }, "normal"); });



      $(".leftbutton img").click(function() {   

      if(sliderPos == 1)
      {
      $(".box1").animate({
      marginLeft: "-200px" },timeDuration);
      }
      else if(sliderPos == 2)
      {
       $(".box2").animate({
      marginLeft: "-200px" }, timeDuration);
      }
      else if(sliderPos == 3)
      {
       $(".box3").animate({
      marginLeft: "-200px" }, timeDuration);
      }
      else if(sliderPos == 4)
      {
       $(".box4").animate({
      marginLeft: "-200px" }, timeDuration);
      }
      else
      {
      return;
      }
      sliderPos++;
      });


      $(".rightbutton img").click(function() {

      if(sliderPos == 2)
      {
      $(".box1").animate({
      marginLeft: "+=200px" }, timeDuration); 
      }
      else if(sliderPos == 3)
      {
      $(".box2").animate({
      marginLeft: "+=200px" }, timeDuration);
      }
      else if(sliderPos == 4)
      {
      $(".box3").animate({
      marginLeft: "+=200px" }, timeDuration);
      }
      else if (sliderPos == 5)
      {
      $(".box4").animate({
      marginLeft: "+=200px" }, timeDuration);
      }
      else
      {
      return;
      }
      sliderPos--;

      });

     });
    &lt;/script&gt;
  &lt;/head&gt;

  &lt;body&gt;
  &lt;div id="slider"&gt;
  &lt;span class="leftbutton"&gt;&lt;img src="left.gif"/&gt;&lt;/span&gt;

  &lt;span id="container"&gt;
  &lt;span class="box1"&gt;
  &lt;div class="information1"&gt;
  &lt;h3&gt; A for Apple&lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;
  &lt;/span&gt;

  &lt;span class="box2"&gt;
  &lt;div class="information2"&gt;
  &lt;h3&gt; B for Ball &lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;

  &lt;span class="box3"&gt;
  &lt;div class="information3"&gt;
  &lt;h3&gt; C for Cat &lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;

  &lt;span class="box4"&gt;
  &lt;div class="information4"&gt;
  &lt;h3&gt; D for Dog&lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;


  &lt;span class="box5"&gt;
  &lt;div class="information5"&gt;
  &lt;h3&gt; E for Elephant &lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;

   &lt;span class="box6"&gt;
  &lt;div class="information6"&gt;
  &lt;h3&gt; F for Frog &lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;

  &lt;span class="box7"&gt;
  &lt;div class="information7"&gt;
  &lt;h3&gt; G for Grasshopper &lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;

  &lt;span class="box8"&gt;
  &lt;div class="information8"&gt;
  &lt;h3&gt; H for Horny ;) &lt;/h3&gt;
  &lt;p&gt; You have never seen something like this before!&lt;/p&gt;
  &lt;/div&gt;  
  &lt;/span&gt;
  &lt;/span&gt;

  &lt;span class="rightbutton"&gt;&lt;img src="right.gif"/&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Right now my focus is on the functionality. I'll take care of the design aspects later.So my questions are-</p>

<ol>
<li><p>Is this the right way to implement a slider? I've just used common sense and some knowledge of JQuery/CSS to create this. Could I have done it in a better way? If yes, how?</p></li>
<li><p>When I change the value of 'timeDuration' in my code to 'slow', the sliding is not smooth, as in, there is white patch that appears when the element moves to the left or right. How does one rectify this issue?</p></li>
<li><p>When I first reload the page and click on the left arrow 4 times, where do the elements get moved? How do they relocate on the page? This concept is unclear to me.</p></li>
</ol>

<p>HELP!</p>

<p>Edit: None find this slider good enough? I need help! :(</p>
