function isdefined(variable) {
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function bind_select(name){
	var parent = $("#id_" + name);
	var scroll_container = parent.find(".scroll-container");
	parent.find(".select-arrow, .select-text").click(function(){
	    scroll_container.toggle();
	});

	var scroll_container_divs = $("#id_"+name+" .scroll-container div");
	scroll_container_divs.click(function(){
		var sender = $(this);
		$("#id_"+name+" #vid_" + name).val(sender.attr("id").replace(name + '_', ''));
		$("#id_"+name+" #sid_" + name).text(sender.text());
		scroll_container.hide();
		if (isdefined("on_" + name + "_change"))  eval("on_" + name + "_change();");
    });

	scroll_container_divs.mouseover(function() {
	      this.className="over"; });
	    
	scroll_container_divs.mouseout(function() {
      this.className=""; });
}