NS4 = (document.layers);
NN6 = (navigator.appName.indexOf("Netscape") != -1 && navigator.appVersion.charAt(0) == "5");
if(!NN6)IE4 = (document.all);
if(NN6)NS6 = (document.getElementById)
appVer = navigator.appVersion;
IEmac = (IE4 && appVer.indexOf("Mac") != -1);
IE4mac = (IEmac && appVer.indexOf("MSIE 4") != -1);
IE40mac = (IE4mac && appVer.indexOf("4.0;") != -1);
IE45mac = (IE4mac && appVer.indexOf("4.5;") != -1);
NSpre401 = (NS4 && (parseFloat(appVer) <= 4.01));
NSpre403 = (NS4 && (parseFloat(appVer) <= 4.03));

FDRjustFlip = (window.FDRjustFlip) ? FDRjustFlip : false;
FDRhdlineCount = (window.FDRhdlineCount) ? FDRhdlineCount : 1;
FDRmaxLoops = 999
FDRfinite = (FDRmaxLoops > 0);
FDRisOver = false;
FDRloadCount = 0;

blendTimer = null;

if (!window.prefix) prefix = "";

if (NS4) {
	if(FDRjustFlip || NSpre403) {
		totalLoads = 1;
		FDRfadeImg = new Object();
		FDRfadeImg.width = FDRboxWid - (FDRborWid*2);;
	}
	else {
		totalLoads = 2;
		FDRfadeImg = new Image();
		FDRfadeImg.onload = FDRcountLoads;
		FDRfadeImg.onerror = FDRcountLoads;
		FDRfadeImg.src = "http://images.vivospage.com/images/fade.gif";
	}
}

function FDRcountLoads(e) {
	if (IE4) {
		setTimeout("FDRinit()",1);
	}
	else {
		if(e.type == "error") FDRjustFlip = true; 
		FDRloadCount++;
		if (FDRloadCount==totalLoads) {
			origWidth = innerWidth;
			origHeight = innerHeight;
			window.onresize = function(){
				if (innerWidth==origWidth && innerHeight==origHeight) return;
				location.reload();
			}
			FDRinit();
		}
	}
}

