// displayDate and displayYear functions
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Lee Underwood :: http://javascript.internet.com/ */

function displayDate() {
  var now = new Date();
  var today = now.getDate();
  var month = now.getMonth();
    var monthName = new Array(12)
      monthName[0]="January ";
      monthName[1]="February ";
      monthName[2]="March ";
      monthName[3]="April ";
      monthName[4]="May ";
      monthName[5]="June ";
      monthName[6]="July ";
      monthName[7]="August ";
      monthName[8]="September ";
      monthName[9]="October ";
      monthName[10]="November ";
      monthName[11]="December ";
  var year = now.getFullYear();

  document.write(monthName[month]+today+ ", "+year);
}


function displayYear() {
  var now = new Date();
  var today = now.getDate();
  var year = now.getFullYear();

  document.write(year);
}


// emailStory function
function htmlEncodeString (inputString)
{
  return escape(inputString);
}

function emailStory(sendStoryURL,winName) {	
	//grabs the URL of the story page
	storyToSendURL = document.location.href;
	
	// grabs the title of the story page and converts all the chars to ascii
	storyTitle = htmlEncodeString(document.title);
		
	// concatenates all the info into one string
	var newLink = sendStoryURL +'?' + storyToSendURL + '&' + storyTitle;
	
	
	// dims of the "Email to a friend" popup window
	var winWidth = 450;
	var winHeight = 325;
	
	// this will center the popup window relative to the screen size
	var winLeft = (screen.width - winWidth) / 2; 
	var winUp = (screen.height - winHeight) / 2; 
	
	// a new window opens and the string is passed to the page
	window.open(newLink, winName, 'top='+ winUp +',left='+ winLeft +',Width=' + winWidth + ',height='+ winHeight+'\'');

}


// breadcrumb function -need to change starting path in 2 places - sURL.indexOf("/xxxx/")
function breadcrumbs(){
  sURL = new String;
  bits = new Object;
  var x = 0;
  var stop = 0;
  var output = "";
  sURL = location.href;
  sURL = sURL.slice(8,sURL.length);
  chunkStart = sURL.indexOf("/");
  sURL = sURL.slice(chunkStart+1,sURL.length)
  while(!stop){
    chunkStart = sURL.indexOf("/");
    if (chunkStart != -1){
      bits[x] = sURL.slice(0,chunkStart)
      sURL = sURL.slice(chunkStart+1,sURL.length);
    }else{
      stop = 1;
    }
    x++;
  }
  for(var i in bits){
    output += "<a href=\"";
    for(y=1;y<x-i;y++){
      output += "../";
    }


// replaces underscore with space, replace starting path in bits[i] == 'xxxx' 
	var noUnderscore = bits[i];
	noUnderscore = noUnderscore.replace(/_/g, " ");
	
	if (bits[i] == '')  {
	output += bits[i] + "/\">"  + "Home</a>  >  ";
	} else
	output += bits[i] + "/\">" + noUnderscore + "</a>  >  ";

}


//var str = output;
//document.write(str.replace(/_/gi, " ") + document.title);


document.write(output + document.title);


}

