/************************************************
   bm_search.js - Search routines
     
   Copyright 2003 Better-Mortgages.co.uk Ltd
   All rights reserved. Version 1.0
   Used in better-mortgages.co.uk &
   	   better-insurance.co.uk  
 ************************************************/

var start, end, last, total, pstart, pend;

/* Do initialisation functions -  Called by <BODY onLoad> */

function doSearchInit() {
  if (br == "DOM") {
    start = document.getElementById("start").value;
    end = document.getElementById("end").value;
    last = document.getElementById("last").value;
    total =  document.getElementById("total").value;
  } else if (br == "IE") {
    start = document.all.start.value;
    end = document.all.end.value;
    last = document.all.last.value;
    total = document.all.total.value;
  } else  if (br == "NS") {
    start = document.start.value;
    end = document.end.value;
    last = document.last.value;
    total = document.total.value;
  }
  pstart = 0;
  pend = 0;
  display(start, end, pstart, pend);
}

function display(S, E, PREVS, PREVE) {
  var i;
  for (i = PREVS; i<= PREVE; i++) { showItem("OFF", "R"+i) }
  for (i = S; i<= E; i++) { showItem("ON", "R"+i)	}
}

function ShowRows(A) {
  pstart = start;
  pend = end;
  if (A == "f") { start = 0; end = 9; }
  if (A == "p") {
    start -=10; end -=10;
    if (start < 0) {start = 0; end = 9; }
  }
  if (A == "n") {
    start +=10; end +=10;
    if (end > (total-1)) {start = total - 11; end = total - 1; }
  }
  if (A == "l") {end = total - 1; start =  total - 11;}
  if (A == "s") {start = 0; end = total - 1;}
  display (start, end, pstart, pend);
}
