Libyan parties agree to hold elections within 18 months