//<![CDATA[

function getAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function send_data(data) {
	ajax = getAjax();
	ajax.open("GET", "elements/store_keywords.php?lang=ES&k="+data, true);
	ajax.send(null);
}

var app;
function OnLoad() {
	app = new App();
}

function App() {
	// Create a search control
	var searchControl = new GSearchControl();

	// Add in a full set of searchers
	var options = new GsearcherOptions();
	options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

	var siteSearch = new GwebSearch();
	siteSearch.setUserDefinedLabel("IE Universidad");
	siteSearch.setUserDefinedClassSuffix("siteSearch");
	siteSearch.setSiteRestriction("ie.edu/universidad");
	searchControl.addSearcher(siteSearch, options);

	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);
	searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	searchControl.setNoResultsString("No existe informaci&oacute;n que coincida con los criterios de b&uacute;squeda");
	searchControl.setSearchStartingCallback(this, App.prototype.OnSearchStarting);
	searchControl.setSearchCompleteCallback(this, App.prototype.OnSearchComplete);
	
	// tell the searcher to draw itself and tell it where to attach
	var drawOptions = new GdrawOptions();
	drawOptions.setDrawMode(GSearchControl.DRAW_MODE_LINEAR);
	drawOptions.setInput(document.getElementById("keywords_text"));
	//drawOptions.setSearchFormRoot(document.getElementById("searchForm"));

	searchControl.draw(document.getElementById("searchForm"), drawOptions);
	searchControl.input.onkeyup = null;

	if (searchstr != "") {
		searchControl.execute(searchstr);
	}

}

App.prototype.OnSearchStarting = function(sc, searcher, query) {
	//document.getElementById(search_results_div).style.display = "block";
	//document.getElementById(main_content_div).style.display = "none";
}

App.prototype.OnSearchComplete = function(searchControl, searcher) {
	send_data (document.getElementById("keywords_text").value);
}

GSearch.setOnLoadCallback(OnLoad, true);

//]]>
