// This Javascript Source File is protected by Copyright laws 2004 January Pinched LTSIII Production and Design.
// Please use this code AT WILL with NO WARRANTY but please keep the following notice in place and give credit where credit is due.
// Special thanks to all of those astounding people who taught through their actions.
//*************************************************
// Javascript composed by Len Schwalm III http://www.pinched.com LTSIII Production and Design
// Please contact Len if you need installation help, have suggestions or would like be a part of any projects
// Phone: (909) 319-1137 Ontario, CA USA
// or
// Fill out the contact form at http://www.pinched.com/contact
//*************************************************

// This shows an Image based on time of day; Emulates Sunrise/Sunset times
// This is a precursor to detailed sunrise/sunset Timed Geographic Content Script based on IP/Hostname 
//   geographic location soon to come
// Please contact me if you would like to help out with this project by usint the contact information above.
function showTimeMsg() {
now = new Date();
nowHour = now.getHours();
//if ((nowHour >= 7) && (nowHour <= 18)) { 
if ((nowHour >= 6) && (nowHour <= 18)) { 
//if (nowHour = 7) { 
// show Day Image between 7am and 6pm
document.write("<img src=\"/images/layout/head_day.jpg\" width=\"805\" height=\"85\" alt=\"Daytime Image\" \/>");
} else {
// show Night Image at all other times
document.write("<img src=\"/images/layout/head_night.jpg\" width=\"805\" height=\"85\" alt=\"Nightime image\" \/>");
}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// Opens New info window
function info_window(url) {
info_window=window.open(url,"Info",'toolbar=0,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=650,height=575');
}

// Opens New comments window
function comments_window(url) {
comments_window=window.open(url,"Comments");
}


//  Feeds the Comments section - This is a top frame that serves to comment on the frame  or frames below it; with remove frame action
function commentsurl(comments,spotlight)
{
// Send GET string with values
var target = "/comments/index.php?comments=" + comments + "&spotlight=" + spotlight;
comments_window(target);
// Reload main page so javascript Comment Links work; without this, links 
// would default to no comments (no frames); javascript link fires only once per page view (there must be a fix for this)
window.parent.location.reload(); 
}

// Breaks the user out of a frame
function remove_frame()
{
//get source of bottomframe from the parent frameset html document 
var cURL=parent.document.getElementById('mainframe').src 
//set the location of the parent window to cURL 
parent.location=cURL
}

var bugRiddenCrashPronePieceOfJunk = (
	navigator.userAgent.indexOf('MSIE 5') != -1
	&&
	navigator.userAgent.indexOf('Mac') != -1
);

var W3CDOM = (!bugRiddenCrashPronePieceOfJunk && 
	document.getElementsByTagName && document.createElement);

if ((top != self.parent) && !self.disabled)
	top.location.href = '/index.php';

if (top.navi && top.navi.setNav) top.navi.setNav(location.href,'currentPage');
top.setNav = location.href;


window.onload = initialize; 

/* Why no window.onload = function () {} ? Because NN3 doesn't support the function
	constructor and gives an error message. This site must be accessible to NN3 */

function initialize () {
/* Hide nifty stuff from old browsers */

	if (W3CDOM)
	
	{

/* Go through all links. If any has a type="popup" write the popup function into its onclick
   Any external link gets a target='ppk'. 
   Any link with a hreflang attribute gets an extra note with its value.   
   */
	var langspan = document.createElement('div');
	langspan.className = 'smaller lang';
	
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('class') == 'popup' || x[i].className == 'popup')
		{
			x[i].onclick = function () {
				return pop(this.href)
			}
			x[i].innerHTML += '<div class="smaller">A new window will open.</div>';
		}
		if (x[i].getAttribute('class') == 'Under_Construction' || x[i].className == 'Under_Construction')
		{
			x[i].onclick = function () {
				return url(this.href)
			}
			x[i].innerHTML += '<div class="tool_tip">Status:<br />Under Construction</div>';
		}
		if (x[i].className == 'external' || x[i].className == 'external')
			x[i].target = 'ppk';
		if (x[i].className == 'outoforder' || x[i].className == 'outoforder')
		{
			x[i].title = 'OUT OF ORDER';
			x[i].target = 'ppk';
			x[i].onclick = function ()
			{
				return confirm('This link is out of order. Continue anyway?');
			}
		}
		var hreflang = x[i].getAttribute('hreflang');
		if (hreflang)
		{
			var newspan = langspan.cloneNode(true);
			newspan.appendChild(document.createTextNode(' (lang=' + hreflang + ')'));
			x[i].parentNode.insertBefore(newspan,x[i].nextSibling);
			
		}		}
	}
}
// Popup

var popUp = null;

function pop(url)
{
	if (popUp && !popUp.closed)
		popUp.location.href = url;
	else
		popUp = window.open(url,'popUp','height=500,width=700,scrollbars=yes,resizable=yes,toolbar=yes,location=yes');
	popUp.focus();
	return false;
}
