google.load("search", "1",{"language" : "es"});
var mainSearch;
function cse() {
    var cseId = "000587527252178718853:nkm_jwh6loi";
    var options = new GsearcherOptions();
    var searcher = new google.search.WebSearch();
    
    var searchDiv = document.getElementById("searchControl");
    var sFormDiv = document.getElementById("searchForm");
    
    this.searchControl = new google.search.SearchControl();
    this.searchForm = new google.search.SearchForm(true, sFormDiv);
    
     this.searchForm.setOnSubmitCallback(this, cse.prototype.onSubmit);
    this.searchForm.setOnClearCallback(this, cse.prototype.onClear);
    
    searcher.setSiteRestriction(cseId);
    searcher.setUserDefinedLabel("Resultados de la b&uacute;squeda");
    
    this.searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
    this.searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);
    
    options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
    
    this.searchControl.addSearcher(searcher,options);
    this.searchControl.draw(searchDiv);
}

cse.prototype.onSubmit = function(form) {
var q = form.input.value;
if (q && q!= "") {
    this.search.execute(q);
}
return false;
}

cse.prototype.onClear = function(form) {
	this.searchControl.clearAllResults();
	form.input.value = "";
	return false;
}

function fn_submit(){
	mainSearch.searchControl.clearAllResults();
	var v = document.forms["cse-search-box"].q.value;;
	var tc = document.getElementById("TemplateContenido");
	if (v && v!=""){
		tc.style.visibility="hidden";
		tc.style.height="0";
		mainSearch.searchControl.execute(v);
	}else{
		tc.style.visibility="visible";
		tc.style.height="";
		mainSearch.searchControl.clearAllResults();
	}
	return false;
}

function OnLoad() {
    mainSearch = new cse();
}
    google.setOnLoadCallback(OnLoad,true);