// library for using the Google Custom Search Engine
// requires common.js

if(!window.clu){
	window.clu = new Object(); // instantiate namespace object if it doesn't exist already
}

if(window.clu){
	window.clu.googleCSE = new Object();
	window.clu.googleCSE.boxID = 'googlesearchbox'
	window.clu.googleCSE.boxSmallID = 'googlesmallsearchbox'
	window.clu.googleCSE.cx = '005883860069803690231:jkuv90zakcy'
	window.clu.googleCSE.resultsURL = 'http://www.callutheran.com/results.html'
	window.clu.googleCSE.boxSize = 40
	window.clu.googleCSE.boxSmallSize = 20
	window.clu.googleCSE.resizeIFrame = true
	window.clu.googleCSE.iFrameHeight = '85em'
	window.clu.googleCSE.iFrameWidth = '100%'
	window.clu.googleCSE.headerSearchBox = new Object();
	window.clu.googleCSE.headerSearchBox.doRewrite = false; // off by default
	window.clu.googleCSE.headerSearchBox.formid = 'content_searchtools'

	if(document.getElementById){
		addEvent(window,'load',insertSearchBox)
		addEvent(window,'load',rewriteHeaderSearchForm)
	}
}

function getSearchQuery(){
	// get the google search query term
	var s = ''
	if(window.location.search){
		var z = window.location.search.split('&')
		for(var i=0;i<z.length;i++){
			var x = z[i].split('=')
			x[0] = x[0].replace('?','');
			if (x[0]=='q'){ s = x[1]; break;  }
		}
	}
	s = unescape(s.replace(/\+/g,' '))
	// resize the results box 
	if(s==''){
		// no search term
		setResultsBoxSize(window.clu.googleCSE.iFrameWidth,'1em')
	}else{
		// search term exists
		setResultsBoxSize(window.clu.googleCSE.iFrameWidth,window.clu.googleCSE.iFrameHeight); 
	}
	return s
}

function setResultsBoxSize(w,h){
	var results = document.getElementsByTagName('iframe')
	if(results.length>0 && window.clu.googleCSE.resizeIFrame){
		results[0].style.width = w; 
		//results[0].style.height = h; 
	}
}


function buildSearchForm(){
	// create the form element
	// IE doesn't seem able to do this properly width DOM, so do it with innerHTML...
	// create the following form: 
	/* 
  <form id="searchbox_005883860069803690231:jkuv90zakcy" action="http://www.google.com/cse">
    <input type="hidden" name="cx" value="005883860069803690231:jkuv90zakcy" />
    <input name="q" type="text" size="40" />
    <input type="submit" name="sa" value="Search" />
    <input type="hidden" name="cof" value="FORID:1" />
  </form>     
	*/
	var form = document.createElement('form')
	form.setAttribute('id','searchbox_'+window.clu.googleCSE.cx)
	form.setAttribute('action',window.clu.googleCSE.resultsURL)
	form.setAttribute('method','get')
	var input = document.createElement('span')
	input.innerHTML = '<input type="hidden" name="cx" value="'+window.clu.googleCSE.cx+'" />'
	form.appendChild(input);
	var input = document.createElement('span')
	input.innerHTML = '<input type="hidden" name="cof" value="FORID:11" />'
	form.appendChild(input);
	var input = document.createElement('span')
	input.className = 'gCSEtextfield'
	input.innerHTML = '<label for="q"><strong>Google: </strong></label><input type="text" name="q" id="q" size="'+window.clu.googleCSE.boxSize+'" value="'+getSearchQuery()+'" />'
	form.appendChild(input);
	var input = document.createElement('span')
	input.innerHTML = '<input type="submit" name="sa" value="Google Search" /><br /><input type="radio" name="sitesearch" value="" id="ss0"></input> <label for="ss0">Web</label><input type="radio" name="sitesearch" value="www.callutheran.edu" checked="checked" id="ss1"></input> <label for="ss1">www.callutheran.edu</label>'
	form.appendChild(input);
	return form	
}
function buildSmallSearchForm(){
	var form = document.createElement('form')
	form.setAttribute('id','searchbox_'+window.clu.googleCSE.cx)
	form.setAttribute('action',window.clu.googleCSE.resultsURL)
	form.setAttribute('method','get')
	var input = document.createElement('span')
	input.innerHTML = '<input type="hidden" name="cx" value="'+window.clu.googleCSE.cx+'" />'
	form.appendChild(input);
	var input = document.createElement('span')
	input.className = 'gCSEtextfield'
	input.innerHTML = '<label for="q"><strong>Google: </strong></label><br /><input type="text" name="q" id="q" size="'+window.clu.googleCSE.boxSmallSize+'" value="'+getSearchQuery()+'" />'
	form.appendChild(input);
	var input = document.createElement('span')
	input.innerHTML = '<br /><input type="radio" name="sitesearch" value="" id="ss0"></input> <label for="ss0">Web</label><br /><input type="radio" name="sitesearch" value="www.callutheran.edu" checked="checked" id="ss1"></input> <label for="ss1">www.callutheran.edu</label><br /><input type="submit" name="sa" value="Google Search" />'
	form.appendChild(input);
	var input = document.createElement('span')
	input.innerHTML = '<input type="hidden" name="cof" value="FORID:11" />'
	form.appendChild(input);
	return form	
}


function insertSearchBox(){
	var hanger = document.getElementById(window.clu.googleCSE.boxID)
	var hangerSmall = document.getElementById(window.clu.googleCSE.boxID)
	if(hanger){
		var formContainer = document.createElement('div')
		var form = buildSearchForm()
		formContainer.appendChild(form)
		hanger.innerHTML = formContainer.innerHTML
	}
	else if (hangerSmall){
		var formContainer = document.createElement('div')
		var form = buildSmallSearchForm()
		formContainer.appendChild(form)
		hanger.innerHTML = formContainer.innerHTML
	}
}

function rewriteHeaderSearchForm(){
	var form=null
	// rewrite the small searchbox in the header section
	if(document.getElementById && window.clu.googleCSE.headerSearchBox.doRewrite){ 
		form = document.getElementById(window.clu.googleCSE.headerSearchBox.formid) 
	}
	if(form){
//		alert('rewriting header search form')
		// build a reference form to pull from
		var ref = buildSearchForm()
		form.action = ref.action
		form.method = ref.method
		var inputs = form.getElementsByTagName('input')
		// make sure we have cof and cx fields
		var foundCOF = false; var foundCX = false;
		for(var i=0;i<inputs.length;i++){
			var node = inputs[i]
			if(node.getAttribute('name')=='cx'){ 
				node.value = ref.cx.value 
				foundCX = true;
			}
			if(node.getAttribute('name')=='cof'){ 
				node.value = ref.cof.value 
				foundCOF = true;
			}
			if(foundCOF && foundCX){ break; }
		}
		if(!foundCOF){ form.appendChild(ref.cof) }
		if(!foundCX){ form.appendChild(ref.cx) }
//	} else {
//		z = '//no header form found\nwindow.clu.googleCSE.headerSearchBox.formid=\n'
//		z += window.clu.googleCSE.headerSearchBox.formid
//		alert(z)
	}
}
<!-- Google Search Result Snippet Begins -->
  var googleSearchIframeName = "results_005883860069803690231:jkuv90zakcy";
  var googleSearchFormName = "searchbox_005883860069803690231:jkuv90zakcy";
  var googleSearchFrameWidth = 600;
  var googleSearchFrameborder = 0;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
<!-- Google Search Result Snippet Ends -->
          