// JavaScript Document
pic1 = new Image(16, 16); 
pic1.src = "images/ajax-loader.gif";

$(document).ready(function(){

$("#checkQnty").click(function() { 
var sitem = $("#sitem").val();
var quantity = $("#itemQuantity").val();

if(sitem==""){
 $("#statusQnty").html('<font color="red">Select an item.</font>');
 $("#sitem").focus();
}
//var quantity=quantity;
//alert(rollno);
if(quantity.length >= 1)
{
$("#statusQnty").html('<img src="images/ajax-loader.gif" align="absmiddle">&nbsp;Checking availability...');

    $.ajax({  
    type: "POST",  
    url: "checkStock.php",  
    data: "quantity="+ quantity+"&item="+sitem,  
    success: function(msg){ 
	//alert(msg);
    $("#statusQnty").ajaxComplete(function(event, request, settings){ 

	if(msg == 'OK')
	{ 
        $("#headAmount").removeClass('object_error'); // if necessary
		$("#headAmount").addClass("object_ok");
		$(this).html('&nbsp;<img src="images/accepted.png" align="absmiddle"> <font color="Green">Qnty is available.</font>  ');
	}  
	else  
	{  
		$("#headAmount").removeClass('object_ok'); // if necessary
		$("#headAmount").addClass("object_error");
		$(this).html('&nbsp;<img src="images/alert.png" align="absmiddle"> <font color="red">Not enough in stock!</font>  ');
	}  
   
   });

 } 
   
  }); 

}
else
	{
	$("#statusQnty").html('<font color="red">Fill up Quantity.</font>');
	$("#rollno").removeClass('object_ok'); // if necessary
	$("#rollno").addClass("object_error");
	}

});

});

