Remember moving charges both produce their own magnetic field as well as experience a force by another field that's in the area. What you are referring to at first is the production of a field by a current. If it looks like the field is coming out of the page in one part and in in the other part it's because it is. The magnetic field produced is actually a radial field (it's ring-shaped) around the wire so if you have a wire with current going right on your paper curl your fingers around with your right hand and you will see that above the wire the field is coming out and below the wire the field goes in. If you turn the wire and make it so that the current is coming head on right at you, the field produced is a ring and the direction is counter-clockwise. Otherwise the stuff mentioned by the other guys here is right on the money....look at your text for pictures and examples applying it.