// From MurkyGoth's Bumper Book of JavaScript Goodies
// Use it if you want to, but you have to email me and let me know
// Mail: murkygoth (at) murkygoth.co.uk
//
function writeEmail(user,domain,clickable) {
  if ( clickable == 1 ) {
    document.write( "<a href='mailto:" + user + "@" + domain + "'>" );
  }
  document.write( user + "@" + domain );
  if ( clickable == 1 ) {
    document.write( "</a>" );
  }
}

function write_header() {
  buttons = new Array;
  buttons[0] = "faq";
  buttons[1] = "features";
  buttons[2] = "recent";
  buttons[3] = "nightlife";
  buttons[4] = "weather";
  buttons[5] = "WMGA";
  buttons[6] = "links";
  buttons[7] = "join";
  buttons[8] = "gallery";
  buttons[9] = "exam";
  buttons[10] = "seti";
  buttons[11] = "memberslogin";

  document.write("<table width='100%' border='0'>");
  document.write("<tr><td width='150'>");
  document.write("<a href='http://www.brumgoth.org.uk/index.html'><img src='http://www.brumgoth.org.uk/images/brumgothlogo.jpg'");
  document.write(" width='150' height='88' alt='BrumGoth Logo'></a>");
  document.write("<td>");
  for ( i=0; i<12; i++ ) {
    if ( i==3 || i==4 || i>5 ) {
      if ( i==4 ) {
        document.write("<a href='http://www.met-office.gov.uk/weather/europe/uk/cities/birmingham.html'");
      };
      if ( i == 6 ) {
        document.write("<a href='http://www.brumgoth.org.uk/cgi-bin/links.pl'");
      };
      if ( i == 3 ) {
        document.write("<a href='http://www.brumgoth.org.uk/nightlife/'");
      };
      if ( i == 7 ) {
        document.write("<a href='http://www.groups.yahoo.com/group/BrumGoth'");
      };
      if ( i == 8 ) {
        document.write("<a href='http://www.brumgoth.org.uk/cgi-bin/gallery.pl'");
      };
      if ( i == 9 ) {
        document.write("<a href='http://www.brumgoth.org.uk/cgi-bin/entry_exam.pl'");
      };
      if ( i == 10 ) {
        document.write("<a href='http://www.brumgoth.org.uk/seti.shtml'");
      };
      if ( i == 11 ) {
        document.write("<a href='http://www.brumgoth.org.uk/cgi-bin/members.pl'");
      };
    } else {
        document.write("<a href='http://www.brumgoth.org.uk/" + buttons[i] + ".shtml'");      
    };
//    document.write( "onMouseOut=\"document.images['b"+i+"'].src='http://www.brumgoth.org.uk/images/");
//    document.write( buttons[i]+".gif'\"" );
//    document.write(" onMouseOver=\"document.images['b"+i+"'].src='http://www.brumgoth.org.uk/images/");
//    document.write( buttons[i]+"_rollover.gif'\">" );
    document.write( ">" );

    document.write("<img src='http://www.brumgoth.org.uk/images/buttons/" + buttons[i] + ".gif' name='b"+i+"' ");
    document.write("alt='[ " + buttons[i] + " ]' width='105' height='15'>");
    document.write("</a> ");
  };
  document.write("</td></tr></table>");
};

function write_footer() {
  document.write("<hr><p style='text-align:center'>");
  document.write("<a href='javascript:history.back()'><img src='http://www.brumgoth.org.uk/images/back.gif'" );
  document.write("width='80' height='90' border='0'></a><br>");
  document.write("<a href='mailto:bex@brumgoth.org.uk'>bex@brumgoth.org.uk</a>");
  document.write("<br>Problem with the site? Mail " );
  document.write("<a href='mailto:murkygoth@brumgoth.org.uk'>murkygoth@brumgoth.org.uk</a>");
};



// (c) Richard Wallman <r_wallman@yahoo.co.uk> 2000. No unauthorised copying.
function check_date(day,month,year) {
  if ( day > 31 || day < 1 || month > 12 || month < 1 || (day>29 && month==2)) {
    alert ("Err..exactly *what* calender are you using!" );
    return 1;
  }

  // Check February
  if (day > 28 && month == 2 ) {
    // Make sure it's not a leap year!
    if (year % 4 != 0) {
      alert( "There aren't " + day + " days in that particular February!" );
      return 1;
    } else {
	// Check the centuries
	if ( year % 100 == 0 && year % 400 != 0 ) {
	  alert( "There aren't " + day + " days in that particular February!" );
	  return 1;
 	};
    };
  };

  // Check the months with 30 days
  if ( day > 30 && (month == 9 || month==4 || month==6 || month==11 ) ) {
    alert( "There isn't " + day + " days in that month!" );
    return 1;
  };

  // All must be fine
  return 0;
};


// Gallery script
function writeGallery( title, basename, tbasename, count ) {
  document.write("<table border='1'>");
  document.write("<tr><td class='cent' colspan='4'><h1>"+title+"</h1>");
  document.write("</td></tr><tr>");
  for ( i = 1; i < count; i++ ) {
    document.write( "<td class='cent'><a href='javascript:showImage(\"" );
    document.write( basename );
    if ( i < 10 )
      document.write( "0" );
    document.write( i );
    document.write( ".jpg\")'><img src='" );
    document.write( tbasename );
    if ( i < 10 )
      document.write( "0" );
    document.write( i );
    document.write(".jpg' alt='picture' /></a></td>" );
    if ( (i % 4) == 0 )
      document.write("</tr><tr>" );
  };
  document.write("</tr></table>");
};
