//* *************************************************************
//*																*
//*	NicheCrafters.com Global Script Reference 				    *
//*	Updated: 8/13/02          	                        		*
//*																*
//*	(c) Copyright 1996-2003 by G. Wood.     					*
//*																*
//*	EXTERNAL SCRIPT TYPE='text/javascript'						*
//*	AUTHOR: Human Engineering & Design Department				*
//*	ACCESSIBILITY: 100 [Global]									*
//*																*
//* *************************************************************

// #########################################################################
// MISCELLANEOUS FUNCTIONS
//
// ________________________________________________________________________
// contact() | v2.0 by Accidental Techie | NicheCrafters.com/NicheTech/ | rev. 2/2001

function contact(user,domain) 
{
	// write it
		document.write('<a href=\"mailto:' + user + '@' + domain + '\" title=\"Click to open your email client and create a new mail message to this address.\">');
		document.write(user + '@' + domain + '</a>');
}
// call the above contact() function like this:
//   <script type="text/javascript">contact('user','domain');</script><noscript>user @ domain</noscript>

// ________________________________________________________________________
// contactLink() | v2.0 by inkFree Media | inkfree.com | rev. 2/2001

function contactLink(user,domain,linkMsg) 
{
	// write it
		document.write('<a href=\"mailto:' + user + '@' + domain + '\" title=\"Click to open your email client and create a new mail message to this address.\">' + linkMsg + '</a>');
		}
// call the above contactLink() function like this:
//   <script type="text/javascript">contactLink('user','domain','linkMsg);</script><noscript>user @ domain</noscript>



// ____________________________________________________________________________
// popup() | by Accidental Techie | NicheCrafters.com/NicheTech/ | rev. 2/2001
// Returns: an open window, formatted as specified, with content specified
//
/*  popup() takes 4 parameters
		url,width,height,windex

		url = destination url (the content)
		width,height = integer pixel values
		windex = a value (integer or name)
				 identifying the new win
*/

function popup(site,width,height,windex) {
	if (site != "") {
	
		var bName = navigator.appName;
		var bVer = navigator.appVersion.charAt(0);
		if (navigator.userAgent.indexOf('Win')!=-1)
			{       bPlat="windows";     }
		else if (navigator.userAgent.indexOf('Mac')!=-1)
			{       bPlat="mac";       }
		else if (navigator.userAgent.indexOf('WebTV')!=-1)
			{       bPlat="webtv";     }
		
		var bV = parseInt(navigator.appVersion), bN = navigator.appName, bP = navigator.userAgent
		if (bV == 3) {
			//document.location.href="/update_browser.html"
		}	
	
		if (bName.indexOf('Microsoft')!=-1) {
			if (bVer>=4) {
				if (bPlat=="mac") { // is mac
					//height-=15;
					height-=10;
					//width-=14;
					width-=8;
				}
			}  else { // is not mac
				//height-=28;
				height-=18;
				//width+=5;
				width+=5;
			} 
		} 

	var popupwindow=window.open(site,"_"+windex,"location=no,status=no,scrollbars=auto,width=" + width + ",height=" +height);
	// return true;
	} // if != ""
} // function

// ________________________________________________________________________
// daTime() | by Accidental Techie | NicheCrafters.com/NicheTech/ |
// Returns: text containing the time in the format hh:mm

function daTime() 
{ 
      
	var now = new Date();
	var meridian = (now.getHours() >= 12) ? " PM" : " AM"
	var hours = now.getHours();
         hours = ((hours > 12) ? hours - 12 : hours);
	var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
	var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
		
	return( hours + minutes + meridian );
}


// ________________________________________________________________________
// daDate() | by Accidental Techie | NicheCrafters.com/NicheTech/ | rev. 2/2001
// Returns: text containing the date in the format: day, month dd, yy

