// Return the url without the query string
function uri (url) {
   var split_url = url.split('?');
   return split_url[0];
 }

 // Does actual search
function doSearch()
{

	var q = document.getElementById('searchbox_007548053462369992495:-c30dsonde4').q.value;
	var origq = q;
	//var siteid = document.getElementById('007548053462369992495:-c30dsonde4').site.value;
	var site = "";
	var url = "";
	var siteid="";
	// Alert and stop search if query string is empty
	if (q=="") {
		alert("Type search words")
		return false
	}


	var cx;
	var cof;
	var respage;
	
		cx = encodeURIComponent("007548053462369992495:-c30dsonde4");
		cof = encodeURIComponent("FORID:11");
		respage = "maamarim.htm";

	
	q = encodeURIComponent(q);
	origq = encodeURIComponent(origq);
	url = respage + "?hl=iw&cx=" + cx + "&q=" + q + "&sa=Search&cof=" + cof + "&origq=" + origq + "&siteID=0" ;
	location.href = url;
	return false;
}

function setQ()
{
	// Set original query string
	var origq = decodeURIComponent(urlParam(location.href, 'origq'));
	
	if (origq != "") {
		document.getElementById('searchbox_007548053462369992495:-c30dsonde4').q.value = origq;
	}
	
	
	
	

	// Place cursor in search box
	//if (origq != "") {
	//	document.getElementById('searchbox_007548053462369992495:-c30dsonde4').q.focus();
	//}
}

function urlParam (url, param) {
   var split_url = url.split('?');
   var cgi_args = split_url[1];
   if (!cgi_args) return "";
   var param_array = cgi_args.split('&');
   for (var i = 0; i < param_array.length; i++) {
      var attr_val = param_array[i].split('=');
      if (attr_val[0] == param) return attr_val[1];
   }
   return "";
 }
