Delay help?

int potPin = A0; // Potentiometer output connected to analog pin 3
double potVal = 0;// Variable to store the input from the potentiometer

const int buttonPin = 2;

int greenPin = 3;
int whitePin = 11;   
int bluePin = 10;  
int yellowPin = 9;  
int redPin = 6; 
int flashPin = 5;





// Program variables
int buttonState = 0;
int greenVal = 0;
int whiteVal = 0;  
int blueVal = 0;  
int yellowVal = 0;  
int redVal = 0; 
int flashVal = 0;




int DEBUG = 1;          // Set to 1 to turn on debugging output

void setup()
{
  pinMode (buttonPin, INPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(whitePin, OUTPUT);   // sets the pins as output
  pinMode(bluePin, OUTPUT);   
  pinMode(yellowPin, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(flashPin, OUTPUT);




  if (DEBUG) {           // If we want to see the pin values for debugging...
    Serial.begin(9600);  // ...set up the serial ouput in 0004 format
  }
}

// Main program
void loop(){
  potVal = analogRead(potPin);


  //potVal = analogRead(potPin);
  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH)
  {

    digitalWrite (greenPin, HIGH);




    potVal = analogRead(potPin);   // read the potentiometer value at the input pin

      if (potVal < 341)  // Lowest third of the potentiometer's range (0-340)
    {                  
      potVal = (potVal * 3) / 4; // Normalize to 0-255

      whiteVal = 255;  // Red from full to off
      blueVal = 0;        // blue from off to full
      yellowVal = 0;
      redVal = 0;
      flashVal = 0;


    }
    else if (potVal < 682) // Middle third of potentiometer's range (341-681)
    {
      potVal = ( (potVal-341) * 3) / 4; // Normalize to 0-255

      whiteVal = 255- potVal;            // Red off
      blueVal = potVal; // Green from full to off
      yellowVal = potVal;       // Blue from off to full
      redVal = 0;
      flashVal = 0;


    }
    else if  (potVal < 900)// Upper third of potentiometer"s range (682-1023)
    {
      potVal = ( (potVal-682) * 3) / 4; // Normalize to 0-255

      whiteVal = 0;       // Red from off to full
      blueVal = 255 - potVal;            // Green off
      yellowVal = 255 - potVal; // Blue from full to off
      redVal = potVal;
      flashVal = 0;

    }

    else
    {
      potVal = ( (potVal-900) * 3) / 4; // Normalize to 0-255

      whiteVal = 0;       // Red from off to full
      blueVal = 0;            // Green off
      yellowVal = 0; // Blue from full to off
      redVal = 255l;
      flashVal = potVal;
      analogWrite (flashPin, flashVal);
      delay(100);
      flashVal = 0;
      analogWrite (flashPin, flashVal);
      delay(100);
      flashVal = potVal;
      analogWrite (flashPin, flashVal);
      delay(100);
      flashVal = 0;
      analogWrite (flashPin, flashVal);
      delay(100);

    }
    analogWrite (whitePin, whiteVal);            // Green off
    analogWrite (bluePin, blueVal);
    analogWrite (yellowPin, yellowVal);
    analogWrite (redPin, redVal);
    analogWrite (flashPin, flashVal);
    digitalWrite (greenPin, greenVal);

   

  }
  else
  {

    analogWrite (whitePin, 0);            // Green off
    analogWrite (bluePin, 0);
    analogWrite (yellowPin, 0);
    analogWrite (redPin, 0);
    analogWrite (flashPin, 0);
    digitalWrite (greenPin, LOW);

  

  }
}