//
// javascript support routines
//

// output date  
function writedate(d) { 
    if(!d) d = new Date(); 
    var monthName = d.getMonth() + 1; 
    var dayName = d.getDay() + 1; 
    var dayNumber = d.getDate(); 
    if(dayName==1) Day = "sunday"; 
    if(dayName==2) Day = "monday"; 
    if(dayName==3) Day = "tuesday"; 
    if(dayName==4) Day = "wednesday"; 
    if(dayName==5) Day = "thursday"; 
    if(dayName==6) Day = "friday"; 
    if(dayName==7) Day = "saturday"; 
    if(monthName==1) Month="january"; 
    if(monthName==2) Month="february"; 
    if(monthName==3) Month="march"; 
    if(monthName==4) Month="april"; 
    if(monthName==5) Month="may"; 
    if(monthName==6) Month="june"; 
    if(monthName==7) Month="july"; 
    if(monthName==8) Month="august"; 
    if(monthName==9) Month="september"; 
    if(monthName==10) Month="october"; 
    if(monthName==11) Month="november"; 
    if(monthName==12) Month="december"; 
    var yearNumber = d.getYear(); 
    if(yearNumber < 100) yearNumber += 1900; 
    window.document.write( Day + ", " + dayNumber + " " + Month + " " + yearNumber); 
} 
 
// output last modified 
function writelastmod() { 
    var d = new Date(document.lastModified); 
    writedate(d); 
    if(d.getHours() < 10) 
        window.document.write(" at 0" + d.getHours() + ":"); 
    else 
        window.document.write(" at " + d.getHours() + ":"); 
    if(d.getMinutes() < 10) 
        window.document.write("0" + d.getMinutes()); 
    else 
        window.document.write(d.getMinutes()); 
}  

// open external link popup window
function ext_link_popup(sourcelink, sourcename, wwide, whigh, xpos, ypos) {
    xlwname = sourcename;
    xlwlink = sourcelink;
    xlww = wwide;
    xlwh = whigh;
    xlwx = xpos;
    xlwy = ypos;
    xlw = window.open(xlwlink, xlwname, "toolbar=yes,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no,width=" + xlww + ",height=" + xlwh + ",left=" + xlwx + ",top=" + xlwy);
    if(xlw) {
        xlw.focus();
    }
}

// open external link popup window
function ext_link_popup_notoolbar(sourcelink, sourcename, wwide, whigh, xpos, ypos) {
    xlwname = sourcename;
    xlwlink = sourcelink;
    xlww = wwide;
    xlwh = whigh;
    xlwx = xpos;
    xlwy = ypos;
    xlw = window.open(xlwlink, xlwname, "toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=no,menubar=no,width=" + xlww + ",height=" + xlwh + ",left=" + xlwx + ",top=" + xlwy);
    if(xlw) {
        xlw.focus();
    }
}

// open external link popup window
function blog_popup(sourcelink, sourcename) {
    xlwname = sourcename;
    xlwlink = sourcelink;
    xlw = window.open(xlwlink, xlwname, "toolbar=yes,location=yes,directories=yes,status=yes,resizable=yes,scrollbars=yes,menubar=yes");
    if(xlw) {
        xlw.focus();
    }
}

// open image popup window - auto-size window
function image_popup_auto(imagesource, imagetitle, imagewindowname, aix, aiy) {
    aiwx = aix+30;
    aiwy = aiy+60
    aiw = window.open("", imagewindowname, "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=" + aiwx + ",height=" + aiwy);
    if(aiw) {
        aiw.document.close();
        aiw.document.writeln('<html><head>');
        aiw.document.writeln('<title>Barry James Moore | ' + imagetitle + '</title></head>');
        aiw.document.writeln('<body bgcolor="#ffffff" text="#000000">');
        aiw.document.writeln('<div align="center">');
        aiw.document.writeln('<img border="1" width="' + aix + '" height="' + aiy + '" src="' + imagesource + '">');
        aiw.document.writeln('<font face="arial" size="2">');
        aiw.document.writeln('<br>' + imagetitle + '');
        aiw.document.writeln('<br><a href="javascript:self.close();")>Close</a>');
        aiw.document.writeln('</font>');
        aiw.document.writeln('</div>');
        aiw.document.writeln('</body></html>');
        aiw.focus();
    }
}

// open image popup window - auto-size window
function image_popup_resize(imagesource, imagetitle, imagewindowname, aix, aiy) {
    aiwx = aix+30;
    aiwy = aiy+60
    aiw = window.open("", imagewindowname, "toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no,width=" + aiwx + ",height=" + aiwy);
    if(aiw) {
        aiw.document.close();
        aiw.document.writeln('<html><head>');
        aiw.document.writeln('<title>Barry James Moore | ' + imagetitle + '</title></head>');
        aiw.document.writeln('<body bgcolor="#ffffff" text="#000000">');
        aiw.document.writeln('<div align="center">');
        aiw.document.writeln('<img border="1" width="' + aix + '" height="' + aiy + '" src="' + imagesource + '">');
        aiw.document.writeln('<font face="arial" size="2">');
        aiw.document.writeln('<br>' + imagetitle + '');
        aiw.document.writeln('<br><a href="javascript:self.close();")>Close</a>');
        aiw.document.writeln('</font>');
        aiw.document.writeln('</div>');
        aiw.document.writeln('</body></html>');
        aiw.focus();
    }
}

// open external imageviewer window
var done=false;
function launchViewer(filename,x,y)
 { 
 if (!done)
 {
  window.imagex=x;
  window.imagey=y;
  window.imagename=filename;
  viewer=window.open("imageviewframes.htm", "bjmimageviewer", "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes");
  viewer.opener=window;
  viewer.focus();
 }
 return done;
 }

// open image popup window - fixed-size window
function image_popup(imagesource, imagetitle) {
    iw = window.open("", "bjmimage", "toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,menubar=no,width=640,height=540");
    if(iw) {
        iw.document.close();
        iw.document.writeln('<html><head>');
        iw.document.writeln('<title>Barry James Moore | ' + imagetitle + '</title></head>');
        iw.document.writeln('<body bgcolor="#ffffff" text="#000000">');
        iw.document.writeln('<table width="100%" height="100%"><tr><td align="center" valign="middle">');
        iw.document.writeln('<div align="center">');
        iw.document.writeln('<img border="1" src="' + imagesource + '">');
        iw.document.writeln('<font face="arial" size="2">');
        iw.document.writeln('<br>' + imagetitle + '');
        iw.document.writeln('<br><a href="javascript:self.close();")>Close</a>');
        iw.document.writeln('</font>');
        iw.document.writeln('</div>');
        iw.document.writeln('</td></tr></table>');
        iw.document.writeln('</body></html>');
        iw.focus();
    }
}

// display status string  
function displaystatus(string) { 
    //window.status = text; 
    window.setTimeout("window.status='" + string + "'", 1);  // for ie5.0 bug 
}

// get a dom element by its id
function getElement(id) {
  if(document.all != null)
    return document.all[id];
  else if(document.layers != null)
    return document.layers[id];
  else if(document.getElementById)
    return document.getElementById(id);
}

// name the window
function bjmooreWindowLoad() {
  top.name="bj-moore";
}
