// ------------------------------------------------------------
// rika toolkit
//
// developed by karsten lueth 
//
// created: dec 14, 2009
//
// version 0.1
// ------------------------------------------------------------

// ------------------------------------------------------------
// title --
//   Creates a title.
//
// Arguments:
//   title_string - the text for the title. 
// ------------------------------------------------------------
function title(title_string) {
    document.write("<H1>" + title_string + "</H1>\n\n");
}

// ------------------------------------------------------------
// textfield --
//   creates a new textfield object 
//
// Arguments:
//   id_string - the id of the textfield. 
// ------------------------------------------------------------
function textfield(id_string)
{
    this.ident   = id_string; 
    this.label   = "";
    this.value   = ""; 
    this.action  = "do_nothing"; 
    this.emit    = textfield_emit; 
}

// ------------------------------------------------------------
// textfield_emit --
//   Emits the code for an textfield. 
//
// Arguments:
//   none. 
// ------------------------------------------------------------
function textfield_emit()
{
    document.write("<form name=\""+this.ident+"\" " 
                  + "action=\"\" "
                  + "onsubmit=\"" + this.action +" (this); return false;\" "
                  + ">"
                  + '<p><table border="0" cellpadding="0" cellspacing="4">'
                  + '<tr><td width="200px">'+this.label+'</td><td>'
                  + "<input name=\"entry\" "
                  + "type=\"text\" "
                  + "size=\"30\" "
                  + 'value="'+this.value+'" '
                  + "maxlength=\"30\"></td></tr></table>"
                  +"</p></form>\n\n");
}

// ------------------------------------------------------------
// selector --
//   creates a new selector object 
//
// Arguments:
//   id_string - the id of the selector. 
// ------------------------------------------------------------
function selector(id_string)
{
    this.ident   = id_string; 
    this.label   = "";
    this.list    = null; 
    this.action  = "do_nothing"; 
    this.emit    = selector_emit; 
}

// ------------------------------------------------------------
// selector_emit --
//   Emits the code for a selector. 
//
// Arguments:
//   none. 
// ------------------------------------------------------------
function selector_emit()
{
    document.write("<form name=\""+this.ident+"\" " 
                  + "action=\"\" "
                  + ">"
                  + '<p><table border="0" cellpadding="0" cellspacing="4">'
                  + '<tr><td width="200px">'+this.label+'</td><td>'
                  + "<select name=\"selector\" "
                  + "onchange=\""+this.action+"(this)\" "
                  + "width=\"250\">");
    if (this.list != null) {
        for (key in this.list) {
            document.write('<option value"'+key+'">'+this.list[key]
                            + '</options>\n');
        }
    }
    document.write("</select></td></tr></table>"
                  +"</p></form>\n\n");
}


// ------------------------------------------------------------
// do_nothing --
//   Default function for no action. 
//
// Arguments:
//   The sender for this message.  
// ------------------------------------------------------------
function do_nothing(sender)
{
}