function photofader(imageClassName, mainDiv, imgArr, hrefArr){
	PhotoTextFader(imageClassName, mainDiv, imgArr, null, hrefArr, null,null);
}

/*** test ***/
function PhotoTextFader(imageClassName, mainDiv, imgArr, hrefId, hrefArr, textDivId, textArr){

	this.imageClassName		= imageClassName;
	this.imgArr = imgArr;
	this.curImg = 0;
	this.curDiv = 1;
	this.hrefArr = hrefArr;
	this.textArr = textArr;
	this.mousein = false;
	
	var mainDv = document.getElementById(mainDiv);
	mainDv.onmouseover = function() { document.pfObj.mousein = true; 
	}
	mainDv.onmouseout = function() { document.pfObj.mousein = false;}
	if(textDivId)
	{
		this.divText = document.getElementById(textDivId);

		// debug
		if (this.divText == null)
		{
			alert("you gave me a text array but a bogus text object");
		}

	}
	else
		this.divText = null;
		
	if (hrefId)
		this.href = document.getElementById(hrefId);
	else
		this.href = null;

/** User variables.  if not defined, used our defaults**/
	this.speed = window.speed ? speed : 10;
	this.delay = window.delay ? delay : 3; // Number of seconds between each slide transition

	
	document.pfObj = this;
	
	this.initImages = function() {
		document.write("<style type='text/css'>\n");
		document.write("#pf_photo1 img { visibility:hidden; }\n");
		document.write("#pf_photo1 { position:absolute; z-index: 1; }\n");
		document.write("#pf_photo2 { position:absolute; z-index: 0; }\n");
		document.write("</style>");
	}
	
	this.start = function(){
		var hldr1 = "pf_photo1";
		var hldr2 = "pf_photo2";
		
		var dv1 = document.createElement("div");
		    dv1.id = hldr1;
		var dv2 = document.createElement("div");
		    dv2.id = hldr2;
		
		mainDv.appendChild(dv1);
		mainDv.appendChild(dv2);
		
	    image1 = document.getElementById(hldr1).childNodes[0];
		this.curImg = -1;
		swapImages();
	}
	
	this.initImages();
	this.start();
}


	
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId).childNodes[0];
    if (opacity < 100) {
		speed = document.pfObj.speed;
		speed = (speed < 2)?2:speed;
      	setOpacity(obj, opacity);
		opacityDif = Math.ceil((100-opacity)/speed);
		opacity += opacityDif;
    	//opacity += 2;
      	window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
	else
	{
		if (document.pfObj.divOld)
			document.pfObj.divOld.innerHTML = "";
		setTimeout("SwapImagesIfMouseOut()",document.pfObj.delay*1000);
	}
  }
}

function SwapImagesIfMouseOut()
{
	if (document.pfObj.mousein == false)
	{
		swapImages();
	}
	else
	{
		setTimeout("SwapImagesIfMouseOut()",document.pfObj.delay*1000);
	}
}

function swapImages(){
	// find out which 
	if(document.pfObj.curImg == document.pfObj.imgArr.length-1 ||
		document.pfObj.curImg == -1)
		document.pfObj.curImg = 0;
	else 
		++document.pfObj.curImg;

	var divNew;
	var divOld;
	
	// now get the div to hld the new image
	if (document.pfObj.curDiv == 1) {
		var divNew = document.getElementById("pf_photo2");
		var divOld = document.getElementById("pf_photo1");
		document.pfObj.curDiv = 2;
	}
	else
	{
		var divOld = document.getElementById("pf_photo2");
		var divNew= document.getElementById("pf_photo1");
		document.pfObj.curDiv = 1;
	}		
	document.pfObj.divOld = divOld; // this is the div that's going away.
	
	var innerHTML = "";
	if (document.pfObj.hrefArr)
	{
		document.pfObj.href.href = document.pfObj.hrefArr[document.pfObj.curImg];
	}
	
	if (document.pfObj.textArr)
	{
		document.pfObj.divText.innerHTML = document.pfObj.textArr[document.pfObj.curImg];
		if (document.pfObj.hrefArr)
			document.pfObj.divText.href = document.pfObj.hrefArr[document.pfObj.curImg];
	}
	
	// now fill the target div
	innerHTML += "<img id='pf_imgFade' class='" + document.pfObj.imageClassName + "' src='"+ document.pfObj.imgArr[document.pfObj.curImg] +"' style='visibility:hidden;' />";
	//"+ document.pfObj.hrefArr[document.pfObj.curImg] +"
	
	divNew.innerHTML = innerHTML;
	//move the divs around in z-index
	divOld.style.zIndex = 0;
	divNew.style.zIndex = 1;
	
	// And finally fade in the image
	
    var img = divNew.childNodes[0];
//    img = document.getElementById('pf_imgFade');
	
    setOpacity(img, 0);
    img.style.visibility = 'visible';
    fadeIn(divNew.id,0);
}

