//* This the setup code for the hierchical menu.
	if(window.event + "" == "undefined") event = null;
 	function HM_f_PopUp(){return false};
 	function HM_f_PopDown(){return false};
 	popUp = HM_f_PopUp;
 	popDown = HM_f_PopDown;


if(document.images){
	logoon 		= new Image(); logoon.src="../images/b-logoon.gif";
  	logooff		= new Image(); logooff.src="../images/b-logooff.gif";
	homeon 		= new Image(); homeon.src="../images/b-homeon.gif";
  	homeoff		= new Image(); homeoff.src="../images/b-homeoff.gif";
	topon 		= new Image(); topon.src="../images/b-topon.gif";
  	topoff		= new Image(); topoff.src="../images/b-topoff.gif"; 
	copyon 		= new Image(); copyon.src="../images/b-copyon.gif";
  	copyoff		= new Image(); copyoff.src="../images/b-copyoff.gif";
	copyhon 	= new Image(); copyhon.src="images/b-copyon.gif";
  	copyhoff	= new Image(); copyhoff.src="images/b-copyoff.gif";  	
	clearon 	= new Image(); clearon.src="../images/b-clearon.gif";
  	clearoff	= new Image(); clearoff.src="../images/b-clearoff.gif";
	sendon	 	= new Image(); sendon.src="../images/b-sendon.gif";
  	sendoff		= new Image(); sendoff.src="../images/b-sendoff.gif"; 
  	scoreon	 	= new Image(); scoreon.src="../images/b-scoreon.gif";
  	scoreoff	= new Image(); scoreoff.src="../images/b-scoreoff.gif";
  	orderon	 	= new Image(); orderon.src="../images/b-orderon.gif";
  	orderoff	= new Image(); orderoff.src="../images/b-orderoff.gif";  	
  	stuffon	 	= new Image(); stuffon.src="images/but-stuffon.gif";
  	stuffoff	= new Image(); stuffoff.src="images/but-stuffoff.gif";
  	freeon	 	= new Image(); freeon.src="../images/but-freeon.gif";
  	freeoff		= new Image(); freeoff.src="../images/but-freeoff.gif";
  	hireon	 	= new Image(); hireon.src="images/but-hireon.gif";
  	hireoff		= new Image(); hireoff.src="images/but-hireoff.gif"; 
  	repon	 	= new Image(); repon.src="images/but-repon.gif";
  	repoff		= new Image(); repoff.src="images/but-repoff.gif"; 
  	tuneon	 	= new Image(); tuneon.src="images/but-tuneupon.gif";
  	tuneoff		= new Image(); tuneoff.src="images/but-tuneupoff.gif";  	   	 	  	  	
//	lineon	 	= new Image(); lineon.src="../images/ani-line.gif";
// 	lineoff		= new Image(); lineoff.src="../images/spacer.gif"; 
//	loadon	 	= new Image(); loadon.src="../images/b-load.gif";
// 	loadoff		= new Image(); loadoff.src="../images/b-clickad.gif";  	  	 	  	   	   	 	  				 	
 }

//******** For Rotating Ad reasons.
//if (HM_IsMenu)
 if ((document.all) || (document.layers) || (document.getElementById)) {
    var picsokay = "y";

//*** this array holds the image flenames which will randomly be generated.
	var picArray = new makeArray('r01','r02','r03','r04','r05','r06','r07','r08','r09','r10','r11','r12','r13','r14','r15','r16','r17','r18','r19','r20','r21','r22');
	var numArray = new makeArray('n01','n02','n03','n04','n05','n06','n07','n08','n09','n10','n11','n12','n13','n14','n15','n16','n17','n18','n19','n20','n21','n22');

}

function flipImg(imgNam,imgTyp,onoff){
   	if(document.images){
   		 document.images[imgNam].src=eval(imgTyp+onoff+'.src');	
   	}
 }

// Trick to dynamically get the file name of the displayed page.
// Hence the "file" argument is not needed.
    var homepage = 0; // default to not the home page
	var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
	var filenm = location.href.substring(dir.length,location.href.length+1);
//alert(filenm);
// Have to use a slightly different page when it's the homepage since the index.html file
// is not in the /html directory.


	
    if (filenm == "index.html" || filenm == ""  || filenm == "home.html"  ) homepage = 1;
