/*
SearchCounsel.com (RAMparts SEO ws18)
General external JavaScript file
by Robin Macrae, March 2002
http://www.ramspace.com
Copyright (c) 2002 Robin Macrae and Innisian Airware
All rights reserved
Scripts are alphabetically ordered by script title
*/

/*----------------------------------------------------------------------------------------------
Clear anchor
Date file last modified, MS PRE
Date file last modified, Koch
Directory path
Display: block
Error handler, silent
File size
IE Hack 1
Name window 'entry'
Popup directory menu window generator
Popup directory menu window generator 2
Reveal/Hide 2
Select stylesheet
Text size changer
Window focus
----------------------------------------------------------------------------------------------*/

/* Clear anchor
    Techniques which use CSS to replace tables (liquid layout) (01-11d t283)
    js_v1_scripts.html#Clear_Anchor
    navbar_v3_01-11b.html#Log_entry_02-02c-21_JS_clearAnchorURL
    js_v1_log.html#[last revision docket]
    Based on http://www.smokinggun.com/demos/anchor.php (John Weir)
*/

function clearAnchorURL()
	{
	// make the location a string
	URLString = document.location+"";
		
	//make sure there is not already an anchor, if there is strip it out and          	//reformat the URL
	if (URLString.indexOf("#") > -1)
		{
		
		URLString = URLString.substring(0,URLString.indexOf("#"));
		document.location = URLString;
		}	
	}

/*-----------------------------------------------------------------------------------------------*/

/* Date file last modified, MS PRE
    MS press release on IDC survey of Cdn retailers, Sep. 2000 (00-09b b104)
    Display a file's last modified date using JS instead of SSI (00-08e t108)
    js_v1_scripts.html#Date_last_modified_MS_PRE
    rev_05b_01-12a_log#02-01c-15_0815
    js_v1_log.html#[last revision docket]
    Based on http://www.microsoft.com/canada/press/releases/2000_09_12.htm
*/

function insertDateModified () {
	if (document.lastModified) {
		var dlm=new Date(document.lastModified);
		var mArray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
		var mnt=mArray[dlm.getMonth()];
		var cen = (dlm.getYear() < 100) ? 1900 + dlm.getYear() : 0 + dlm.getYear();
		var cen = (cen < 1997) ? 100 + cen : cen;
		document.write(dlm.getDate() + " " + mnt + " " + cen + ".");
	}
}

/*-----------------------------------------------------------------------------------------------*/

/* Date file last modified, Koch
    Peter-Paul Koch's date and time tutorial and JavaScripts (various formats,                        time since last modified) (01-12c t303)
    js_v1_scripts.html#Date_last_modified_Koch
    js_v1_log.html#[implementation docket]
    js_v1_log.html#[last revision docket]
    Based on http://www.xs4all.nl/~ppk/js/lastmod.html
*/

function lastMod()
{
	var x = new Date (document.lastModified);
	Modif = new Date(x.toGMTString());
	Year = takeYear(Modif);
	Month = Modif.getMonth();
	Day = Modif.getDate();
	Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
	x = new Date();
	today = new Date(x.toGMTString());
	Year2 = takeYear(today);
	Month2 = today.getMonth();
	Day2 = today.getDate();
	now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
	daysago = now - Mod;
	if (daysago < 0) return '';
	unit = 'days';
	if (daysago > 730)
	{
		daysago = Math.round(daysago/365);
		unit = 'years';
	}
	else if (daysago > 60)
	{
		daysago = Math.round(daysago/30);
		unit = 'months';
	}
	else if (daysago > 14)
	{
		daysago = Math.round(daysago/7);
		unit = 'weeks'
	}
	towrite = 'Page last changed ';
	if (daysago == 0) towrite += 'today';
	else if (daysago == 1) towrite += 'yesterday';
	else towrite += daysago + ' ' + unit + ' ago';
	towrite += ' on ';
	return towrite;
}


function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

/*-----------------------------------------------------------------------------------------------*/

/* Directory path 
    Filename and directory path JavaScripts (01-12b t296)
    js_v1_scripts.html#Directory_Path
    js_v1_log.html#02-02d-27_0745 
    Based on http://developer.irt.org/script/1458.htm
*/

thePath = '';
loc = '' +location.href;
paths = loc.substring(7).split('/');
file = loc.substring(0,6);
for (i=0, n=paths.length;i<n;i++) {
  file += "/" + paths[i];
  thePath += '> <a href="' + file + '">' + paths[i] + '<\/a> ';
}

/*-----------------------------------------------------------------------------------------------*/

/* Display: block
    Koch (01-12b t291)
    js_v1_scripts.html#Display_Block
    rev_05b_01-12a_log.html#02-01c-15_Display_Block_implmt 
    Based on http://www.xs4all.nl/~ppk/js/display.html
*/

var supported = (document.getElementById || document.all);

if (supported)
{
	document.write("<STYLE TYPE='text/css'>");
	document.write(".blockText {display: none}");
	document.write(".annotBlock {display: none}"); /*renamed 02-04c-16 */
	document.write(".tocPg {display: none}"); /*added 02-01e-31 */
	document.write("</STYLE>");

	var max = 7;
	var shown = new Array();
	for (var i=1;i<=max;i++)
	{
		shown[i+1] = false;
	}

}

