
window.addEventListener?window.addEventListener("load",so_init4,false):window.attachEvent("onload",so_init4);

var d=document, imgs4 = new Array(), zInterval = null, current4=0, pause=false;

var counterValue4 = 0;
var bahTwo4 = true;
function so_init4() {
	if(!d.getElementById || !d.createElement)return;
	
	imgs4 = d.getElementById("imageContainerHeader").getElementsByTagName("img");
	for(i=1;i<imgs4.length;i++) imgs4[i].xOpacity4 = 0;
	imgs4[0].style.display = "block";
	imgs4[0].xOpacity4 = .99;
		
	checkHeights4(0);
}

function so_xfade4() {
	cOpacity4 = imgs4[current4].xOpacity4;
	nIndex4 = imgs4[current4+1]?current4+1:0;
	nOpacity4 = imgs4[nIndex4].xOpacity4;
	
	cOpacity4-=.02; 
	nOpacity4+=.02;
	
	imgs4[nIndex4].style.display = "block";
	imgs4[current4].xOpacity4 = cOpacity4;
	imgs4[nIndex4].xOpacity4 = nOpacity4;
	
	setOpacity4(imgs4[current4]); 
	setOpacity4(imgs4[nIndex4]);
			
	if(cOpacity4<=0) {
		
		imgs4[current4].style.display = "none";
		current4 = nIndex4;
		
		// check height of image and if falls outside of div then move up.
		x=new Image;
		x.src=imgs4[current4].src;
		
		iw=x.width;
		ih4=x.height;
		ix=imgs4[current4].style.top;
		iy=imgs4[current4].style.left;
		imgs4[previousImage4].style.top = "0px";
		checkHeights4(0);
		bahTwo4 = true;
		
	} else {
		setTimeout(so_xfade4,50);
	}
	
	function setOpacity4(obj) {
		if(obj.xOpacity4>.99) {
			obj.xOpacity4 = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity4;
		obj.style.MozOpacity = obj.xOpacity4;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity4*100) + ")";
	}
	
}

function checkHeights4(dodis4) {
	ih4 = imgs4[current4].height;

	if (ih4 > (157+20)) {
		ih4d = ih4 - 157;
	
		if (dodis4 < ih4d) {
			topStr4 = imgs4[current4].style.top;
			pxStart4 = topStr4.indexOf("px");
			topVal4 = topStr4.substring(0,pxStart4);
			imgs4[current4].style.top = (topVal4 - 1) + "px";
			dodis4 += 1;
			bahTwo4 = false;
			the_timeout4 = setTimeout("checkHeights4("+ dodis4 +");", 50);
		} else {
			bahTwo4 = true;
			setTimeout(so_xfade4,4000);
		}
	}
	else {
		setTimeout(so_xfade4,4000);
	}
	previousImage4 = current4;
}