//
// Displays ml block menu.
//
function switch_to_ml_screen(ml_id)
{
    var ml_url = get_url_screen('ml')+'&'+FLD_ML_ID+'='+ml_id;
    if (g_is_mblock_link) { location.href = ml_url; }
}

//
// Send add-ml form.  
//
function send_add_ml()
{
    var block_title = get_form_field('form_add_ml', 'block_title');
    
    if (block_title == '')
    {
        my_alert('all field are must');
        return false;
    }
    
    var data = $("#form_add_ml").serialize();
    
    var code = "display_media_blocks_sw_mode(%%%);";
    code += "close_modals();"
    
    ajax(data, code, "", "button_add_ml", "saving_add_ml");

    return false;
}

// **********************************************************
//
//   The following functions relate to the behaviour of 
//   contact form, and not the the block itself.
//
// **********************************************************


//
// Generates ml form HTML.
//
function gen_html_ml_form(block_id, config)
{
    var html = '';
    
    html += '<form id="form_'+block_id+'" name="form_'+block_id+'" method="post" action="'+get_url_action()+'">'
    
    html += '<input type="hidden" name="action" value="unid_join_ml" />';
    html += '<input type="hidden" name="'+FLD_BLOCK_ID+'" value="'+block_id+'" />';
    
    if (IS_SW_MODE)
    {
        html += '<input type="hidden" name="'+FLD_TOKEN+'" value="'+get_current_token()+'" />';
    }
    
    html += '<div class="form_item">'; 
    html += '<input type="text" name="name" value="'+translate('name')+'" alt="must" onfocus="$(\'#msg_'+block_id+'\').html(\'\'); clear_field(this, \''+translate('name')+'\');" onblur="reset_field(this, \''+translate('name')+'\');" />'; 
     
    html += '</div>'; 
    
    html += '<div class="form_item">'; 
    html += '<input type="email" name="email" value="'+translate('email')+'" class="ltr" alt="must" onfocus="$(\'#msg_'+block_id+'\').html(\'\'); clear_field(this, \''+translate('email')+'\');" onblur="reset_field(this, \''+translate('email')+'\');" />'; 
    html += '</div>'; 
    
    html += '<div class="form_item">'; 
    html += '<button id="button_'+block_id+'" onclick="send_bform('+block_id+'); return false;">'+translate('send')+'</button>'; 
    html += '<img id="saving_'+block_id+'" class="image_saving hidden" src="'+CSS_IMAGE_SAVING+'" />'; 
    html += '<span class="middle" id="msg_'+block_id+'"></span>'; 
    html += '</div>'; 
    
    html += '</form>';
    
    return html; 
}
