// Common JavaScript - Copyright (C) 2007-2011 Charles A Upsdell, All Rights Reserved; www.upsdell.com
//
// This has JavaScript common to all pages.


//	Function called when page has been loaded
function myCommonOnLoad( )
{
startList( 'dropdown' );
myShowItem( 'submenu', ['hide_this1', 'list-item'], ['hide_this2', 'list-item']  );
if ( typeof(myXmasPhoto) != 'undefined' )
  {
	myXmasPhoto.insertPhoto();
	if ( typeof(myXmasPhoto.testPhotos) != 'undefined' )
		myXmasPhoto.testPhotos( 'ins_test_xmas', 'xmas_greetings' );
  }
if ( typeof(myNewsAlertText) != 'undefined' )
  {
	if ( typeof(myNewsAlertFields) != 'undefined' )
		myNewsAlertFields();
	else
		myNewsAlert( 'ins_newsalert' );
  }
if ( typeof(myRoar) != 'undefined' )
	myRoar();
if ( typeof(myJavaScriptEnabled) != 'undefined' )
	myJavaScriptEnabled();
}


// Library function
function myScrollTo ( left, top )
{
if ( arguments.length < 1 )
	left = 0;
if ( arguments.length < 2 )
	top = 0;
var value = true;
if ( typeof(window.scrollTo) != 'undefined' )
  {
 	window.scrollTo( left, top );
	value = false;
  }
return( value );
}


// Scroll to an anchor; return false
function myScrollToAnchor ( id )
{
id = id || window.location.hash;
if ( id.indexOf('#') == 0 )
	id = id.substring(1);
var o = getElement( id );
if ( o )
  {
	if ( (typeof(o.offsetTop) != 'undefined') && (typeof(window.scrollTo) != 'undefined') )
	  {
		var x = 0;
		var y = 0;
		while ( o )
		  {
			x += o.offsetLeft;
			y += o.offsetTop;
			o = o.offsetParent;
		  }
		window.scrollTo( x, y );
	  }
	else
		window.location.replace( '#' + id );
  }
return( false );
}


// If local file, reveal item; else if IE 5 or 6, hide item
function myShowItem ( arglist )
{
for ( var i = 0; i < arguments.length; ++i )
  {
	if ( arguments[i] instanceof Array )
	  {
		myShowItem ( arguments[i][0], arguments[i][1] );
	  }
	else
	  {
		var sID = arguments[i];
		var sDisplayType = 'block';
		if ( (arguments[i+1] !== undefined) && !(arguments[i+1] instanceof Array) )
			sDisplayType = arguments[++i];
		if ( String(window.location).indexOf('file:') == 0 )
		  {
			var o = getElement( sID );
			if ( o )
			  {
				o.style.display = sDisplayType;
				o.style.color = 'green';
			  }
		  }
		else if ( typeof(isIE5or6) == 'undefined' )
		  {
			continue;
		  }
		else
		  {
			var o = getElement( sID );
			if ( o )
				o.style.display = 'none';
		  }
	  }
  }
}


// Library function
function startList ( id_list )
{
if ( typeof(isIE5or6) != 'undefined' )
  {
	for ( var i = 0; i < arguments.length; ++i )
	  {
		var id = arguments[i];
		navRoot = document.getElementById(id);
		if ( navRoot == null )
			continue;
		for ( var j = 0; j < navRoot.childNodes.length; ++j )
		  {
			node = navRoot.childNodes[j];
			if (node.nodeName=="LI")
			  {
				node.onmouseover=function() { this.className+=" over"; }
				node.onmouseout=function() { this.className=this.className.replace(" over", ""); }
			  }
		  }
	  }
  }
}


