
var QUERY_TEMPLATE = '--';
var QUERY_IMPL_DELIM = '.';
var QUERY_IMPL_ESC = '_';
var QUERY_IMPL_ESCESC = '__';
var QUERY_IMPL_DELIMESC = '_o';

function encodeArgValue(src_value)
{
   var enc_value = src_value.replace(QUERY_IMPL_ESC, QUERY_IMPL_ESCESC);   
   enc_value = enc_value.replace(QUERY_IMPL_DELIM, QUERY_IMPL_DELIMESC);   
   enc_value = escape(enc_value);

   return enc_value.replace('@', '%40');
}

function Nav(form_obj, uri_templ, arg_name)
{
   this.form_obj = form_obj;
   this.uri_templ = uri_templ;
   
   this.arg_pattern = QUERY_TEMPLATE + arg_name + QUERY_TEMPLATE;

   this.go = Nav_go;
}

function Nav_go(arg_value, target)
{
   if ( typeof(target) == "undefined" )
   {
      target = "_self";
   }

   var uri = this.uri_templ.replace(this.arg_pattern, encodeArgValue(arg_value));

   if ( this.form_obj )
   {
      this.form_obj.action = uri;
      this.form_obj.target = target;
      this.form_obj.submit();
   }
   else
   {
      window.open(uri, target);
   }
}

