﻿function empty( mixed_var ) {
	// http://kevin.vanzonneveld.net
	// +   original by: Philippe Baumann
	// +      input by: Onno Marsman
	// +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +      input by: LH
	// +   improved by: Onno Marsman
	// +   improved by: Francesco
	// *     example 1: empty(null);
	// *     returns 1: true
	// *     example 2: empty(undefined);
	// *     returns 2: true
	// *     example 3: empty([]);
	// *     returns 3: true
	// *     example 4: empty({});
	// *     returns 4: true
	
	var key;
	
	if (mixed_var === ""
		|| mixed_var === 0
		|| mixed_var === "0"
		|| mixed_var === null
		|| mixed_var === false
		|| mixed_var === undefined
	){
		return true;
	}
	if (typeof mixed_var == 'object') {
		for (key in mixed_var) {
			if (typeof mixed_var[key] !== 'function' ) {
			  return false;
			}
		}
		return true;
	}
	return false;
}

// Below is a collection of special selectors that may be useful for 
// the ITI portal and other projects that use jQuery
$.extend($.expr[':'],{
    empty_val: function(a) {
		return empty($(a).val());
    },
	not_empty_val: function(a) {
		return !empty($(a).val());
	}
});