//
// Displays ml block.
//
function display_ml_block(block_id, block)
{
    update_block_title(block_id, block.title);
}

//
// Switch to ml page.
// Called upon clicking block ml title.
//
function switch_to_ml(block_id, ml_id)
{
    var url = get_url_screen('ml') + '&'+FLD_ML_ID+'='+ml_id + '&'+FLD_BLOCK_ID+'='+block_id + '&'+FLD_PAGE_ID+'='+PAGE_ID;
    location.href = 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 contact form HTML.
//
function gen_html_ml_form(block_id, config)
{
    var html = '';
    
    html += '<form id="form_'+block_id+'" name="form_'+block_id+'" class="block_contact" 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+'" />';
    
    html += '<div class="form_item">'; 
    html += '<label>'+translate('name')+'</label>'; 
    html += '<input type="text" name="name" alt="must" onfocus="$(\'#msg_'+block_id+'\').html(\'\')" />'; 
    html += '</div>'; 
    
    html += '<div class="form_item">'; 
    html += '<label>'+translate('email')+'</label>'; 
    html += '<input type="text" name="email" class="ltr" alt="must" onfocus="$(\'#msg_'+block_id+'\').html(\'\')" />'; 
    html += '</div>'; 
    
    html += '<div class="form_item big">'; 
    html += '<label>&nbsp;</label>'; 
    html += '<p>'; 
        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 += '</p>'; 
    html += '</div>'; 
    
    html += '</form>';
    
    return html; 
}

