// FILE: published.js
// GOAL: To identify current publishing attributes
// WHO:  Bradley Roberts


// Set the following attributes for each edition in turn:
// Update these as appropriate with each publishing of the site
var copyright_year = "2009";
var current_edition = "3";
var as_of_date = "03/03/2009";
var webmaster_name = "Webmaster";
var webmaster_id = "webmaster";
var webmaster_domain = "bradley.roberts.net";
var staff_name = "Bradley Roberts";
var staff_id = "Bradley";
var staff_domain = "Roberts.net";

// The following sets the minimum date to show for the next meeting of the Partnership
var next_date = "Sep 18, 2009"; 	// Next birthday

// The following is for count down timing for the next major event
var next_major_event = "Fri, 18 Sep 2009 08:30:00 EDT";  // Launch

// The following functions use the information above to display 
// various items on a page. You should not have to change these.

//////////////////////////////////////////////////////////////////
// FUNCTION: show_copyright()
// GOAL:     To show the copyright notice on a particular page
// EG:       © 2007 by Bradley Roberts
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              show_copyright();
//              // End --></script>
//////////////////////////////////////////////////////////////////
function show_copyright()
{
    document.write('&copy;&nbsp;' + copyright_year + ' by <b>Bradley Roberts</b>');
}


//////////////////////////////////////////////////////////////////
// FUNCTION: show_volume()
// GOAL:     To show the volume number on the page
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              show_volume();
//              // End -->
//              </script>
//////////////////////////////////////////////////////////////////
function show_volume()
{
    document.write(copyright_year);
}


//////////////////////////////////////////////////////////////////
// FUNCTION: show_edition()
// GOAL:     To show the edition on the page
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              show_edition();
//              // End --></script>
//////////////////////////////////////////////////////////////////
function show_edition()
{
    document.write(current_edition);
}


//////////////////////////////////////////////////////////////////
// FUNCTION: get_email(subject)
// GOAL:     To generate an eMail link as appropriate. This helps 
//           combat SPAM by encapsulating the actual mailto link.
// EG:       webmaster@DarbyConsulting.net
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//               get_email("Need Info, Please");
//               // End --></script>
//////////////////////////////////////////////////////////////////
function get_email(subject)
{
    document.write('<a href=\"mailto:' + webmaster_id + '@' + webmaster_domain + '?subject='+subject+ '\">'); 
    document.write('<font face="Arial, Helvetica, sans-serif">' + webmaster_name + '</font></a>');
}


//////////////////////////////////////////////////////////////////
// FUNCTION: link_email(name, subject)
// GOAL:     To generate an eMail link as appropriate. This helps 
//           combat SPAM by encapsulating the actual mailto link.
// EG:       staff_member@domain
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//               link_email("Info", "Need Info, Please");
//               // End --></script>
//////////////////////////////////////////////////////////////////
function link_email(name, subject)
{
    document.write('<a href=\"mailto:' + staff_id + '@' + staff_domain + '?subject='+subject+ '\">'); 
    document.write('<font face="Arial, Helvetica, sans-serif">' + name + '</font></a>');
}


//////////////////////////////////////////////////////////////////
// FUNCTION: get_staff_email(subject)
// GOAL:     To generate an eMail href link as appropriate. This helps 
//           combat SPAM by encapsulating the actual mailto link.
// EG:       staff_id@DarbyConsulting.net
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//               get_staff_email("Need Info, Please");
//               // End --></script>
//////////////////////////////////////////////////////////////////
function get_staff_email(subject)
{
    document.write('<a href=\"mailto:' + staff_id + '@' + staff_domain + '?subject='+subject+ '\">' + staff_name + '</a>');
}


//////////////////////////////////////////////////////////////////
// FUNCTION: get_yellow_email(subject)
// GOAL:     To generate an eMail link as appropriate. This helps 
//           combat SPAM by encapsulating the actual mailto link.
// EG:       name@DarbyConsulting.net
// USE:      Just call this as follows where needed:
//               <script><!-- Hidden from some browsers
//               get_yellow_email("Need Info, Please");
//               // End --></script>
//////////////////////////////////////////////////////////////////
function get_yellow_email(subject)
{
    document.write('<a href=\"mailto:' + webmaster_id + '@' + webmaster_domain + '?subject='+subject+ '\">');
	document.write('<img src="images/email_address_blue.gif" alt="electronic mail address" height="26" width="180" border="0"></a>');
}


//////////////////////////////////////////////////////////////////
// FUNCTION: get_link_email(subject, btn)
// GOAL:     To generate an eMail href link as appropriate. This helps 
//           combat SPAM by encapsulating the actual mailto link.
// EG:       staff_id@DarbyConsulting.net
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//               get_link_email("Need Info, Please", "event_btn.jpg");
//               // End --></script>
//////////////////////////////////////////////////////////////////
function get_link_email(subject, img)
{
    document.write('<a href=\"mailto:' + staff_id + '@' + webmaster_domain + '?subject='+subject+ '\">');
	document.write('<img src=\"images/' + img + '\" alt=\"eMail to \"' + staff_name + '\" width=\"67\" height=\"70\"/>');
	 
}


