// JavaScript Document

function getTodaysDate ()
{
	var this_weekday_name_array = new Array ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
	var this_month_name_array 	= new Array ("Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec.");

	var this_date_timestamp		= new Date ();			//get current day-time stamp

	var this_weekday = this_date_timestamp.getDay ();	//extract weekday
	var this_date = this_date_timestamp.getDate ();		//extract day of month
	var this_month = this_date_timestamp.getMonth ();	//extract month
	var this_year = this_date_timestamp.getYear ();		//extract year

	if (this_year < 1000)	this_year+= 1900;			//fix Y2K problem

	var this_date_string = this_month_name_array[this_month] + " " + this_date + ", " + this_year;
	
	return this_date_string;
}
function getTodaysDay ()
{
	var this_date_timestamp		= new Date ();			//get current day-time stamp
	var this_date = this_date_timestamp.getDate ();		//extract day of month
	if (this_date < 10)	this_date = '0' + this_date;
	return this_date;
}
function getTodaysMonth ()
{
	var this_date_timestamp		= new Date ();			//get current day-time stamp
	var this_month = this_date_timestamp.getMonth ();	//extract month
	this_month++;
	if (this_month < 10)	this_month = '0' + this_month;
	return this_month;
}
function getTodaysYear ()
{
	var this_date_timestamp		= new Date ();			//get current day-time stamp
	var this_year = this_date_timestamp.getYear ();		//extract year
	if (this_year < 1000)	this_year+= 1900;			//fix Y2K problem
	return this_year;
}
function tocActiveLink()
{
	var currentPath = location.pathname;
	
	var reg = new RegExp(/\d\d/);
	var results = currentPath.match(reg);
	var currentSection;
	if(results != null && results.length > 0)
	{ currentSection = results[0]; }
	else
	{ currentSection = "00"; }

	// Next line not supported in IE 6 (strange?)
	//document.links['sl' + currentSection].className = 'toc-link-active';
    document.getElementById('sl' + currentSection).className = 'toc-link-active';
	document.images['si' + currentSection].src = '/images/bullet_arrows.gif';
}
function tocLinkOver(linkSection)
{
	var currentPath = location.pathname;
	
	var reg = new RegExp(/\d\d/);
	var results = currentPath.match(reg);
	var currentSection;
	if(results != null && results.length > 0)
	{ currentSection = results[0]; }
	else
	{ currentSection = "00"; }
	
	if (linkSection != currentSection)
	{
	  document.images['si' + linkSection].src = '/images/bullet_arrows.gif';
	}
}
function tocLinkOut(linkSection)
{
	var currentPath = location.pathname;
	
	var reg = new RegExp(/\d\d/);
	var results = currentPath.match(reg);
	var currentSection;
	if(results != null && results.length > 0)
	{ currentSection = results[0]; }
	else
	{ currentSection = "00"; }
	
	if (linkSection != currentSection)
	{
	  document.images['si' + linkSection].src = '/images/pixel.gif';
	}
}
function printPage() 
{
	window.print();  
}
function getGoogleMaps()
{
	//http://www.google.com/maps?q=from%3A+21+rockwren+irvine,+ca+92604+to%3A+1113+N+Spurgeon+St,+Santa+Ana,+CA+92701&f=d&hl=en
	//http://maps.google.com/maps?q=1113+N.+Spurgeon+St,+Santa+Ana,+CA+92701&spn=0.017050,0.031148&iwloc=A&hl=en
	if (document.googleMaps.from.value.length < 3)
	{
		document.googleMaps.q.value = document.googleMaps.to.value;	
	}
	else
	{
		document.googleMaps.q.value = 'from: ' + document.googleMaps.from.value + ' to: ' + document.googleMaps.to.value;
	}
}
function openDirections()
{
	window.open('directions.html','directionsWindow','location=0,status=0,menubar=0,scrollbars=1,resize=1,width=570,height=750');  
}
function submitFormToNewWindow(form)
{ 	
  var xSize = 300;
  var ySize = 100;

  var w = window.open('','submitWindow','location=0,status=0,menubar=0,scrollbars=1,resize=1,width=' + xSize + ',height=' + ySize);
  form.target = "submitWindow";
  //  form.submit();  //doesn't work for some reason?  works without it?
  w.focus(); 
  
  var xRes = screen.width;
  var yRes = screen.height;
  
  var xLoc = Math.round((xRes/2)-(xSize/2));
  var yLoc = Math.round((yRes/2)-(ySize/2));
  
  w.moveTo(xLoc,yLoc);
}
