// ************************************************************************
// 
//   COPYRIGHT (C) 2002-2010 by David Nason
// 
//   ALL RIGHTS RESERVED
// 
//   MODULE:       utils.js
// 
//   DESCRIPTION:  
// 
//   HISTORY:
//    10 Apr 2002  David Nason
//                 Created.
// 
// ************************************************************************

var wPopup = null;

var msg="";
var spacer = " "; 
var pos = 0; 

function DoScrollMessage()
{
	if (msg!="") {
		window.status = msg.substring(pos, msg.length) + spacer + msg.substring(0,pos); 
		pos++; 
		if (pos > msg.length)
			pos = 0;
		window.setTimeout("DoScrollMessage()", 250);
	}
} 

function ScrollMessage(init)
{
	msg=init;
	for(x=1; x<init.length; x++)
		spacer+=" ";
	DoScrollMessage();
}

function copyright_notice(which)
{
	if (which)
		document.write('Copyright &copy; 2002-2010  <a class="nav" href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#121;&#101;&#101;&#64;&#116;&#121;&#101;&#101;&#110;&#97;&#116;&#105;&#111;&#110;&#46;&#99;&#111;&#109;">Bainbridge&nbsp;Island&nbsp;Tyee&nbsp;Nation</a><br>All Rights Reserved')
	else
		document.write('Copyright &copy; 2002-2010  <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;&#121;&#101;&#101;&#64;&#116;&#121;&#101;&#101;&#110;&#97;&#116;&#105;&#111;&#110;&#46;&#99;&#111;&#109;">Bainbridge&nbsp;Island&nbsp;Tyee&nbsp;Nation</a><br>All Rights Reserved');

//	eval(unescape('%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%27%3C%61%20%68%72%65%66%3D%22%6D%61%69%6C%74%6F%3A%74%79%65%65%40%6E%61%73%6F%6E%2E%6E%65%74%22%3E%42%61%69%6E%62%72%69%64%67%65%20%49%73%6C%61%6E%64%20%54%79%65%65%20%4E%61%74%69%6F%6E%3C%2F%61%3E%27%29'));
}

function sitedesign_notice()
{
	document.write('<table align=right cellpadding=0 cellspacing=0 style="color:#7F7FFF;font-family:arial;font-size:.7em"><tr><td align=right valign=bottom>by&nbsp;<br>&#110;&#97;&#115;&#111;&#110;&#46;&#110;&#101;&#116;&nbsp;</td><td align=right valign=bottom><img src="/images/nasonnet.gif" alt=""></td></tr></table>');
}

function add_favorite_btn()
{
	document.write('<a href="javascript:window.external.AddFavorite(document.location, document.title)">Add page to your Favorites</a>');
}

function SetNameArray(item)
{
	this.length = item;
	return this;
}

function TodaysDate(theDate)
{
	Month = new SetNameArray(12);
	Month[1] = "January";
	Month[2] = "February";
  Month[3] = "March";
	Month[4] = "April";
	Month[5] = "May";
	Month[6] = "June";
	Month[7] = "July";
	Month[8] = "August";
	Month[9] = "September";
	Month[10] = "October";
	Month[11] = "November";
	Month[12] = "December";

	WeekDay = new SetNameArray(7);
	WeekDay[1] = "Sunday";
	WeekDay[2] = "Monday";
	WeekDay[3] = "Tuesday";
	WeekDay[4] = "Wednesday";
	WeekDay[5] = "Thursday";
	WeekDay[6] = "Friday";
	WeekDay[7] = "Saturday";

	var theWeekDay = WeekDay[theDate.getDay() + 1];
	var theMonth = Month[theDate.getMonth() + 1];
	var theYear = theDate.getYear();

	return theWeekDay + ", " + theMonth + " " + theDate.getDate() + ", " + theYear;
}

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
									((expires) ? "; expires=" + expires.toGMTString() : "") +
									((path) ? "; path=" + path : "") +
									((domain) ? "; domain=" + domain : "") +
									((secure) ? "; secure" : "");
	document.cookie = curCookie;
}


// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}


// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
											((path) ? "; path=" + path : "") +
											((domain) ? "; domain=" + domain : "") +
											"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
}

function getClientAreaX()
{
	if (typeof window.screenX!='undefined') {
		var winX = window.screenX;
	} else {
		if (typeof window.screenLeft!='undefined') {
			var winX = window.screenLeft;
		}
	}
	return winX;
}

function getClientAreaY()
{
	if (typeof window.screenY!='undefined') {
		var winY = window.screenY;
	} else {
		if (typeof window.screenTop!='undefined') {
			var winY = window.screenTop;
		}
	}
	return winY;
}

function getClientAreaWidth() {
	d = document;
	if (typeof window.innerWidth!='undefined') {
		var winWidth = window.innerWidth;
	} else {
		if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
			var winWidth = d.documentElement.clientWidth;
		} else {
			if (d.body && typeof d.body.clientWidth!='undefined') {
				var winWidth = d.body.clientWidth;
			}
		}
	} 
	return winWidth;
}

function getClientAreaHeight() {
	d = document;
	if (typeof window.innerWidth!='undefined') {
		var winHeight = window.innerHeight;
	} else {
		if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
			var winHeight = d.documentElement.clientHeight;
		} else {
			if (d.body && typeof d.body.clientWidth!='undefined') {
				var winHeight = d.body.clientHeight;
			}
		}
	} 
	return winHeight;
}

function popupwindow (URL,popupWidth,popupHeight)
{
	var chasm = getClientAreaWidth();
	var mount = getClientAreaHeight();
	var screenX = getClientAreaX();
	var screenY = getClientAreaY();

	if (chasm <= 0 || screenX <= 0) {
		chasm = screen.availWidth;
		screenX = 0;
	}
	if (mount <= 0 || screenY <= 0) {
		mount = screen.availHeight;
		screenY = 0;
	}

	if (popupWidth > chasm) {
		popupWidth = chasm - 10;
	}
	if (popupHeight > mount) {
		popupHeight = mount - 40;
	}

	screenX = ((chasm - popupWidth - 10) * .5) + screenX;
	screenY = ((mount - popupHeight - 30) * .5) + screenY;
			
	wPopup = window.open(URL,"","width=" + popupWidth + ",height=" + popupHeight + ",toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=no,left=" + screenX + ",top=" + screenY);
}

function windowOpener(URL, popupWidth, popupHeight)
{
	var chasm = screen.availWidth;
	var mount = screen.availHeight;

	if (popupWidth > chasm) {
		popupWidth = chasm - 10;
	}
	if (popupHeight > mount) {
		popupHeight = mount - 40;
	}

	if (!wPopup || (typeof(wPopup) != "object")) {
		wPopup = window.open(URL,"","width=" + popupWidth + ",height=" + popupHeight + ",toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=no,left=" + ((chasm - popupWidth - 10) * .5) + ",top=" + ((mount - popupHeight - 30) * .5));
	} else {
		if (!wPopup.closed) { 
			wPopup.location.href = URL;
			wPopup.show();
		} else {
			wPopup = window.open(URL,"","width=" + popupWidth + ",height=" + popupHeight + ",toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=no,left=" + ((chasm - popupWidth - 10) * .5) + ",top=" + ((mount - popupHeight - 30) * .5));
		}
	}
	wPopup.focus();
}

function addToFavorites()
{
	if (window.external) {
		alert("ok");
	} else { 
		alert("Your browser does not support this function.");
	}
}

function goRegister(prompt,clstype)
{
	if (prompt)
	{
		if (clstype)
			document.write("<a class='"+clstype+"' href='http://tyeenation.com/register.php' target='_top'>"+prompt+"</a>");
		else
			document.write("<a href='http://tyeenation.com/register.php' target='_top'>"+prompt+"</a>");
	}
	else
	{
		if (clstype)
			document.write("<a class='"+clstype+"' href='http://tyeenation.com/register.php' target='_top'>Register Online</a>");
		else
			document.write("<a href='http://tyeenation.com/register.php' target='_top'>Register Online</a>");
	}
}


	
//-->


