function tx_comments_pi1_utfdecode(utftext) {
	var string = "";
	var i = 0;
	var c = c1 = c2 = 0;

	while ( i < utftext.length ) {

		c = utftext.charCodeAt(i);

		if (c < 128) {
			string += String.fromCharCode(c);
			i++;
		}
		else if((c > 191) && (c < 224)) {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		}
		else {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}

	}

	return string;
}


function tx_comments_pi1_readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') {
			c = c.substring(1, c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			return tx_comments_pi1_utfdecode(unescape(c.substring(nameEQ.length,c.length)).replace(/\+/, ' '));
		}
	}
	return false;
}

function tx_comments_pi1_setUserDataField(name) {
	var	field = document.getElementById('tx_comments_pi1_' + name);
	try {
		if (field && field.value == '') {
			var	value = tx_comments_pi1_readCookie('tx_comments_pi1_' + name);
			if (typeof value == 'string') {
				field.value = value;
			}
		}
	}
	catch (e) {
	}
}

function tx_comments_pi1_setUserData() {
	tx_comments_pi1_setUserDataField('firstname');
	tx_comments_pi1_setUserDataField('lastname');
	tx_comments_pi1_setUserDataField('location');
	tx_comments_pi1_setUserDataField('email');
	tx_comments_pi1_setUserDataField('homepage');
}