jQuery.fn.mandantory = function (text,mandantoryClass) {
	if (!mandantoryClass) { 
		mandantoryClass = 'mandantoryhighlite';
  	}

	return this.each(function () {
		var input = $(this);
		title = input.attr('title');
		var form = $(this.form);
		var win = $(window);
		var textmessage = text;
		function remove() {
			if (($(this).val() == text) && input.hasClass(mandantoryClass)) {
				$(this).val('').removeClass(mandantoryClass);
			}
		}

		input.blur(function () {
			if (this.value == '') {
				alert(this.id);
				$(this).val(textmessage).addClass(mandantoryClass);
			}
		}).focus(remove).blur();

		form.submit(remove);
		win.unload(remove);
  	});
};

jQuery.fn.saveForm = function (box,url,command,pageId) {
	var input = $(this);
	var fields = $(this).serializeArray();
	var values = $.param(fields);
	var targetBox = box;
	
	$(this).find("input:checkbox").each(function () {
		var id = this.id;
		if ($(this).attr("checked")) {
			values += "&" + id + "=1";
		} else {
			values += "&" + id + "=0";
		}
	});

	$.post(url,{'command' : command, 'pageId' : pageId, 'formValues' : values},function(data) {
		document.location = data;
	});
};

