if (!Array.prototype.some)
{
  Array.prototype.some = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this &&
          fun.call(thisp, this[i], i, this))
        return true;
    }

    return false;
  };
}

function catThumb() {
	$.ajax({
		type: "POST",
		url: "../includes/categories.php",
		data: "catid="+$('select option:selected').val(), //select
		success: function(r) {
			switch(r) {
				case "false":
					$('div#error').html('There Were No Results For That Query.');
					$('div#pageResults').html('');
				break;
				case "MySQL Error":
					$('div#error').html('There Was A MySQL Query Error. Please Contact The Webmaster About This Error If It Persists.');
					$('div#pageResults').html('');
				break;
				default:
					$('div#error').html('');
					$('div#pageResults').html(r);
				break;
			}
		}
	});		
}




function addBasket() {
	
var arraynumb = new Array;
 $("input.numb").each(function(classe) {
var myVar= $("input.numb").get(classe);
arraynumb.push(myVar.value);
    });
   
   
 
function isZeroAbove(element, index, array) {
return (element > 0);
}

if (arraynumb.some(isZeroAbove)) { //evaluates to true

 var queryString = $('#preventivo').formSerialize(); 

 $.post("../includes/addBasket.php",queryString), {
       numb: $('input.numb').val(),
       code: $('input.code').val(),
       name: $('input.name').val(),
	   color: $('input.color').val()
       
      
   };// end post
   
    alert('prodotto inserito');
   
}else{
	
alert("inserire quantita'");	
   
   
} //end evaluates 
   
	
 	
}//end addBasket









function addBasket_eng() {

arraynumb = new Array;
 $("input.numb").each(function(classe) {
  myVar= $("input.numb").get(classe);
   arraynumb.push(myVar.value);
    });
   
   
 
function isZeroAbove(element, index, array) {
return (element > 0)
}
 
if (arraynumb.some(isZeroAbove)){ //evaluates to true

 var queryString = $('#preventivo').formSerialize(); 

 $.post("../../includes/addBasket.php",queryString), {
       numb: $('input.numb').val(),
       code: $('input.code').val(),
       name: $('input.name').val(),
	   color: $('input.color').val()
       
      
   };// end post
   
    alert('product inserted');
   
}else{
	
alert("insert quantity'");	
   
   
} //end evaluates
   
	
 	
}//end addBasket_eng




function send() {
	
	$.getScript("includes/send.php");

	
}//end send
	


// digits only input block
$('#preventivo').ready(function(){
    
    //called when key is pressed in textbox
	$(".numb").keypress(function (e)  
	{ 
	  //if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
		//display error message
		$(".errmsg").html("Digits Only").show().fadeOut("slow"); 
	    return false;
      }	
	});


  });






