var Today = new Date();
var Weekdays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var Months = new Array("January", "February", "March", "April", "May", "June", 
			"July", "August", "September", "October", "November", "December");
var MonthsAbbrev = new Array("Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.");			

function TodaySpot() {
	var thisWeekday = Weekdays[Today.getDay()];
	var thisMonth = Months[Today.getMonth()];
	var thisDay = Today.getDate();	
	var thisYear = Today.getFullYear();
	var Temp = "<b>Pittsburgh, PA</b><br>" + thisWeekday + "<br>";
	Temp += thisMonth + " " + thisDay + ", " + thisYear;
	
	return Temp;
}

function TodaySpotWide() {
	var thisWeekday = Weekdays[Today.getDay()];
	//var thisMonth = Months[Today.getMonth()];
	var thisMonth = MonthsAbbrev[Today.getMonth()];
	var thisDay = Today.getDate();	
	var thisYear = Today.getFullYear();				

	var Temp = "<a href=\"http://www.post-gazette.com\"><img src=\"http://www.post-gazette.com/includes/images/topthingroot.gif\"";
	Temp += " alt=\"post-gazette.com\" border=0></a><br>";
	Temp += "<span style=\"font: 12px Arial\">&nbsp;<b>Pittsburgh, Pa.</b> " + thisWeekday + ", ";
	Temp += thisMonth + " " + thisDay + ", " + thisYear + "</span>";
	
	return Temp;
}

function TodaySpotWider() {
	var thisWeekday = Weekdays[Today.getDay()];
	//var thisMonth = Months[Today.getMonth()];
	var thisMonth = MonthsAbbrev[Today.getMonth()];
	var thisDay = Today.getDate();	
	var thisYear = Today.getFullYear();				

	var Temp = "<font face=\"Arial\" size=2>";
	Temp += "<b>Pittsburgh, Pa.</b><br>";
	Temp += thisWeekday + ", " + thisMonth + " " + thisDay + ", " + thisYear;
	Temp += "<br><br></font>";
	
	return Temp;
}

function AdTag(dartSite, dartPage, dartSize) {
	// var dartSeed = Math.floor(Math.random() * 10e8);	
	var dartNum = DartRandom();
	
	var Tag = "<a href=http://ad.doubleclick.net/jump/" + dartSite + "/" + dartPage + ";sz=" + dartSize + ";ord=" + dartNum + "?>";
	Tag = Tag + "<img src=http://ad.doubleclick.net/ad/" + dartSite + "/" + dartPage + ";sz=" + dartSize + ";ord=" + dartNum + "? border=0></a>";
	return Tag;
}

function DartRandom() {
	var dartSeed = Math.floor(Math.random() * 10e8);	
	return (dartSeed.toString());
}

function MakePFLink() {
	var thisPage = escape(document.URL);
	
	//var output = "<font face=\"Arial\" size=2>";
	//output += "<a href=\"/storymailer.asp?story=" + thisPage + "\" target=\"_img\" ";
	//output += "onClick=\"window.open('/storymailer.asp?story=" + thisPage + "',";
	//output += "'_img','sizable=0,width=430,height=425');return true;\">E-mail this story&nbsp;<img src=";
	//output += "\"/includes/images/25x19email.gif\" alt=\"E-mail this story\" border=0 align=\"absmiddle\">";
	//output += "</a>&nbsp;";
	//output += "<a href=\"/printer.asp?story=" + thisPage + "\">Print this story&nbsp;";
	//output += "<img src=\"/includes/images/25x19printer.gif\" alt=\"Printer-friendly page\" border=0 ";
	//output += "align=\"absmiddle\"></a></font>";
	
	var output = "<font face=\"Arial\" size=2>";
	output += "<a href=\"/storymailer2.asp?story=" + thisPage + "\">E-mail this story&nbsp;";
	output += "<img src=\"/includes/images/25x19email.gif\" alt=\"E-mail this story\" border=0 align=\"absmiddle\">";
	output += "</a>&nbsp;";
	output += "<a href=\"/printer.asp?story=" + thisPage + "\">Print this story&nbsp;";
	output += "<img src=\"/includes/images/25x19printer.gif\" alt=\"Printer-friendly page\" border=0 ";
	output += "align=\"absmiddle\"></a></font><br><br>";
	
	return output;
}

function MakeOnlyPFLink() {
	var thisPage = escape(document.URL);
	
	var output = "<font face=\"Arial\" size=2>";
	output += "<a href=\"/printer.asp?story=" + thisPage + "\">Print this story&nbsp;";
	output += "<img src=\"/includes/images/25x19printer.gif\" alt=\"Printer-friendly page\" border=0 ";
	output += "align=\"absmiddle\"></a></font><br><br>";
	
	return output;
}

function NoDFPAdTag() {
	// rotates non-DFP ads.
	var Imgs = new Array(	"120x240businessnews.gif", 
							"120x240health.gif", 
							"120x240weather.gif",
							"120x240hssports.gif");
							
	var URLs = new Array(	"http://www.post-gazette.com/businessnews", 
							"http://www.post-gazette.com/healthscience", 
							"http://www.post-gazette.com/weather", 
							"http://www.post-gazette.com/highschoolsports");
							
	var ImgDir = "http://www.post-gazette.com/includes/images/";
	
	var adCount = Imgs.length;
	var i = Math.floor(Math.random() * adCount);

	return ("<a href=" + URLs[i] + "><img border=0 vspace=1 src=" + ImgDir + Imgs[i] + "></a>");
}

function RightRailAdTag(dartSite, dartPage, dartSize) {
	// var dartSeed = Math.floor(Math.random() * 10e8);	
	var dartNum = DartRandom();
	
	var Tag = "<a href=http://ad.doubleclick.net/jump/" + dartSite + "/" + dartPage + ";sz=" + dartSize + ";ord=" + dartNum + "?>";
	Tag = Tag + "<img src=http://ad.doubleclick.net/ad/" + dartSite + "/" + dartPage + ";sz=" + dartSize + ";ord=" + dartNum + "? border=0 vspace=1></a>";
	return Tag;
}

function getDirectory(someURL) {
	// Returns only the directory name from within a URL.
	// It also handles directories that are nested, like sports/golf.
	var temp = someURL.split("/");		// split the URL on the slashes.
	var num = temp.length;
	var retVal = "";
	
	// If the array contains less than four elements, the URL is pointing
	// to a file that is sitting directly on the root of the site.  Thus, 
	// we return nothing.
	// http://www.post-gazette.com/sports/golf/default.asp
	// ------ -------------------- -----  ---- -----------
	//   0  1         2              3      4     5
	if(num > 3) {
		for(var i = 3; i < num - 1; i++) {
			retVal += temp[i];
			if(i < num - 2)
				retVal += "/";
		}					
	}								
	
	return retVal;
}

function getFilename(someURL) {
	// Returns only the file name from within a URL.
	var temp = someURL.split("/");		// split the URL on the slashes.
	var num = temp.length;
	var retval = "";
	
	// Get the last item in the array.  It will be the file name.
	if(num > 2)
		retVal = temp[num - 1];				
	
	// Test for the existence of a query string, and remove it.
	if(retVal.indexOf("?") != -1)
		retVal = retVal.substring(0, retVal.indexOf("?"));
	
	return retVal;
}

