var mainLinkArr_3;
function photofader3(nm, mainDiv, imgArr, linkArr){
	this.name		= nm;
	this.imgArr = imgArr;
	this.curImg = 0;
	this.curDiv = 1;
	mainLinkArr_3 = linkArr;
	var mainDv = document.getElementById(mainDiv);
	
	document.pfObj_3 = this;
	
	document.write("<style type='text/css'>\n");
	document.write("#pf_photo1_3 img { visibility:hidden; }\n");
	document.write("#pf_photo1_3 { position:absolute; z-index: 1; }\n");
	document.write("#pf_photo2_3 { position:absolute; z-index: 0; }\n");
	document.write("</style>");
	
	this.initImages_3 = function() {
		document.write("<scr");
		document.write("ipt type='text/javascript'>\n");
		for(var i=0; i<this.imgArr.length; i++){
			document.write("var img"+i+" = new Image();\n");
			document.write("img"+i+".src = '"+ this.imgArr[i] +"';\n");			
		}
		document.write("document.pfObj_3.start_3();\n");
		document.write("</scr");
		document.write("ipt>\n");
		
	} 
	
	this.start_3 = function(){
		var hldr1 = "pf_photo1_3";
		var hldr2 = "pf_photo2_3";
		
		var dv1 = document.createElement("div");
				dv1.id = "pf_photo1_3";
				loc = "document.location='"+mainLinkArr_3[0]+"'";
				dv1.innerHTML = '<img src="'+ imgArr[0] +'" onclick="'+loc+'" style="cursor:pointer;" />';
		var dv2 = document.createElement("div");
				dv2.id = "pf_photo2_3";
		
		mainDv.appendChild(dv1);
		mainDv.appendChild(dv2);
		
	  image1 = document.getElementById(hldr1).childNodes[0];
		
	  setOpacity_3(image1, 0);
	  image1.style.visibility = 'visible';
	  fadeIn_3(hldr1,0);
	}
	
	this.initImages_3();
}
	
function setOpacity_3(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_3(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId).childNodes[0];
    if (opacity < 100) {
			speed_3 = (speed_3 < 2)?2:speed_3;
      setOpacity_3(obj, opacity);
			opacityDif = Math.ceil((100-opacity)/speed_3);
			opacity += opacityDif;
      //opacity += 2;
      window.setTimeout("fadeIn_3('"+objId+"',"+opacity+")", 100);
    }
		else
			setTimeout("swapImages_3()",delay_3*1000);
  }
}

function swapImages_3(){
	// find out which 
	if(document.pfObj_3.curImg == document.pfObj_3.imgArr.length-1)
		document.pfObj_3.curImg = 0;
	else 
		++document.pfObj_3.curImg;

	// now get the div to hld the new image
	var dvName	= (document.pfObj_3.curDiv == 1)?"pf_photo2_3":"pf_photo1_3";
	var eDivName		= (document.pfObj_3.curDiv == 1)?"pf_photo1_3":"pf_photo2_3";
	document.pfObj_3.curDiv = (document.pfObj_3.curDiv == 1)?2:1;
	
	var tgtDiv = document.getElementById(dvName);
	var eDiv = document.getElementById(eDivName);

	
	loc = "document.location='"+mainLinkArr_3[document.pfObj_3.curImg]+"'";
	
	// now fill the target div
	tgtDiv.innerHTML = '<img src="'+ document.pfObj_3.imgArr[document.pfObj_3.curImg] +'" style="visibility:hidden; cursor:pointer;" onclick="'+loc+'" />';
	
	//move the divs around in z-index
	eDiv.style.zIndex = 0;
	tgtDiv.style.zIndex = 1;
	
	// And finally fade in the image
	
  var img = tgtDiv.childNodes[0];
	
  setOpacity_3(img, 0);
  img.style.visibility = 'visible';
  fadeIn_3(tgtDiv.id,0);
}