// 	homepage = 0;
 	if (homepage) {
 	   imagedir = "images";
 	   htmldir = "html/";
 	}   
 	else {   
	   imagedir = "../images";
	   htmldir = "../html/";
	   //* This is the TOLL FREE NUMBER. It's placed on the page via WAW.css
	  document.write('<div id="tollfree"><img src="../images/toll-free.gif" width="230" height="12" border="0" alt="Toll-Free Outside Toronto: 1-877-940-6610"></div>');
	  
 	  document.write('<div id="emailtofriend">Think this information is of<br>interest to others? <a href="mailto:wolfgang@wordsatwork.ca?subject=Words at Work Link Referral Link&Body=Thought you might be interested in this link: http://www.wordsatwork.ca/html/' + filenm + '"><b>Pass&nbsp;it&nbsp;on</b></a></div>');

//	  document.write('<div id="emailtofriend2">Think this information is of interest to others? <a href="mailto:wolfgang@wordsatwork.ca?subject=Ask Wolf&Body=Thought you might be interested in this link: http://www.wordsatwork.ca/html/' + filenm + '"><b>Pass&nbsp;it&nbsp;on</b></a></div>');
	  
	  	} 
 
function adshow( adfn ) {
//*******************************************************************************
//	Display a window with big add pic
//*******************************************************************************
 
 	setCookie("ad", adfn);
	window.open("adshow.html", "newwin", "width=650,height=720,scrollbars=yes,status=yes,resizable=yes");
}

function show( adfn ) {
//*******************************************************************************
//	Display a window with big add pic - From home page
//*******************************************************************************
 
 	setCookie("ad", adfn);
	window.open("html/adshow.html", "newwin", "width=630,height=580,scrollbars=yes,status=yes,resizable=yes");
}

function copyright() {
//*******************************************************************************
//	Display a window with copyright info
//*******************************************************************************
 //   alert("homepage=" + homepage);
 	if (homepage) {
 	   cdir = "html/";
 	}   
 	else {   
	   cdir = "";
	} 
 
	window.open(cdir + "copyright.html", "newwin", "width=400,height=500,scrollbars=yes,status=yes,resizable=yes");
}
function copyright2() {
//*******************************************************************************
//	Display a window with copyright info from Homepage
//*******************************************************************************
	window.open("html/copyright.html", "newwin", "width=300,height=400,scrollbars=yes,status=yes,resizable=yes");
}
function setCookie(name, value, expires, path, domain, secure) {
//*******************************************************************************
// Generic rtn to set a cookie.
//*******************************************************************************
       var curCookie = name + "=" + escape(value) +
           ((expires) ? "; expires=" + expires.toGMTString() : "") +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           ((secure) ? "; secure" : "");
       document.cookie = curCookie;
}
function getCookie(name) {
       var dc = document.cookie;
       var prefix = name + "=";
       var begin = dc.indexOf("; " + prefix);
       if (begin == -1) {
         begin = dc.indexOf(prefix);
         if (begin != 0) return null;
       } else
         begin += 2;
       var end = document.cookie.indexOf(";", begin);
       if (end == -1)
         end = dc.length;
       return unescape(dc.substring(begin + prefix.length, end));
     }     
function makeArray(){
    this.length = makeArray.arguments.length 
        for (var i = 0; i < this.length; i++)
        this[i + 1] = makeArray.arguments[i]
}

function randNum (num) {
    var now = new Date();                                  
    var rand = Math.round(num * Math.cos(now.getTime()));  
    if (rand < 0) rand = - rand; if (rand == 0) rand++;        
    return rand;                                           
}

