var lastDate = new Date();

function changeDate(currentDate) 
	{
	if (currentDate != lastDate)
		{
		lastDate = currentDate;
		document.writeln("<p class='date'>"+lastDate+"</p>");
		}
	}

function power30_parse1(headline)
	{
	var head = headline.split(".");
	document.write(head[0]);
	}

function power30_parse2(headline)
	{
	var head = headline.split(".");
	name = head[1];
	document.write(name.substr(1));
	}

function subheadTest(subheader) 
	{
	if (subheader != "")
		{
		document.writeln("<h4>"+subheader+"</h4>");
		}
	}

function bylineTest(byline) 
	{
	if (byline != " ")
		{
		document.writeln("<br />"+byline+"<p>");
		}
	}

function bylineBracket(byline) 
	{
	if (byline != " ")
		{
		if (byline.charAt(0) == " ")
			{ byline = byline.slice(1); }
		byline = byline.toLowerCase();
		var byname = byline.split(" ");
		i = 0;
		document.write("(");
		for (i=0;i<byname.length;i++) 
			{
			var cap = byname[i].charAt(0);
			var rest = byname[i].slice(1);
			cap = cap.toUpperCase();
			document.write(cap+rest+" ");
			}
		document.write(")");
		}
	}

function bylineParse(byline) 
	{
	if (byline != " ")
		{
		if (byline.charAt(0) == " ")
			{ byline = byline.slice(1); }
		var byname = byline.split(" ");
		i = 0;
		span = 0;
		for (i=0;i<byname.length;i++) 
			{
			if (byname[i] == "By" ) 
				{
				document.write("By: ");
				} 
			else if (byname[i] == "and") 
				{
				document.write("</span>and ");
				span = 0;
				}
			else if (span == 0) 
				{
				document.write("<span>"+byname[i]+" ");
				span = 1;
				} 
			else 
				{
				document.write(byname[i]+" ");
				}
			}
		document.write("</span>");
		}
	}

function openWin(url,name,options)  
	{
	win = window.open(url,name,options);
	self.name = "main";
	win.focus();
	}

function fixedPath(form)
	{
	var i=0;
	for(i=0;i<form.section_path.length;i++) {
		if(form.section_path.options[i].selected) 
			{
			form.sf_dwb_section_path.value = form.sf_dwb_section_path.value + ' or ' + form.section_path.options[i].value ;
			if (form.sf_dwb_section_path.value.substring(0,4) == ' or ') 
				{
				form.sf_dwb_section_path.value = form.sf_dwb_section_path.value.substring(4,10000);
				}
			if (form.sf_dwb_section_path.value.substring(0,-4) == ' or ') 
				{
				form.sf_dwb_section_path.value = form.sf_dwb_section_path.value.substring(form.sf_dwb_section_path.value.length -4,form.sf_dwb_section_path.value);
				}
			}
		}
	}

function convertOrigPubDate(origPubDate)
	{
	if (origPubDate != "")
		{
		var now = new Date();
		var nowmonth = now.getMonth()+1;
		if (nowmonth < 10) { nowmonth = "0"+nowmonth; }
		var nowday = now.getDate();
		if (nowday < 10) { nowday = "0"+nowday; }
		var nowyear = String(now.getFullYear());
		nowyear = nowyear.substr(2);
		nowdate = " "+nowmonth+"/"+nowday+"/"+nowyear;

		var d = new Date(origPubDate);
		var month = d.getMonth()+1;
		if (month < 10) { month = "0"+month; }
		var day = d.getDate();
		if (day < 10) { day = "0"+day; }
		var year = String(d.getFullYear());
		year = year.substr(2);
		newdate = " "+month+"/"+day+"/"+year;
		
		if (newdate != nowdate) { document.write(newdate); }
		}
	}

