// Add dish
function addDish(id, idDish, dishName, type, limit, register){

    jQuery( "#" + id ).val( "" );
    var tag = "<li id = '" + id + "_" + idDish + "' class = 'block'>" + dishName + "<span  id = '" + id + "_" + idDish + "' class = 'cursorPointer delete-dish'  onclick = 'garbageDish( this, false, " + type + " )'>" + trad_delete_dish + "</span></li>";
    
    jQuery("#restaurant_id").parent().removeClass('wrong_data');

    if( jQuery("#" + id + "_list" ).children().length > ( limit - 1 ) )
        jQuery( "#" + id ).attr( "disabled", true );
    else
        jQuery( "#" + id + "_list" ).append( tag );
    if( !register )
    {
        var tmpChildren = jQuery( "#" + id + "_list" ).children();
        var dishesId = "";
        for( i = 0; i < tmpChildren.length; i++ )
        {
            idTmp = tmpChildren[ i ].id.split( "_" );
            idTmp = idTmp[ 1 ];
            dishesId += ( "," + idTmp );
        }
        if( dishesId != "" )
        {
            dishesId = dishesId.substr( 1 );
            jQuery.ajax(
            {
                type: "post",
                url: "/application/ajax/sameDishesAsMe.php",
                data: "dishesId=" + dishesId + "&type=" + type,
                success:    function( response )
                            {
                                jQuery( "#" + id + "_same" ).html( response );
                                //console.info( "autocomplete_dishes: #" + id + "_same, " + response );
                            },
                error:  function(){}
            });
        }
    }

  }

