	var redo = "true";
	var searchControl;
	var searcher;
	var initsearchforArray = new Array();
	var initlwords = "";
	var count = 0;
	var wcount = 0;
	var itemcount = 0;
	var searchfor = initsearchfor;
	var thistype = 'web';
	var keywords = "";
	var test = "";
	var keywordArray = new Array();
	keywordArray[0] = "0 ";
	var letterArray = new Array();
	var searches = new Array();
	
	var searchestrs = new Array();

    var wordArray = new Array();
    var wordscore = new Array();
    var sortArray = new Array();
    var sortedwordArray = new Array();
    var titleArray = new Array();
    var urlArray = new Array();
    	urlArray[0] = "0 ";
    	titleArray[0] = "0 ";
    var useddroptextArray = new Array();
    var droptextArray = new Array();
    var exclusions = new Array("definitions","dictionary","encyclopedia","wikipedia","information","resources","online","recommendations");

	function init() {
		GSearch.getBranding(document.getElementById("searchcontrolbrand"));
		initlwords = initsearchfor.toLowerCase();
		initlwords = initlwords.replace(/(^\s+)|(\s+$)/g,"");
		initlwords = initlwords.replace(/\s+/g," ");
		letterArray = initlwords.split("");
		if (letterArray[0]=="\"" && letterArray[letterArray.length-1]=="\"") {
			initsearchforArray[0] = initlwords;
		} else {
			var reg2 = /\s+/;
			initsearchforArray = initlwords.split(reg2);
		}
		initlwords = initsearchforArray.join(" ");
		initsearchfor = initlwords;
		searches[0] = initsearchfor+" ";
		searchestrs[0] = initsearchfor;
		wcount = wcount + initsearchforArray.length;
		document.searchform.q.value = initlwords;
		document.searchform.q.focus();
		if (initproc == 1 && initsearchfor != "") {			
			process();
		}
		else {
			var searchResultPanels = document.getElementById("record");
			var panetitle = "newpanel0";
			if(navigator.userAgent.search(/msie/i)!= -1) { 
				class1 = "iepaneltabseld";
				class2 = "iepaneltab";
			} else { 
				class1 = "paneltabseld";
				class2 = "paneltab";
			}
			try {
				title = document.createElement("<li id='title' class='title'>");
				newpane = document.createElement("<li id='"+panetitle+"' class='"+class1+"' onClick='togglesearch(0);'>");
				panelink = document.createElement("<a href='#' class='panel'>");
			} catch (e) {
				title = document.createElement("li");
				title.setAttribute("id", "title");
				title.setAttribute("class", "title");
				newpane = document.createElement("li");
				panelink = document.createElement("a");
				panelink.setAttribute("href", "#");
				panelink.setAttribute("class", "panel");
				newpane.setAttribute("id", panetitle);
				newpane.setAttribute("class", class1);
				newpane.setAttribute("onClick", "togglesearch(0);");
			}
			if(navigator.userAgent.search(/msie/i)!= -1) { 
				panelink.innerHTML = initlwords.replaceAll(" ","&nbsp;")+" ";
			} else { 
				panelink.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;"+initlwords.replaceAll(" ","&nbsp;")+"&nbsp;&nbsp;&nbsp; ";
			} 
			newpane.appendChild(panelink);
			if (initsearchfor != "") {
				searchResultPanels.appendChild(title);
				title.innerHTML = "searches:&nbsp;";
				searchResultPanels.appendChild(newpane);
			}
			if (initsite != "") {
				document.getElementById("siteradio").checked = "true";
				document.getElementById("sitesearchform").style.visibility = "visible";
				DoSearch('site');
			}
			else {
				DoSearch('web');
			}
		}
	}

	function clickRadio(value) {
		type = value;
		if (type == "site") {
			document.getElementById("sitesearchform").style.visibility = "visible";
			if (document.getElementById("sq").value != "") {
				if (document.getElementById("searchresults").style.display == "none") {
					document.getElementById("search_results").style.display = "none";
					document.getElementById("saved_folder").style.display = "block";
					document.getElementById("searchresults").style.display = "block";
					document.getElementById("record").style.display = "block";
					document.getElementById("saved_results").style.display = "none";
					document.getElementById("intro").style.display = "none";
				}
				thistype = type;
				redo = "true";
				DoSearch(thistype);
				return false;
			}
		}
		else {
		document.getElementById("sitesearchform").style.visibility = "hidden";
		if (document.getElementById("searchresults").style.display == "none") {
			document.getElementById("search_results").style.display = "none";
			document.getElementById("saved_folder").style.display = "block";
			document.getElementById("searchresults").style.display = "block";
			document.getElementById("record").style.display = "block";
			document.getElementById("saved_results").style.display = "none";
			document.getElementById("intro").style.display = "none";
		}
		thistype = type;
		redo = "true";
		DoSearch(thistype);
		}
	}

	function DoSearch(type) {
		if (searchfor == "") {
			document.getElementById("intro").style.display = "block";
		}
		else {
			document.getElementById("intro").style.display = "none";
			thistype = type;
			document.getElementById("searchcontrolbrand").style.visibility = "visible";
			subj = searchfor;
			searchControl = new GSearchControl();
			var options2 = new GsearcherOptions();
			options2.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

			options2.setRoot(document.getElementById("searchresults"));

			if (type == 'web') { searcher = new GwebSearch() };
			if (type == 'image') {
				searcher = new GimageSearch();
				//searcher.setRestriction(GSearch.RESTRICT_SAFESEARCH, GSearch.SAFESEARCH_OFF);
			};
			if (type == 'video') { searcher = new GvideoSearch() };
			if (type == 'news') { searcher = new GnewsSearch() };
			if (type == 'blog') { searcher = new GblogSearch() };
			if (type == 'book') { searcher = new GbookSearch() };
			if (type == 'site') { 
				searcher = new GwebSearch();
				subj = "site:"+document.getElementById("sq").value+" "+subj;
			}

			searchControl.addSearcher(searcher, options2);
			var sharebutton = "<button type='button' class='buttontext' title='save this'><img src='images/inset/add.gif'></button>";
			searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
			searchControl.setSearchCompleteCallback(null, OnSearchComplete, [null]);
			searchControl.draw(document.getElementById("searchcontrol"));
			searchControl.setOnKeepCallback(this, MyKeepHandler, sharebutton );
			searchControl.execute(subj);
		}
	}

	function OnSearchComplete() {
		if ( (searcher.results.length == 0) && (redo == "false") && !(document.getElementById("errormsg")) ) {
			var errroot = document.getElementById("searchresults");
			try {
				errormsg = document.createElement("<div id='errormsg' class='gs-no-results-result1'>");
			} catch (e) {
				errormsg = document.createElement("div");
				errormsg.setAttribute("id", "errormsg");
				errormsg.setAttribute("class", "gs-no-results-result1");
			}
			errormsg.innerHTML = "Nothing, nada, zip, rien . . try another search."
			errroot.appendChild(errormsg);
		}
		var stuff = "";
		if ( ((searcher.results.length > 0) || (redo == "false")) ) {
		}
		else {
			redo = "false";
			//searchfor = searchfor.replaceAll(" AND ("," OR (");
			DoSearch(thistype);
		}
		hook();
	}

