 
function myFileBrowser (field_name, url, type, win) {

    var cmsURL = window.location.pathname;      // script URL
    cmsURL = '/fitstream/admin/manage-images/browse';
    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 = "?";
    }

    // block multiple file browser windows
    if (!tinyMCE.selectedInstance.fileBrowserAlreadyOpen) {
        // no file browser window open
        tinyMCE.selectedInstance.fileBrowserAlreadyOpen = true; // but now it will be

        tinyMCE.openWindow({
            file : cmsURL + searchString + "&type=" + type,
            title : "File Browser",
            width : 420,
            height : 400,
            close_previous : "no"
        }, {
            window : win,
            input : field_name,
            resizable : "yes",
            inline : "yes",
            editor_id : tinyMCE.selectedInstance.editorId
        });
    }

    return false;
}


function fsImageBrowser (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. */

    var cmsURL = window.location.toString();    // script URL - use an absolute path!
    var cmsURL = '/fitstream/admin/manage-images/browse';
    if (cmsURL.indexOf("?") < 0) {
        //add the type as the only query parameter
        cmsURL = cmsURL + "?type=" + type;
    }
    else {
        //add the type as an additional query parameter
        // (PHP session ID is now included if there is one at all)
        cmsURL = cmsURL + "&type=" + type;
    }

    tinyMCE.activeEditor.windowManager.open({
        file : cmsURL,
        title : 'Image Browser',
        width : 800,  // Your dimensions may differ - toy around with them!
        height : 600,
        resizable : "yes",
        inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous : "no"
    }, {
        window : win,
        input : field_name
    });
    return false;
  }

  
  function fileBrowserCallBack(field_name, url, type, win)
  { 
  	browserField = field_name; 
  	browserWin = win; 
  	window.open("/filebrowser.php", "browserWindow", "modal,width=600,height=400"); 
  } 
  
  
  function selectURL(url) 
  {
  	field = window.top.opener.browserWin.document.forms[0].elements[window.top.opener.browserField];
  	//alert('field:' + field.name);
  	field.value = url; 
  	if (field.onchange != null)
  		 field.onchange(); 
  	window.top.close(); 
  	window.top.opener.browserWin.focus(); 
  }