Q:

How to avoid javascript countdown timer not to go negative?

I've got here a countdown, for testing purposes I have it set for 10 seconds, but once It's perfected I'll have it as 30 minutes. Everything runs smoothly until the countdown goes negative, I want it to be negative, but in a proper format and for it to not jump from 0 to -01:00. Math.Floor seemed like a good idea, but with this code it ran with negative numbers right away. Also, once it is negative the format is -00:0-0, I would like -00:00.
How can the format be fixed once it's negative? 
Please, refrain from object orientated, our web server is several years out of date. 

var seconds = 10;
function secondPassed() {
  var minutes = Math.round((seconds - 30)/60);
  var remainingSeconds = seconds % 60; 

  if (remainingSeconds < 10) 
  {
    remainingSeconds = "0" + remainingSeconds;  
  }

  document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds;
  if (seconds > 0) {
    seconds--;
    if (seconds > 8) {
      document.body.style.backgroundColor = "green"; }
    else if (seconds == 8) {document.body.style.backgroundColor = "yellow";}
    else if (seconds == 3) {document.body.style.backgroundColor = "red";}
  }
  else{
    seconds--;
  }
}
var countdownTimer = setInterval('secondPassed()', 1000);
<body onload = "getSeconds()">
  <p align ="center">
    <span id="countdown" style="color:black; font-size: 20px; font-weight: bold"> </span>
  </p>
</body>

A:

Here is a floor function that rounds -0.5 to 0, and -1.5 to -1, as you require:
function floor(x) {
    return x | 0;
}

Here is a padding function that correctly pads an integer with 0s:
function pad(n) {
    if (n < 0) {
      n = -n;
    }
    if (n < 10) {
        return '0' + n.toString();
    }
    return n.toString();
}

Your code becomes:

<html>
    <head>
    <title>Countdown</title>
    <script type="text/javascript">
    var seconds = 10;

    function floor(x) {
        return x | 0;
    }

    function pad(n) {
        if (n < 0) {
          n = -n;
        }
        if (n < 10) {
            return '0' + n.toString();
        }
        return n.toString();
    }

    function secondPassed() {
        var minutes = pad(floor(seconds/60));
        if (seconds < 0) {
            minutes = '-' + minutes;
        }
        var remainingSeconds = pad(seconds % 60); 

        document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds;
        if (seconds > 0) {
            seconds--;
            if (seconds > 8) {
            document.body.style.backgroundColor = "green"; }
            else if (seconds == 8) {document.body.style.backgroundColor = "yellow";}
            else if (seconds == 3) {document.body.style.backgroundColor = "red";}
        }
        else{
        seconds--;
        }
    }
    var countdownTimer = setInterval('secondPassed()', 1000);
    </script>
    </head>
    <body onload = "getSeconds()">
    <p align ="center">
    <span id="countdown" style="color:black; font-size: 20px; font-weight: bold">     </span>
    </p>
    </body>
    </html>

