function validateForm() {
    var listNotFilled = "";

    for (var e = 0; e < document.forms[0].elements.length; e++) {
        var el = document.forms[0].elements[e];
        if (el.type == 'text') {
            if (el.value == '') {
                listNotFilled = listNotFilled + el.name.substr(el.name.lastIndexOf("$") + 1) + ":";
            }
        }
        else if (el.type == 'select-one') {
            if (el.value == '') {
                listNotFilled = listNotFilled + el.name.substr(el.name.lastIndexOf("$") + 1) + ":";
            }
        }
        else if (el.type == 'radio') {
            var group = form1.elements[el.name];
            var checked = false;

            if (!group.length) checked = el.checked;
            else {
                for (var r = 0; r < group.length; r++) {
                    if ((checked = group[r].checked))
                        break;
                }
                if (!checked) {
                    listNotFilled = listNotFilled + el.name.substr(el.name.lastIndexOf("$") + 1) + ":";
                }
            }
        }
        else if (el.type == 'checkbox') {
            if (!el.checked) {
                listNotFilled = listNotFilled + el.name.substr(el.name.lastIndexOf("$") + 1) + ":";
            }
        }

    }
    if (listNotFilled.indexOf(":") > -1)
        listNotFilled = listNotFilled.substring(0, listNotFilled.length - 1);

    return listNotFilled;
}

jQuery(document).ready(function() {

    window.onbeforeunload = function() {
        var lstnotfilled = validateForm();
        if (lstnotfilled == '') return;
        jQuery.cookie('notfilledfields', lstnotfilled);

    }

}); 


