function check_Form(formname) {
    ctrl = document.forms[formname];
    var chckdata;
    eval('chckdata = '+formname+';');
    return FormControl(ctrl, chckdata);
}

function FormControl(ctrl,FC){
    var Message,Field,value,i;
    var RetVal=true;
    var result
    
    for (i=0; i<FC.length && RetVal; i++){
        checked = false;
        index = '';
        value = '';
        Field = eval("ctrl."+FC[i][0]);
        if (Field) {
            if (Field.type == 'select-one') {
                index = Field.selectedIndex;
                value = Field.options[Field.selectedIndex].value;
            } else if (!Field.type) {
                if (Field.length) {
                    for (y=0; y<Field.length; y++) {
                        if (Field[y].checked) {
                            index = y;
                            value = Field[y].value;
                            checked = true;
                            y = Field.length + 1;
                        }
                    }
                }
            } else {
                value = Field.value;
                checked = Field.checked;
            }
            result = eval(FC[i][1]);
            if(!result) {
                Message=FC[i][2];
                RetVal=false;
            }
        }
    }

    if(!RetVal){
        alert(Message);
        if (Field.style && Field.style.display != 'none') {
            if (!Field.type || (Field.type == 'undefined')) {
                if (Field.length != 'undefined') {
                    Field[0].focus();
                }
            } else Field.focus();
            if (Field.type=="text" || Field.type=="password"){
                Field.select();
            }
        }
    }
    return RetVal;
}

function clearContent(id) {
    var x = document.getElementById(id);
    if (x) {
        if (x.value) {
            if ( (x.value.substring(0,1)=='\u00A0') || (x.value.substring(0,1) == ' ')) {
                x.value = '';
            }
        }
    }
}