function clean_input(ktory, co){
	var x=document.getElementById(ktory).value;
	if(x==co)document.getElementById(ktory).value='';
}

function checkEmail(str) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) {
        return true;
    } else {
        return false;
    }
}

function validate_contact_form(){
	var isError = false;
	var numericExpression = /^[0-9]+$/;

	if($("#contact_form #name").val() == "" ){
        isError = true;
    }
	if($("#contact_form #surname").val() == "" ){
        isError = true;
    }
	if($("#contact_form #email").val() == "" ){
        isError = true;
    }
	else{
		if(!checkEmail($("#contact_form #email").val())){
			isError = true;
		}
	}
	if($("#contact_form #contact_message").val() == "" ){
        isError = true;
    }

	if(isError){
		alert("Wpisz poprawne wartości w obligatoryjnych polach.");
		return false;	
	}
	else{
		if($("#contact_form #phone").val() != "" && !$("#contact_form #phone").val().match(numericExpression)){
			alert("Numer telefonu może składać się wyłącznie z liczb.");
			return false;	
		}

		$("#text_value").val($("#email").val());

		return true;
	}
	

}