

//////////////////////////////////
// My Cellar Add Wine Functions //
//////////////////////////////////



function mycellar_addwine() 
{
	error = false;
	msg = "";

	//Check that all ratings have been submitted
	if (isNaN($("#my_cellar_quantity").val())) { error = true; msg+="The value you entered was not a number.<br/>";}

	// echo error message
	if (error == true)
	{
		$('#mycellar_error').html(msg);
	} else 
	// otherwise submit via ajax!
	{

		//show loading image
		$('#mycellar_error').html('<img src="'+base_url+'/skins/'+skin+'/js/ajax-loader.gif" height="16" width="16" /><br/>');	

		// build query string
		query = "wine_id="+$("#my_cellar_wine_id").val();
		query += "&quantity="+$("#my_cellar_quantity").val();
		query += "&function=add";


		//submit ajax query
		$.ajax({
		  url: base_url+'/sources/ajax/mycellar.php',
		  data: query,
		  dataType: 'json',
		  type: 'post',
		  success: function (j) 
				{
					if (j.ok) {	
							
								$("#my_cellar").html(j.html);
								$("#my_cellar").slideDown();
							


					} else {	
						$('#mycellar_error').html(j.msg+"<br/>");

					}
				}
		});
	}
}
