
function SmartInputText(el,params)
{

    if(typeof params != 'object') params = {};

    var EXT = el;this.EL = EXT;
    if(!EXT || EXT.tagName.toLowerCase() != 'input' || (EXT.type != 'text' && EXT.type != 'password'))
	return;

    if(!EXT.v) EXT.v = EXT.value;
    if(!EXT.style) EXT.setAttribute('style','');
    if(!EXT.fc){
	if(EXT.style.color) EXT.fc=EXT.style.color;	
	else EXT.fc = '#000000';
    }
	
    try{
	//init
	EXT.style.border="0px";
	EXT.style.padding="0 1px";
	
	//draw a table
	var t = document.createElement('table');
	t.cellPadding="0";
	t.cellSpacing="0";
	t.border="0";
	t.setAttribute('style','');
	t.style.display="inline";

	if(!params.novalign)
	    t.style.verticalAlign='bottom';
	if(params.valign)
	    t.style.verticalAlign=params.valign;

	var r=t.insertRow(0);
	var td=r.insertCell(0);
	td.setAttribute('style','');
	td.style.padding="0px";
	td.style.border="1px solid #7f9db9";
	var div = document.createElement('div');
	div.setAttribute('style','');
	div.style.border="1px solid #fff";
	td.appendChild(div);
	

	
	var ep =EXT.parentNode;
	var ni = EXT;
	ep.replaceChild(t,EXT);
	div.appendChild(ni);
	
	
	}catch(e){}
	
	//attach event;
    EXT.onfocus = function(){
	if(EXT.value==EXT.v && !params.notip)
	    EXT.value='';
	else
	    EXT.select();
	try{
	    var b1 = EXT.parentNode;
	    var b2 = b1.parentNode;
	    b1.style.borderColor="#d1fdcd";
	    b2.style.borderColor="#54ce43";
	    EXT.style.color='#000';
	    
	}catch(e){}
    };
	
    EXT.onblur = function(){
	if(String(EXT.value).replace(/^\s*/g,'').replace(/\s*$/g,'')=='')
	    EXT.value = EXT.v;		
	try{
	    var b1 = EXT.parentNode;
	    var b2 = b1.parentNode;
	    b1.style.borderColor="#fff";
	    b2.style.borderColor="#7f9db9";
	    EXT.style.color = EXT.fc;
	}catch(e){}
    };

}