function openWindow(surl,windowName,params) {
// We have to double-encode some URL strings to account for an IE bug where
// IE un-encodes the URL before passing it to this function. This line
// causes the function to un-encode the URL if the URL was double-encoded
// but was (correctly) passed without decoding by a sane browser.
  if (surl.indexOf('%2520') != -1) {
    surl = unescape(surl);
  }
  if (window.windowHandle && !windowHandle.closed) { // if window exists and not closed, close it
    if (window.windowHandle.name == windowName) windowHandle.close();
  }
  windowHandle = window.open(surl,windowName,params);
}

// add a name and value dynamically to the hard-coded URL before calling openWindow().

function modURLOpenWindow(the_name, the_value,surl,windowName,params) {
    if ( (the_value!=null) && (the_name!=null)) {
        if (surl.indexOf('#')>=0) {
            xa = surl.split("#");
            if (xa[0].indexOf('?')>=0) {
                surl = xa[0] + '&' + the_name + '=' + the_value + '#' + xa[1];
            } else {
                surl = xa[0] + '?' + the_name + '=' + the_value + '#' + xa[1];
            }
        } else {
            if (surl.indexOf('?')>=0) {
                surl = surl + '&' + the_name + '=' + the_value ;
            } else {
                surl = surl + '?' + the_name + '=' + the_value ;
            }
        }
    }
    openWindow(surl,windowName,params);
    if(window.focus) {
    	windowName.focus();
    }
}
