Quijonsith thanks a lot!
I´ve tried your notes and here is the result:
1.)GOOD NEWS: map function is mostly working. I´ve made simple code to test it:
average=map(average, 170, 700, 0, 255);
analogWrite (ledPin1, average);
it is working, but only when IR is detcting something.
BUT when the space infront of the IR is empty ( so the measured data is about 160 -- so this might be remaped to 0) the LED is fully shining. Thats the first problem...

The result was that when I was in range, the LED lights on}OK thats GOOD!) and stay shining even when I moved out of the range... (thats BAD...)
So I ve tried simple test of the fading code:
if (average >= 600 ) //if the average is high enough and LED1 is not already on
{ led1val=255; // set the starting value to max
led1val -= ledDecay; // start fading out LED1's brightness
analogWrite (ledPin1, led1val); //set LED1 to it's brightness
}But the result was , the same - LED starts shinig and stay shining all the time and didnt react on anything....
3.) I ve noted that when LED puted on PWM+ (just pin6) and no specified data is send there, the LED is shining.
(i ve just declard it as output - nothing more...). Is it normal? But the PWM+ in pin 5 doesn´t do this....
To fix the new problem you could reverse all of your code, changing 255's to 0's and 0's to 255's aswell as changing to ledval-= to ledval+=, or you could do it the easy way and reverse your LED as it sounds to me like it's in backwards.

The millis() function returns the number of milliseconds since the program started, so it's like an internal clock. So when it says LED1ON = millis(), if the program has been running for 7298319 milliseconds, that's what is stored in LED1ON. Then later when you have if(millis() - LED1ON >= interval) it's comparing the current number of milliseconds since program start to LED1ON. So "interval" is how many milliseconds the LED will stay on until it starts to fade out.
Using millis() instead of delay() allows the program to do other things (like compare the other ranges) while it waits to fade the LED, instead of sitting and doing nothing until it's time to fade the LED. So using:
LED1ON = millis();
if(millis() - LED1ON >= interval);
is the same as:
delay(interval);
Only it lets your program keep running. If the LED isn't fading out smoothly/slowly enough for you then you can decrease the subtraction, such as led1val-=1. If it starts fading too soon, increase interval.
You could also hook a potentiometer up to another analog input and read it's value as interval, or do the same for the subtraction value, or both, and you would be able to adjust them while the program is running without having to rewrite your program every time.
Also:
if (average >= 600 ) //if the average is high enough and LED1 is not already on
{ led1val=255; // set the starting value to max
led1val -= ledDecay; // start fading out LED1's brightness
analogWrite (ledPin1, led1val); //set LED1 to it's brightness
}The problem with this test fade code is every time it runs it sets led1val to 255, so even though it subtracts afterwards, as long as you're >=600, led1val gets set to 255 again. The subtraction and analogwrite should be outside the if statement.
Try my code again, but with the LED reversed from how it is now and try simply adjusting ledDecay and interval as I described.
Also, you are correct about using && in the if statement. That's why I asked you to look it over

. I haven't programmed in a long time so I'm still remembering the syntax.
[edit]Also, here's the reference for millis():
http://www.arduino.cc/en/Reference/Millis[/edit]