
function parsequery(){
    var arg_pairs = new Object();
    arg_pairs.names = new Array();
    arg_pairs.values = new Array();
    var query = location.search.substring(1);
    if(query == "") { return null; }
    var pairs = query.split("\&");
    for(var i = 0; i < pairs.length; i++){
        var pos = pairs[i].indexOf('=');
        if(pos == -1){ continue; }
        var arg_name = pairs[i].substring(0,pos);
        var arg_value = pairs[i].substring(pos+1);
        arg_pairs.names[i] = arg_name;
        arg_pairs.values[i] = arg_value;
    }
    return arg_pairs;
}

function getqueryparam(arg_pairs, paramname){
  for(var i = 0; i < arg_pairs.names.length; i++){
    if(arg_pairs.names[i] == paramname){ return arg_pairs.values[i]; }
  }
  return null;
}

var url_pairs = parsequery();
var keywordvalue = getqueryparam(url_pairs, "tkeyword");
var authorvalue = getqueryparam(url_pairs, "author");
var numbervalue = getqueryparam(url_pairs, "number");
var choice = getqueryparam(url_pairs, "category");

if (authorvalue > (""))
{document.write("'" + unescape(authorvalue) + "' ")};

if (keywordvalue > (""))
{
keywordvalue = keywordvalue.replace( /\+/g, " " );
keywordvalue = keywordvalue.replace( /%2C/g, " " );
var strReplaceAll = keywordvalue;
var intIndexOfMatch = strReplaceAll.indexOf( "%20" );
// Loop over the string value replacing out each matching
// substring.
while (intIndexOfMatch != -1){
// Relace out the current instance.
strReplaceAll = strReplaceAll.replace( "%20", " " )
// Get the index of any next matching substring.
intIndexOfMatch = strReplaceAll.indexOf( "%20" );
}
keywordvalue = strReplaceAll;
document.write("'" + unescape(keywordvalue) + "' ")};

if (numbervalue > (""))
{document.write("'" + numbervalue + "'")};

if (choice > (""))
{document.write(categories[parseInt(choice)]);}