//////////////////////////////////////////////////////////////////
// FUNCTION: last_update()
// GOAL:     To show the last time this site was updated
// EG:       "Last updated on 06/15/2007"
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              last_update();
//              // End --></script>
//////////////////////////////////////////////////////////////////
function last_update()
{
    document.write('Last updated on ' + as_of_date + ' ');
}


//////////////////////////////////////////////////////////////////
// FUNCTION: next_meeting()
// GOAL:     To show the next date the Partnership meets - variable
// EG:       "June 14, 2007"
//           Partnership meetings are typically held on the 2nd Thursday of the Month
//           Specify next_date forward to skip dates
// NOTE:     =FIRST-WEEKDAY(FIRST,3)+10+IF(WEEKDAY(FIRST,3)>3,7,0)
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              next_meeting();
//              // End --></script>
//////////////////////////////////////////////////////////////////
function next_meeting()
{
  	now = new Date();
	ahead = new Date(next_date);
	if (now < ahead)
	{
		now = ahead;
	}

  	first = new Date(now.getFullYear(), now.getMonth(), 1);
	dow = first.getDay();	// 0=SU, 1=MO, 2=TU, 3=WE, 4=TH, 5=FR, 6=SA
	dom = first.getDate();
	mth = first.getMonth();
	yr  = first.getFullYear();
	thur = new Date(yr, mth, 12-dow);
	if (dow > 4) 
	{
		thur = new Date(yr, mth, 19-dow);;
	}

	// Now determine if we have missed the meeting
	if (now.getDate() > thur.getDate()) 
	{
		mth = mth + 1;
		if (mth > 11) 
		{
			mth = 0; // Jan
			yr += 1;
		}
		nxtmth = new Date(yr, mth, 1);
		dow = nxtmth.getDay();
		thur = new Date(yr, mth, 12-dow);
		if (dow > 4) 
		{
			thur = new Date(yr, mth, 19-dow);;
		}
	}

	document.write(" "+ thur.toLocaleDateString());   

}


//////////////////////////////////////////////////////////////////
// FUNCTION: setNewDeliveryTimeAgain()
// GOAL:     To set the time this site will be delivered
// EG:       "Last updated on 08/15/2004. Contact the _Webmaster_
//           with any corrections."
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              setNewDeliveryTimeAgain();
//              // End --></script>
//////////////////////////////////////////////////////////////////
function setNewDeliveryTimeAgain()
{   // Called by setNewDeliveryTimeAgain
  setDeliveryTime();
}



//////////////////////////////////////////////////////////////////
// FUNCTION: setDeliveryTime()
// GOAL:     To show the time this site will be delivered
// EG:       "Last updated on 08/15/2004. Contact the _Webmaster_
//           with any corrections."
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              setDeliveryTime();
//              // End --></script>
//////////////////////////////////////////////////////////////////
function setDeliveryTime()
{
  now = new Date();
  launch = Date.parse(next_major_event);
  timeNow = now.getTime();

  if ( (launch - timeNow) >= 0)
  {
	  timeLeft = launch - timeNow;
  }

  else
  {
  	  timeLeft = timeNow - launch;
  }

  days = parseInt(timeLeft / 86400000);
  if (isNaN(days))
  {
	  days = 0;
  }

  timeLeft = parseInt(timeLeft % 86400000);
  hours = parseInt(timeLeft / 3600000);
  timeLeft = parseInt(timeLeft % 3600000);
  mins = parseInt(timeLeft / 60000);
  timeLeft = parseInt(timeLeft % 60000);
  secs = parseInt(timeLeft / 1000);
  d1 = parseInt(days / 10);

  if ( isNaN(d1))
	  d1 = 0;
  d2 = parseInt(days % 10);

  if ( isNaN(d2))
	  d2 = 0;
  h1 = parseInt(hours / 10);

  if ( isNaN(h1))
	  h1 = 0;
  h2 = parseInt(hours % 10);

  if ( isNaN(h2))
	  h2 = 0;
  m1 = parseInt(mins / 10);

  if ( isNaN(m1))
	  m1 = 0;
  m2 = parseInt(mins % 10);

  if ( isNaN(m2))
	  m2 = 0;
  s1 = parseInt(secs / 10);

  if ( isNaN(s1))
	  s1 = 0;
  s2 = parseInt(secs % 10);

  if ( isNaN(s2))
	  s2 = 0;

  document.timeForm.deliveryTime.value="  "+days+" Days "+h1+h2+" hrs "+m1+m2+" mins "+s1+s2+" secs";
  setTimeout("setNewDeliveryTimeAgain()", 950);
  return;
}


//////////////////////////////////////////////////////////////////
// FUNCTION: email_popup()
// GOAL:     To popup an eMail window
// EG:       © 2007 Darby Consulting
// USE:      Just call this as follows where needed:
//              <script language="javascript" type="text/javascript"><!-- Hidden from some browsers
//              email_popup(email_url);
//              // End --></script>
//////////////////////////////////////////////////////////////////
function email_popup(email_url) 
{
		window.open(email_url, "_blank", "width=500,height=500,toolbar=0,menubar=0,location=0,resizable=0,scrollbars=1,status=0");
}

// End of functions


