App.UI = {
	
	hasInit : false,
	
	_preinit : function(){
		
		if (this.hasInit) return;
		this.hasInit = true;
		
		$('#hpmenu li').live('mouseenter mouseleave', function(oEvent){ App.UI.ContentMenu.HPMenu(oEvent); });
	},
	
	redirect : function(type, link) {
		switch(type) {
			case 'direct':
				window.location = link;
			break;
			
			case 'timeout':
				setTimeout(function(){ window.location = link; }, '3000');
			break;
			
			case 'internal':{
				App.Core.Nav.changeMenu(link);
				break;
			}
			
			default:
				return;
			break;
		}		
	}
	
};

App.UI.ContentMenu = {
	
	HPMenu : function(oEvent){
		
		var element = oEvent.currentTarget;
		
		switch(oEvent.type){
			
			case 'mouseenter':{
				$('.overlay', element).fadeOut('50');
				break;
			}
			
			case 'mouseleave':{
				$('.overlay', element).fadeIn('50');
				break;
			}
		}
			
	}
	
};

App.UI.Tiny = {
	
	__setup: function(){
		var oTextarea = $('#content_body').find('textarea.tinymce');
		if (oTextarea.length > 0){
			var oArgs = {};
			oArgs.change = false;
			
			for(var i=0; i < oTextarea.length; i++ ){
				oArgs.id = $(oTextarea[i]).attr('id');
				App.UI.Tiny.__executeTiny(oArgs);
			}
		}
	},
	
	__executeTiny :function(oArgs) {
				
		if((oArgs == null) || (oArgs == 'undefined')) var oArgs = {};
		
		if((oArgs.theme == null) || (oArgs.theme == 'undefined')){
			oArgs.btn1 = '"|,bold,italic,underline,|,bullist,numlist,|,forecolor,|,link,unlink,|"';
			oArgs.btn2 = '';
			oArgs.btn3 = '';
			oArgs.btn4 = '';
			oArgs.plugins = '';
			
		}
		
		var onChange;
		if((oArgs.change == null) ||(oArgs.change == 'undefined')){
			onChange = '';
		} else {
			onChange = oArgs.change;
		}
		
		$('#'+ oArgs.id).tinymce({
			
			// Location of TinyMCE script
			script_url : '/js/tiny_mce/tiny_mce.js',
			
			// General options
			mode : 'none',
			theme : 'advanced',
			plugins : oArgs.plugins,
	//		force_br_newlines : true,
	//		force_p_newlines : false,
	//		forced_root_block : '',

			onchange_callback : onChange,
			
			// Theme options
			
			theme_advanced_buttons1 : oArgs.btn1,
			theme_advanced_buttons2 : oArgs.btn2,
			theme_advanced_buttons3 : oArgs.btn3,
			theme_advanced_buttons4 : oArgs.btn4,
						
			theme_advanced_toolbar_location : 'top',
			theme_advanced_toolbar_align : 'left',
			theme_advanced_statusbar_location : '',
			theme_advanced_resizing : false,

			// Example content CSS (should be your site CSS)
			content_css : '/css/type.css',

			// 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 : 'CreativeUrbans',
				staffid : '11213'
			}
		});
		
	}
	
};


$(document).ready(function(){
	
	App.UI._preinit();
	
});

