// VARIABLES
var obj = null;

// JQUERY
$(document).ready(function() {
				   
	$(".mainMenu:even ul").hide();
	
	$(".mainMenu:even > li").hover(function() {
		if (obj) {
			obj.find('ul').fadeOut('fast');
			obj = null;
		}
		
		$(this).toggleClass("hover");
		$(this).find('ul').fadeIn('fast');
		
	}, function() {
		$(this).toggleClass("hover");
		obj = $(this);
		setTimeout(
		"checkHover()",
		0);
	});
	
	
	$('textarea').tinymce({
		// Location of TinyMCE script
		script_url : 'scripts/tiny_mce/tiny_mce.js',
		height: 400,
		width : 635,
		language : "fr",
		
		// General options
		theme : "advanced",
		plugins : "style,table,advhr,advimage,advlink,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,spellchecker",
		
		spellchecker_languages : "+Francais=fr",


		// Theme options
		theme_advanced_buttons1 : "undo,redo,|,cut,copy,paste,pastetext,pasteword,|,cleanup,code",
		theme_advanced_buttons2 : "formatselect,fontselect,fontsizeselect,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull",
		theme_advanced_buttons3 : "bold,italic,underline,strikethrough,|,sub,sup,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,|,charmap,iespell,media,image",
		theme_advanced_buttons4 : "tablecontrols,|,hr,removeformat,visualaid,|,spellchecker",

		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		//theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,


		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",
		
		file_browser_callback : tinyBrowser
		
		// Drop lists for link/image/media/template dialogs
		//template_external_list_url : "lists/template_list.js",
		//external_link_list_url : "lists/link_list.js",
		//external_image_list_url : "lists/image_list.js",
		//media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		//template_replace_values : {
		//	username : "Some User",
		//	staffid : "991234"
		//}
	});
	
	function ajaxfilemanager(field_name, url, type, win) {
		var ajaxfilemanagerurl = "../../../../scripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php";
		switch (type) {
			case "image":
				break;
			case "media":
				break;
			case "flash": 
				break;
			case "file":
				break;
			default:
				return false;
		}
		tinyMCE.activeEditor.windowManager.open({
			url: "../../../../scripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php",
			width: 500,
			height: 400,
			inline : "yes",
			close_previous : "no"
		},{
			window : win,
			input : field_name
		});
		
		/*            return false;			
		var fileBrowserWindow = new Array();
		fileBrowserWindow["file"] = ajaxfilemanagerurl;
		fileBrowserWindow["title"] = "Ajax File Manager";
		fileBrowserWindow["width"] = "782";
		fileBrowserWindow["height"] = "440";
		fileBrowserWindow["close_previous"] = "no";
		tinyMCE.openWindow(fileBrowserWindow, {
		  window : win,
		  input : field_name,
		  resizable : "yes",
		  inline : "yes",
		  editor_id : tinyMCE.getWindowArg("editor_id")
		});
		
		return false;*/
	}
	
});

// FONCTIONS
function checkHover() {
	if (obj) {
		obj.find('ul').fadeOut('fast');
	} //if
}
