// functions.js

// ask to delete
function do_question() {
         return confirm("Are you sure want to delete?");
}

/*
// onMouseOver
function over(obj){
         obj.style.background="#CCCCCC"
         obj.style.color="#FFFFFF"
}

// onMouseOut
function out(obj){
         obj.style.background="#FFFFFF"
         obj.style.color="#000000"
}
*/

function stepIn(obj, color) {
         obj.style.backgroundColor= color;
}

function stepOut(obj, color) {
         obj.style.backgroundColor= color;
}

function clickDown(obj) {
         obj.style.backgroundColor= '#f9abab';
}
//onMouseover="this.style.backgroundColor='#CCFFFF'"
// onMousedown="this.style.backgroundColor='#FFFF99'"
// onMouseout="this.style.backgroundColor='#DDDDDD'"

function show(item) {
    var x=document.getElementById(item);
    x.style.visibility='visible';

}

function hide(item) {
    var x=document.getElementById(item);
    x.style.visibility='hidden';

}





/*
function checkIt(form) {

    alert('Enter number!');
    var quantity=form.elements["quantity"].value;

    if(isNaN(quantity)) {
        alert('Enter number!');
        return false;
    }

    return true;

} */

function checkIt(field)
{
      if ( field.value == "" )
      {
        alert( "Моля въведете цяло число." );
        field.focus();
        return ( false );
      }
      var checkOK = "0123456789";
      var checkStr = field.value;
      var allValid = true;
      var decPoints = 0;
      var allNum = "";
      for ( i = 0;  i < checkStr.length;  i++ )
      {
        ch = checkStr.charAt( i );
        for ( j = 0;  j < checkOK.length;  j++ )
          if ( ch == checkOK.charAt( j ))
            break;
        if ( j == checkOK.length )
        {
          allValid = false;
          break;
        }
        allNum += ch;
      }
      if (!allValid)
      {
        alert( "Моля въведете само цяло число." );
        field.focus();
        return ( false );
      }
    return ( true );
}


function ReCalc(form, index) {
         form.price[index].value =  form.category[index].options[form.category[index].selectedIndex].value*form.quantity[index].value;
         TotalSum(form);
}

function TotalSum(form) {
         form.totalprice.value = 0;
         for (i=0; i<35; i++) {
              form.totalprice.value = eval(parseFloat(form.totalprice.value)+parseFloat(form.price[i].value));
         }

}
