function rpztip(pfield,phtml,ploc,poffsetx,poffsety,pnofollow,pshowmode,phidemode,pshowtime,phidetime,ppers)
{
	$(pfield).simpletip(
	{ 
		content: phtml,
		persistent: ppers,
		position : ploc,
		offset: [poffsetx,poffsety],
		fixed: pnofollow,
		showEffect: pshowmode,
		hideEffect: phidemode,
		showTime: pshowtime,
		hideTime: phidetime
	}) ;
}

function rpzclosetip(form,parm)
{
	var id = form+parm ;
	var api = $(id).simpletip() ;
	if (api == null) return true ;
	api.hide() ;
	return true ;
}

function rpzauto(pfield,ptarg,purl,pmin,pdelay,phi,pwid)
{
	var pobj = null ;
	var potarg = null ;	
	var po = null ;	
	var pval = 0 ;
	
	pobj = $(pfield) ;
	pobj.autocomplete(
	{ 
		source: purl,
		disabled: false,
		delay: pdelay,
		minLength: pmin,
		open: function(event, ui)
		{
			var po = $(this).autocomplete("widget") ;
			var pval = $(this).data("rpzwid") ;
            po.css({"width": pval});		
			pval = $(this).data("rpzhi") ;
            po.css({"max-height": pval});		
			po.css({"overflowY":"auto"}) ;
			po.css({"overflowX":"hidden"}) ;		
			po.css({"white-space":"nowrap"}) ;					
		}
	}) ;
	
	potarg = $(ptarg) ;		

	pobj.data("rpzwid",pwid) ;	
	pobj.data("rpzhi",phi) ;		
	pobj.data("rpztarg",ptarg) ;
	pobj.data("rpzkey",potarg[0].value) ;
	pobj.data("rpzval",pobj[0].value) ;	

	po = pobj.data("autocomplete") ;
	po._renderItem = function( ul, item)
	{
		return $( "<li></li>" )
			.data( "item.autocomplete", item )
			.append( $( "<a>" + item.label + "</a>" ) )
			.appendTo( ul );
	} ;
	
	pobj.bind("autocompleteselect", function(event,ui)
	{ 
		var pcont = event.currentTarget ;	
		var po = $(this) ;
		var starg = po.data("rpztarg") ;
		var ptarg = $(starg) ;
		
		var slabel = ui.item.label ;
		var svalue = ui.item.value ;
		var skey = ui.item.key ;
		
		ptarg.attr('value',skey) ;
		pcont.value = svalue ;

		po.data("rpzval",svalue) ;		
		po.data("rpzkey",skey) ;
		
	});

	pobj.bind("autocompletesearch", function(event,ui)
	{ 
		var pcont = event.currentTarget ;	
		var po = $(this) ;
		var pval = pcont.value ;
		var sval = po.data("rpzval") ;
		sval = $.trim(sval) ;
		pval = $.trim(pval) ;		
		sval = sval.toLowerCase() ;
		pval = pval.toLowerCase() ;		
		if (sval == pval)
		{
			//Do not search if no change in string
			return false ;
		}
		return true ;		
	});
	
	pobj.focus( function()
	{ 
		var po = $(this) ;
		var aval = po.value ;
		var bval = po.data("rpzval") ;
		if (aval == bval)
		{
			po.value = "" ; //Clear it out when gaining focus
		} 
	});
	
	pobj.focusout( function()
	{ 
		var po = $(this) ;
		var	pval = po.data("rpzval") ;
		po[0].value = pval ; //Clear it out when gaining focus
	});

	pobj.bind("keydown",function(event)
	{ 
		//Backspace - Erase Selection
		var pcont = event.currentTarget ;
		if (event.keyCode == '8')
		{
			//pcont.value = "" ; //Disable backspace for now
		}
		//Delete Key - Erase selection
		if (event.keyCode == '46')
		{
			pcont.value = "" ;
		}
		//Tab Key - No Changes
		if (event.keyCode == '9')
		{
			pcont.value = $(this).data("rpzval") ;
		}
		//Escape Key - No Changes		
		if (event.keyCode == '27')
		{
			pcont.value = $(this).data("rpzval") ;
		}
		
	});
}


