/* Javascript by Daniel Cohen Gindi (c) danielgindi@gmail.com 054-5655765 */
/* Version: 2009-01-01 */

function $find(n) { return document.getElementById ? document.getElementById(n) : (document.layers ? document.layers[n] : document.all[n]); }
function $offset(e) { if(e.pageX) return [e.pageLeft, e.pageTop]; else {var l = 0, t = 0; if (e.offsetParent) { do { l += e.offsetLeft; t += e.offsetTop; } while (e = e.offsetParent); } return [l, t];}; }
function $height(e) {
	var ret=
	((e.clip&&e.clip.bottom)?(e.clip.bottom-e.clip.top):((e.document&&e.document.height)?e.document.height:null)) || 
	e.style.height || e.clientHeight || e.height || e.offsetHeight || 
	e.parentNode.style.height || e.parentNode.clientHeight || e.parentNode.height;
	if (ret) return parseInt(ret); else return null;
}
function $width(e) {
	var ret=
	((e.clip&&e.clip.right)?(e.clip.right-e.clip.left):((e.document&&e.document.width)?e.document.width:null)) || 
	e.style.width || e.clientWidth || e.width || e.offsetWidth || 
	e.parentNode.style.width || e.parentNode.clientWidth || e.parentNode.width;
	if (ret) return parseInt(ret); else return null;
}
$ver={
	w3c:((document.getElementById)?true:false), 
	ns4:((document.layers)?true:false), 
	ie4:(document.all && !this.w3c)?true:false,
	ie5:(document.all && this.w3c)?true:false,
	ie6:(document.getElementById && navigator.appVersion.indexOf("MSIE 6.0")>=0)?true:false,
	ie7:(document.getElementById && navigator.appVersion.indexOf("MSIE 7.0")>=0)?true:false,
	ns6:(document.getElementById && navigator.appName.indexOf("Netscape")>=0)?true:false,
	chrome:(document.getElementById && navigator.appVersion.indexOf("Chrome")>=0)?true:false
	};
function registerEvent(element, event, ev_func, capture) {
    if (element == null) return;
    if (element.addEventListener) element.addEventListener(event, ev_func, capture ? true : false);
    else if (element.attachEvent) element.attachEvent('on' + event, ev_func);
    return ev_func;
}
function unregisterEvent(element, event, ev_func, capture) {
    if (element == null) return;
    if (element.removeEventListener) element.removeEventListener(event, ev_func, capture ? true : false);
    else if (element.detachEvent) element.detachEvent('on' + event, ev_func);
}
function escapeJsString(str)
{
	if (str===undefined || str===null) return '';
	else return str.replace(/\'/,"\\\'").replace(/\"/,"\\\"").replace(/\\/,"\\\\").replace(/\r/,"\\r").replace(/\n/,"\\n");
}
function winPopup(URL,width,height,wndName,forceReload)
{
	if (wndName==undefined || wndName==null) wndName="";
	var newWnd = window.open("",wndName,config="height="+height+",width="+width+",resizable=no,toolbars=no,address=no,status=no,menubar=no,location=no,toolbar=no,scrollbars=no")
	if (forceReload==true)
	{
		newWnd.document.close();
		newWnd.document.open();
	}
	newWnd.document.location=URL;
	newWnd.window.focus();
	return newWnd;
}