
$(document).ready(function () {

$('.tx-thmailformplus-pi1 form').submit(function(){
	// set Form-Values to Cookie on Submit
	var formVals = $.evalJSON($.cookie('formVals'));
	if(!formVals) formVals = new Object();
	$('.tx-thmailformplus-pi1 form input').each(function(){
		if($(this).attr('type') == 'text'){
			formVals[$(this).attr("name")] = $(this).attr("value");
		}
	});
	$('.tx-thmailformplus-pi1 form select option:selected').each(function(){
		formVals[$(this).parent().attr("name")] = $(this).attr("value");
	});
	//alert($.toJSON(formVals));
	$.cookie('formVals', $.toJSON(formVals), { path: '/', expires: 10 });
});


$('.tx-thmailformplus-pi1 form').ready(function(){
	// set Form-Values from Cookie to Field-Values
	var formVals = $.evalJSON($.cookie('formVals'));
	//alert($.toJSON(formVals));
	if(formVals){
		$('.tx-thmailformplus-pi1 form input').each(function(){
			$(this).attr("value", formVals[$(this).attr("name")]);
		});
		$('.tx-thmailformplus-pi1 form select').each(function(){
			if(selectVal = formVals[$(this).attr("name")]){
				$(this).children("option").each(function(){
					if($(this).attr("value") == selectVal){
						$(this).attr("selected","selected");
					}
				});
			}
		});
	}

});


});// EO $(document).ready(function (){