function MyKeepHandler(result) {
	count = count+1;
	itemcount = itemcount+1;
	document.getElementById("counternumber").innerHTML = count;
	document.getElementById("counternumber").className = "counter";
        var node = result.html.cloneNode(true);
        if (thistype == 'image') {
        	titleArray[itemcount] = result.contentNoFormatting;
        	keywordArray[itemcount] = result.contentNoFormatting + " ";
        }
        else {
        	titleArray[itemcount] = result.titleNoFormatting;
        	keywordArray[itemcount] = result.titleNoFormatting + " " + result.content + " ";
        }
        if (thistype == 'blog') {
        	urlArray[itemcount] = result.postUrl;
        }
        else if (thistype == 'video') {
        	urlArray[itemcount] = escape(result.url);
        }
        else {
        	urlArray[itemcount] = result.url;
        }
        var savedResults = document.getElementById("saved_results");
        try {
        	container = document.createElement("<div id='item"+itemcount+"' class='container'>");
        	br = document.createElement("<br>");
        	buttons = document.createElement("<div class='buttons'>");
        	rembuttonlabel = document.createElement("<div onClick='remove("+itemcount+")' title='unsave this item' class='button'>");
		rembutton = document.createElement("<img src='images/smboxclose.gif' border='0'/>");
		rembuttonlabeltext = document.createTextNode("  unsave");
		
        	oddbuttonlabel = document.createElement("<div onClick='oddflower("+itemcount+")' title='add to oddflower' style='text-align:right; padding:right:10px;' class='button'>");
		oddbutton = document.createElement("<img src='images/smoddflower.gif' border='0'/>");
		oddbuttonlabeltext = document.createTextNode("  oddflower this");

		addthis_url = urlArray[itemcount];
        	addthis_title = titleArray[itemcount];
		bookbuttonlabel = document.createElement("<div class='button'>");
		bookbuttonlabel.onclick = function(){addthis_sendto()};
		bookbuttonlabel.onmouseout = function(){addthis_close()};
		bookbuttonlabel.onmouseover = function(){addthis_open(this, '', addthis_url, addthis_title)};
		bookbuttonlabeltext = document.createTextNode("  bookmark ");
		bookbutton = document.createElement("<img src='images/bookmark.gif' border='0'/>");
		
	} catch (e) {
		container = document.createElement("div");
		container.setAttribute("id", "item"+itemcount);
		container.setAttribute("class", "container");
		buttons = document.createElement("div");
		buttons.setAttribute("class", "buttons");
		br = document.createElement("br");

		rembuttonlabel = document.createElement("div");
		rembuttonlabel.setAttribute("onClick", "remove("+itemcount+")");
		rembuttonlabel.setAttribute("class", "button");
		rembuttonlabel.setAttribute("title", "unsave this item");
		rembuttonlabeltext = document.createTextNode("unsave");
		rembutton = document.createElement("img");
		rembutton.setAttribute("src", "images/smboxclose.gif");
		rembutton.setAttribute("border", "0");
		rembutton.setAttribute("style", "padding-right:4px; padding-left:5px;");

		oddbuttonlabel = document.createElement("div");
		oddbuttonlabel.setAttribute("onClick", "oddflower("+itemcount+")");
		oddbuttonlabel.setAttribute("class", "button");
		oddbuttonlabel.setAttribute("title", "add to oddflower");
		oddbuttonlabeltext = document.createTextNode("oddflower this ");
		oddbutton = document.createElement("img");
		oddbutton.setAttribute("src", "images/smoddflower.gif");
		oddbutton.setAttribute("border", "0");
		oddbutton.setAttribute("style", "padding-right:4px; padding-left:5px;");

		addthis_url = urlArray[itemcount];
        	addthis_title = titleArray[itemcount];
		bookbuttonlabel = document.createElement("div");
		bookbuttonlabel.setAttribute("onClick", "return addthis_sendto()");
		bookbuttonlabel.setAttribute("onmouseover","return addthis_open(this, '', '"+addthis_url+"', '"+addthis_title+"')");
		bookbuttonlabel.setAttribute("onmouseout","addthis_close()");
		bookbuttonlabel.setAttribute("class", "button");
		bookbuttonlabeltext = document.createTextNode("bookmark ");
		bookbutton = document.createElement("img");
		bookbutton.setAttribute("src", "images/bookmark.gif");
		bookbutton.setAttribute("border", "0");
		bookbutton.setAttribute("style", "padding-right:4px; padding-left:5px;");
	}
	savedResults.appendChild(container);
	
        container.appendChild(node);
        rembuttonlabel.appendChild(rembutton);
        rembuttonlabel.appendChild(rembuttonlabeltext);
 	oddbuttonlabel.appendChild(oddbutton);
        oddbuttonlabel.appendChild(oddbuttonlabeltext);
 	bookbuttonlabel.appendChild(bookbutton);
        bookbuttonlabel.appendChild(bookbuttonlabeltext);
        buttons.appendChild(rembuttonlabel);
	buttons.appendChild(oddbuttonlabel);
	buttons.appendChild(bookbuttonlabel);
	container.appendChild(buttons);
        container.appendChild(br);
	redo = "true";
        process();
}

    function remove(num) {
    	thisone = "item"+num;
    	var removed = document.getElementById(thisone);
    	var savedResults = document.getElementById("saved_results");
        savedResults.removeChild(removed);
        keywordArray[num] = "";
        count = count-1;
        document.getElementById("counternumber").innerHTML = count;
        if (count < 1) {
        	document.getElementById("counternumber").className = "columnhead";
        }
        redo = "true";
        process();
    }



    function oddflower(num) {
		u = urlArray[num];
		t = titleArray[num];
		regexp = /\s+/;
		t = t.replaceAll(regexp,'z__');
		regexp = /\W+/;
		t = t.replaceAll(regexp,'-');
		t = t.replaceAll('z__',' ');
		window.open("http://www.oddflower.com/editlink-googlupon.jsp?t="+t+"&u="+u);
    }

