function ylib_Browser()
{
	d=document;
	this.agt=navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion,10);
	this.dom=(d.getElementById)?1:0;
	this.ns=(d.layers);
	this.ns4up=(this.ns && this.major >=4);
	this.ns6=(this.dom&&navigator.appName=="Netscape");
	this.op=(window.opera? 1:0);
	this.ie=(d.all);
	this.ie4=(d.all&&!this.dom)?1:0;
	this.ie4up=(this.ie && this.major >= 4);
	this.ie5=(d.all&&this.dom);
	this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
	this.mac=(this.agt.indexOf("mac")!=-1);
};

var oBw = new ylib_Browser();

function ylib_getPageX(o) 
{ 
	var x=0; 
	if(oBw.ns) x=o.pageX; 
	else 
	{ while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } } 
	return x; 
}

function ylib_getPageY(o) 
{ 
	var y=0; 
	if(oBw.ns) y=o.pageY; 
	else { while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } } 
	return y; 
}

//get event object in firefox
if(window.addEventListener)
{
	FixPrototypeForGecko();
}

function FixPrototypeForGecko()
{
	HTMLElement.prototype.__defineGetter__("runtimeStyle",element_prototype_get_runtimeStyle);
	HTMLElement.prototype.__defineGetter__("innerText",function (){var anyString = ""; var childS = this.childNodes; for(var i=0; i<childS.length; i++) { if(childS[i].nodeType==1) anyString += childS[i].tagName=="BR" ? "\n" : childS[i].innerText; else if(childS[i].nodeType==3) anyString += childS[i].nodeValue; } return anyString; }); 
	window.constructor.prototype.__defineGetter__("event",window_prototype_get_event);
	Event.prototype.__defineGetter__("srcElement",event_prototype_get_srcElement);
};

function element_prototype_get_runtimeStyle()
{
	//return style instead...
	return this.style;
}

function window_prototype_get_event()
{
	return SearchEvent();
}

function event_prototype_get_srcElement()
{
	return this.target;
}

function SearchEvent()
{
	//IE
	if(document.all)
		return window.event;

	func=SearchEvent.caller;
	while(func!=null)
	{
		var arg0=func.arguments[0];
		if(arg0)
		{
			if(arg0.constructor==Event)
				return arg0;
		}
		func=func.caller;
	}
	return null;
}

function formatValue(str)
{
	var rStr = str;
	if (str.length < 0 ) return "";
	rStr = rStr.replace(/(^\s*)|(\s*$)/g,"");
	rStr = rStr.replace(/<\/?[^>]+>|(&nbsp;)/gi,"");
	rStr = rStr.replace(/(&amp;)/gi,"&");
	return rStr;
}
function CustomString(str)
{
	if (str.length < 1)
		return str;

	for(var i=1;i<arguments.length;i++)
	{
		str = str.replace("{" + (i-1).toString() + "}",arguments[i]);
	}
	
	return str;
}

function toggleDisp(theLayer, dispType) {
	document.getElementById(theLayer).style.display = dispType;
}
