

function SASSearch(){
   var queryString = "http://search.sas.no/search?";
queryString += "q=" + Url.encode(document.getElementsByName("q")[0].value) + 
"&";
queryString += "site=" + document.getElementsByName("site")[0].value + 
"&";
queryString += "client=" + document.getElementsByName("client")[0].value + 
"&";
queryString += "proxystylesheet=" + document.getElementsByName("proxystylesheet")[0].value + 
"&";
queryString += "output=" + document.getElementsByName("output")[0].value + 
"&";

   location.replace(queryString);
}



var Url = {
  encode : function (string) {
    return escape(this._utf8_encode(string));
  },
  
  _utf8_encode : function (string) {
    string = string.replace(/\r\n/g,"\n");
    var utftext = "";
    for (var n = 0; n < string.length; n++) {
      var c = string.charCodeAt(n);
      if (c < 128) {
        utftext += String.fromCharCode(c);
      }
      else if((c > 127) && (c < 2048)) {
        utftext += String.fromCharCode((c >> 6) | 192);
        utftext += String.fromCharCode((c & 63) | 128);
      }
      else {
        utftext += String.fromCharCode((c >> 12) | 224);
        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
        utftext += String.fromCharCode((c & 63) | 128);
      }
    }
    return utftext;
  }
}

function handleKeyUp(){
var k;
if(event.which)
k = event.which.keyCode;
else
k = event.keyCode;
if(k == 13)
SASSearch();
return true;
}