if (!Array.prototype.indexOf)
	Array.prototype.indexOf = function(item, startIndex) {
		var len = this.length;
		if (startIndex == null)
			startIndex = 0;
		else if (startIndex < 0) {
			startIndex += len;
			if (startIndex < 0)
				startIndex = 0;
		}
		for (var i = startIndex; i < len; i++) {
			var val = this[i] || this.charAt && this.charAt(i);
			if (val == item)
				return i;
		}
		return -1;
	};

String.prototype.replaceAll=function(s1, s2) {return this.split(s1).join(s2)}

function process() {
	keywords = "";
        for (i=0; i<initsearchforArray.length; i++) {
           	keywords = keywords + " " + initsearchforArray[i];
        }
        keywords = keywords + " ";
        for (i=0; i<keywordArray.length; i++) {
           	keywords = keywords + keywordArray[i];
        }
        test="";
    	wordArray.length = 0;
    	wordscore.length = 0;
    	sortArray.length = 0;
    	sortedwordArray.length = 0;
    	var text = keywords.toString();
    	var reg = /\<b\>/;
    	var reg1 = /\<\/b\>/;
    	var reg4 = /.\d+./;
    	var reg2 = /&\w+/;
    	text = text.replaceAll(reg,"");
    	text = text.replaceAll(reg1,"");
    	text = text.replaceAll(reg4," ");
    	text = text.replaceAll(reg2," ");
	text = text.replaceAll("&#39;","\'");
    	text = text.replaceAll("&quot;"," ");
    	text = text.replaceAll("&middot;"," ");
    	text = text.replaceAll("&ell;"," ");
    	text = text.replaceAll("\""," ");
    	text = text.replaceAll("\`"," ");
    	text = text.replaceAll("\'"," ");
    	text = text.replaceAll("/"," ");
    	text = text.replaceAll(","," ");
    	text = text.replaceAll("."," ");
    	text = text.replaceAll("_"," ");
    	text = text.replaceAll("&"," ");
    	text = text.replaceAll(";"," ");
    	text = text.replaceAll("<"," ");
    	text = text.replaceAll(">"," ");
    	text = text.replaceAll("?"," ");
    	text = text.replaceAll("("," ");
    	text = text.replaceAll(")"," ");
    	text = text.replaceAll(":"," ");
    	text = text.replaceAll("|"," ");
    	text = text.replaceAll("?"," ");
    	text = text.replaceAll("!"," ");
    	text = text.replaceAll("["," ");
    	text = text.replaceAll("]"," ");
    	text = text.replaceAll("@"," ");
    	var reg3 = /\s+/;
    	textArray = text.split(reg3);
    	for (i=0; i<textArray.length; i++) {
    		if (typeof(textArray[i]) != "undefined") {
    		word = textArray[i].toLowerCase();
    		for (j=0; j<exclusions.length; j++) {
    			if (word == exclusions[j]) {
    				word = "";
    			}
    		}
    		wordArrayposn = wordArray.indexOf(word)
			if ( wordArrayposn > -1 ) {
				wordscore[wordArrayposn] = wordscore[wordArrayposn]+Math.pow(word.length,2);
			}
			else {
				if ( initsearchforArray.indexOf(word) > -1) {
						wordArray.push(word);
						wordscore.push(60);
				}
				else if ( (word.length > 5) ) {
						wordArray.push(word);
						wordscore.push(word.length);
				}
			}
		}
    	}
    	for (i=0; i<wordArray.length; i++) {
    		sortArray[i] = wordscore[i];
    	}
    	sortArray.sort(function(a,b){return b - a});
    	for (i=0; i<sortArray.length; i++) {
    		score = sortArray[i];
    		wordArrayposn = wordscore.indexOf(score);
    		sortedwordArray[i] = wordArray[wordArrayposn];
    		wordArray[wordArrayposn] = "";
    		wordscore[wordArrayposn] = 0;
    	}
    	
    	if ((count >= 0) || (initproc == "1")) {
    		numqwords = wcount + Math.min(count,sortedwordArray.length);
    		if (numqwords > 5) {
    			numqwords = 5;
    		}
    		if (sortedwordArray.length == 1) {
    			searchfor = sortedwordArray[0];
    			searchstr = sortedwordArray[0] + " ";
    		}
    		else if (sortedwordArray.length == 2) {
    			searchfor = sortedwordArray[0] + " AND ~" + sortedwordArray[1];
    			searchstr = sortedwordArray[0] + " " + sortedwordArray[1];
    			document.searchform.q.value = searchstr;
    		}
    		else {
    			searchfor = sortedwordArray[0] + " AND (~";
    			searchstr = sortedwordArray[0] + " ";
    			for (i=1; i<numqwords; i++) {
    				if (typeof(sortedwordArray[i]) != "undefined") {
    				searchfor = searchfor + sortedwordArray[i] + " OR ~";
    				searchstr = searchstr + sortedwordArray[i] + " ";
    				}
    			}
    			searchfor = searchfor.substring(0,searchfor.length-5) +")";
    			document.searchform.q.value = searchstr; 
    		}
    	}
    	else {
    		searchfor = initsearchfor;
    		searchstr = searchfor;
    		document.searchform.q.value = sortedwordArray;
    	}
    	if (searchestrs[searchestrs.length-1] != searchfor) {
		if(navigator.userAgent.search(/msie/i)!= -1) { 
			class1 = "iepaneltabseld";
			class2 = "iepaneltab";
		} else { 
			class1 = "paneltabseld";
			class2 = "paneltab";
		}
    		for (i=0; i<searches.length; i++) {
			panel = "newpanel"+i;
			document.getElementById(panel).className = class2;
		}
		searchestrs.push(searchfor);
		searches.push(searchstr);
		var searchResultPanels = document.getElementById("record");
		indexno = searches.length-1;
		var panetitle = "newpanel"+(indexno);
			try {
				newpane = document.createElement("<li id='"+panetitle+"' class='"+class1+"' onMouseover='show("+indexno+");'  onMouseout='hide("+indexno+");'>");
				drop = document.createElement("<div id='drop"+indexno+"' class='dropchoices'>");
				panelink = document.createElement("<a href='#' class='panel' onClick='togglesearch("+indexno+"); hide("+indexno+");'>");
			} catch (e) {
				newpane = document.createElement("li");
				drop = document.createElement("div");
				panelink = document.createElement("a");
				panelink.setAttribute("href", "#");
				panelink.setAttribute("class", "panel");
				newpane.setAttribute("id", panetitle);
				newpane.setAttribute("class", class1);
				panelink.setAttribute("onClick", "togglesearch("+indexno+"); hide("+indexno+");");
				newpane.setAttribute("onMouseover", "show("+indexno+");");
				drop.setAttribute("id", "drop"+indexno);
				drop.setAttribute("class", "dropchoices");
				newpane.setAttribute("onMouseout", "hide("+indexno+");");
			}
		if(navigator.userAgent.search(/msie/i)!= -1) { 
			panelink.innerHTML = searches[indexno].replaceAll(" ","&nbsp;")+" ";
			
		} else { 
			panelink.innerHTML = "&nbsp;"+searches[indexno].replaceAll(" ","&nbsp;");
		}
		j = 0;
		droptextArray.length = 0;
		droptextArray = sortedwordArray.slice();
		for (i=indexno+initsearchforArray.length; i<droptextArray.length; i++) {
			dropsearchterm = droptextArray[i];
			test = useddroptextArray.indexOf(dropsearchterm);
			if (test == -1 && j < 7) {
				useddroptextArray.push(dropsearchterm);
				j = j + 1;
			try {
				dropholder = document.createElement("<div>");
				droppanelink = document.createElement("<a href='#' class='panel' onClick='dropsearch(\""+dropsearchterm+"\"); hide("+indexno+");'>");
			} catch (e) {
				dropholder = document.createElement("div");
				dropholder.setAttribute("class", "panel");
				droppanelink = document.createElement("a");
				droppanelink.setAttribute("href", "#");
				droppanelink.setAttribute("class", "panel");
				droppanelink.setAttribute("onClick", "dropsearch('"+dropsearchterm+"'); hide("+indexno+");");
			}
			dropholder.appendChild(droppanelink);
			drop.appendChild(dropholder);
			droppanelink.innerHTML = "&hellip;&nbsp;+&nbsp;"+dropsearchterm+"&nbsp;";
			}
		}
		newpane.appendChild(panelink);
		newpane.appendChild(drop);
		searchResultPanels.appendChild(newpane);
		elwidth = document.getElementById(panetitle).offsetWidth;
		document.getElementById("drop"+indexno).style.width = elwidth-2;
	}
	DoSearch(thistype);
	//document.getElementById("testit2").innerHTML = searches + "<br>" + searchestrs + "<br>" + sortedwordArray + "<br>" + sortArray;
    }
   
    	function hide(id) {
    		dropit = "drop"+id;
    		document.getElementById(dropit).style.visibility = "hidden";
    	}
    	
    	function show(id) {
    		dropit = "drop"+id;
    		document.getElementById(dropit).style.visibility = "visible";
    	}

	function newsearch() {
		redo = "true";
		var searchfor = document.searchform.q.value;
		initproc = 0;
		DoSearch(thistype);
	}

	function toggle() {
		if (searchfor == "") {
			mainpanel = document.getElementById("intro");
		}
		else {
			mainpanel = document.getElementById("searchresults");
		}
		if (mainpanel.style.display == "block") {
			document.getElementById("searchresults").style.display = "none";
			document.getElementById("saved_folder").style.display = "none";
			document.getElementById("search_results").style.display = "block";
			document.getElementById("intro").style.display = "none";
			document.getElementById("saved_results").style.display = "block";
			document.getElementById("record").style.display = "none";
		}
		else {
			document.getElementById("saved_results").style.display = "none";
			document.getElementById("intro").style.display = "none";
			document.getElementById("saved_folder").style.display = "block";
			document.getElementById("record").style.display = "block";
			document.getElementById("search_results").style.display = "none";
			mainpanel.style.display = "block";
			for (i=1; i<searches.length; i++) {
				elwidth = document.getElementById("newpanel"+i).offsetWidth;
				document.getElementById("drop"+i).style.width = elwidth-2;
			}
		}
	}

	function clearall() {
		redo = "true";
		initproc = 0;
		document.searchform.q.value = "";
		document.getElementById("sq").value = "";
		var searchfor = document.searchform.q.value;
		DoSearch('web');
	}
	
	function togglesearch(thisone) {
		indexno = thisone;
        	searchfor = searchestrs[indexno];
        	document.searchform.q.value = searches[thisone];
 		if(navigator.userAgent.search(/msie/i)!= -1) { 
 			class1 = "iepaneltabseld";
 			class2 = "iepaneltab";
		}
		else {
        		class1 = "paneltabseld";
        		class2 = "paneltab";
        	}
        	for (i=0; i<searches.length; i++) {
        		panel = "newpanel"+i;
        		document.getElementById(panel).className = class2;
        	}
        	panel = "newpanel"+thisone;
 		document.getElementById(panel).className = class1;
        	DoSearch(thistype);
	}
	
	function dropsearch(thisone) {
        	document.searchform.q.value = searches[indexno]+thisone;
        	if (indexno == 0) {
        		searchfor = searchestrs[indexno]+" AND ~"+thisone;
        	}
        	else {
        		searchfor = searchestrs[indexno].replaceAll(")"," OR ~" + thisone + ")");
		}
 		if(navigator.userAgent.search(/msie/i)!= -1) { 
 			class1 = "iepaneltabseld";
 			class2 = "iepaneltab";
		}
		else {
        		class1 = "paneltabseld";
        		class2 = "paneltab";
        	}
        	for (i=0; i<searches.length; i++) {
        		panel = "newpanel"+i;
        		document.getElementById(panel).className = class2;
        	}
        	DoSearch(thistype);
	}
	
	function hook() {
		document.getElementById("testit").innerHTML = "";
		greenlinks = document.getElementsByTagName("div");
		for (i=0; i<greenlinks.length; i++) {
			classs = greenlinks.item(i).className;
			if (classs == "gs-visibleUrl gs-visibleUrl-short") {
				var siteurl = greenlinks.item(i).childNodes[0].nodeValue;
				makeEvent(greenlinks.item(i), newlinkclick, siteurl, "click");
				greenlinks.item(i).setAttribute("title", "click to search within this site");
			}
			else if (classs == "gs-publisher" || classs == "gs-visibleUrl") {
				var pageurl = greenlinks.item(i).childNodes[0].href;
				var siteurl = greenlinks.item(i).childNodes[0].childNodes[0].nodeValue;
				makeEvent(greenlinks.item(i), newlinkclick, siteurl, "click");
				greenlinks.item(i).setAttribute("title", "click to search within this site");
				greenlinks.item(i).innerHTML = siteurl;
				if (type == "image") {
					var parent = greenlinks.item(i).parentNode;
					parent.firstChild.className = "gs-title";
					var text = parent.firstChild.title;
					parent.firstChild.innerHTML = "<a href='"+pageurl+"' TARGET='blank' title=''>"+text+"</a>";
				}
			}
		}
		
	}
	
	function newlinkclick(thisurl) {
		document.getElementById("sq").value = thisurl;
		document.getElementById("siteradio").checked = "true";
		clickRadio('site');
	}
	
	function makeEvent(element, callback, param, event) {
    		function local() {
        		return callback(param);
    		}
		if (element.addEventListener) {
			element.addEventListener(event,local,false);
		} 
		else if (element.attachEvent) {
			element.attachEvent("on"+event,local);
		}
	}
		
