function remove_element_and_one_before(child)
{
    if($(child).previousSiblings().length > 0) {
//        child.parentNode.removeChild(child.previousSiblings()[0]);
         Element.remove($(child).previousSiblings()[0]);
    }
    Element.remove(child);
    return false;
}

function ciapek()
{
    return '"';
}

function start_loading() {
    $('indicator').style.display='';
    $('frame').src = "/javascripts/frame.html";
}

function stop_loading() {
    $('indicator').style.display='none';
}


function error_loading(request) {
    alert('HTTP Error ' + request.status + '!');
    stop_loading();
}



/*
*/
function openDialog(id_name, id2_name, options) {
      
      Dialog.info($(id_name).innerHTML, {
           windowParameters: {
               className: "alphacube",  
               width: options.width, 
               height: options.height, 
               showEffect2:Effect.Appear, 
               hideEffect2: Effect.Appear, 
               effectOptions: {duration:0.3},
               recenterAuto: false
           }, 
           cancel: function() { $(id_name).innerHTML = '<div id="'+id2_name+'"></div>'; }
           }
       );
      $(id_name).innerHTML = '';
      elem = $(options.focus);
      if (options.focus) {
      setTimeout("elem.focus()",400);
      }
      //alert(options.focus);
      //Dialog.confirm({url:'/app/folder/add', asynchronous:true, evalScripts:true}, {windowParameters: {className: "alphacube",  opacity:2}, showProgress: true})
  }
  
  
function li_tree_toggle(no) {
    $('li-id-' + no).toggle();
    $('li-plus-id-' + no).toggle();
    $('li-minus-id-' + no).toggle();
}

/*
function showWin(ajaxArgs) {
    foo = new Window('dialog'+xidx, {className: "dialog", title: "Yahoo"+idx, top:(0+(cascade*cOffset)), left:(0+(cascade*cOffset)), width:300, height:200, zIndex:100, opacity:1, resizable: true, xurl:'http://www.yahoo.com'});
    foo.getContent().innerHTML='stubbed:getAjax(ajaxArgs)';
    foo.show();
    foo.toFront();
    cascade++;
    idx++;
    xidx++;
    cWins.push(foo);
}

function showWin2(id_name) {
    w = new Window("w2", {});
    w.show();
    w.toFront();
}

*/


//tinymce

bTextareaWasTinyfied = false; //this should be global, could be stored in a cookie...

function setTinyMCE(sEditorID) {
    //var oEditor = $(sEditorID);
    //if(oEditor && !bTextareaWasTinyfied) {
        tinyMCE.execCommand('mceAddControl', true, sEditorID);
    //    bTextareaWasTinyfied = true;
    //}
    return;
}

function unsetTinyMCE(sEditorID) {
    //var oEditor = $(sEditorID);
    //if(oEditor && bTextareaWasTinyfied) {
        tinyMCE.execCommand('mceRemoveControl', true, sEditorID);
    //    bTextareaWasTinyfied = false;
    //}
    return;
}


function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to );
        idx = str.indexOf( from );
    }

    return str;
}

function insertAtCursor(myField, myValue) {
    //IE support
    if (document.selection) {
        myField.focus();
        sel = document.selection.createRange();
        sel.text = myValue;
    }
    //MOZILLA/NETSCAPE support
    else if (myField.selectionStart || myField.selectionStart == '0') {
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        myField.value = myField.value.substring(0, startPos)
        + myValue
        + myField.value.substring(endPos, myField.value.length);
    } else {
        myField.value += myValue;
    }
}

function onSave() {
}

function onCancel() {
}

function pxx(str) {
    return str.substr(0, str.length - 2);
}
