//	Common Javascript - Copyright (C) 2003-2009 Charles A Upsdell, All Rights Reserved; www.upsdell.com


function cVersion ( version, separator, bSkipSpace )
{
if ( version === undefined )
	version = '0';
if ( separator === undefined )
	separator = '.';
if ( bSkipSpace === undefined )
	bSkipSpace = false;
if ( version instanceof cVersion )
  {
	this.separator = (arguments.length < 2) ? version.separator : separator;
	this.v = new Array();
	this.v = version.v;
  }
else
  {
	var s = ( typeof(version) == 'number' ) ? version.toString() : version;
	this.separator = separator;
	this.v = new Array();
	var vindex = 0;
	var sindex = 0;
	var c;
	this.v[vindex] = '';
	if ( bSkipSpace) for ( ; sindex < s.length; ++sindex )
	  {
		c = s.charAt(sindex);
		if ( c != ' ' )
			break;
	  }
	for ( ; sindex < s.length; ++sindex )
	  {
		c = s.charAt(sindex);
		if ( c == separator )
			this.v[++vindex] = '';
		else if ( (c >= '0') && (c <= '9') )
			this.v[vindex] += c.toString();
		else
			break;
	  }
  }
return;
}


cVersion.prototype.toString = function ( separator )
{
if ( separator === undefined )
	separator = this.separator;
var result = '';
for ( var i = 0; i < this.v.length; ++i )
  {
	if ( i == 0 )
		result += this.v[0];
	else
		result += separator + this.v[i];
  }
return( result );
}


cVersion.prototype.comp = function ( version2 )
{
var operand;
if ( version2 === undefined )
	version2 = '0';
if ( version2 instanceof cVersion )
	operand = version2;
else
	operand = new cVersion( version2 );
var nLoops = Math.max( this.v.length, operand.v.length );
var result = 0;
for ( var i = 0; i < nLoops; ++i )
  {
	var n1 = Number( (i < this.v.length) ? this.v[i] : 0 );
	var n2 = Number( (i < operand.v.length) ? operand.v[i] : 0 );
	if ( n1 == n2 )
		continue;
	else if ( n1 < n2 )
		{ result = -1; break; }
	else
		{ result = 1; break; }
  }
return( result );
}


String.prototype.alert = function ( method, arglist )
{
var errmsg = this;
errmsg += (method == '') ? '()' : ('.' + method + '()');
errmsg += ' error: ' + arguments[1];
for ( var i = 2; i < arguments.length; ++i )
	errmsg += ((i == 2 ) ? ': ' : ', ' ) + arguments[i];
alert( errmsg );
}


function myInsertPhoto ( sPhoto, id )
{
$name = 'myInsertPhoto';
if ( sPhoto === undefined )
	$name.alert( '', 'photo name missing' );
id = id || 'ins_enlargement';
var o = getElement( id );
if ( o == null )
	return( true );
var sHTML = '<img src="' + sPhoto + '" />';
o.innerHTML = sHTML;
return( false );
}


// Mark anchor specifified in hash
function myMarkAnchor ( )
{
var o;
if ( ((window.location.href.indexOf("archive.htm") != -1)
   )
  && (window.location.hash != '') )
  {
	var sHash = window.location.hash.substr(1);
	if ( (o = document.anchors[sHash]) != null )
	  {
		o.style.color = '#090';
	  }
	else if ( (o = getElement(sHash)) != null )
	  {
		o.style.color = '#090';
	  }
  }
}


//	OnUnload Function
function myOnUnload( oPageStyle )
  {
	oPageStyle.saveActiveStylesheet();
  }


function startList ( id_list )
{
if ( myBrowser.isIE && (myBrowser.version.comp('7')<0) )
  {
	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", ""); }
			  }
		  }
	  }
  }
}


// getElement - get element associated with an ID, or null if not found
function getElement ( id )
{
var element = null;
if ( (arguments.length == 0) || (id == "") )
	return( null );
if ( document.getElementById )
	element = document.getElementById( id );
else if ( document.all )
	element = document.all[id];
return( element );
}


// 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) !== typeof(nosuchvalue)) && (typeof(window.scrollTo) !== typeof(noSuchFunction)) )
	  {
		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 );
}


// Scroll to a position, defaulting to top of page; return false if done
function myScrollTo ( left, top )
{
left = left || 0;
top = top || 0;
var value = true;
if ( typeof(window.scrollTo) !== typeof(noSuchFunction) )
  {
 	window.scrollTo( left, top );
	value = false;
  }
return( value );
}


//	Init

var myBrowser = new cBrowser();
if ( (typeof(myBrowser)=='object') && ((myBrowser.isIE && (myBrowser.version.comp('5')>=0)) || myBrowser.isG || myBrowser.isK || (myBrowser.isO && (myBrowser.version.comp('7')>=0))) )
	; // browser is modern
else if ( (typeof(myBrowser)!='object') || myBrowser.isIE || myBrowser.isN || myBrowser.isO )
	alert( 'Sorry, this site is not designed for ancient browsers' );



