/* funzioni editor */

  tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen",
    theme_advanced_buttons1_add_before : "save,newdocument,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,pastetext,pasteword,separator,search,replace,separator",
    theme_advanced_buttons3_add_before : "tablecontrols,separator",
    theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    content_css : "example_word.css",
      plugi2n_insertdate_dateFormat : "%Y-%m-%d",
      plugi2n_insertdate_timeFormat : "%H:%M:%S",
    external_link_list_url : "example_link_list.js",
    external_image_list_url : "example_image_list.js",
    media_external_list_url : "example_media_list.js",
    file_browser_callback : "fileBrowserCallBack",
    paste_use_dialog : false,
    theme_advanced_resizing : true,
    theme_advanced_resize_horizontal : false,
    theme_advanced_link_targets : "_something=My somthing;_something2=My somthing2;_something3=My somthing3;",
    paste_auto_cleanup_on_paste : true,
    paste_convert_headers_to_strong : false,
    paste_strip_class_attributes : "all",
    paste_remove_spans : false,
    paste_remove_styles : false
  });

  function fileBrowserCallBack(field_name, url, type, win) {
    // This is where you insert your custom filebrowser logic
    alert("Filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);

    // Insert new URL, this would normaly be done in a popup
    win.document.forms[0].elements[field_name].value = "someurl.htm";
  }
  
  function reset()
  {
   document.getElementById("testo_area").value="";
  }


  function sv()
  {
     var titolo = document.getElementById("listForm").titolo_area.value;
     
     if(titolo != '')
     { 
       document.getElementById("listForm").azione.value="SV";
       document.getElementById("listForm").submit();
     }
     else
     {
       alert("please select a title");
     }
  }
    

/*
  function modifyPosts(range)
  {
     for(i=1; i<= range; i++)
     {
       
       if(document.getElementById("visible"+i).checked)
         document.getElementById("visible"+i).value = "1"
       else  
         document.getElementById("visible"+i).value = "0"
     }
     document.getElementById("listForm").azione.value="MOD";
     document.getElementById("listForm").submit();

  }
*/     
    

  function modifyPosts(range)
  {

//    alert("range "+range);

    var changeList = "";
    
    for(i=0; i<= range; i++)
    {

      if(document.getElementById("visible"+i)) 
      {

//          alert("z"+document.getElementById("visible"+i).checked);
//          alert("id"+document.getElementById("P_ID"+i).value);

        changeList += ""+document.getElementById("P_ID"+i).value;
        if(document.getElementById("visible"+i).checked)
          changeList += ":T";
        else
          changeList += ":F";

        changeList += "&";
      }

    }
//    alert("ciao "+changeList);

    document.getElementById("listForm").azione.value="MOD";
    document.getElementById("listForm").changeList.value=changeList;
    document.getElementById("listForm").submit();

  }


/* fine funzioni editor */

  function openForum(index, toType)
  {

    if (toType == "posts")
    {
      document.getElementById("listForm").content.value="forum/posts.jsp"
//        document.getElementById("listForm").jGrants.value=j;
    }
    else
      document.getElementById("listForm").content.value="forum/list.jsp"


    document.getElementById("listForm").orderby.value='';
    document.getElementById("listForm").type.value=toType;
    document.getElementById("listForm").idObj.value=index;
    document.getElementById("listForm").submit();
  }
  function noAccess()
  {
    alert("accesso non consentito");    
  }



  function add()
  {
    document.getElementById("listForm").content.value="forum/posts.jsp"
    document.getElementById("listForm").azione.value="INS";
    document.getElementById("listForm").submit();
  }


  function change(index)
  {
    document.getElementById("listForm").pagina.value=index
    document.getElementById("listForm").submit();
  }
  function orderBy(order, direction)
  {


    document.getElementById("listForm").orderby.value=order+" "+direction
    document.getElementById("listForm").submit();

  }


  function display(period)
  {
    document.getElementById("listForm").display.value=period
    document.getElementById("listForm").submit();
  }
  function find(place)
  {
    document.getElementById("listForm").content.value="forum/search.jsp"
    document.getElementById("listForm").place.value=place
    document.getElementById("listForm").search.value=document.getElementById("search_keywords").value;
    document.getElementById("listForm").submit();
  }
  function register()
  {

    signIn();
  }
  function logIn(direct)
  {
 //   alert()
    window.opener.listForm.logAction.value="IN"
    window.opener.listForm.login.value=document.getElementById("login").login.value
    window.opener.listForm.password.value=document.getElementById("login").password.value
    window.opener.listForm.submit();
    window.close();

  } 
  function log(direct)
  {

    if(direct == "OUT")
    {

      document.getElementById("listForm").logAction.value=direct;
      document.getElementById("listForm").idObj.value=""
      document.getElementById("listForm").type.value="topics"
      document.getElementById("listForm").content.value="forum/list.jsp"
      document.getElementById("listForm").submit();
      
    }
    else
      toolWindow("forum/login.jsp", 250, 300);


  }

  function src(direct)
  {

    alert("go to search page ")

  }


/* funzioni ereditate dal sito*/
  function toolWindow(page, h, w, tw, sb, rs)
  {
    if(!tw) tw = 'tw';
    if(!sb) sb = 'no';
    if(!rs) rs = 'no';
    var s='height='+h+', width='+w+', top='+(screen.height-h)/2+', left='+(screen.width-w)/2+', status=no, scrollbars='+sb+', resizable=' + rs;
    win=window.open(page, tw, s);
    win.moveTo ((screen.width-w)/2, (screen.height-h)/2);
    win.resizeTo (w, h);
    if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
  }


  function signIn()
  {
    h = 850;

    toolWindow('join.jsp', h, 500, 'register', 'no');
  }      
/* funzioni ereditate dal sito*/
