$(document).ready(function() {
	function codeTipped() {
		document.getElementById('sendbutton').disabled = '';
	}

	function checkMail(obj) {
		var checkedMail = '';
		var mail = obj.value;
		if (mail != '') {
	
			/* info this function does not work perfectly. The quantifire is not accepted. In php works the expression */
			checkedMail = obj.value.replace(/^[a-zA-Z0-9-_.]+(@)[a-z-.]+\.[a-z]{2,6}$/, '');
			if (checkedMail != '') {
				obj.value = '';
			}
		}
	}

	function onError(state) {
		if (state == true) {
			// Write the error-fields in an array called errorArray
	
		        var errorGets = '{/literal}{$data.onerror_fields}{literal}';
	
		        var errorArray = errorGets.split(',');
		        var iErrorArray = errorArray.length - 1;        // - 1 because the split-function create 1 key/value which is empty
	
			// Marks the fields which has posted wrong
		        for (i = 0; i < iErrorArray; i++) {
		                var errorFields = errorArray[i] + 'Text';
		                document.getElementById(errorFields).style.color        = '#cc0000';
		                document.getElementById(errorFields).style.fontWeight   = 'bold';
			}
		}
	}
	
	function changeHumImg() {
		document.getElementById('huc_img').src = '{/literal}{$SUB_DIR}{literal}libs/captcha/new_captcha/capimg.php?blah=' + Math.random();
		document.getElementById('captcha').value = '';
		document.getElementById('captcha').focus();
	}
	
	$('#suchmaschinen label').hover(function() {
		$(this).css('backgroundColor', '#DDDDDD');
	}, function() {
		$(this).css('backgroundColor', '#FFFFFF');
	});
	
	
	onError({/literal}{$data.state}{literal});
});
