function getContent (elem, w, h, p) {

    if (!$(elem)) {
       //alert('Content element ['+elem+'] not found');
       return;
    }
    if (typeof(w) == 'undefined' || typeof(h) == 'undefined') {
       alert('Content element ['+elem+'] Width or Height does not has value.');
       return;
    }

    var param = (typeof(p) == 'undefined') ? {} : p;
    var hash  = $H({option:'com_content', task:'x_feed', tag:elem, width:w, height:h});
    hash.update(param);

    new Ajax.Request(_absolutePath+'/ajax.lnk.php', {
       method: 'get',
       parameters: hash.toObject(),
       //onLoading: function() { $(elem).update('loading..') },
       onFailure: function() { $(elem).update('error'); },
       onSuccess: function(transport, json) {
          var text    = transport.responseText;
          var scripts = text.extractScripts();

          if (json && (json.status == -1 || json.status == 0)) { $(elem).update(json.message); }
          else if (scripts.length > 0) { scripts.map(function(script) { eval(script); }); }
          else { $(elem).update(text); }
       }
    });
} // getContent

function switchMode (elem) {

    if ($('div_'+elem+'_editArea').style.display == 'none') {
       $('div_'+elem).hide();
       $('div_'+elem+'_editArea').show();
    } else {
       $('div_'+elem+'_editArea').hide();
       $('div_'+elem).show();
    }

} // switchMode

function saveContent (elem) {
       var message  = 'Do you want to insert empty content?';
       var txt_con  = $F('txt_'+elem);
       var fulltext = nl2br(txt_con);

       if (!$F('txt_'+elem) && !confirm(message)) {
          $('txt_'+elem).focus();
          return;
       }

       new Ajax.Request(_absolutePath+'/ajax.lnk.php', {
          method: 'post',
          parameters: { option:'com_content', task:'x_save', tag:elem, content:txt_con, autoCreate:1 },
          onLoading: function() { $('div_'+elem+'_actions').hide(); $('div_'+elem+'_loading').show(); },
          onComplete: function() {  $('div_'+elem+'_loading').hide(); $('div_'+elem+'_actions').show(); },
          onSuccess: function(transport, json) {
             var text    = transport.responseText;
             var scripts = text.extractScripts();

             if (json && json.status == -1) { alert(json.message); }
             else if (json && json.status == 1) { $('content_'+elem).update(fulltext); switchMode(elem); }
             else if (scripts.length > 0) { scripts.map(function(script) { eval(script); }); }
          }
       });
} // saveContent