// author: dasir

//****************************************************************************

function setup_tinymce()
{
  tinyMCE.init({
    editor_selector : "mceEditor",
    theme: "advanced",
    mode : "textareas",
    plugins: "contextmenu,insertdatetime,layer,paste,searchreplace,table,style,nonbreaking,visualchars,fullscreen,advlink,advimage,autonbsp",
    theme_advanced_buttons1: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,insertlayer,moveforward,movebackward,absolute,|,link,unlink,anchor,image,|,insertdate,inserttime,charmap,hr,nonbreaking,autonbsp,visualchars",
    theme_advanced_buttons2: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,bullist,numlist,|,sub,sup,|,outdent,indent",
    theme_advanced_buttons3 : "forecolor,backcolor,|,styleprops,code,removeformat,cleanup,|,tablecontrols,|,fullscreen",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "none",
    theme_advanced_resizing: true,
    theme_advanced_resize_horizontal: false,
    theme_advanced_resizing_use_cookie : false,
    theme_advanced_path : true,
    theme_advanced_fonts : "Arial=sans-serif;Times=Times New Roman, Times, serif;Courier=courier new,courier,monospace",
    theme_advanced_blockformats: "p,h1,h2,h3",
    theme_advanced_styles: "",
    plugin_insertdate_dateFormat : "%d.%m.%Y",
    plugin_insertdate_timeFormat : "%H:%M:%S",
    language : "cs",

    accessibility_warnings : false,
    convert_fonts_to_spans: true,
    entities: "160,nbsp,38,amp,34,quot,60,lt,62,gt",
    entity_encoding: "named",
    convert_urls: false,
    verify_html: false,
    apply_source_formatting : true,
    cleanup_on_startup : true,
    invalid_elements : "",

    auto_reset_designmode: true
  });
}

//****************************************************************************

function confirm_url(msg, url)
{
  if (confirm(msg)) document.location.href = url;
}

//****************************************************************************

function load_image(img, dst)
{
  dst = getElement(dst);
  dst.src = img;
}

//****************************************************************************

function menu_load_image(img, idx, cnt)
{
  for (var i = 0; i < cnt; i++)
  {
    if (i == idx)
      showElement("orig_image", "big_picture_"+i);
    else
      hideElement("orig_image", "big_picture_"+i);
  }
}

//****************************************************************************

function show_orig_image(img)
{
  showElement("orig_image");
  getElement("orig_image_img").src = img;
}

//****************************************************************************

function sel_val(select)
{
  return select.options[select.selectedIndex].value;
}


//****************************************************************************

function save_gen(what)
{
  form = getElement("orderf");
  form.after_save.value = what;
  log(what);
  form.submit();
}

//****************************************************************************
//****************************************************************************

setup_tinymce();

jQuery(document).ready(function(){
  jQuery("a[rel='categoryphotos']").colorbox({
      current: "{current}/{total}",
      maxWidth: "90%",
      maxHeight: "90%"
    });
});

