function Obj(Id) { return document.getElementById(Id); }
function Trim(s) {
    s = s.replace(/\s+/g,"\n");
    s = s.replace(/^\n|\n$/g,"");
    return s;
}
function PopUp (URL,width,height,opts) {
    if(URL.match(/ /)) {
	var text = URL;
	return Help(text,width,height);
    }
    winName = "PopUp"+Math.floor(10000*Math.random());
    NewWin (URL,winName,width,height,opts);
}
function NewWin (URL,winname,width,height,opts) {
    if(width  == null || width  == 0) { width  = 500 }
    if(height == null || height == 0) { height = .6*width }
    if(opts   == null ) { opts   = "" }
    if(opts   == "all") { opts = "status=1,location=1,navigation=1,toolbar=1" }
    if(opts   != ""   ) { opts   = "," + opts }
    win = window.open (
	    URL, winname,
	    "width=" + width + ",height=" + height +
	    ",scrollbars,menubar,resizable" + opts );
    win.creator = window;
    WinFocus(win);
}
function WinFocus(win) {
    // assume win.focus works, unless broken old MS browser
    if ( (navigator.appName.search (/^microsoft/i) == -1) ||
         (navigator.appName == "Microsoft Internet Explorer" &&
          navigator.appVersion.indexOf("Windows", 0) != -1   &&
          navigator.appVersion.substring(0,1) >= 4) ) {
		win.focus()
    }
}
function TimeStamp() {
    Date = " " + document.lastModified;
    Date = Date.replace(/([A-Z][a-z]{2})[a-z]*/g,"$1");
    Date = Date.replace(/:\d\d($|[^\d:])/g,"$1");
    Date = Date.replace(/\//g," / ");
    Date = Date.replace(/ 0/g," ");
    Date = Date.replace(/ ([0-9]+:)/,",&nbsp $1");
    document.write("<nobr>Last updated: " + Date + "</nobr>\n");
}
function Help(content,width,height) {
    if(width  == null) { width  = "500" }
    if(height == null) { height = .6*width }
    winName = "Help"+Math.floor(10000*Math.random());
    hwin = window.open (
	    "", winName,
	    "scrollbars,menubar,resizable," +
	    "width=" + width + ",height=" + height );
    doc = hwin.document;
    doc.writeln('<HTML>\n<HEAD>\n<TITLE>Help</TITLE>');
    doc.writeln('<style>');
    doc.writeln('td, .td, p, .p, pp, .pp {');
    doc.writeln('margin-bottom:0.0001pt; margin-top:3.0pt;');
    doc.writeln('font-family:arial,sans-serif;font-size:9.0pt; }');
    doc.writeln('b9, .b9 {');
    doc.writeln('font-family:arial,sans-serif;font-size:9.0pt;');
    doc.writeln('font-weight:bold; }');
    doc.writeln('</style>');
    doc.writeln('</HEAD>');
    doc.writeln('<BODY BGCOLOR="#EFE7D0" CLASS=pp><FORM>\n');
    doc.writeln(content);
    doc.writeln('\n<HR><CENTER><SPAN class=b9>');
    doc.writeln('<INPUT TYPE=button ONCLICK="window.close()" VALUE="&nbsp;ok&nbsp;" class=b9>');
    doc.writeln('</SPAN></CENTER></FORM>\n</BODY>\n</HTML>\n');
    doc.close();
    WinFocus(hwin);
}


// Yu-Yun added these two functions to be used when online editor is invoked

function filename_and_IE_alert(thisForm){
  if (thisForm.saveas.value == ""){
    alert('Please enter a file name for the new page!');
    return(false);
  }
  else {return check_isIE55()};
}

function check_isIE55(){
  var version = parseFloat(navigator.appVersion);
  var isMS = navigator.appName.indexOf("Microsoft")
  var version_strg = navigator.appVersion;
  var temp = (version_strg .split(";"))[1];
  version =  parseFloat(temp.replace(/MSIE/gi, ""));
  if (isMS != -1 && version >= 5.5){
     return(true);
  }
  else {
     Help('<center>Sorry, you must be using Internet Explorer 5.5 (or higher) '+
          'as your browser to edit this page!<hr>You can download and '+
	  'install IE 5.5 from the Microsoft website at '+
          '<a href="http://windowsupdate.microsoft.com" target=_blank>'+
          'http://windowsupdate.microsoft.com</a><p>');
     return(false);
  }
}

