/*************************************************************
 *	faderObj
 *	version 1.0
 *************************************************************/
faderObj.Instances = new Array();

function faderObj() {
	var count = 1;
	var opactity = 0;
	var width;
	var height;
	var top;
	var left;
	var div;
	var repeated;
	var functionAfter;
	
	this.id = faderObj.Instances.length;
	faderObj.Instances[this.id] = this;
		
	this.findPercentX = findPercentX;
	this.findPercentY = findPercentY;
	this.findCenterX = findCenterX;
	this.findCenterY = findCenterY;
	this.doPlacement = doPlacement;
	this.doCenter = doCenter;
	this.doPosition = doPosition;
	this.doFade = doFade;
	this.undoFade = undoFade;
	this.startShow = startShow;
	this.endShow = endShow;
	this.startHide = startHide;
	this.endHide = endHide;
	
	function findPercentX(percent) {
		var myWidth = this.width
		
		var winW = 630;
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				//alert("Using MS");
				winW = document.body.offsetWidth;
			}
			
		}
		
		var left = (winW * percent) - (myWidth / 2) ;
		return left;
	}
	function findCenterX() {
		var myWidth = this.width
		
		var winW = 630;
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				//alert("Using MS");
				winW = document.body.offsetWidth;
			}
			
		}
		
		var left = (winW / 2) - (myWidth / 2) ;
		return left;
		
	}
	function findPercentY(percent) {
		var myHeight = this.height;
		
		var winH = 460;
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winH = window.innerHeight;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				//alert("Using MS");
				winH = document.body.offsetHeight;
			}
			
		}
		var ScrollTop = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			ScrollTop = window.pageYOffset;
			
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			ScrollTop = document.body.scrollTop;
			
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			ScrollTop = document.documentElement.scrollTop;
			
		}
		var top = ScrollTop + ((winH * percent ) - (myHeight /2 ));
		return top;
	}
	function findCenterY() {
		var myHeight = this.height;
		
		var winH = 460;
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winH = window.innerHeight;
			}
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				//alert("Using MS");
				winH = document.body.offsetHeight;
			}
			
		}
		var ScrollTop = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			ScrollTop = window.pageYOffset;
			
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			ScrollTop = document.body.scrollTop;
			
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			ScrollTop = document.documentElement.scrollTop;
			
		}
		var top = ScrollTop + ((winH / 2 ) - (myHeight /2 ));
		return top;
	}
	function doPlacement(div,percentX,percentY) {
		//get the height and width of the element
		this.top = this.findPercentY(percentY);
		this.left = this.findPercentX(percentX);
		this.div = div;
		this.doPosition();
	}
	function doCenter(div) {
		
		//get the height and width of the element
		this.top = this.findCenterY();
		this.left = this.findCenterX();
		this.div = div;
		this.doPosition();
	}
	function doPosition() {
		
		//now position the element
		this.opacity = 0;
		this.div.style.filter="alpha(opacity=" + this.opacity + ")";
		this.div.style.position = "absolute";
		this.div.style.top = this.top + "px";
		this.div.style.left = this.left + "px";
		this.div.style.display = "block";
		this.div.style.width = this.width + "px";
		this.div.style.height = this.height + "px";
		
		this.startShow();
	}
	
	function doFade() {
		
		this.count++;
		if(typeof(this.div) == "undefined") { this.endShow(); }
		if(this.opacity <= 100) {
			//div = document.getElementById('confirmed');
			this.div.style.filter="alpha(opacity=" + this.opacity + ")";
			this.div.style.MozOpacity = this.opacity / 100;
		}
		else { this.endShow(); }
		this.opacity = this.opacity + 20;
	
	}
	
	function undoFade() {
		if(typeof(this.div) == "undefined") { this.endShow(); }
		if(this.opacity >= 0) {
			//div = document.getElementById('confirmed');
			this.div.style.filter="alpha(opacity=" + this.opacity + ")";
			this.div.style.MozOpacity = this.opacity / 100;
		}
		else { this.endHide(); }
		this.opacity = this.opacity - 20;
	
	}
	
	function startShow() {
		
		this.opacity = 0;
		this.repeated = window.setInterval("faderObj.Instances[" + this.id + "].doFade()",1);
	}
	function endShow() {
		window.clearInterval(this.repeated);
		
		if(this.functionAfter) {
			eval(this.functionAfter + "()");
		}
		
	}
	
	function startHide() {
		this.opacity = 0;
		this.repeated = window.setInterval("faderObj.Instances[" + this.id + "].undoFade()",1);
	}
	function endHide() {
		
		this.div.style.display = "none";
		window.clearInterval(this.repeated);
		
		if(this.functionAfter) {
			eval(this.functionAfter + "()");
		}
	}

}