/****************************************************
*			    	General Routines
*             ==================
*            (c) Adrian Jones, woodsgood.ca
*****************************************************/

// returns the "name" Object
function getObject(name) {return (document.getElementById?document.getElementById(name):document.all?document.all[name]:document.layers?eval("document.layers[\"" + name + "\"]"):null); }

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// "within-page" navigation; one <DIV> (of id "objid") is displayed while making previous element invisible.
var objPage = null;										// old (or previous) object
function doShow(objid) {
	if (objPage) objPage.style.display="none";	// blank any that are displayed
	objPage=getObject(objid)							// get referenced object
	objPage.style.display = "block";					// display it
}

// writes the copyright information on page
function doCopy() {
	var r=new Date(),y=r.getFullYear();
	document.write('<div id="copy"> © <a href="mailto:deborah.margo@sympatico.ca">deborah margo</a>, ' + y + '</div>');
}


function doAdd() {
	document.write('<p><span class="bigLetter">2</span> Allan Place<br />Ottawa, Ontario  K1S 3T1<br />Email: <a href="mailto:deborah.margo@sympatico.ca">deborah.margo@sympatico.ca</a></p>');
}


/* ***************************************************/

var pX = 100;var pY = 100;
var picMat=25; 	// mat border (pixels) around picture (height & width)
var matBorder=25;	// border (pixels) around mat for window (height & width)
var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isOP=(navigator.appName=="Opera")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

function popImage(imageURL,imageTitle,w,h){
// option list for opening //
   var matW=(w+2*picMat);var matH=(h+2*picMat);
   var boxW=(matW+2*matBorder+11);var boxH=(matH+2*matBorder+11);
	var opt='status=no,scrollbars=no,menubar=no,toolbar=no,resizable=no,width='+boxW+',height='+(boxH+5)+',left='+pX+',top='+pY+'';
// unique for ie
	if (isIE) opt='status=no,scrollbars=no,menubar=no,toolbar=no,resizable=no,width='+boxW+',height='+(boxH+5)+',left='+pX+',top='+pY+'';
// open window
	imgWin=window.open('','n',opt);
	with (imgWin.document){

// header & styles
  var msg =  '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
		msg += '<html><head><title>'+imageTitle+'</title><meta http-equiv="Content-Style-Type" content="text/css">';
		msg += '<style type="text/css">#theArt {visibility:hidden} #artBox {background:transparent url(\'images/loading.gif\') 50% 50% no-repeat;}.tit {height:15px;font-weight:bold;font-family:"Trebuchet MS",sans-serif;font-size:10pt;text-align:center;}</style>';

// javascript for fading in image
	  msg += '<script type="text/Javascript">function initImage() {imageId="theArt";image=getObject(imageId);image.style.visibility="visible";setOpacity(image,0);fadeIn(imageId,0);} function fadeIn(objId,opacity) {obj = getObject(objId);if (opacity <= 100) {setOpacity(obj, opacity);opacity += 10;window.setTimeout("fadeIn(\'"+objId+"\',"+opacity+")", 50);}} function setOpacity(obj, opacity) { opacity = (opacity == 100)?99.999:opacity; obj.style.filter = "alpha(opacity:"+opacity+")"; obj.style.KHTMLOpacity = opacity/100; obj.style.MozOpacity = opacity/100; obj.style.opacity = opacity/100;}function getObject(obj) {var theObj;if(document.all) {if(typeof obj=="string") { return document.all(obj);} else {return obj.style;}} if(document.getElementById) {if(typeof obj=="string") {return document.getElementById(obj); } else {return obj.style;}} return null; }</script>';

// body
		msg += '</head><body bgcolor="#ffffff" scroll="no" onload="self.focus();initImage();'
		msg += (!AutoClose)?'">':'" onblur="self.close()">';

// main table inside window
	msg += '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="10"><tr><td align="center" valign="middle">';

//
	msg += '<table height="'+(matH+11)+'" width="'+(matW+11)+'" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td style="border-top: solid 1px #dddddd;border-left: solid 1px #dddddd;">';

// image box
	msg += '<table height="'+matH+'" width="'+matW+'" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td align="center" valign="middle"><div id="artBox"><img alt="art" name="theArt" src="'+imageURL+'" style="display:block" id="theArt" height="'+h+'" width="'+w+'"></div></td></tr></table>';
// right shadow...
	msg += '</td><td valign="top" background="images/rt.jpg"><img border="0" width="11" height="13" src="images/tr.jpg" alt="shadow"></td></tr>';
// bottom shadow...
	msg += '<tr><td width="'+matW+'" align="left" background="images/bt.jpg"><img border="0" width="11" height="11" src="images/bl.jpg" alt="shadow"></td><td width="11"><img border="0" width="11" height="11" src="images/br.jpg" alt="shadow"></td></tr></table><div class="tit">'+imageTitle+'</div></td></tr></table>';

   msg += '</body></html>';
   writeln (msg);
	close();
	}
}

// functions for fading in image
function initImage() {
	imageId='thephoto';
	image = getObject(imageId);
	image.style.visibility="visible";
	setOpacity(image,0);
	fadeIn(imageId,0);
}

function fadeIn(objId,opacity) {
	obj = getObject(objId);
	if (opacity <= 100) {
		setOpacity(obj, opacity);
		opacity += 10;
		window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
	}
}

