Alternating gradient focusing and deceleration of polar molecules