//////////////////////////////////////////////
// Kasseler CMS: Content Management System  //
// ===========================              //
// Copyright (c)2007-2008 by Igor Ognichenko//
// http://www.kasseler-cms.net/             //
//////////////////////////////////////////////

var validFields = Array();
var validateForm = '';

function validateCheck(field, type, minlength){
return true;
}

function validation(field, type, minlength){
    var valid = validateCheck(field, type, minlength);
    if (typeof validFields[field]!='undefined' && validFields[field][0]==valid) return;
    validFields[field.name] = Array(type, minlength);
    disableButton();
    return valid;
 }
 
 function Mark(field, valid){
     if (field){
         if(!valid) field.style.background = '#FFF0F0';
         else field.style.background = '';
     }
 }
 
 function disableButton () {
    var disable = false;
    var field;
    for (var iField in validFields){

        field = document.getElementById(iField);
        valid = validateCheck(field, validFields[iField][0], validFields[iField][1]);
        Mark(field, valid);
        if(!valid) disable = true;
    }
    var button;
    if (document.getElementById('SuperSubmit')) button = document.getElementById('SuperSubmit');
    else if (document.getElementById('submit')) button = document.getElementById('submit');
         else return false;
    button.disabled = disable;
    if(!validateForm) {
        window.clearInterval(validateForm);
        validateForm = '';
        if(disable) validateForm = window.setInterval("disableButton ()", 1000);
    }
}
