var urlobj;

function BrowseServer(form,el)
{
	urlobj = document.forms[form].elements[el];
	
	OpenServerBrowser(
		'http://www.cravingsmaternityandbaby.com/tiny_mce/filemanager/browser.html?Type=Image&Connector=connectors/php/connector.php',
		screen.width * 0.7,
		screen.height * 0.7 ) ;
}

function OpenServerBrowser( url, width, height )
{
	var iLeft = (screen.width  - width) / 2 ;
	var iTop  = (screen.height - height) / 2 ;

	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
	sOptions += ",width=" + width ;
	sOptions += ",height=" + height ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	var oWindow = window.open( url, "BrowseWindow", sOptions ) ;
}

function SetUrl( url, width, height, alt )
{
	url = url.substr(3);
	urlobj.value = url ;
	oWindow = null;
}



function fileBrowserCallBack(field_name, url, type, win) {
		var connector = "http://www.cravingsmaternityandbaby.com/tiny_mce/filemanager/browser.html?Connector=connectors/php/connector.php";
		var enableAutoTypeSelection = true;
		
		var cType;
		tinyfck_field = field_name;
		tinyfck = win;
		
		switch (type) {
			case "image":
				cType = "Image";
				break;
			case "flash":
				cType = "Flash";
				break;
			case "file":
				cType = "File";
				break;
		}
		
		if (enableAutoTypeSelection && cType) {
			connector += "&Type=" + cType;
		}
		
		window.open(connector, "tinyfck", "modal,width=600,height=400");
	}
    


var tinyMCE_attributes = 
    {
	    language: 'en',
        mode : "textareas",
        theme : "advanced",
        convert_urls : false,
        relative_urls : true,
	   plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",        
        theme_advanced_buttons1_add : ",hr,charmap,pastetext,pasteword,styleselect",
        theme_advanced_buttons2_add : ",cut,copy,paste,table,sub,sup,preview",
	   theme_advanced_buttons3: "",
        theme_advanced_disable: "help,visualaid,sub,sup,separator", 

        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "center",
		theme_advanced_blockformats : "p,div,h1,h2,h3,h4,h5,h6",

        
        extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],a[name|href|target|title|onclick|rel],div[class|style|]",
        file_browser_callback : "fileBrowserCallBack",
	   
	   content_css: "../css/textstyles.css,../css/style.css",

        paste_use_dialog : false,
        remove_script_host : false,
        theme_advanced_resizing : true,
        theme_advanced_resize_horizontal : true,
        apply_source_formatting : false,
        force_br_newlines : true, 
        force_p_newlines : false,
        height : 450,
	   width: 590
    }
    
   tinyMCE.init( tinyMCE_attributes );
/*    
    function loadFCK() {
	var oFCKeditor = new FCKeditor( 'body' ) ;
	oFCKeditor.BasePath = "../editor/" ;
	oFCKeditor.ToolbarSet = 'cravings1' ;
	if ( document.getElementById( 'body' ) ) oFCKeditor.ReplaceTextarea() ;
    }
window.onload = function() { loadFCK(); }

*/