
// Script used by the browsers to reload the page reflecting options chosen
// in the forms used by the object browsers.
// Changes
//    24-09-2009  Added third parameter (optional) to allow base URL to be specified


  function reload(form, x, urlbase)
  {
    var a = form.a.value;                                                       // this control always exists
    var y;
    var c;
    var p;
    var no;
    var at;
    var cy;
    var bi;
    var n;
    var pu;
    var pt;
    var se;
    var pr;
    var ga;
    var l;
    var b;
    var au;                                                                     // author
    var e = 0;                                                                  // everything
    var t = form.t.value;                                                       // this control always exists
    if (typeof urlbase == 'undefined' )
    {
      urlbase = 'index.php';                                                    // default base URL
    }
    if (form.se)                                                                // for the rest, check the control is
    {                                                                           // present before accessing to prevent
      se = form.se.options[form.se.options.selectedIndex].value                 // run time errors
    }
    if (form.pu)
    {
      pu = form.pu.options[form.pu.options.selectedIndex].value;
    }
    if (form.pt)
    {
      pt = form.pt.options[form.pt.options.selectedIndex].value;
    }
    if (form.pr)
    {
      pr = form.pr.options[form.pr.options.selectedIndex].value;
    }
    if (form.n)
    {
      n = form.n.value;
    }
    if (form.no)
    {
      no = form.no.value;
    }
    if (form.y)
    {
      y = form.y.options[form.y.options.selectedIndex].value;
    }
    if (form.p)
    {
      p = form.p.options[form.p.options.selectedIndex].value;
    }
    if (form.bi)
    {
      bi = form.bi.options[form.bi.options.selectedIndex].value;
    }
    if (form.c)
    {
      c = form.c.options[form.c.options.selectedIndex].value;
    }
    if (form.ga)
    {
      ga = form.ga.options[form.ga.options.selectedIndex].value;
    }
    if (form.l)                                                                 // control flag for admin console
    {
      l = form.l.value;
    }
    if (form.b)
    {
      b = form.b.value;
    }
    if (form.au)
    {
      au = form.au.value;
    }
    switch (x)                                                                  // x is a control parameter
    {                                                                           // used for resetting form elements
      case 0:                                                                   // as the user selects various options
        c = 0;
        break;
      case 1:
        pu = 0;
        se = 0;
        pt = 0;
        au = 0;
        break;
      case 2:
        break;
      case 3:
        n = "";
        break;
      case 4:
        p = 0;
        break;
      case 5:
        c = 0;
        pu = 0;
        pt = 0;
        se = 0;
        au = 0;
        break;
      case 30:
        bi = 0;
        break;
      case 31:
        y = 0;
        bi = 0;
        break;
      case 50:
        n = 0;
        break;
      case 60:
        break;
      case 80:
        c = 0;
        p = 0;
        break;
      case 500:
        e=1;
        break;
    }
    if (form.at)
    {
   	  var radioLength = form.at.length;
	    if (radioLength == undefined)
      {
	    	if(form.at.checked)
	    	{
		    	at = form.at.value;
        }
		    else
		    {
			    at = 0;
        }
      }
      else
      {
      	for(var i = 0; i < radioLength; i++)
        {
		      if(form.at[i].checked)
          {
			      at = form.at[i].value
          }
        }
      }
    }
    if (form.cy)
    {
   	  var radioLength = form.cy.length;
	    if (radioLength == undefined)
      {
	    	if(form.cy.checked)
	    	{
		    	cy = form.cy.value;
        }
      }
      else
      {
      	for(var i = 0; i < radioLength; i++)
        {
		      if(form.cy[i].checked)
          {
			      cy = form.cy[i].value
          }
        }
      }
    }
    urlParameters = urlbase+"?t="+t+"&a="+a;                                    // we always need these parameters
    if (n>0)
    {
      urlParameters += "&n="+n;
    }
    if (p)
    {
      urlParameters += "&p="+p;
    }
    if (c)
    {
      urlParameters += "&c="+c;
    }
    if (at)
    {
      urlParameters += "&at="+at;
    }
    if (cy)
    {
      urlParameters += "&cy="+cy;
      switch (cy)                                                               // make sure the breadcrumbs track
      {
        case '2':
          no = 7;
          break;
        case '1':
          no = 6;
          break;
        default:
          no = 5;
          break;
      }
    }
    if (no>0)
    {
      urlParameters += "&no="+no;
    }
    if (y)
    {
      urlParameters += "&y="+y;
    };
    if (bi)
    {
      urlParameters += "&bi="+bi;
    };
    if (pu)
    {
      urlParameters += "&pu="+pu;
    };
    if (pt)
    {
      urlParameters += "&pt="+pt;
    }
    if (pr)
    {
      urlParameters += "&pr="+pr;
    }
    if (se)
    {
      urlParameters += "&se="+se;
    }
    if (l)
    {
      urlParameters += "&l="+l;
    }
    if (b)
    {
      urlParameters += "&b="+b;
    }
    if (ga)
    {
      urlParameters += "&ga="+ga;
    }
    if (au)
    {
      urlParameters += "&au="+au;
    }
    if (e)
    {
      urlParameters += "&e="+e;
    }
    self.location = urlParameters;
  }
