function checkEmailFormat( emailStr ) {
	var email = emailStr;
	emailTest = "^[_\\.0-9A-z-]+@([0-9a-z][0-9a-z_-]+\\.)+[a-z]{2,4}$";
	var regex = new RegExp( emailTest );
	if( !regex.test( email ) || !( email.length > 0 ) ){
		return false;
	}else{
		return true;
	}
}

function HideHint( obj, hint2, hint3 ){
	if( document.getElementById ){
		document.getElementById(obj).style.borderColor = '#777777';
		document.getElementById(obj + "hint").style.display = 'none';
		document.getElementById(obj + "comment").style.display = 'block';
		if( "" != hint2 ){
			document.getElementById(obj + "hint2").style.display = 'none';
		}
		if( "" != hint3 ){
			document.getElementById(obj + "hint3").style.display = 'none';
		}
	}
}

function HideBorderWarning( obj ){
	if( document.getElementById ){
		document.getElementById(obj).style.borderColor = '#777777';
	}
}

function fCheckRequiredFieldsRegister(){

	var ok = true;

	if( "" == document.getElementById("username").value ){
		document.getElementById("username").style.borderColor = '#ff0000';
		document.getElementById("usernamecomment").style.display = 'none';
		document.getElementById("usernamehint").style.display = 'block';
		ok = false;
	}

	if( "" == document.getElementById("password").value ){
		document.getElementById("password").style.borderColor = '#ff0000';
		document.getElementById("passwordcomment").style.display = 'none';
		document.getElementById("passwordhint").style.display = 'block';
		ok = false;
	}
	
	if( "" == document.getElementById("repassword").value ){
		document.getElementById("repassword").style.borderColor = '#ff0000';
		document.getElementById("repasswordcomment").style.display = 'none';
		document.getElementById("repasswordhint").style.display = 'block';
		ok = false;
	}
	
	if( "" != document.getElementById("password").value && "" != document.getElementById("repassword").value && document.getElementById("password").value != document.getElementById("repassword").value ){
		document.getElementById("repassword").style.borderColor = '#ff0000';
		document.getElementById("repasswordcomment").style.display = 'none';
		document.getElementById("repasswordhint2").style.display = 'block';
		ok = false;
	}
	
	if( "" == document.getElementById("email").value ){
		document.getElementById("email").style.borderColor = '#ff0000';
		document.getElementById("emailcomment").style.display = 'none';
		document.getElementById("emailhint").style.display = 'block';
		ok = false;
	}else{
		checkemail = checkEmailFormat( document.getElementById("email").value );
		if( !checkemail ){
			document.getElementById("email").style.borderColor = '#ff0000';
			document.getElementById("emailcomment").style.display = 'none';
			document.getElementById("emailhint2").style.display = 'block';
			ok = false;
		}
	}
	
	if( "" == document.getElementById("firstname").value ){
		document.getElementById("firstname").style.borderColor = '#ff0000';
		document.getElementById("firstnamecomment").style.display = 'none';
		document.getElementById("firstnamehint").style.display = 'block';
		ok = false;
	}
	
	if( "" == document.getElementById("lastname").value ){
		document.getElementById("lastname").style.borderColor = '#ff0000';
		document.getElementById("lastnamecomment").style.display = 'none';
		document.getElementById("lastnamehint").style.display = 'block';
		ok = false;
	}

	if( "" == document.getElementById("aboutyou").value ){
		document.getElementById("aboutyou").style.borderColor = '#ff0000';
		document.getElementById("aboutyoucomment").style.display = 'none';
		document.getElementById("aboutyouhint").style.display = 'block';
		ok = false;
	}

	if( "" == document.getElementById("captcha").value ){
		document.getElementById("captcha").style.borderColor = '#ff0000';
		document.getElementById("captchacomment").style.display = 'none';
		document.getElementById("captchahint").style.display = 'block';
		ok = false;
	}
	
	if( ok ){
		return true;
	}else{
		return false;
	}

}

function fCheckRequiredFieldsForgotten(){

	var ok = true;

	if( "" == document.getElementById("email").value ){
		document.getElementById("email").style.borderColor = '#ff0000';
		document.getElementById("emailcomment").style.display = 'none';
		document.getElementById("emailhint").style.display = 'block';
		ok = false;
	}else{
		checkemail = checkEmailFormat( document.getElementById("email").value );
		if( !checkemail ){
			document.getElementById("email").style.borderColor = '#ff0000';
			document.getElementById("emailcomment").style.display = 'none';
			document.getElementById("emailhint2").style.display = 'block';
			ok = false;
		}
	}
	
	if( ok ){
		return true;
	}else{
		return false;
	}

}

function fCheckRequiredFieldsEmailNews(){

	var ok = true;

	if( "" == document.getElementById("name").value ){
		document.getElementById("name").style.borderColor = '#ff0000';
		document.getElementById("namecomment").style.display = 'none';
		document.getElementById("namehint").style.display = 'block';
		ok = false;
	}

	if( "" == document.getElementById("email").value ){
		document.getElementById("email").style.borderColor = '#ff0000';
		document.getElementById("emailcomment").style.display = 'none';
		document.getElementById("emailhint").style.display = 'block';
		ok = false;
	}else{
		checkemail = checkEmailFormat( document.getElementById("email").value );
		if( !checkemail ){
			document.getElementById("email").style.borderColor = '#ff0000';
			document.getElementById("emailcomment").style.display = 'none';
			document.getElementById("emailhint2").style.display = 'block';
			ok = false;
		}
	}
	
	if( "" == document.getElementById("captcha").value ){
		document.getElementById("captcha").style.borderColor = '#ff0000';
		document.getElementById("captchacomment").style.display = 'none';
		document.getElementById("captchahint").style.display = 'block';
		ok = false;
	}

	if( ok ){
		return true;
	}else{
		return false;
	}

}

function SelectAll( mark, formname ){
	for( i = 0; i < document.forms[formname].elements.length; i++ ){
		var item = document.forms[formname].elements[i];
		if( item.name == "item[]" ){
			item.checked = mark;
		}
	}
}

function showCommentForm( act ){

	if( "show" == act ){
		document.getElementById("fCommentSwitcher").style.display = 'none';
		document.getElementById("fCommentForm").style.display = 'block';
	}

}

function AddVote( id ){
	var vote = parseInt( document.getElementById("votesvalue"+id).value );
	vote = vote + 1;
	document.getElementById("votes"+id).innerHTML = vote;
	document.getElementById("vote"+id).innerHTML = '<img src="/_vote/' + id + '/" alt="" width="1" height="1" border="0">';
}
