//
// format date as dd-mmm-yy
// example: 12-Jan-99
//
function date_ddmmmyy(date)
{
  var d = date.getDate();
  var m = date.getMonth() + 1;
  var y = date.getYear();

  // handle different year values 
  // returned by IE and NS in 
  // the year 2000.
  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }

  // could use splitString() here 
  // but the following method is 
  // more compatible
  var mmm = 
    ( 1==m)?'January':( 2==m)?'February':(3==m)?'March':
    ( 4==m)?'April':( 5==m)?'May':(6==m)?'June':
    ( 7==m)?'July':( 8==m)?'August':(9==m)?'September':
    (10==m)?'October':(11==m)?'November':'December';

  return "" +
    (d<10?"0"+d:d) + " " +
    mmm + ", " +
    (y<10?"200"+y:y);
}


//
// get last modified date of the 
// current document.
//
function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = "" + date_ddmmmyy(new Date(d1));
  }

  return s;
}

function generate_address(department) {

	var username = "";
	var hostname = "squalorsurvivors";
        var domain = ".com";
        var atsign = "&#64;";
        if (typeof(department) == "undefined") {
        username = "pigpen";
        }
        else
        {
        username = department;
        }
        var addr = username + atsign + hostname + domain;
        document.write( 
          "<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" +
          addr +
          "<\/a>");
      }
  

function generate_copyright(lastmod) {
	var rightnow=new Date();
	var yearend = "2005";
	var copyright = "&copy;"
	document.write("<p>Copyright " + copyright + " 2001 - " + yearend + " Squalor Survivors <br />Unless otherwise noted.</p>");
	document.write("<p>Last updated:  " + lastmod + "</p>" );
	}
	
function randomquote(department) {
	var motivation = new Array();
	motivation[0] = new Array("Anthony Robbins", "People are not lazy. They simply have impotent goals: that is, goals that do not inspire them.") ;
	motivation[1] = new Array("Therese of Lisieux (paraphrase)", "Picking up one piece of paper, but doing it with respect and attention: now that can change your world.") ;
	motivation[2] = new Array("Napoleon", "Take time to deliberate; but when the time for action arrives, stop thinking and go in.") ;
	motivation[3] = new Array("Mark Victor Hansen", "Don't wait until everything is just right. It will never be perfect. There will always be challenges, obstacles and less than perfect conditions. So what? Get started now. With each step you take, you will grow stronger and stronger, more and more skilled, more and more self-confident and more and more successful.") ;
	motivation[4] = new Array("Janis Joplin", "Don't compromise yourself.  You're all you've got.") ;
	motivation[5] = new Array("Helen Keller", "The most pathetic person in the world is someone who has sight, but has no vision.") ;
	motivation[6] = new Array("Dr. Phil McGraw", "Life rewards action.") ;
	motivation[7] = new Array("Buddha", "Your work is to discover your work and then with all your heart to give yourself to it.") ;

	
	var myarray = new Array();
		myarray[0] = new Array("M. Scott Peck", "The truth is that our finest moments are most likely to occur when we are feeling deeply uncomfortable, unhappy, or unfulfilled. For it is only in such moments, propelled by our discomfort, that we are likely to step out of our ruts and start searching for different ways or truer answers.") ;
		myarray[1] = new Array("James Lane Allen", "The outer conditions of a person's life will always be found to reflect their inner beliefs.") ;
		myarray[2] = new Array("Henry Ford", "Whether you think you can or you think you can't you're right.") ;
		myarray[3] = new Array("Anais Nin", "And the day came when the risk it took to remain tight inside the bud was more painful than the risk it took to blossom.") ;
		myarray[4] = new Array("Janis Joplin", "Don't compromise yourself.  You're all you've got.") ;
		myarray[5] = new Array("Theodore Roosevelt", ". . . the best thing you can do is the right thing, the next best thing is the wrong thing, and the worst thing you can do is nothing.") ;
		myarray[6] = new Array("Dr. Phil McGraw", "Life rewards action.") ;
		myarray[7] = new Array("Eleanor Roosevelt", "You gain strength, courage and confidence by every experience in which you really stop to look fear in the face. You are able to say to yourself, 'I lived through this horror. I can take the next thing that comes along.' You must do the thing you think you cannot do.") ;
		myarray[8] = new Array("Ann Landers", "If I were asked to give what I consider the single most useful bit of advice for all humanity it would be this: Expect trouble as an inevitable part of life and when it comes, hold your head high, look it squarely in eye and say, 'I will be bigger than you. You cannot defeat me.'") ;
		myarray[9] = new Array("Helen Keller", "Avoiding danger is no safer in the long run than outright exposure. The fearful are caught as often as the bold.") ;
		myarray[10] = new Array("Joan Didion", "Character - the willingness to accept responsibility for one's own life - is the source from which self-respect springs.") ;
		myarray[11] = new Array("Hesiod", "If you add a little to a little, and then do it again, soon that little shall be much.") ;
		myarray[12] = new Array("Dr. Martin Luther King Jr.", "Take the first step in faith. You don't have to see the whole staircase, just take the first step.") ;
		myarray[13] = new Array("Sogyal Rinpoche", "Although we have been made to believe that if we let go we will end up with nothing, life reveals just the opposite: that letting go is the real path to freedom.") ;
		myarray[14] = new Array("Eleanor Roosevelt", "Remember, no one can make you feel inferior without your consent.") ;
		myarray[15] = new Array("Grace Hansen", "Don't be afraid your life will end; be afraid that it will never begin.") ;
		myarray[16] = new Array("Anne Bradstreet", "If we had no winter, the spring would not be so pleasant; if we did not sometimes taste of adversity, prosperity would not be so welcome.") ;
		myarray[17] = new Array("Trina Paulus", "'How does one become a butterfly?' she asked pensively. 'You must want to fly so much that you are willing to give up being a caterpillar.' ") ;
		myarray[18] = new Array("Kirsti A. Dyer, MD, MS", "Like the butterfly, I have the strength and the hope to believe In time I will emerge from my cocoon... Transformed.") ;
		myarray[19] = new Array("Maya Angelou", "Since time is the one immaterial object which we cannot influence--neither speed up nor slow down, add to nor diminish--it is an imponderably valuable gift.") ;
		myarray[20] = new Array("Horace", "Why do you hasten to remove anything which hurts your eye, while if something affects your soul you postpone the cure until next year?") ;
	myarray[21] = new Array("Sir Winston Churchill", "Sure I am of this, that you have only to endure to conquer. You have only to persevere to save yourselves.") ;
	var randomnumber=Math.floor(Math.random()*22);
        if (department == "motivation") {
	document.write("<blockquote><div>" + motivation[randomnumber][1] + "<p class='quotesource'>" + motivation[randomnumber][0] + "</p></div></blockquote>");
        }
        else
        {
        	document.write("<blockquote style='clear:left'><div >" + myarray[randomnumber][1] + "<strong> ~ " + myarray[randomnumber][0] + "</strong></div></blockquote>");
        }

	}