function OpenFileBrowser( url )
{
	var winwidth = 600;
	var winheight = 450;
	var iLeft = ( screen.width  - winwidth ) / 2 ;
	var iTop  = ( screen.height - winheight ) / 2 ;

	var sOptions = "toolbar=no,status=no,resizable=no,dependent=yes,scrollbars=1,location=no,menubar=no,directories=no,personalbar=no" ;
	sOptions += ",width=" + winwidth ;
	sOptions += ",height=" + winheight ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	window.open( url, 'FileBrowserWindow', sOptions ) ;
}

function SetUrl(fileurl,imagename,imgname,ffield,fname) 
{
 	document.getElementById(imgname).src = fileurl ;
 	document.getElementById(ffield).value = imagename ;
}

function mycallback() { 
}

function myerror() { 
}

function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

function togglerow(id,cbox) {
 if(document.getElementById(id).className == 'menu_row_over2') {
 	document.getElementById(id).className = 'menu_row_over';
	document.getElementById(cbox).checked = true;
 }
 else {
  	document.getElementById(id).className = 'menu_row_over2';
	document.getElementById(cbox).checked = false;
 }
}

function rowhoverin(id) {
 if(document.getElementById(id).className == 'menu_row_over') {
 	document.getElementById(id).className = 'menu_row_over';
 }
 else {
  	document.getElementById(id).className = 'menu_row_over2';
 }
}

function rowhoverout(id) {
 if(document.getElementById(id).className == 'menu_row_over') {
 	document.getElementById(id).className = 'menu_row_over';
 }
 else {
  	document.getElementById(id).className = 'menu_row';
 }
}

function resizeall() {
var NS = (navigator.appName=="Netscape")?true:false; 
iWidth = (NS)?window.innerWidth:document.body.clientWidth; 
iHeight = (NS)?window.innerHeight:document.body.clientHeight; 
mainwidth = iWidth - 100;
document.getElementById('main_div').style.width = mainwidth + 'px';
}

function delayer(pageurl){
    window.location = pageurl;
}


/*TinyMCE integration (file browser) */
function myFileBrowser (field_name, url, type, win) {

// alert("Field_Name: " + field_name + "nURL: " + url + "nType: " + type + "nWin: " + win); // debug/testing

var cmsURL = '/admin/dialogs/filebrowser/browse.cfm';    // 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 : 'Browser',
	width : 850,  // Your dimensions may differ - toy around with them!
	height : 650,
	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;
}

var FileBrowserDialogue = {
    init : function () {
        // Here goes your code for setting your custom things onLoad.
    },
    getlink : function (imgurl) {
        var URL = imgurl;
        var win = tinyMCEPopup.getWindowArg("window");

        // insert information now
        win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = URL;

        // are we an image browser
        if (typeof(win.ImageDialog) != "undefined") {
            // we are, so update image dimensions...
            if (win.ImageDialog.getImageData)
                win.ImageDialog.getImageData();

            // ... and preview if necessary
            if (win.ImageDialog.showPreviewImage)
                win.ImageDialog.showPreviewImage(URL);
        }

        // close popup window
        tinyMCEPopup.close();
    }
}
/*End TinyMCE Integration */