function FDRinit(myElmObj){
	FDRboxWid = parseInt(contentCell*0.9);
	FDRboxHgt = 32;
	FDRbackCol = "white";
	FDRborWid = 3;
	FDRborSty = "solid";
	FDRborCol = "#FFFFFF";
	FDRboxPad = 5;
	
	FDRtxtAln = "center";
	FDRlinHgt = "11pt";
	FDRfntFam = "Geneva,Arial,sans-serif";
	FDRfntSiz = "10pt";
	FDRfntWgh = "bold";
	FDRfntSty = "normal";
	FDRfntCol = "black";
	FDRlnkDec = "none";
	FDRlnkCol = "blue";
	FDRhovCol = "red";
	
	FDRblendInt = 5;
	FDRblendDur = 1;
	FDRmaxLoops = 999;
	FDRendWithFirst = true;
	FDRreplayOnClick = true;
	FDRjustFlip = false;
	FDRhdlineCount = 1;
	FDRgifSrc = "http://images.vivospage.com/images/fade.gif";
	FDRgifInt = 60
    
    if (NS4) {
		with(document.classes.newslink.A) {
			textDecoration = FDRlnkDec;
			color = FDRlnkCol;
			fontWeight = FDRfntWgh;
			fontSize = FDRfntSiz;
			fontStyle = FDRfntSty;
			fontFamily = FDRfntFam;
			lineHeight = FDRlinHgt;
			textAlign = FDRtxtAln;
		}
		with(document.classes.nolink.P) {
			color = FDRfntCol;
			fontWeight = FDRfntWgh;
			fontSize = FDRfntSiz;
			fontStyle = FDRfntSty;
			fontFamily = FDRfntFam;
			lineHeight = FDRlinHgt;
			textAlign = FDRtxtAln;
		}
		FDRjustFlip = 1
		elGif = new Array();
		elCont = new Array();
		elNews = new Array();
		slideInc = new Array();
		startTop = new Array();
		WindowW = parseInt(window.innerWidth);
		for (i=0;i<window.ElmFader.length;i++){//here
	        //elFader = document.elFader;
			elFader = eval("document."+window.ElmFader[i].layer)
			with (elFader) {
				document.write(" ");
				document.close();
				bgColor = FDRborCol;
				clip.width = FDRboxWid;
				clip.height = FDRboxHgt;
				//left = (WindowW - FDRboxWid)
			}
			contWidth = FDRboxWid - (FDRborWid*2);
			contHeight = FDRboxHgt - (FDRborWid*2);
			elCont[i] = new Layer(contWidth,elFader);
			
			with (elCont[i]) {
				top = FDRborWid;
				left = FDRborWid;
				clip.width = contWidth;
				clip.height = contHeight;
				bgColor = FDRbackCol;
				visibility = "inherit";
			}
			
			newsWidth = contWidth - (FDRboxPad*2);
			newsHeight = contHeight - (FDRboxPad*2);
	        elNews[i] = new Layer(newsWidth,elCont[i]);
			with (elNews[i]) {
				top = FDRboxPad;
				left = FDRboxPad
				clip.width = newsWidth ;
				clip.height = newsHeight;
			}
			if (!FDRjustFlip) {
				elGif[i] = new Layer(contWidth,elCont[i]); 
		        imStr = "<IMG SRC='" + FDRgifSrc +"' WIDTH="+ Math.max(FDRfadeImg.width,(FDRboxWid - (FDRborWid*2)));
				imStr += (NSpre403) ? " onError='window.FDRjustFlip = true'>" : ">";
		        with (elGif[i]) {
					document.write(imStr);
		        	document.close();
					moveAbove(elNews[i]);
				}
		
				imgHeight = elGif[i].document.height;
				slideInc[i] = (imgHeight/(FDRblendDur*1000/FDRgifInt));
				startTop[i] = -(imgHeight - FDRboxHgt);
			}
	
			elFader.visibility =  "show";
		}//here
    }
    else if(IE4){
		//if (!window.elFader) return;
		for (i=0;i<window.ElmFader.length;i++){//here		
			myObj = eval("document.all." + window.ElmFader[i].layer)
			myObj.innerHTML ="";
			if(IE4mac) {
				document.body.insertAdjacentHTML("BeforeBegin","<STYLE></STYLE>");
			}
			else {
				if (!document.styleSheets.length) document.createStyleSheet();
			}
			with (document.styleSheets(document.styleSheets.length-1)) {
				addRule("A.newslink","text-decoration:"+FDRlnkDec+";color:"+ FDRlnkCol);
				addRule("A.newslink:hover","color:"+ FDRhovCol);
			}
	
			with (myObj.style) {
				errorOffset = (IE4mac) ? (FDRboxPad + FDRborWid) : 0;
				width = FDRboxWid - (errorOffset * 2);
				height = FDRboxHgt - (errorOffset * 2);
				if(IE4mac && !IE45mac){
					pixelLeft = myObj.offsetLeft + errorOffset;
					pixelTop = myObj.offsetTop + errorOffset;
				}
	
				backgroundColor = FDRbackCol;
				overflow = "hidden";
				color = FDRfntCol;
				fontWeight = FDRfntWgh;
				fontSize = FDRfntSiz;
				fontStyle = FDRfntSty;
				fontFamily = FDRfntFam;
				lineHeight = FDRlinHgt;
				textAlign = FDRtxtAln;
				cursor = "default";
				visibility = "visible";
				borderWidth = FDRborWid;
				borderStyle = FDRborSty;
				borderColor = FDRborCol;
				padding  = FDRboxPad;
	
				if(!FDRjustFlip) filter = "blendTrans(duration=" + FDRblendDur + ")";
			}
			myObj.onselectstart = function(){return false};	
			IEhasFilters = (myObj.filters.blendTrans) ? true : false;
	    }
		
		/*if (!NSpre401) {
			myObj.onmouseover = function (){
				FDRisOver = true;
			}
			myObj.onmouseout = function(){
				FDRisOver = false;
				status = "";
			}
		}*/
	}//here
	
	
	FDRstart(0);
}

