/**
 * Show a warning if search field is null or, is equal to string arg
 * @param form node - the form containing the field
 * @param text field - the field we're watching
 * @param str - the string we're comparing to
 *
 * usage: new searchWarning("formId", "inputId", "Please search");
 */
var DOM = YAHOO.util.Dom;
var EVT = YAHOO.util.Event;

function searchWarning(formNode, inputNode, str)
{
    this.form = DOM.get(formNode);
    this.input = DOM.get(inputNode);
    if (!this.form || !this.input) return;

    EVT.addListener(this.form, "submit", function(e) {
        if (this.input.value == '' || this.input.value == str)
        {
            if (this.dialog)
            {
              this.dialog.show();
            }
            else
            {
              this.dialog = new YAHOO.widget.SimpleDialog(
                this.form.id + this.input.id +"dialog1", 
                {
                    width: "300px",
                    fixedcenter: true,
                    visible: false,
                    draggable: false,
                    close: true,
                    modal: true,
                    zindex: 10,
                    text: "Please enter a search term.",
                    constraintoviewport: true,
                    buttons: [ { text:"OK", handler:function() {dialog.hide();}, isDefault:true } ]
                } );
              var dialog = this.dialog;
	      this.dialog.setHeader("Missing parameters");
              this.dialog.render('modals');
              this.dialog.show();
            }
            EVT.preventDefault(e);
        }
    }, this, true);
     

}

