//	script.js - Common Javascript
//
//	Copyright (C) 1998-2011 Charles A Upsdell, All Rights Reserved; www.upsdell.com


//	Initialization

// Break out of frame
if (top.location != self.location)
	top.location = self.location;


// Add my extra menu items
function myAddMenuItems ( arglist )
{
if ( (arguments.length == 0) || (String(window.location).indexOf('file:') != 0) )
	return;
if ( arguments.length == 1 )
  {
	var o = getElement( arguments[0] );
	if ( o )
	  {
		o.style.display = 'inline';
		o.style.color = 'green';
	  }
  }
else
  {
	for ( var i = 0; i < arguments.length; ++i )
		myAddMenuItems( arguments[i] );
  }
}


// Suppress display
function myDisplayNone ( arglist )
{
for ( var i = 0; i < arguments.length; ++i )
  {
	var o = getElement( arguments[i] );
	if ( o )
		o.style.display = 'none';
  }
}


// At find.htm etc. mark anchor specifified in hash
function myMarkAnchor ( )
{
var obj;
if ( ((window.location.href.indexOf("find.htm") != -1)
  || (window.location.href.indexOf("find_other.htm") != -1)
  || (window.location.href.indexOf("store_sw.htm") != -1)
   )
  && (window.location.hash != '') )
  {
	var sHash = window.location.hash.substr(1);
	if ( (obj = document.anchors[sHash]) != null )
	  {
		obj.firstChild.style.display = 'block';
	  }
	else if ( (obj = getElement(sHash)) != null )
	  {
		obj.firstChild.style.display = 'block';
	  }
  }
}


//	Function to run after page loads
function myOnLoad ()
{
myDateModified( 'ins_DateModified', '<p class="small dim centert"><br />Page updated ', '</p>\n' );

myAddMenuItems( 'ins_ResMobile' );

myDisplayNone( 'ins_noscript' );

if ( typeof(myBookAds) != 'undefined' )
	myBookAds();
if ( typeof(myUpcomingBookAds) != 'undefined' )
	myUpcomingBookAds();
if ( typeof(myGetQuote) != 'undefined' )
	myGetQuote();
if ( typeof(myGetQuotes) != 'undefined' )
	myGetQuotes();
if ( typeof(myItemAd) != 'undefined' )
	myItemAd();
if ( typeof(ISBN) != 'undefined' )
	ISBN.ListISBNs( 'ins_ListISBNs' );
if ( typeof(ISBN_1) != 'undefined' )
	ISBN_1.ListISBNs();
if ( typeof(ISBN_2) != 'undefined' )
	ISBN_2.ListISBNs();
if ( typeof(ISBN_2a) != 'undefined' )
	ISBN_2a.ListISBNs();
if ( typeof(ISBN_2b) != 'undefined' )
	ISBN_2b.ListISBNs();
if ( typeof(ISBN_3) != 'undefined' )
	ISBN_3.ListISBNs();
if ( typeof(ISBN_ListTitles) != 'undefined' )
	ISBN_ListTitles.ListTitlesISBNs();
myMarkAnchor();
if ( typeof(ISBN) != 'undefined' )
	ISBN.RandomISBN( 'ins_RandomISBN' );
if ( typeof(myBrowserDetected) != 'undefined' )
	myBrowserDetected();
if ( typeof(myReportAnyBrowserUpdate) != 'undefined' )
	myReportAnyBrowserUpdate( '', getElement('ins_BrowserUpdate') );
if ( typeof(mySoftwareAds) != 'undefined' )
	mySoftwareAds();
if ( typeof(myTestAds) != 'undefined' )
	myTestAds();
if ( typeof(myTestFacts) != 'undefined' )
	myTestFacts();
if ( typeof(myJavaScriptEnabled) != 'undefined' )
	myJavaScriptEnabled();
if ( typeof(myResBrowserPage) != 'undefined' )
	myResBrowserPage();
}


// Scroll to a position, defaulting to top of page; return false if done
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 );
}


//	Insert date when file was last modified
function myDateModified ( id, prefix, suffix )
{
if ( arguments.length < 1 )
	alert( 'myDateModified() error: no arguments' );
if ( arguments.length < 2 )
	prefix = '';
if ( arguments.length < 3 )
	suffix = '';
var o = getElement( id );
if ( o )
  {
	var sHTML = '';
	if ( document.lastModified == '' )
		return;
	var theDateMs = Date.parse( document.lastModified );
	var theDate = new Date( theDateMs );
	if ( theDateMs != 0 )
	  {
		var strDate;
		if ( typeof(theDate.toLocaleDateString) != 'undefined' )
			strDate = theDate.toLocaleDateString();
		else
			strDate = theDate.toString();
		sHTML += prefix + strDate + suffix;
	  }
	o.innerHTML = sHTML;
  }
}

