// returntowaha.js    JavaScript routine to return to previous waha.asp page
//
//    9.27.2000  jrc  1.0  Written
//
// Includes the following functions:
//
//    returntowaha	return the user to the previous page, using URL stored in cookie
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  
// returntowaha  -  return the user to the previous page, using URL stored in cookie

function returntowaha() {
  var start_point=0;
  var cookie_length=0;
  var semicolon_position=0;
  var x=0;
  var returnURL="";
  cookie_length=document.cookie.length;
  //  window.alert("cookie length = " + cookie_length);

  //  loop through all of the cookies looking for the "WAHAurl" cookie that contains
  //    the return address
  
  while (start_point<cookie_length) {
    if ((semicolon_position=document.cookie.indexOf(";",start_point))==-1) {
      semicolon_position=cookie_length;
    }
    x=start_point + 7;
    if(document.cookie.substring(start_point,x)!="WAHAurl") {
      start_point++;
      x++;
      if(document.cookie.substring(start_point,x)!="WAHAurl") {
        start_point=semicolon_position+1;
      }
    }
    if(start_point<semicolon_position) {
      x++;                                                          // skip the "=" character in the string
      returnURL=document.cookie.substring(x,semicolon_position);
      start_point=cookie_length+1;
      //    window.alert("returnURL = " + returnURL);
    }
  }

  //  if return URL found, link to that page

  if (returnURL!="") {
    location.href=returnURL;
  }
}
// end of returntowaha function 

