﻿

    //
    //  FILE BROWSER
    //

        tinyMCE_GZ.init({
        plugins: "safari,save,advlink,advimage,paste,inlinepopups,media,noneditable,table,contextmenu",
            themes: 'simple,advanced',
            languages: 'en',
            disk_cache: false,
            debug: false
        });

        tinyMCE.init({

	            // General options
	            mode: "specific_textareas",
	            theme: "advanced",
    	        editor_selector : "mceEditor",
    	        plugins: "safari,save,advlink,advimage,paste,inlinepopups,media,noneditable,table,contextmenu",

	            // Theme options
    	        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,formatselect,|,bullist,numlist,|,link,unlink,anchor,|,justifyleft,justifycenter,justifyright,justifyfull,|,table,image,media,|,removeformat,code",
	            theme_advanced_buttons2: "",
	            theme_advanced_buttons3: "",
	            theme_advanced_buttons4: "",
	            theme_advanced_toolbar_location: "top",
	            theme_advanced_toolbar_align: "left",
	            theme_advanced_resizing: true,
        	    theme_advanced_blockformats : "p,h1,h2,h3",
                custom_elements : "~macro",
                extended_valid_elements : "macro[*]",
                relative_urls : false,

	            // Example word content CSS (should be your site CSS) this one removes paragraph margins
	            content_css: "/_admin/_media/styles/editor.css",

	            // Drop lists for link/image/media/template dialogs
	           // external_link_list_url: "/_admin/_media/scripts/ajax/pages.aspx",
	            //external_docs_list_url: "/_admin/_media/scripts/ajax/documents.aspx",
	           // external_image_list_url: "/_admin/_media/scripts/ajax/images.aspx",
	          //  media_external_list_url: "/_admin/_media/scripts/ajax/media.aspx",
                //usercontrol_external_list_url: "/_admin/_media/scripts/ajax/controls.aspx",

                //  custom file browser
                file_browser_callback: 'loadFileBrowser'

	    });

	//
	//  FILE BROWSER
	//

	    function loadFileBrowser(field_name, url, type, win) {

	        // alert("Field_Name: " + field_name + "\nURL: " + url + "\nType: " + type + "\nWin: " + win); // debug/testing

	        var cmsURL = '/_admin/_media/scripts/ajax/browser.aspx';    // 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: 'Site Browser',
	            width: 300,
	            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;
	    }

