
/**
 * General con|comm JavaScript
 *
 * This file is part of the con|comm framework
 * (c) EZdesign.de
 *
 * Author:   Timo Besenreuther
 * Created:  2007
 * Modified: 2010-05-18
 */


/** Login Box */
$(document).ready(function() {
	var box = $('#LoginBox input.UserName');
	if (box.length) box.inputDescription('E-Mail');
	box = $('#LoginBox input.Password');
	if (box.length) box.inputDescription('Password');
});

$.fn.inputDescription = function(text) {
	var input = $(this);
	input.blur(function() {
		if (input.attr('value') == '' || input.attr('value') == text) {
			input.attr('value', text).addClass('Faded');
		}
	}).focus(function() {
		if (input.attr('value') == text) {
			input.attr('value', '').removeClass('Faded');
		}
	}).trigger('blur');
}

/** Ajax request */
var ConComm_Ajax = {
	request: function (module, method, data, callback) {
		data = jQuery.extend({
			'class': module,
			'module': 'ConComm',
			'namespace': 'Core/Modules',
			'method': method
		}, data);
		$.post('includes/ezajax/ezajax.php', data, function(response, textStatus) {
			if (textStatus != 'success') {
				alert('There was an error, see log for details.');
				console.log(response);
			} else {
				callback(response);
			}
		}, 'json');
	}
};