function autoClearInputBox(item, value, action)
{
  if (action=='focus')
  {
    if(item.value==value) item.value='';
  }
  else if(action=='blur')
  {
    if(item.value=='') item.value=value;
  }
  return false;
}

function elShowHide(to_hide_id)
{
  if (document.getElementById(to_hide_id).style.display=="none")
  {
    document.getElementById(to_hide_id).style.display="block"
  }
  else
  {
    document.getElementById(to_hide_id).style.display="none"
  }
  return false;
}

function showInputTip(item, text, action)
{
  tip = item.id + '_tip';   
  item_el = document.getElementById(item.id);   
  if (action=='show' && text)
  {
    popup_tip = document.createElement('div');
    popup_tip.setAttribute('id', tip);
    popup_tip.setAttribute('class', 'popup_tip');
    popup_tip.setAttribute('className', 'popup_tip');
    popup_tip.setAttribute('style', 'left: ' + item_el.offsetWidth + 'px;');
    popup_tip.style.cssText = 'left: ' + item_el.offsetWidth + 'px;';
    item_el.parentNode.appendChild(popup_tip);
    
    left_tip = document.createElement('div');
    left_tip.setAttribute('class', 'left_tip');
	left_tip.setAttribute('className', 'left_tip');
    document.getElementById(tip).appendChild(left_tip);
    
    right_tip = document.createElement('div');
    right_tip.setAttribute('id', tip + '_text');
    right_tip.setAttribute('class', 'right_tip');
    right_tip.setAttribute('className', 'right_tip');
    right_tip.innerHTML = unescape(text);
    document.getElementById(tip).appendChild(right_tip);
    clear_tip = document.createElement('div');
    clear_tip.setAttribute('style', 'clear: both');
    clear_tip.style.cssText = 'clear: both';
    document.getElementById(tip).appendChild(clear_tip);
    
    item.className += ' input_focus';  
  }
  else if (action=='hide')
  {
    popup_tip_div = document.getElementById(tip);
    if (popup_tip_div != undefined)
    {
      item_el.parentNode.removeChild(popup_tip_div);
    }
    
    item.className = item.className.replace(' input_focus', '');
    
  }
}

function tinyMCEit(el, addMCEC, js_theme)
{
  if(addMCEC != undefined && addMCEC) tinyMCE.addMCEControl(el, el.id);

  if(js_theme == undefined) js_theme="advanced";
  
  tinyMCE.init({
    mode : "exact",
    elements : el.id,
    theme : js_theme,
    plugins : "table,save,advhr,advimage,advlink,emotions,insertdatetime,preview,zoom,flash,searchreplace,print,fullscreen,contextmenu,imagemanager,filemanager",
    theme_advanced_buttons1_add_before : "save,separator",
    theme_advanced_buttons1_add : "fontselect,fontsizeselect",
    theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
    theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
    theme_advanced_buttons3_add_before : "tablecontrols,separator",
    theme_advanced_buttons3_add : "emotions,flash,advhr,separator,print,fullscreen",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_path_location : "bottom",
    plugin_insertdate_dateFormat : "%Y-%m-%d",
    plugin_insertdate_timeFormat : "%H:%M:%S",
    extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],script[type|src]",
    paste_use_dialog : false,
    apply_source_formatting : true,
    force_br_newlines : true,
    force_p_newlines : false,
    relative_urls : false,
    content_css: "/css/tinymce_classes.css"

    //      external_link_list_url : "example_data/example_link_list.js",
    //      external_image_list_url : "example_data/example_image_list.js",
    //      flash_external_list_url : "example_data/example_flash_list.js",
    //              gecko_spellcheck : true,
    //              content_css: "/css/tinymce_classes.css"
  });
}

function openImagePopup(url)
{
  window.open(url, 'MaiMultVerde', 'fullscreen=no, statusbar=no, addressbar=no, toolbar=no, menubar=no, navbar=no, scrollbars=yes, width=600, height=720, 0, 0');
}

