﻿document.write('<script type="text/javascript" src="/js/checkPhone.js"></script>');
function validate_form() {
	theForm = document.contact_broker;
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,3}$/;
	/*
	if(theForm.user_name_and_family.value.length == 0) {
		alert('Моля, въведете Име и Фамилия!');
		theForm.user_name_and_family.focus();
		return (false);
	}

	if ((theForm.user_email.value.length == 0) || !reMail.exec(theForm.user_email.value)) {
		alert('Моля, въведете валиден e-mail адрес!');
		theForm.user_email.focus();
		return false;
	}
	*/
	
	 if (!checkPhone(1, 'user_phone')) {
		 	return false;
		 }         
	
	if(theForm.code.value.length == 0) {
		alert('Моля, въведете кода от изображението по-долу!');
		theForm.code.focus();
		return (false);
	}
	
	return true;
}

function validate_form_2() {
	theForm = document.pop_up_login_form;
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,3}$/;
	
	if(theForm.new_user.checked) {
		if((theForm.login_username.value.length == 0) || !reMail.exec(theForm.login_username.value)) {
			alert('Моля, въведете ВАЛИДЕН e-mail адрес!');
			theForm.login_username.focus();
			return (false);
		}
	}
	else {
		if(theForm.login_username.value.length == 0) {
			alert('Моля, въведете потребителско име или email!');
			theForm.login_username.focus();
			return (false);
		}
	}
	
	if(theForm.login_password.value.length == 0) {
		alert('Моля, въведете парола!');
		theForm.login_password.focus();
		return (false);
	}
	
	if(theForm.new_user.checked && theForm.login_password_rep.value.length == 0) {
		alert('Моля, повторете парола!');
		theForm.login_password_rep.focus();
		return (false);
	}
	
	if(theForm.new_user.checked && theForm.login_password.value != theForm.login_password_rep.value) {
		alert('Паролите не съвпадат!');
		theForm.login_password_rep.focus();
		return (false);
	}
	
	if(theForm.new_user.checked && theForm.login_name_family.value.length == 0) {
		alert('Моля, въведете Име и фамилия!');
		theForm.login_name_family.focus();
		return (false);
	}
	
	return true;
}

function validate_login_form_2() {
	theForm = document.pop_up_login_form_2;
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,3}$/;
	
	/*if((theForm.login_username_2.value.length == 0) || !reMail.exec(theForm.login_username_2.value)) {
		alert('Моля, въведете валиден e-mail адрес!');
		theForm.login_username_2.focus();
		return (false);
	}*/
	
	if(theForm.login_username_2.value.length == 0) {
		alert('Моля, въведете потребителско име или email!');
		theForm.login_username_2.focus();
		return (false);
	}
	
	if(theForm.login_password_2.value.length == 0) {
		alert('Моля, въведете парола!');
		theForm.login_password_2.focus();
		return (false);
	}
	
	return true;
}

function validate_friend_form() {
	theForm = document.friend_form;
	var reMail = /^[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\.[A-Za-z]{2,3}$/;
	
	if(theForm.friend_name.value.length == 0) {
		alert('Моля, въведете име на приятеля!');
		theForm.friend_name.focus();
		return (false);
	}
	
	if ((theForm.friend_email.value.length == 0) || !reMail.exec(theForm.friend_email.value)) {
		alert('Моля, въведете валиден e-mail адрес на приятеля!');
		theForm.friend_email.focus();
		return false;
	}
	
	if(theForm.fr_message.value.length == 0) {
		alert('Моля, въведете съобщение!');
		theForm.fr_message.focus();
		return (false);
	}
	
	return true;
}

/*
function login_or_register() {
	if(document.getElementById('new_user').checked == true) {
		if(isMSIE) document.getElementById('email_tr').style.display = 'inline';
		else document.getElementById('email_tr').style.display = 'table-row';
		document.getElementById('reg_button').style.display = 'inline';
		document.getElementById('log_button').style.display = 'none';
	}
	else {
		document.getElementById('email_tr').style.display   = 'none';
		document.getElementById('reg_button').style.display = 'none';
		document.getElementById('log_button').style.display = 'inline';
	}
}
*/





















