// JavaScript functions to insert common code into web pages.
// (c) RaspberRypple 1999, 2002
// Feel free to use, but please acknowledge and inform author:
//           peter@thehaywards.clara.co.uk



//get system date foredition() and greeting()
var sysDate=new Date();

//write current month/year
function edition() {
    month=sysDate.getMonth();
    if      (month=="0") month = "January"
    else if (month=="1") month = "February"
    else if (month=="2") month = "March"
    else if (month=="3") month = "April"
    else if (month=="4") month = "May"
    else if (month=="5") month = "June"
    else if (month=="6") month = "July"
    else if (month=="7") month = "August"
    else if (month=="8") month = "September"
    else if (month=="9") month = "October"
    else if (month=="10")month = "November"
    else if (month=="11")month = "December"
    else month = "";
    edn=month+" "+sysDate.getFullYear();
    document.write(edn);
}

// write greeting depending on time of day
function greeting() {
    hours=sysDate.getHours()
    if (hours>=1&&hours<=11) //morning
    document.write('Good morning')
    else if (hours>=12&&hours<=17) //afternoon
    document.write('Good afternoon')
    else  //evening
    document.write('Good evening')
}

// write pps email address 
function ppsEmail() {
  document.write("<a href='mailto:ppssteam");
  document.write("@freeola.com?subject=PPS: " );
  edition();
  document.write(" catalogue'>ppssteam");
  document.write("@freeola.com</a>")
}
// write webmaster email address 
function webEmail() {
  document.write("<a href='mailto:webmaster");
  document.write("@pps-steam-models.co.uk?subject=PPS: " );
  edition();
  document.write(" catalogue'>webmaster");
  document.write("@pps-steam-models.co.uk</a>")
}

function showPrevious() {
  if (window.history.length>0)
    document.write("<a href='javascript:history.go(-1)'>Previous</a> |")
}

function infoHeader() {
  document.write("<p align='right'><font size='-1'><b>");
  if (window.history.length>0) {
    document.write("<a href='javascript:history.back()' onFocus='if(this.blur)this.blur()'>&lt;</a> | ");
    document.write("<a href='javascript:history.forward()' onFocus='if(this.blur)this.blur()'>&gt;</a> | ");
  }
document.write("<a href='javascript: self.close(); if(PicWindow!=null)PicWindow.close()' onFocus='if(this.blur)this.blur()'>Close Window</a> | ");
document.write("<a href='javascript:opener.focus()' onFocus='if(this.blur)this.blur()'>Main Window</a></b></font></p>");
}

function infoFooter() {
  infoHeader();
  document.write("<br>");
}

InfoWindow=null;
function info(url) {
InfoWindow=window.open(url,'ppsinfo','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=660,height=550,left=10,top=10');
InfoWindow.focus();
}

PicWindow=null;
function pic(img, title, longtitle) {
if (arguments.length > 5) {
  PicWindow=window.open('', 'ppspic', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=100,top=80');
}
else {
  PicWindow=window.open('', 'ppspic', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=100,top=80');
}
PicWindow.document.close();
doc=PicWindow.document.open();
x=680;
y=610;
if (arguments.length > 4) {
  x=arguments[3]*1 + 80;
  y=arguments[4]*1 +150;
}
else if (arguments.length > 3) {
  if (arguments[3] == "small") {x=480; y=410;}
  else if (arguments[3] == "medium") {x=580; y=510;}
}
doc.write('<script>window.resizeTo('+x+','+y+')</script>');
doc.write('<title>' + title + '</title>');
if (img.indexOf("mss/")>-1 || img.indexOf("pps/")>-1 || img.indexOf("acb/")>-1 || img.indexOf("bits/")>-1|| img.indexOf("blw/")>-1 || img.indexOf("pjm/")>-1 || img.indexOf("jkm/")>-1 || img.indexOf("ndr/")>-1 || img.indexOf("prs/")>-1 || img.indexOf("sch/")>-1 || img.indexOf("act/")>-1 || img.indexOf("acc/")>-1 || img.indexOf("acs/")>-1 || img.indexOf("sah/")>-1 || img.indexOf("ccc/")>-1 || img.indexOf("rhe/")>-1) {
  doc.write('<link rel="StyleSheet" href="pps.css">');
  doc.write('<script language="JavaScript" src="pps.js"></script>');
} else {
  doc.write('<link rel="StyleSheet" href="../pps.css">');
  doc.write('<script language="JavaScript" src="../pps.js"></script>');
}
doc.write('<p align="right"><font size="-1"><b>');
doc.write('<a href="javascript: self.close()" onFocus="if(this.blur)this.blur()">Close Window</a>');
doc.write('</b></font></p>');
doc.write('<p align="center">');
doc.write('<img src="' + img + '"><br>');
doc.write('<span style="font-size:90%;">' + longtitle + '</span></p></html>');
PicWindow.focus();
}

// write dimension as fraction of an inch
//   3 args: 1 2/3"
//   2 args: 1/2"
//   1 args: 1"

function inches() {
  if (arguments.length > 2) {
    if (arguments[0]!=0) document.write(arguments[0]);
    document.write("<font size='-1'><sup>"
                 + arguments[1]
                 + "</sup></font>/<font size='-2'>"
                 + arguments[2]
                 + "</font>");
  }
  else if (arguments.length > 1) {
    document.write("<font size='-1'><sup>"
                 + arguments[0]
                 + "</sup></font>/<font size='-2'>"
                 + arguments[1]
                 + "</font>");
  }
  else { document.write(arguments[0]); }
  if (arguments.length < 4) document.write("\"");
  else { document.write(arguments[3]); }
  
}


