var rightCaret = String.fromCharCode (62);
var coordx = (screen.availWidth-600)/2;
var coordy = (screen.availHeight-450)/2;

function openWin(url) {
	if(navigator.appName == "Netscape") {
		myWin = window.open(url, "s", "width=600,height=450,screenX="+coordx+",screenY="+coordy+",status=1,resizeable=no,scrollbars=yes");
	} else {
		myWin = window.open(url, "s", "width=600,height=450,left="+coordx+",top="+coordy+",status=1,resizeable=no,scrollbars=yes");
	}
}

function go_go(){
	openWin('');
	myWin.document.close()
	myWin.document.write('<html>');
	myWin.document.write('<head>');
	myWin.document.write('<title>PRD (ENGLISH) WEBSITE MANAGEMENT SYSTEM</title>');
	myWin.document.write('<meta http-equiv="Content-Type" content="text/html; charset=windows-874">');
	myWin.document.write('<LINK href="style.css" rel=stylesheet  type=text/css>');
	myWin.document.write('</head>');
	myWin.document.write('<body bgcolor="#99CCFF" leftmargin="0" topmargin="0"><br>');
	myWin.document.write('<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">');
	myWin.document.write('<tr><td>');
	myWin.document.write(this.document.AddEditForm.desc_text.value);
	myWin.document.write('</td></tr>');
	myWin.document.write('</table>');
	myWin.document.write('</body>');
	myWin.document.write('</html>');
	myWin.focus();

}

function go_go2(v){
	openWin('');
	myWin.document.close()
	myWin.document.write('<html>');
	myWin.document.write('<head>');
	myWin.document.write('<title>PRD (ENGLISH) WEBSITE MANAGEMENT SYSTEM</title>');
	myWin.document.write('<meta http-equiv="Content-Type" content="text/html; charset=windows-874">');
	myWin.document.write('<LINK href="style.css" rel=stylesheet  type=text/css>');
	myWin.document.write('</head>');
	myWin.document.write('<body bgcolor="#99CCFF" leftmargin="0" topmargin="0"><br>');
	myWin.document.write('<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">');
	myWin.document.write('<tr><td>');
	myWin.document.write(v);
	myWin.document.write('</td></tr>');
	myWin.document.write('</table>');
	myWin.document.write('</body>');
	myWin.document.write('</html>');
	myWin.focus();

}

function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function pick(tagName) {
        if (tagName == "")
                return (false);

        var selectionRange;
        selectionRange = getSelectionRange ();

        if (selectionRange != null) {

                var currentText;
                currentText = selectionRange.text;

                var preText, postText;
                preText = "";
                postText = "<" + tagName + rightCaret;

                replaceText (selectionRange, preText, postText, currentText);
		        }
}

function isEditable (selectionRange) {

        //Return true if the selection is in an editable part of the page -- in the textarea.

        if (selectionRange.parentElement ().tagName == "TEXTAREA")
                return (true);

        return (false);
        } //isEditable


function getSelectionRange () {

        //Get a reference to the current selection range.
        //If there is no selection range, or it's not in a textarea, return null.

        var selectionRange;
        selectionRange = document.selection.createRange ();

        if (isEditable (selectionRange)) {

                var currentText = selectionRange.text;
                if (currentText != "")
                        return (selectionRange);
                }

        return (null);
        } //getSelectionRange


function highlightButton (buttonRef) {

        //Highlight the button only if there is currently editable text.

        var selectionRange;
        selectionRange = getSelectionRange ();

        if (selectionRange == null) {

                buttonRef.style.cursor = "default";
                return (false);
                }

        buttonRef.style.color = "blue";
        //buttonRef.style.cursor = "hand";

        buttonRef.style.cursor = "default";

        return (true);
        } //highlightButton


function unHighlightButton (buttonRef) {

        //Unhighlight a button.

        buttonRef.style.color = "black";

        return (true);
        } //unHighlightButton


function urlPrompt () {

        //Prompt the user via dialog box for a URL.

        var url;
        url = prompt ("URL:", "");
        return (url);
        } //urlPrompt


function replaceText (selectionRange, preText, postText, currentText) {

        //Enclose the selected text with preText and postText.

        selectionRange.text = preText + currentText + postText;

        selectionRange.parentElement ().focus ();
        } //replaceText


function simpleEnclose (tagName) {

        //Enclose selected text with a tag and closing tag.

        if (tagName == "")
                return (false);

        var selectionRange;
        selectionRange = getSelectionRange ();

        if (selectionRange != null) {

                var currentText;
                currentText = selectionRange.text;

                var preText, postText;
                preText = "<" + tagName + rightCaret;
                postText = "</" + tagName + rightCaret;

                replaceText (selectionRange, preText, postText, currentText);
                }
        } //simpleEnclose

function addFontColor (colorName) {

        //Enclose the selected text with a font tag that specifies the color

        if (colorName == "")
                return (false);

        var selectionRange;
        selectionRange = getSelectionRange ();

        if (selectionRange != null) {

                var currentText;
                currentText = selectionRange.text;

                var preText, postText;
                preText = "<font color=\"" + colorName + "\"" + rightCaret;
                postText = "</font" + rightCaret;

                replaceText (selectionRange, preText, postText, currentText);
                }
        } //addFontColor

function addAlignment (alignment) {

        //Enclose the selected text with a font tag that specifies the color

        if (alignment == "")
                return (false);

        var selectionRange;
        selectionRange = getSelectionRange ();

        if (selectionRange != null) {

                var currentText;
                currentText = selectionRange.text;

                var preText, postText;
                preText = "<p align=\"" + alignment + "\"" + rightCaret;
                postText = "</p" + rightCaret + "\r\n";

                replaceText (selectionRange, preText, postText, currentText);
                }
        } //addAlignment


function addLink () {

        //Prompt the user for a URL and make the selection a link.

        var selectionRange;
        selectionRange = getSelectionRange ();

        if (selectionRange != null) {

                var currentText;
                currentText = selectionRange.text;

                var url;
                url = urlPrompt ();

                if ((url == "") || (url == "http://") || (url == null))
                        return;

                var preText, postText;
                preText = "<a target = \"_blank\" href=\"" + url + "\"" + rightCaret;
                postText = "</a" + rightCaret;

                replaceText (selectionRange, preText, postText, currentText);
                }
         }
