var jsDOM0 = (document.all);
var jsDOM1 = (document.getElementById);
var jsDOM = jsDOM0 || jsDOM1;

function getObj (name) {
    if (typeof name == "object") return name;
    if (jsDOM1) return document.getElementById(name);
    if (jsDOM0) return eval('document.all.'+name);
    else return null;
}

function getObjCSSProp(obj,prop) {
    var x;
    if (obj.style) x=eval("obj.style."+prop); else x=null;
    return x;
}

function setObjCSSProp(obj,prop,val) {
    var x=eval("obj.style."+prop+"='"+val+"'");
    return obj;
}

function getObjDisplayed(obj) {
    var x = getObjCSSProp(obj,'display'); x=(x!='none');
    return x;
}

function setObjDisplayed(obj,show) {
    return setObjCSSProp(obj,'display',(show)?'block':'none');
}



function OnOffObj(name) {
    if (name) {
        var obj = getObj (name);
        submenus = obj.getElementsByTagName("ul")
        for (var i = 0; i<submenus.length; i++) {
            x = getObjDisplayed(submenus[i]);
            y = (x == true ? 0 : 1);
//             hideAllBut(name);
            setObjDisplayed(submenus[i],y);
        }
    }
}

function vd(v)
{
	if (typeof v == 'object')
	{
		var p = Array();
		for (id in v)
		{
			p[p.length] = id+' : '+v[id];
		}
		if (p.length && p.length > 2)
			return "{\n"+p.join(",\n")+ "\n }";
		else if (p.length)
			return "{ "+p.join(",")+ " }";
		else return '{ }';

		return s;
	}
	return v;
}

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. */

    var cmsURL = fbURL;    // script URL - use an absolute path!
    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 : 'My File Browser',
        width : 720,  // Your dimensions may differ - toy around with them!
        height : 400,
        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;
  }


