/* # $Id$
 */

function doSearchSubmit() {
    var v = document.getElementById("searchText").value;
    if (v == "" || v == "Search") {
	alert("Error: no search text");
	return false;
    }
    return true;
}

var Research = {
    m_over : function(el) {
	if (el.className.indexOf(" over") == -1)
	    el.className += " over";
    },
 
    m_out: function (el) {
	el.className = el.className.replace(/ over/, "");
    },

    m_showpdf: function (id, f) {
	var w = window.open("/x/research?id=" + encodeURIComponent(id) + "&f=" + encodeURIComponent(f));
	if (w) w.focus();
    },

    m_showtxt: function (id) {
	var w = window.open("/x/research-display.html?rid=" + encodeURIComponent(id));
	if (w) w.focus();
    },
    
    company_link: function(id) {
	location.href = "research-company.html?cid=" + encodeURIComponent(id);
    },

    linkto: function(id) {
	location.href = "research-library.html?s=" + encodeURIComponent(id);
    }

}

var ResearchBasket = {
    update : function() { this.send(""); },
    clear : function() { this.send("?op=clear"); },
    add : function(id) { this.send("?op=add&id=" + escape(id)); },
    send : function(arg) {
	$.ajax({
		url: '/x/research-basket' + arg,
		success: function( data ) {
		    data = $.trim(data);
		    if (/^0 /.test(data)) {
			$('#researchBasket').slideUp();
		    } else {
			$('#researchBasketCount').html(data);
			$('#researchBasket').slideDown();
		    }
		}
	    });
    }
}