function daDate()
{
	var now = new Date();
		
	var yr = now.getYear();
	var mName = now.getMonth() + 1;
	var dName = now.getDay() + 1;
	var dayNum = ((now.getDate()<10) ? "0" : "")+ now.getDate();

	if(dName==1) day = "Sunday";
	if(dName==2) day = "Monday";
	if(dName==3) day = "Tuesday";
	if(dName==4) day = "Wednesday";
	if(dName==5) day = "Thursday";
	if(dName==6) day = "Friday";
	if(dName==7) day = "Saturday";

	if(mName==1) month="January";
	if(mName==2) month="February";
	if(mName==3) month="March";
	if(mName==4) month="April";
	if(mName==5) month="May";
	if(mName==6) month="June";
	if(mName==7) month="July";
	if(mName==8) month="August";
	if(mName==9) month="September";
	if(mName==10) month="October";
	if(mName==11) month="November";
	if(mName==12) month="December";

   var todaysDateString =(" "
       + day
       + ", "
       + month
       + " "
       + dayNum
       + ", "
       + yr);
       
   return (todaysDateString);
}


// ________________________________________________________________________
// countdown() | by inkFree Media | inkfree.com | rev. 2/2001
// Returns: seconds, minutes, hours, days from 'now' until 'then'
//          param whatDate is passed as a date in long form
//
//               Jan 01 16:00:00 2020 | mmm dd hh:mm:ss yyyy 

function countdown(whatDate) 
{ 
	now = new Date();
	then = new Date(whatDate);

	seconds = (then - now) / 1000;
	seconds = Math.round(seconds);
	minutes = seconds / 60;
	minutes = Math.round(minutes);
	hours = minutes / 60;
	hours = Math.round(hours);
	days = hours / 24.25;
	days = Math.round(days);
	
	/* old uses
	dmnwHours = hours + 1.5;
	spencerHours = hours + .5;
	document.write("<I>Hours until DMNW's hair gets frizzy: " + dmnwHours + "</I><BR>");
	document.write("<I>Hours until Billy Spencer falls asleep in a chair: " + spencerHours + "</I><BR>");
	*/
	
} // end countdown()


// ________________________________________________________________________
// showLinks() | 
// Returns: open window listing only A links on the current page
//
// Use:  in an <A HREF=> link, for user to see links-only window

function showLinks() {

	text = '<html><head><title>PAGE LINKS</title><style type="text/css"><!-- BODY,P {font:11px/13px Tahoma,Verdana,Geneva,Helvetica,Arial,sans-serif;} --></style></head><body bgcolor=#FFFFFF><img src="../../assets/image/programImages/peaceLink/75x30_peacelink_above.gif" align=bottom><font size=-2>&trade; v1.0.1</font><br>&nbsp;&nbsp;<b>Links Only View</b><BR<BR>The following links are available on this page:<hr size=1 noshade>';

	windowprops = "menubars=no,location=no,toolbars=no,"
	+"scrollbars=yes,width=350,height=350,top=100,left=100";
	self.name="main";

	for (i=0; i<document.links.length; i++)
	
	text += "<p><a target='_new' href="+document.links[i]+">"+document.links[i]+"<\/a>";

	linkswin = window.open("","",windowprops);
	with (linkswin.document) {
		open();
		write(text);
		write("<br></body></html>");
		close();
	}
}

// ________________________________________________________________________
// SetFocus() | 
// Returns: focuses the first text input form element
//
// Use:  in an body onload="SetFocus();"

function SetFocus() {
  if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i=0; i<field.length; i++) {
      if ( (field.elements[i].type != "image") && 
           (field.elements[i].type != "hidden") && 
           (field.elements[i].type != "reset") && 
           (field.elements[i].type != "submit") ) {

        document.forms[0].elements[i].focus();

        if ( (field.elements[i].type == "text") || 
             (field.elements[i].type == "password") )
          document.forms[0].elements[i].select();
        
        break;
      }
    }
  }
}



// ________________________________________________________________________
// oXwin() | by inkFree Media | inkfreepress.com | rev. 2/2001
// Returns: a 500 x 500 open window, formatted as specified, with content specified
function oXwin(daLink,windex) 
{
	var xWin = window.open(daLink,windex,'width=500,height=500,scrollbars=auto,resize=no');
	xWin.focus();
	
	return true;
	
} // end oXwin()



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




// #########################################################################
// DHTML FUNCTIONS
//
// ________________________________________________________________________

/* see external file:  cbdhtml.js */