function showgal(pic,w,h) {
//*******************************************************************************
//	Display a window with big pic - For Pubinfo Image Gallery
//*******************************************************************************
	 
	var title="Words At Work - Gallery";
	 
	
//	if (h > 700) h = 700;
	var wsave = w;
	var h = h + 70;
	var w = w + 40;
 
	var data = '<html><head>';

 	data += '<script type="text/javascript" language="JavaScript"><!--  ';
 	data += 'if(document.images){ lineon = new Image(); lineon.src="../images/ani-line.gif"; lineoff = new Image(); lineoff.src="../images/spacer.gif";'
 	data += ' loadon = new Image(); loadon.src="../images/b-load.gif"; loadoff = new Image(); loadoff.src="../images/b-clickad.gif"; }';
 	data += 'function flipImg(imgNam,imgTyp,onoff){ if(document.images) { document.images[imgNam].src=eval(imgTyp+onoff+".src");  } } ';
 	data += '//--> </script>';
 	data +='<link rel="stylesheet" href="waw.css">';
 	data +='</head>';
	data += '<title>' + title + '</title><body bgcolor="#103063" background="../images/bg.gif" leftmargin=0 topmargin=0 marginheight=0 ';
	data += 'xonLoad=\'flipImg("load","load","off");flipImg("line","line","off");\'>';
	data += '<center>';
	data += '';
//	data += '<img xname="load" src="../images/spacer.gif" width="1" height="10" alt="" border=""><br>';
	data += '<img name="load" src="../images/b-clickad.gif" width="142" height="11" alt="" border="0"><br>';
//	data += '<img name="line" src="../images/ani-line.gif" width="398" height="1" alt="" border="0"><br>';
	data += '';

	data += '<a href="javascript:self.close()" onMouseOver="self.status=\'Click on image to close window.\'; return true" onMouseOut="self.status=\'\'; return true">';
	data += '<img src="../images/' + pic + '" alt="Click on image to close window." border="0"></a></center>';	
	data += '</td></tr></table>';
	data += '</body></html>';	
 
	var newWindow = window.open('','newWin', "width=" + w + ",height=" + h + ",scrollbars=yes,status=yes,resizable=yes", "alwaysRaised");	
 	
	newWindow.document.write(data);
	newWindow.document.close('newWin'); //* Close the data stream
	newWindow.resizeTo(w,h);			//* Resize the window for latest image 
	newWindow.focus(); 					//* Bring to front
} 

 function spaceTrim(InString) {
//*******************************************************************************
// Trim leading and trailing spaces of form input fields
//*******************************************************************************
	var LoopCtrl=true;
	while (LoopCtrl) {
		if (InString.indexOf("  ") != -1) {
			Temp = InString.substring(0, InString.indexOf("  "))
			InString = Temp + InString.substring(InString.indexOf("  ")+1, 
				InString.length)
		} else
			LoopCtrl = false;
	}
	if (InString.substring(0, 1) == " ")
		InString = InString.substring(1, InString.length)
	if (InString.substring (InString.length-1) == " ")
		InString = InString.substring(0, InString.length-1)
	return (InString)
}

// Email.js version 5 http://www.bronze-age.com/nospam/
var tld_ = new Array()
tld_[0] = "com";
tld_[1] = "org";
tld_[2] = "net";
tld_[3] = "ws";
tld_[4] = "info";
tld_[10] = "co.uk";
tld_[11] = "org.uk";
tld_[12] = "gov.uk";
tld_[13] = "ac.uk";
tld_[14] = "ca";
var topDom_ = 14;
var m_ = "mailto:";
var a_ = "@";
var d_ = ".";

function mail(name, dom, tl, params)
{
	var s = e(name,dom,tl);
	document.write('<a href="'+m_+s+params+'">'+s+'</a>');
}
function mail2(name, dom, tl, params, display)
{
	document.write('<a href="'+m_+e(name,dom,tl)+params+'">'+display+'</a>');
}
function e(name, dom, tl)
{
	var s = name+a_;
	if (tl!=-2)
	{
		s+= dom;
		if (tl>=0)
			s+= d_+tld_[tl];
	}
	else
		s+= swapper(dom);
	return s;
}
function swapper(d)
{
	var s = "";
	for (var i=0; i<d.length; i+=2)
		if (i+1==d.length)
			s+= d.charAt(i)
		else
			s+= d.charAt(i+1)+d.charAt(i);
	return s.replace(/\?/g,'.');
}

//******************************************************************************* 
//  Toggle show/hide div   http://www.randomsnippets.com/2008/02/12/how-to-hide-and-show-your-div/
//******************************************************************************* 
function toggle5 (showHideDiv, switchImgTag) {
        var ele = document.getElementById(showHideDiv);
        var imageEle = document.getElementById(switchImgTag);
        if(ele.style.display == "block") {
                ele.style.display = "none";
		imageEle.innerHTML = '<img src="../images/icon-plus.gif">';
        }
        else {
                ele.style.display = "block";
                imageEle.innerHTML = '<img src="../images/icon-minus.gif">';
        }
}

function showAddr(part1, part2){
//*******************************************************************************
//	Display mailto link, hide from spam miners.
//*******************************************************************************
  if (part2 == undefined) part2 = "wordsatwork.ca";	
  var addr = part1 + "@" + part2;
  var result = ("<a href='" + "mail" + "to:" + addr + "'>" + addr + "</a>")
  return result;
} 