function setOpacity(obj, opacity) {
	if(isIE) opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	if(isIE) obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	if(isNN) obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	if(isNN) obj.style.opacity = opacity/100;
}


function toggle(){
	var About = getObject("AboutToggle");
	var ABody = getObject("AboutBody");
	if(ABody.style.display == 'none'){
		ABody.style.display="block";
//		About.innerHTML=('&laquo; Hide Details'); 
		
	} else {
//		About.innerHTML=('About <em>Deborah Margo</em> &raquo;');
		ABody.style.display="none";
	}
}

var startFlag="true"
function stop() {
	if (startFlag) startFlag=!startFlag
}
function start() {
	if (!startFlag) startFlag=!startFlag
}


/**********************************************************************************
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
*
* Mods [*] by Adrian Jones: woodsgood.ca
***********************************************************************************/
//called with "fadeshow(image_array,width,height,border,delay(ms),pause(0=no,1=yes),optionalRandomOrder)"

var fadebgcolor="#C6CCAC"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all;
var len=0;								// number of images in array
var picAlign="middle"				// vertical alignment of images
 
function fadeshow(theimages, fadewidth,fadeheight,valign,borderwidth,delay,pause,displayorder,bW){
	len=theimages.length;
	picAlign = (valign!="")? valign:"middle";

 	this.pausecheck=pause;
	this.mouseovercheck=0;
	this.delay=delay;
	this.degree=10;		//initial opacity degree (10%)
	this.curimageindex=0;
	this.nextimageindex=1;
	fadearray[fadearray.length]=this;
	this.slideshowid=fadearray.length-1;
	this.canvasbase="canvas"+this.slideshowid;
	this.curcanvas=this.canvasbase+"_0";
//	if (typeof displayorder!="undefined") theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
	this.theimages=theimages;
	this.imageborder=parseInt(borderwidth);
	this.postimages=new Array() //preload images
	for (p=0;p<theimages.length;p++){
		this.postimages[p]=new Image();
		this.postimages[p].src=theimages[p][0];
	}
// var sc=Math.min(1,(bW-450)/500);
var fadewidth=fadewidth+this.imageborder*2;
var fadeheight=fadeheight+this.imageborder*2;
 
if (iebrowser&&dom||dom) {//if IE5+ or modern browsers (ie: Firefox)
	document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=0);-moz-opacity:0;background-color:'+fadebgcolor+'"></div></div>')}
else {
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')}
 
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
		this.startit()
	else{
		this.curimageindex++
		setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
	}
}

function fadepic(obj){
	if (obj.degree<100){
	obj.degree+=5;
	if (obj.tempobj.filters&&obj.tempobj.filters[0]){
		if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
			obj.tempobj.filters[0].opacity=obj.degree
		else //else if IE5.5-
			obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
	}
else if (obj.tempobj.style.MozOpacity) obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity) obj.tempobj.style.KhtmlOpacity=obj.degree/100
	}else{
  		clearInterval(fadeclear[obj.slideshowid])
  		obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
  		obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
  		obj.populateslide(obj.tempobj, obj.nextimageindex)
  		obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
  		setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex, sc){
	var slideHTML='<table width="100%" height="100%" align="center"><tr><td valign="'+picAlign+'">';
	if (this.theimages[picindex][1]!="") {    //if associated link exists for image
		slideHTML+='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">';
	}
	var t=this.postimages[picindex];
	sc=1;
	var tW=t.width*sc;var tH=t.height*sc;
	slideHTML+='<img src="'+this.postimages[picindex].src+'" width="'+tW+'" height="'+tH+'" border="'+this.imageborder+'px" class="slidePic">';
/* addition by AJ to add picture text (if present) and image number below image */
//	slideHTML+='<div class="picTitle">'+((this.theimages[picindex][3]!="")?this.theimages[picindex][3]:(picindex+1)+"/"+len+"")+'</div>';
slideHTML+='<div class="picTitle">['+(picindex+1)+'/'+len+']<br />';
slideHTML+= (this.theimages[picindex][3]!="")? this.theimages[picindex][3]:"";
slideHTML+='</div>';
	if (this.theimages[picindex][1]!="") {   //if associated link exists for image
		slideHTML+='</a>';
	}
	slideHTML+='</td></tr></table>';
//	alert(slideHTML);
	setOpacity(picobj, 0);
	picobj.innerHTML=slideHTML

}
 
 
fadeshow.prototype.rotateimage=function(){
	if (this.pausecheck==1) //if pause onMouseover enabled, cache object
	var cacheobj=this
	if (this.mouseovercheck==1) setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
	if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
		crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
		crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
	}
this.rotateimage()
}


function initNews(time){
	newsTime=Number(time)
	if(newsTime>0) {
		objPage=getObject("newsBox");						// get referenced object
		objPage.style.display = "block";					// display it
		showNews();
	}
}

/*******************************************************
* showNews() makes the box visible for (adTime) seconds
* A seconds countdown (object "count") is shown in the box
********************************************************/

var newsTime=30;  // default seconds box is shown
var newsCount=0;

function showNews() {
	if(newsCount<newsTime) {
		newsCount+=1;
     	obj = getObject("newsCount");
		obj.innerHTML="<small>Hide in "+(newsTime-newsCount+1)+" secs</small>";
		setTimeout("showNews()",1000);}
	else closeNews();
}

function closeNews() {
	objPage=getObject("newsBox")							// get referenced object
	objPage.style.display = "none";					// display it
}
//***************************