function blocking(i)
{
	if (!supported)
	{
		alert('This link does not work in your browser.');
		return;
	}
	shown[i] = (shown[i]) ? false : true;
	current = (shown[i]) ? 'block' : 'none';
	if (document.getElementById)
	{
		document.getElementById('number'+i).style.display = current;
	}
	else if (document.all)
	{
		document.all['number'+i].style.display = current;
	}
}

/*-----------------------------------------------------------------------------------------------*/

/* Error handler, silent
    Developer and programmer JavaScript tools, utilities, etc. (01-06b t151 js                    function dev-tools)
    js_v1_scripts.html#Error_handling
    js_v1_log.html#02-02d-28_0745 
    Based on http://www.pbs.org/
*/

function NoError ()
{
	return (true);
}
onError = NoError;


/*-----------------------------------------------------------------------------------------------*/

/* File size
    Peter-Paul Koch's CSS, DOM and JavaScript pages (expert) (01-12b t292)
    js_v1_scripts.html#File_Size
    js_v1_log.html#02-02d-28_0745 
    rev_05b_01-12a_log.html#02-02b-11_1000
   Based on http://www.xs4all.nl/~ppk/js/filesize.html
*/

function calculate()
{
	if (!document.fileSize)
	{
		alert('This script does not work in your browser.');
		return;
	}
	var size = (document.fileSize)*1;
	var y = document.images;
	var imglength = 0;
	for (i=0;i<y.length;i++)
	{
		imglength += (y[i].fileSize)*1;
	}
	var total = size + imglength;
	var writestring = 'File size HTML: ' + size;
	writestring += '\nFile size images: ' + imglength;
	writestring += '\nTotal file size: ' + total;
	if (total > 40000) writestring += "\nFile too large!";
	alert(writestring);
}

/*-----------------------------------------------------------------------------------------------*/

/* IE Hack 1
    Page Reference [documentation, source, etc.]
    js_v1_scripts.html#IE_Hack_01
    js_v1_log.html, [implementation docket]
    js_v1_log.html#02-02d-28_0745: delete
    Based on [URL]
*/

/*-----------------------------------------------------------------------------------------------*/

/* Name window 'entry'
    Page Reference [documentation, source, etc.]
    js_v1_scripts.html#Name_Window_entry
    cntl_Log.html#05_mo_1000
    js_v1_log.html#[last revision docket]
    Based on [URL]
*/

name = 'entry';

/*-----------------------------------------------------------------------------------------------*/

/* Popup directory menu window generator
    Generate an offset index listing page using JavaScript's openWindow function (00-05a t120) [includes a log section]
    js_v1_scripts.html#Popup_Dir_Window_Gen
    Inventory revision log 030 (00-02d m102)
    js_v1_log.html#[last revision docket]
    Based on http://www.builder.com/Programming/Kahn/092497/toolwb.html
*/

function openWindow(url, name) {
  popupWin = window.open(url, name, 'scrollbars,width=225,height=900,left=857,top=63')
}

/*-----------------------------------------------------------------------------------------------*/

/* Popup directory menu window generator 2
    Generate an offset directory menu page with targeting back to opener
    X-ref Referencing original window from new window using JavaScript                    opener property (02-04b t321)
    js_v1_scripts.html#Popup_Dir_Window_Gen
    js_v1_log.html#02-04b-12
    Based on http://www.xs4all.nl/~ppk/js/croswin.html
*/

var newwindow = '';

function popitup(url)
{
	if (newwindow.location && !newwindow.closed)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'name','scrollbars,height=900,width=225,left=857,top=63');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
}

function to_old_win(url)
{
	opener.location.href = url;
}
/*-----------------------------------------------------------------------------------------------*/

/* Reveal/Hide 2 v1.1
    Reveal/hide 2 v1, standard page components DDA (m5 rev 05 reveal1 v1)
    04_log_02-06.html#02-07a-04_1515
    Based on http://www.microsoft.com/technet/security/bulletin/MS01-020.asp
*/

function revealText(objText,objImage)
{
   if (objText.style.display == "none")
   {
       objText.style.display = "";
       objImage.src = "../../../Internals/Images/reveal_01a_close.gif";
   }
   else
   {
       objText.style.display = "none";
       objImage.src = "../../../Internals/Images/reveal_01b_open.gif";
   }
}

/*-----------------------------------------------------------------------------------------------*/

/* Select stylesheet 
    Select stylesheet 1 v1 (ALA, Sowden), standard page components' DDA (m5                   rev 05 css select1 v1)
    Dynamically switch between style sheets, cross–browser JavaScript                  technique, Sowden, ALA (01-11a t264)
    js_v1_scripts.html#Select_Stylesheet
    js_v1_log.html#[implementation docket]
    js_v1_log.html#[last revision docket]
    Based on http://www.alistapart.com/stories/alternate/
*/

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

/*-----------------------------------------------------------------------------------------------*/

/* Text size changer
    Page Reference [documentation, source, etc.]
    rev_05b_01-12a_log#02-02b-12_0830
    js_v1_log.html#[last revision docket]
    Suspended; see the docket.
    Based on http://www.saila.com/usage/tips/
*/

/*-----------------------------------------------------------------------------------------------*/

/* Window focus
    Set focus to target window/page (00-08e t106)
    js_v1_scripts.html#[script_section]
    rev_05b_01-12a_log.html#00-11e-30_0915
    js_v1_log.html, [last revision docket]
    Based on [none]
*/

if (window.focus) {
  self.focus();
}

/*-----------------------------------------------------------------------------------------------*/

/* end */