Ultrasonic Control of Continuous rotation servo

hello gugs,
Im new to this arduino platform. I need help constructing a code for making a continuous rotation servo spin in one direction when an object is within 10cm of an ultrasonic sensor and in opposite direction when object is moved away. At the moment the servo only changes direction once and doesn't happen again after that. Please help!This is the code i have so far:

#define trigPin 12
#define echoPin 13
#define servoPin 9
#define DEFAULT_SERVO_POS 0
#define TRIGGERED_SERVO_POS 90
#include <Servo.h>

Servo myservo;

void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
myservo.write(DEFAULT_SERVO_POS);
myservo.attach(servoPin);
}

void loop()
{
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
long distance = (duration / 2) / 29.1;
Serial.print(distance);
Serial.println(" cm");
if (distance <= 5) {
myservo.write (TRIGGERED_SERVO_POS);
}
delay(500);
}
else if (distance > 5) {
myservo.write (DEFAULT_SERVO_POS);
}

That version doesn't compile - the else clause isn't in the loop function. Do you have a version that does? Can you post it with code tags?

I am very new to this and still getting to grips with the code language. I will read up some more to see if I can provide you with any more information.

#define trigPin 12
#define echoPin 13
#define servoPin 9
#define DEFAULT_SERVO_POS 0
#define TRIGGERED_SERVO_POS 180
#include <Servo.h>

Servo myservo;

void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
myservo.write(DEFAULT_SERVO_POS);
myservo.attach(servoPin);
}

void loop()
{
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
long distance = (duration/2) / 29.1;
Serial.print(distance);
Serial.println(" cm");
if (distance<=5){
myservo.write(TRIGGERED_SERVO_POS);//turn servo in one direction
}
else{
if distance>5{
myservo.write(DEFAULT_SERVO_POS);// turn servo in opposite direction
delay(500);
}

The distance in the code should be 10 and not 5. I made an error in writing up the code.