function urlParameter( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function initSbox()
{
	document.getElementById('cse-search-box').q.value = decodeURIComponent(urlParameter('sbox'));
}

function invokeSearch()
{
	var q = document.getElementById('cse-search-box').q.value;
	var query;
	var cx;
	var cof;

	if (q=="") {
		return false
	}

	cx = encodeURIComponent("004883432834942578848:utvkcdqgb9w");
	cof = encodeURIComponent("FORID:9");

//	query = q + ' OR intitle:"' + q + '"';
	query = q;
	query_uri = encodeURIComponent(query);
	
	url = "search.php?cx=" + cx + "&cof=" + cof + "&ie=UTF-8" + "&q=" + query_uri + "&sa=Search" + "&sbox=" + encodeURIComponent(q);
	//url = "search.php?cx=" + cx ;
	location.href = url;
	return false;
}
