function addHandler(obj, event, action) { 
            if(document.addEventListener) { 
                 obj.addEventListener(event, action, false); 
            } else if(document.attachEvent) { 
                 obj.attachEvent('on' + event, action); 
            } else { 
                 obj['on' + event] = action; 
            } 
        
            obj['has' + event] = true; 
       } 
 var $j  = jQuery;
 $u  = function(id)
 {
 	return document.getElementById(id);
 }
 $u.query = function(className, method, args, data, callback)
 {
 	
 }
 $u.setUP = function(id, obj)
 {
 	if(!obj)
 	{
 		return;
 	}
 	obj.ident = id;
 	if(window.UP == undefined)
 	{
 		window.UP = [];
 	}
 	obj.onmouseout = function()
 	{
 		window.UP[this.ident] = false;
 		setTimeout(function()
 		{
 			if(!window.UP[id])
 			{
 				$u.slide(obj);
 			}
 		}, 500);
 	}
 	obj.onmouseover = function() {window.UP[this.ident] = true;} 
 }
 $u.slide = function(el, speed, callback)
{
	if($u.isMSIE())
	{
		if(el.style.display == 'none')
		{
			var d = el.cloneNode(true);
			el.parentNode.insertBefore(d, el);
			var tmp = function()
			{
				d.parentNode.removeChild(d);
				$j(el).css('display', '');	
				if(callback)
				{
					new callback;
				}
			}
			$j(d).slideDown(speed, tmp);
		}
		else
		{
			$j(el).slideUp(speed, callback);
		}
	}
	else
	{
		el.style.display == 'none' ? $j(el).slideDown(speed, callback) : $j(el).slideUp(speed, callback);
	}
}

$u.isChrome = function()
{
	return false;
}
$u.isFirefox = function()
{
	return !$u.isMSIE() && !$u.isSafari() && !$u.isChrome();
}
$u.isMSIE = function()
{
	return (document.all && !$u.isOpera() && !$u.isSafari() ? true : false);
}
$u.isOpera = function()
{
	return navigator.userAgent.indexOf ("Opera") != -1 ;
}
$u.isSafari = function()
{
	return navigator.userAgent.indexOf ("Safari") != -1 ;
}

$u.print = function(obj, getOnlyNoneEmpty)
{
	var s = '';
	for(var i in obj)
	{
		if((obj[i] != undefined && obj[i].length != undefined) || !getOnlyNoneEmpty)
		{
			s += i + ': ' + obj[i] + "\r\n";
		}
	}
	return s;
}

$u.getJSON = function(jsonString)
{
	eval(" var tmp = " + jsonString);
	return tmp;
}


$u.getBodyScrollLeft = function()
{
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

$u.getBodyScrollTop = function()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}	
	
$u.TextField = function(obj)
{
	
	obj.setInnerDescription = function(text)
	{
		this.innerDescription 	= text;
		
		this.onfocus = function()
		{
			if(this.value == this.innerDescription)
			{
				this.value = '';
				this.removeStopper();
			}
		}
		if(this.onblur)
		{
			this.callOnblur = this.onblur;
		}
		this.onblur = function()
		{
			if(this.value == '')
			{
				this.value = this.innerDescription;
				this.attachStopper();
			}
			if(this.callOnblur)
			{
				this.callOnblur();
			}
		}		
		if(this.value == '')
		{
			this.value = this.innerDescription;
			this.attachStopper();
		}
	}	
	
	obj.makeNumeric = function()
	{
		if(this.onblur != undefined)
		{
			this.callOnblur = this.onblur;
		}
		this.onblur = function()
		{
			if(this.value.length > 0)
			{
				var v = parseFloat(this.value);
				var l = this.value.length;
				
				while(isNaN(v) && l > 0)
				{
					v = parseFloat(this.value.substr(0, --l));
				}
				if(l==0)
				{
					v = 0;
				}
				this.value = v;				
			}
			if(this.callOnblur != undefined)
			{
				this.callOnblur();
			}
		}
	}
	
	obj.attachStopper = function()
	{
		if(this.stopper == undefined)
		{
			this.stopper 			= document.createElement('input');
			this.stopper.type		= 'hidden';
			this.stopper.name 		= this.name;
			this.stopper.value		= '';
		}
		this.parentNode.appendChild(this.stopper);
		this.stopper.attached = true;
	}
	
	obj.attachMirror = function(mirror, limit, prefix, postfix, firstSource)
	{
		var exe	= this;
		prefix	= prefix 	? prefix 	: '';
		postfix	= postfix	? postfix 	: '';
		this.__callback = this.onkeyup;
		this.onkeyup = function()
		{
			if(!firstSource || firstSource.value.length == 0)
			{
				var v = limit > 0 ? exe.value.substr(0, limit) : exe.value;
				mirror.innerHTML = prefix + v + postfix;
			}
			if(this.__callback)
			{
				this.__callback();
			}
		}
		if(firstSource)
		{
			var callback_2 = firstSource.onkeyup;
			firstSource.onkeyup = function()
			{				
				if(callback_2)
				{
					callback_2();
				}
				if(this.value.length == 0)
				{
					var v = limit > 0 ? exe.value.substr(0, limit) : exe.value;
					mirror.innerHTML = prefix + v + postfix;
				}
			}
		}
	}
	
	obj.removeStopper = function()
	{
		if(this.stopper != undefined)
		{
			this.stopper.parentNode.removeChild(this.stopper);
		}
	}
	
	obj.setMaxLength = function(limit)
	{
		var exe = this;
		var callback = this.onkeyup;
		this.onkeyup = function()
		{
			if(exe.value.length > limit)
			{
				exe.value = exe.value.substr(0, limit);
			}
			if(callback)
			{
				callback();
			}
		}
	}
	
	return obj;
}

$u.createPassOpener = function(passId, openerId)  
	{
		var pass 	= document.getElementById(passId);
		var opener	= document.getElementById(openerId);
		if(!pass || !opener)
		{
			return false;
		}
		var text	= document.createElement("input");
		opener.changeMode = false;
		pass.opener = opener;
		text.opener = opener;
		pass.active = true;
		text.active = false;
		text.value	= pass.value;
		text.type 	= 'text';
		text.size	= pass.size;
		text.style.display = 'none';
		text.id = opener.id + "_text";
		pass.parentNode.insertBefore(text, pass);
		pass.f = text.f = opener.f = {'opener': opener, 'pass': pass, 'text': text};
		opener.onclick = function()
		{
			this.changeMode = true;
			this.f["pass"].active = !this.f["pass"].active;
			$u.slide(this.f["pass"]);//alert('1');
			this.f["text"].active = !this.f["text"].active;			
			$u.slide(this.f["text"]);
			this.changeMode = false;
			try
			{
				this.f["pass"].focus();
			}
			catch(e)
			{
				this.f["text"].focus();
			}
		}
		pass.onkeyup = function()
		{
			if(this.active && !this.opener.changeMode)
			{
				this.f["text"].value = this.value;
			}
		}
		text.onkeyup = function()
		{
			if(this.active && !this.opener.changeMode)
			{
				this.f["pass"].value = this.value;
			}
		}
	}