/**
 * $RCSfile: common.js,v $
 * $Revision: 1.0a $
 * $Date: Jan 2005  $
 *
 * @author Konstantin Kolev kkolev@dotmedia.bg
 * @copyright Copyright © 2005, http://www.dotmedia.bg
 */
var __validate_required   = 0;
var __validate_float      = 1;
var __validate_integer    = 2;

function chg_img_over(sender) {
    sender.src = sender.src.replace("_p", "_a");
}
function chg_img_out(sender) {
	sender.src = sender.src.replace("_a", "_p");
}
function MM_openBrWindow(theURL,winName,features) {
   window.open(theURL,winName,features);
}
function Validator() {
    this.id;
    this.type = __validate_required;
    this.errorMessage;
    this._count = 0;
    this.items = new Array();

    function validate() {
        result = true;
            var count = 0;
            while ((count < this.items.length) && (result)) {
                control = document.getElementById(this.items[count].id);
                if (control != null) {
                    switch (this.items[count].type) {
                        case __validate_float:
                            if ((control.value != null) && (isNaN(control.value))) {
                                result = false;
										  control.focus();
                                alert(this.items[count].errorMessage);
                            }
                            break;
                        case __validate_integer:
                            if ((control.value != null) && (isNaN(control.value))) {
                                result = false;
                                control.focus();
										  alert(this.items[count].errorMessage);
                                exit();
                            }
                            break;
                        default:
                             if ((control.value != null) && (control.value == "")) {
                                result = false;
										  control.focus();
                                alert(this.items[count].errorMessage);
                             }
                            break;
                    }
                }
                count++;
            }

        return result;
    }
    function app(_id, _errorMessage, _type) {
        var item = new Validator();
        item.id = _id; item.type = _type; item.errorMessage = _errorMessage;
        this.items[this._count++] = item;
    }
    Validator.prototype.Validate    = validate;
    Validator.prototype.Append      = app;
}
