time lapse dolly code problems

sorry i wasn't very clear about it all
so what the code does now is run the motor fine in fwd direction but wen it reaches the limit switch at that end( which is a normally open switch) it goes into reverse for 1 second which then releases the limit switch but then it goes straight back into forward and hits the limit switch again. also depending on when it hits the limit switch eg after motor power is turned off the whole sketch seems to stop until i release the switch manually. does this make sense.
what i want the code to do is start the motor running in one direction with small pauses to slow it down then when it reaches the limit switch at one end it reverses the direction of the motor and travels all the way down the other end (with small pauses) until the other limit is hit then change direction again. kinda like bouncing from end to end.
i have the limit switches wired from the 5v supply to digital pins 2 and 5 and i have 2 10k ohm resistors between pins 2, 5 and ground.
i am not sure what a pull up resistor is so if u could explain i would be happy to use them.
are they in the limit switch or in the arduino????
thanks very much for the replies