/**
* toggles a object with id = i
*/

function toggle(i)
{
		aelement = document.getElementById(i).style;
		if(aelement.display == 'none')
		{
			aelement.display='inline';
			aelement.display='inline';
		}
		else
		{
			aelement.display ='none';
		};
};

		function myFileBrowser (field_name, url, type, win) {

    // alert("Field_Name: " + field_name + "\nURL: " + url + "\nType: " + type + "\nWin: " + win); // debug/testing

    /* If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
       the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
       These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */

    /* Here goes the URL to your server-side script which manages all file browser things. */
    var cmsURL = ".././../../../../index.php?page=admin.Modules.TinyMCE.ImageBrowser";     // your URL could look like "/scripts/my_file_browser.php"
    var searchString = window.location.search; // possible parameters
    if (searchString.length < 1) {
        // add "?" to the URL to include parameters (in other words: create a search string because there wasn't one before)
        searchString = "?";
    }

    // newer writing style of the TinyMCE developers for tinyMCE.openWindow

    tinyMCE.openWindow({
        file : cmsURL , // PHP session ID is now included if there is one at all
        title : "File Browser",
        width : 420,  // Your dimensions may differ - toy around with them!
        height : 400,
        close_previous : "no"
    }, {
        window : win,
        input : field_name,
        resizable : "yes",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        editor_id : tinyMCE.selectedInstance.editorId
    });
    return false;
  }	
  
  function SubmitImage(URL,Name) {
  //call this function only after page has loaded
  //otherwise tinyMCEPopup.close will close the
  //"Insert/Edit Image" or "Insert/Edit Link" window instead


  var win = tinyMCE.getWindowArg("window");

  // insert information now
  win.document.getElementById(tinyMCE.getWindowArg("input")).value = URL;
  win.document.getElementById("alt").value = Name;

  // for image browsers: update image dimensions
  if (win.getImageData) win.getImageData();

  // close popup window
  tinyMCEPopup.close();
  }