$(document).ready(function(){ 
		$('#notes.tinymce').tinymce({
				// Location of TinyMCE script
				script_url : '/_inc/tiny_mce/tiny_mce.js',
				// General options
				theme : "advanced",
				plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,inlinepopups,preview,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

				// Theme options 
				theme_advanced_layout_manager : "SimpleLayout",
				theme_advanced_buttons1 :
				"bold,italic,underline,link,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,print", 
				theme_advanced_buttons2 :"",
				theme_advanced_buttons3 :"",   
				theme_advanced_buttons4 :"",   
				theme_advanced_toolbar_location : "top",
				theme_advanced_toolbar_align : "left",
				theme_advanced_statusbar_location : "bottom",
				theme_advanced_resizing : true,

				// Example content CSS (should be your site CSS)
				content_css : "css/content.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 : "Some User",
					staffid : "991234"
				}
			});


$("#notes-email, #notes-send").hide();
     
     $("#notesutil #emailnotes a").click(function(){ 
		 $("#notesform #sermon").val($(".contents h3:first").text());
         $("#notes-email, #notes-send").slideToggle("fast");
     }); 

	/*$("#notesutil #printnotes").click(function(){   
		  var nt = $("#notes").val();
	      window.open('/print.php?notes='+nt,'Print','width=650,height=800');
	}); */
     
       //$("#response").hide();
   
  
       $("#notesform").validate({
				rules: {
				email: {
					required: true,
					email: true
				}
			},
			messages: {
				email: "Please enter a valid email address"
								},
			submitHandler: function(form) {
         				var inputs = [];
                         $("#result").html("<p>Sending Notes...</p>").show();
                         $('#notesform input').each(function(){
                            inputs.push(this.name + '=' + escape(this.value));
                         });
                         inputs.push('notes='+ escape($("#notesform #notes").val()));
                          //console.log($("#notesform #notes").val());
                         jQuery.ajax({
                             data: inputs.join('&'),
							 dataType:"html", 
                             url: "/mailnotes.php",
                             timeout: 3000,
							 
                             error: function(){
                               $('#result').html("<strong>Err: Email Not Set Try Again Later</strong>");   
                             },
                             success: function(r){
                               $("#result").html(r);
                             }
                         });
                         //return false;
					}
		        });
		
	
});