windowStyle = null;

function openPostANote(){
    if (!windowStyle) 
        windowStyle = addStyleToDOM('/css/test.css');
    postAnoteWindow = new windowCreator('postAnote', 'modules/postAnote.html','loadPostANoteEditor()');
}
var myEditor = {}
function attachWinDragObj() {
	alert('test');
}
function loadPostANoteEditor() {
		var Dom = YAHOO.util.Dom, 
        Event = YAHOO.util.Event; 
	   var myConfig = { 
	            height: '200px', 
	            width: '650px', 
	            dompath: true, 
	            focusAtStart: true,
				toolbar: { 
			        collapse: true,
					titlebar: 'Sage Computing Editor',
					buttonType: 'advanced',
					buttons: [
					    { group: 'fontstyle', label: 'Font Name and Size',
					        buttons: [
					            { type: 'select', label: 'Arial', value: 'fontname', 
					                menu: [
					                    { text: 'Arial', checked: true },
					                    { text: 'Arial Black' },
					                    { text: 'Comic Sans MS' },
					                    { text: 'Courier New' },
					                    { text: 'Lucida Console' },
					                    { text: 'Tahoma' },
					                    { text: 'Times New Roman' },
					                    { text: 'Trebuchet MS' },
					                    { text: 'Verdana' }
					                ]
					            },
					            { type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ] }
					        ]
					    },
					    { type: 'separator' },
					    { group: 'textstyle', label: 'Font Style',
					        buttons: [
					            { type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' },
					            { type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' },
					            { type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' },
					            { type: 'separator' },
					            { type: 'push', label: 'Subscript', value: 'subscript' },
					            { type: 'push', label: 'Superscript', value: 'superscript' },
					            { type: 'separator' },
					            { type: 'color', label: 'Font Color', value: 'forecolor' },
					            { type: 'color', label: 'Background Color', value: 'backcolor' },
					            { type: 'separator' },
					            { type: 'push', label: 'Remove Formatting', value: 'removeformat' },
					            { type: 'push', label: 'Show/Hide Hidden Elements', value: 'hiddenelements' }
					        ]
					    },
					    { type: 'separator' },
					    { group: 'alignment', label: 'Alignment',
					        buttons: [
					            { type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' },
					            { type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' },
					            { type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' },
					            { type: 'push', label: 'Justify', value: 'justifyfull' }
					        ]
					    },
					    { type: 'separator' },
					    { group: 'parastyle', label: 'Paragraph Style',
					        buttons: [
					        { type: 'select', label: 'Normal', value: 'heading', 
					            menu: [
					                { text: 'Normal', value: 'none', checked: true },
					                { text: 'Header 1', value: 'h1' },
					                { text: 'Header 2', value: 'h2' },
					                { text: 'Header 3', value: 'h3' },
					                { text: 'Header 4', value: 'h4' },
					                { text: 'Header 5', value: 'h5' },
					                { text: 'Header 6', value: 'h6' }
					            ]
					        }
					        ]
					    },
					    { type: 'separator' },
					    { group: 'indentlist', label: 'Lists',
					        buttons: [
					            { type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },
					            { type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' }
					        ]
					    },
					    { type: 'separator' },
					    { group: 'insertitem', label: 'Insert Item',
					        buttons: [
					            { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink' },
					            { type: 'push', label: 'Insert Image', value: 'insertimage' }
					        ]
					    }
					]
		
			    }  
	        }; 
	 
	    //Now let's load the SimpleEditor.. 
	    myEditor = new YAHOO.widget.Editor('postAnoteEditor', myConfig); 
		myEditor.on('toolbarLoaded', function() { 
				objEditorTool = new YAHOO.util.DD('postAnoteEditor-panel');
				objEditorTool.setOuterHandleElId('body_postAnote');
		})
	    myEditor.render(); 
}
function postAnoteSubmit() {
	myEditor.saveHTML(); 
    //The var html will now have the contents of the textarea 
	f = document.postAnote;
	txtName = urlEncodeCustom(f.txtName.value);
	txtEmail = urlEncodeCustom(f.txtEmail.value);
	txtSubject = urlEncodeCustom(f.txtSubject.value);
	tarNote = myEditor.get('element').value; 
	loadURL = '/modules/postAnote.html?txtName='+txtName+'&txtEmail='+txtEmail+'&txtSubject='+txtSubject+'&tarNote='+tarNote;
	loadXMLDoc(loadURL);
	if(postAnoteWindow) postAnoteWindow.closeBox.closeContainer();
}
function urlEncodeCustom(parseString) {
	parseString = parseString.replace(/%/g,'%25');
	parseString = parseString.replace(/&/g,'%26');
	parseString = parseString.replace(/#/g,'%23');
	parseString = parseString.replace(/\s/g,'%20');
	parseString = parseString.replace(/'/g,'%27');
	parseString = parseString.replace(/"/g,'%22');
	parseString = parseString.replace(/!/g,'%21');
	parseString = parseString.replace(/\t/g,'%09');
	parseString = parseString.replace(/\?/g,'%3f');
	return parseString;
}