function areYouSure(){
  if (confirm(MSGs[12]))
    return true;
  else return false;
}


function resetCart(){
  if (confirm(MSGs[12]))
    document.location.href = SITEURL + "scripts/reset_cart.php";
  else return false;
}


function step2(){
  document.location.href = SITEURL + "scripts/step_2.php";
}


function rest2pay(Total,Points){
  setTimeout('delayedRest2pay('+Total+','+Points+')', 10);
}

function delayedRest2pay(Total,Points){

  var Used=document.getElementById('c_points').value;

  if (Used != '' && isNumeric(Used)){
    
    if (Used>Points){
      if (Points >= Total){
        document.getElementById('c_points').value=Total;
        document.getElementById('rest2pay').innerHTML = 0;
      }
      else{
        document.getElementById('c_points').value=Points;
        document.getElementById('rest2pay').innerHTML = Math.round((parseFloat(Total) - parseFloat(Points))*100)/100;       
      }
    }
    else{
      if (Used > Total){
        document.getElementById('c_points').value=Total;
        document.getElementById('rest2pay').innerHTML = 0;
      }
      else{
        document.getElementById('rest2pay').innerHTML = Math.round((parseFloat(Total) - parseFloat(Used))*100)/100;
      }
    }
  }
  else {
    document.getElementById('rest2pay').innerHTML = Total;
    document.getElementById('c_points').value= 0;
  }
}

function isNumeric(sText){

    var ValidChars = "0123456789.";
    var IsNumber   = true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1){
        IsNumber = false;
      }
    }
    return IsNumber;
};
