Quitting loop

So basically I am trying to make PIR Sensor alarm with IR remote control.
On my remote control I have two buttons - ON and OFF to turn alarm on and off. When alarm is activated and PIR sensor detects motion - it blinks LED for 3 seconds and then turns on siren. I managed to program this far and run into problem - I cannot deactivate my alarm with remote. I can deactivate it with remote when PIR sensor does not detect motion, but when it does - it just keeps ringing the siren. Probably there is an easy fix that I am not aware of.
Thank you in advance.

/* YourDuino.com Example Software Sketch
IR Remote Kit Test
Uses YourDuino.com IR Infrared Remote Control Kit 2
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=153
based on code by Ken Shirriff - http://arcfn.com
Get Library at: https://github.com/shirriff/Arduino-IRremote
Unzip folder into Libraries. RENAME folder IRremote
terry@yourduino.com */

/*-----( Import needed libraries )-----*/

#include "IRremote.h"

/*-----( Declare Constants )-----*/
int receiver = 2; // pin 1 of IR receiver to Arduino digital pin 11
int ledPin = 12;                // choose the pin for the LED
int inputPIR = 6;  // choose the input pin (for PIR sensor)
int val = 0;                    // variable for reading the pin status
int pinSpeaker = 11;           //Set up a speaker on a PWM pin (digital 9, 10, or 11)
int time = 10;
int var = 0;

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'
/*-----( Declare Variables )-----*/


void setup()   /*----( SETUP: RUNS ONCE )----*/
{
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);      // declare LED as output
    pinMode(inputPIR, INPUT);     // declare PIR sensor as input
    pinMode(pinSpeaker, OUTPUT);
    Serial.println("IR Receiver Raw Data + Button Decode Test");
    irrecv.enableIRIn(); // Start the receiver
    
}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
    val = digitalRead(inputPIR);  // read PIR input value
    if (irrecv.decode(&results)) // have we received an IR signal?
    
    {
        //Serial.println(results.value, HEX);//  UN Comment to see raw values
        
        if (results.value == 0xFF22DD)
        {
            Serial.println(" ON    ");
            var = 1; // alarm is on
            
            
        }
        if (results.value == 0xFFA25D)
        {
            Serial.println(" OFF    ");
            var = 0; // alarm is off
            
        }
        translateIR();
        irrecv.resume(); // receive the next value
    }
    
    
    if (val == HIGH && var==1) {            // check if the input is HIGH and alarm is on
        digitalWrite(ledPin, HIGH);  // turn LED ON
        delay(1000);
        digitalWrite(ledPin, LOW);  // turn LED OFF
        delay(1000);
        digitalWrite(ledPin, HIGH);  // turn LED ON
        delay(1000);
        digitalWrite(ledPin, LOW);  // turn LED OFF
        delay(1000);
        digitalWrite(ledPin, HIGH);  // turn LED ON
        
        for(int i=0; i<time ; i++) {
            
            tone(300, 160);
            delay(100);
        }
        
        
    }
    
    
    
    /*
    if (var == 1 && val==HIGH){
        Serial.println(" SIGNALS    ");
        digitalWrite(ledPin, HIGH);  // turn LED ON
        delay(1000);
        digitalWrite(ledPin, LOW);  // turn LED ON
        delay(1000);
        digitalWrite(ledPin, HIGH);  // turn LED ON
        delay(1000);
        digitalWrite(ledPin, LOW);  // turn LED ON
        delay(1000);
        digitalWrite(ledPin, HIGH);  // turn LED ON
        
        
        tone(300, 160);
        delay(100);
        
    }
    */
}/* --(end main loop )-- */

/*-----( Declare User-written Functions )-----*/
void tone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 10000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
    
}

void translateIR() // takes action based on IR code received
// describing Car MP3 IR codes

{
   
    
} //END translateIR



/* ( THE END ) */

See blink without delay in the examples. The can't respond when its doing something such as delay().

Mark