
/**
 * eversjung package
 *
 * This package contains initialization functions.
 *
 * @author <a href="mailto:info@cappuccinonet.com.com">Bernhard Woehrlin, IT.CappuccinoNet.com</a>
 */
if (typeof eversjung == 'undefined') {
  eversjung = function () { }
}

eversjung.kontaktform = function () { }


// pre-submit callback
eversjung.kontaktform.showRequest = function (formData, jqForm, options) {
	// formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
    var queryString = $.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    //var formElement = jqForm[0];

    FB.log('pre-submit: '+queryString, DEBUG);

    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
}

// pre-submit callback
eversjung.kontaktform.validate = function (formData, jqForm, options) {
	// formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
    var queryString = $.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    //var formElement = jqForm[0];

    FB.log('pre-submit: '+ jqForm[0], DEBUG);

    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
}


// post-submit callback
eversjung.kontaktform.showResponse = function (data) {

	// for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property

    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property
	FB.log('post-submit: \n' + data['name'] + '\n', DEBUG);

	FB.log ('data.ok: '+data.ok);

	if (data.ok == 'true')
	{
		$('#content').html('<h1>'+STRING_THANKS+'</h1><p>'+STRING_SUCCESS_SENT+'</p>');
	}
	return false;
    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server
	//alert(data['name']);


}



