batarejka,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body{
background-color: #D2B48C;
}
</style>
</head>
<body>
<input id="n" name="" value="3">
<input id="b" name="" type="button" value="go" onclick="go(n.value)">
<script>
function blinker(color, duration, elem) {
var timer, rgb = getComputedStyle(elem)["backgroundColor"];
return function fn(num) {
window.clearTimeout(timer);
if (isNaN(+num)) { alert("!!!"); return}
(function mig(a) {
elem.style.backgroundColor = a % 2 ? color : rgb;
a-- && (timer = window.setTimeout(function() {
mig(a)
}, duration))
})(num * 2)
}
};
var go = blinker('#FF00FF',300, document.body)
</script>
</body>
</html>