
//	Copyright (C) 2002-2010 FoxSet IT Solutions Ltd. All rights reserved.
//	www.foxset.com

var lastpop,amenu,hidetid=0;

function sopt(p) {

    if (amenu) {
        var ix = -1,i = amenu.length;
        while(i--)
            if (amenu[i].tp == p)
                if (amenu[i].bid == lbtn) {
                    amenu[i].fdis();
                    return;
                } else
                    ix = i;
        if (ix >= 0) amenu[ix].fdis();
    }
}

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;

	if (o.tagName == "A" && o.offsetParent.tagName == "TD") reverseover(o.offsetParent);
}

/*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 = "pointer";
}*/

function disforwardi(ot, seq, act) {

    var s = "(o=document.getElementById('" + ot.tid + "')).style.cursor='" + ot.o.style.cursor + "';";
    ot.setprop("style.cursor", seq);
    ot.o.style.cursor = "default";
    if (act) {
        if (ot.o.onmouseout)
            ot.o.onmouseout();
        ot.setprop("src", seq);
        s += "o.src='" + ot.o.src + "';";
        swimg(ot.o, arguments[2]);
    }
    return (s);
}

function disforward(ot, seq, act) {

	if ((ot.o = document.getElementById(ot.tid)).tagName == "IMG")
		return (disforwardi(ot, seq, act));

	var p, s = "o=document.getElementById('" + ot.tid + "');";

	if (act) {

		ot.o = document.getElementById(ot.tid);

		if (ot.o.onmouseout)
			ot.o.onmouseout();

		for (var i = arguments.length - 2; i > 1; i -= 3) {
			ot.setprop(p = arguments[i - 1], seq);
			s += "o." + p + "='" + eval("ot.o." + p) + "';";
			eval("ot.o." + p + "='" + arguments[i] + "'");
		}
	}

	return (s);
}

function ptarget(s) {

	this.prop = s;
	this.nval = new Array();
	this.pval = new Array();
	this.f = new Array();
	this.b = new Array();    // si probabil nici asta
}

function otarget(s) { this.tid = s; this.o = null; this.prop = new Array(); this.ix = 0; this.prex = -1; }

function fsetprop(p, i, f, n) {

    var prop;
    if (!this.o) this.o = document.getElementById(this.tid);
	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 (this.prex != -1 && this.prex != i)
		this.ix = this.prex;
	this.prex = i;
	if (this.o.tagName != "A" || p.indexOf("border") < 0)
		prop.pval[this.ix] = eval("this.o." + p);
	else {
		prop.pval[this.ix] = eval("this.o.offsetParent." + p);
		prop.b[this.ix] = true;
	}
	prop.f[this.ix] = f;
	prop.nval[this.ix] = n;
	return(prop.b[this.ix]);
}

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 = o.offsetParent);
}

