// code by A.Kemeny, all rights reserved, (c)opyright 2002.

var xPageLoad = false;

var ns4 = (document.layers) ? true : false;
var ie4 = (document.all) ? true : false;
var stateHidden = (ns4) ? "hide" : "hidden";
var stateVisible = (ns4) ? "show" : "visible";
var iPF = null;var iPFd = '';var iGF = new Array();

function _findImageGroup(groupName,entryPath) {
	myReg = new RegExp("^"+groupName+"_");
	if (ie4) {
		iGF.length = 0;
		for(var i=0;i<document.images.length;i++) {
			if (document.images[i].name.match(myReg)) {
				iGF[iGF.length] = document.images[i].name;
			}
		}
		return(true);
	}
	entryPath = (entryPath!='') ? entryPath : "document";
	eval("ep = "+entryPath+";");
	if (entryPath == 'document') { iGF.length = 0; }
	if (ep.images.length>0) {
		for(var i=0;i<ep.images.length;i++) {
			if (ep.images[i].name.match(myReg)) { iGF[iGF.length] = ep.images[i].name; }
		}
	}
	if (ep.layers.length>0) {
		for(var i=0;i<ep.layers.length;i++) {
			_findImageGroup(groupName,entryPath+".layers["+i+"].document");
			eval("ep = "+entryPath+";");
		}
	}
	return(true);
}
function _findImage(imgName,entryPath) {
	if (ie4) { iPF = document.all[imgName];iPFd = "document.all['"+imgName+"']";return(true); }
	entryPath = (entryPath!='') ? entryPath : "document";
	eval("ep = "+entryPath+";");
	if (ep.images.length>0) {
		for(var i=0;i<ep.images.length;i++) {
			if (ep.images[i].name==imgName) { iPF=ep.images[i];iPFd=entryPath+".images["+i+"]";return(true); }
		}
	}
	if (ep.layers.length>0) {
		for(var i=0;i<ep.layers.length;i++) {
			if (_findImage(imgName,entryPath+".layers["+i+"].document")) return(true);
			eval("ep = "+entryPath+";");
		}
	}
	return(false);
}
function xImage(imgName,animNum) {
	this.xIName = imgName;
	_findImage(imgName,'');
	this.xPath = iPF;
	this.xPathDesc = iPFd;
	this.xSrc = this.xPath.src;
	this.xAnimPlays = false;
	this.xPhase = 0;
	this.xNextPhase = 1;
	this.xPhases = new Array();
	this.xPhases[0] = new Image();
	this.xPhases[0].src = this.xSrc;
	if (animNum>0) {
		i=1;
		while(i<=animNum) {
			this.xPhases[i] = new Image();
			this.xPhases[i].src = this.xSrc.replace(/^(.+)\.([^.]+)$/,"$1"+"_"+i+".$2");
			i++;
		}
		this.xAnim = 1;
	} else {
		this.xAnim = -1;
	}
	this.getWidth = xImage_getWidth;
	this.getHeight = xImage_getHeight;
	this.setWidth = xImage_setWidth;
	this.setHeight = xImage_setHeight;
	this.isComplete = xImage_isComplete;
	this.gotoPhase = xImage_gotoPhase;
}
function xImage_gotoPhase(phaseNo) {
	if (this.xAnim==-1) { return(false); }
	this.xPath.src = this.xPhases[phaseNo].src;
	this.xPhase = phaseNo;
	return(true);
}
function xImage_resetAnim() {
	if (this.xAnim==-1) { return(false); }
	this.xSrc = this.xPhases[0].src;
	this.xAnimPlays = false;
	this.xPhase = 0;
	return(true);
}
function xImage_getWidth() {
	return(this.xPath.width);
}
function xImage_getHeight() {
	return(this.xPath.height);
}
function xImage_setWidth(nW) {
	this.xPath.width = nW;
}
function xImage_setHeight(nH) {
	this.xPath.height = nH;
}
function xImage_isComplete() {
	for(i=0;i<this.xPhases.length;i++) {
		if (this.xPhases[i].complete==false) { return(false); }
	}
	return(true);
}

function xFlipFlop(groupName) {
	window.status='Initializing new xFlipFlop object...';
	this.xGroup = new Array();
	_findImageGroup(groupName,"");
	for (l=0;l<iGF.length;l++) {
		this.xGroup[l] = new xImage(iGF[l],2);
	}
	this.unLight = xFlipFlop_unLight;
	this.highLight = xFlipFlop_highLight;
	this.highLightNum = xFlipFlop_highLightNum;
	window.status='Init done.';
}
function xFlipFlop_unLight() {
	for(var i=0;i<this.xGroup.length;i++) {
		this.xGroup[i].gotoPhase(0);
	}
	return(true);
}
function xFlipFlop_highLight(imageName) {
	this.unLight();
	for(var i=0;i<this.xGroup.length;i++) {
		if (this.xGroup[i].xIName == imageName) { this.xGroup[i].gotoPhase(1);return(true); }
	}
	return(true);
}
function xFlipFlop_highLightNum(imageNum) {
	this.unLight();
	this.xGroup[imageNum].gotoPhase(1);
	return(true);
}
function xSaW(xObj,xMethod,xArg) {
	if (xPageLoad == true) {
		eval(xObj+"."+xMethod+"("+xArg+");");
	}
	return;
}
function xAddtoFav(xLink,xDesc) {
	if (document.all) {
		window.external.AddFavorite(xLink,xDesc);
	}
	return;
}
function xMakeHome(xLink) {
	if (document.all) {
		window.external.setHomePage(xLink);
	}
	return;
}
function xStatMsg(xMsg) {
	status=xMsg;
	document.x_returnValue = true;
}
function xOpenWin( wName, wURL, wWidth, wHeight, wScroll, wResize ) {
	window.open(wURL,wName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+wScroll+',resizable='+wResize+',width='+wWidth+',height='+wHeight);
}