function FDRstart(ind){
    newsCount = new Array();
	for(k=0;k<window.ElmFader.length;k++){
		newsCount[k]=ind;
	}
    if (FDRfinite) loopCount = 0;
    FDRdo();
    blendTimer = setInterval("FDRdo()",FDRblendInt*1000)
}

function FDRdo() {
	if(!blendTimer && loopCount>0) return;

    if (FDRfinite && loopCount==FDRmaxLoops) {
        for (i=0;i<window.ElmFader.length;i++){
			FDRend(window.ElmFader[i].layer,window.ElmFader[i].arNews);
		}
		return;
    }
	FDRfade();
    for(l=0;l<window.ElmFader.length;l++){
		if (newsCount[l] == window.ElmFader[l].arNews.length) {
	        newsCount[l] = 0;
	        //if (FDRfinite) loopCount++;
	    }
	}
}

function FDRmakeStr(myStr,myIndex){
	tempStr = "";
	for (i=0;i<FDRhdlineCount;i++){
		if(newsCount[myIndex]>=myStr.length)break;
		dispStr = myStr[newsCount[myIndex]];
		linkStr = myStr[newsCount[myIndex]+1];
		isLink = linkStr.length;
		if (isLink) {
			tempStr += "<P><A CLASS=newslink "
					+ "HREF='" + prefix + linkStr + "'>"
		            + dispStr + "</A></P>"
		}
		else {
			tempStr += ((NS4) ? "<P CLASS=nolink>" : "<P>") +dispStr+"</P>";

		}
        if(IE40mac) tempStr +="<BR>";
		newsCount[myIndex] += 2;
	}
	return tempStr;
}

function FDRfade(){
	for (j=0;j<window.ElmFader.length;j++){
		myStr = window.ElmFader[j].arNews;
		newsStr = FDRmakeStr(myStr,j);
	    if (NS4) {
			if (!FDRjustFlip) {
				elGif[j].top = startTop[j];
				elGif[j].visibility = "inherit";
			}
			elNews[j].visibility = "hide";
	        with (elNews[j].document) {
	            write(newsStr);
	            close();
	        }
			elNews[j].visibility = "inherit";
	    }else if(IE4){
			myObj = eval("document.all." + window.ElmFader[j].layer);
	        if(IEhasFilters)myObj.filters.blendTrans.Apply();
	        myObj.innerHTML = newsStr;
	        if(IEhasFilters)myObj.filters.blendTrans.Play();
	    }
	}
	if(FDRhdlineCount==1) window.status = (FDRisOver && isLink) ? (prefix + linkStr) : "";

    if (NS4 && !FDRjustFlip) FDRslide();
}

function FDRslide(){
	for (m=0;m<window.ElmFader.length;m++){
	    elGif[m].top += slideInc[m];
	    if (elGif[m].top >= 0) {elGif.visibility = "hide";return}
	}
    setTimeout("FDRslide()",FDRgifInt);
}

function FDRdblClickNS(){
	elFader.releaseEvents(Event.DBLCLICK);
	FDRstart(startIndex);
	return false;
}

function FDRend(){
	clearInterval(blendTimer);

	blendTimer = null;

	if (FDRendWithFirst) {
		newsCount = 0;
		FDRfade();
	}
	if (FDRreplayOnClick) {
		startIndex = FDRendWithFirst ? (FDRhdlineCount * 2) : 0;
		if (IE4) {
			elFader.title = "Double click to replay";
			elFader.ondblclick = function(){
				this.ondblclick = null;
				this.title = "";
				FDRstart(startIndex);
			}
		}
		else {
			elFader.captureEvents(Event.DBLCLICK);
			elFader.ondblclick = FDRdblClickNS;
		}
    }
}
