
//	Copyright (C) 2002-2006 FoxSet IT Solutions Ltd. All rights reserved.
//	www.foxset.com

var lastpop = null, hidetid = 0, actbtn = "";

function someescape(s) {

	var r = s.replace(/"/g, "&quot;");
	return(r.replace(/\\r|\\n/g, " "));
}

function overcolors(o, c, b) {

	if (! o.showsover) {
		o.showsover = true;
		if (c) {
			o.kcolor = o.style.color;
			o.style.color = c;
		}
		if (b) {
			o.kbackgroundColor = o.style.backgroundColor;
			o.style.backgroundColor = b;
		}
	}
}

function swimg(o, s) {

	var k, x;
	o.src = (x=(k=o.src).lastIndexOf("/"))<0?s:k.substr(0,x+1)+s;
}

function setoverimg(o, src) {

	if (! o.showsover) {
		o.showsover = true;
		o.koversrc = o.src;
		swimg(o, src);
	}
}

function ovbgi(o, im) {

	if (! o.kbgi) {
		o.kbgi = o.style.backgroundImage;
		o.style.backgroundImage = "url(" + im + ")";
	}
}

function setovcls(o, cls) {

	if (! o.bcls) {
		o.bcls = true;
		o.kclass = o.className;
		o.className = cls;
	}
}

function reverseover(o) {

	if (o.kbackgroundColor) o.style.backgroundColor=o.kbackgroundColor,o.kbackgroundColor="";
	if (o.kcolor) o.style.color=o.kcolor,o.kcolor="";
	if (o.koversrc) o.src=o.koversrc,o.koversrc="";
	if (o.kbgi) o.style.backgroundImage=o.kbgi,o.kbgi="";
	if (o.bcls) o.className=o.kclass;
	o.showsover=o.bcls=false;
}

function setbackimg(ot, src) {

	ot.o = document.getElementById(ot.tid);
	ot.setprop("src", 1);
	swimg(ot.o, src);
	ot.setprop("style.cursor", 1);
	ot.o.style.cursor = pcursor;
}

function qsetbacktxt(m, ot) {

	if ((m = document.getElementById(m)).tagName == "IMG")
		m = null;
	ot.o = document.getElementById(ot.tid);
	for (var i = arguments.length - 3; i > 1; i -= 3) {
		ot.setprop(arguments[i], 1);
		if (m)
			eval("ot.o." + arguments[i] + "=m." + arguments[i]);
		else
			eval("ot.o." + arguments[i] + "='" + arguments[i+2] + "';");
	}
	ot.setprop("style.cursor", 1);
	ot.o.style.cursor = pcursor;
}

function disforward(ot, seq, act) {

	var s = "(o=document.getElementById('" + ot.tid + "')).style.cursor='" + (ot.o = document.getElementById(ot.tid)).style.cursor + "';";
	ot.setprop("style.cursor", seq);
	ot.o.style.cursor = "default";
	if (act) {
		if (ot.o.onmouseout)
			ot.o.onmouseout();
		switch(ot.o.tagName) {
			case "DIV":
				for (var i = arguments.length - 2; i > 1; i -= 3) {
					ot.setprop(arguments[i - 1], seq);
					s += "o." + arguments[i - 1] + "='" + eval("ot.o." + arguments[i - 1]) + "';";
					eval("ot.o." + arguments[i - 1] + "='" + arguments[i] + "'");
				}
				break;
			case "IMG":
				ot.setprop("src", seq);
				s += "o.src='" + ot.o.src + "';";
				swimg(ot.o, arguments[2]);
		}
	}
	return(s);
}

function ptarget(s) {

	this.prop = s;
//	this.nval = new Array();
	this.pval = new Array();
	this.pset = new Array();
}

function otarget(s) { this.tid = s; this.prop = new Array(); }

function fsetprop(p, i) {

	var prop;
	for(var j = this.prop.length; j--; )
		if (this.prop[j].prop == p) {
			prop = this.prop[j];
			break;
		}
	if (! prop)
		this.prop[this.prop.length] = prop = new ptarget(p);
	if (prop.pset[i])
		prop.pset[i] = false;
	else {
		j = eval("this.o." + p);
		prop.pval[i] = p == "innerHTML" ? someescape(j) : j;
	}
}

otarget.prototype.setprop = fsetprop;

function parentdiv(o) { return(o.tagName == "DIV" || o.tagName == "BODY" ? o : parentdiv(o.parentNode)); }

function uppop(lastpop) {

	lastpop.style.visibility = "hidden";
	reverseover(lastpop.masterpop);
	return(parentdiv(lastpop.masterpop));
}

function hideallpop() {

	clearTimeout(hidetid);
	if (lastpop)
		while(lastpop.masterpop)
			lastpop = uppop(lastpop);
}

function refo(o) {

	this.x = this.y = 0;
	do {
		this.y += o.offsetTop;
		this.x += o.offsetLeft;
	} while(o.offsetParent.tagName != "BODY" ? (o = o.offsetParent) : null);
}

