var lang_msg = new Array();
lang_msg['sended_msg'] = 'Mesajul a fost trimis\r\nVa multumim';
lang_msg['no_position'] = 'Nu ati completat pozitia';
lang_msg['no_name'] = 'Nu ati completat numele';
lang_msg['no_surname'] = 'Nu ati completat prenumele';
lang_msg['no_address'] = 'Nu ati completat adresa';
lang_msg['no_email'] = 'Nu ati completat adresa de email';
lang_msg['invalid_email'] = 'Adresa de email nu este valida';
lang_msg['no_phone'] = 'Nu ati completat numarul de telefon';
lang_msg['no_english'] = 'Nu ati completat nivelul de cunostinta al limbii engleze';
lang_msg['invalid_phone'] = 'Numarul de telefon nu este valabil';
lang_msg['no_comments'] = 'Nu ati scris comentariile';
lang_msg['message_send'] = 'Mesajul a fost trimis cu succes';
lang_msg['message_not_send'] = 'Mesajul nu a fost trimis\r\nMai incercati o data';
lang_msg['server_error'] = 'Eroare de server';
lang_msg['no_transaction_type'] = 'Nu ati completat tipul tranzactiei';
lang_msg['no_imobil_type'] = 'Nu ati completat tipul imobilului';
lang_msg['no_city'] = 'Nu ati completat localitatea';
lang_msg['no_zone'] = 'Nu ati completat zona';
lang_msg['no_price'] = 'Nu ati completat pretul';


function setEng(){
	
lang_msg['sended_msg'] = 'Message has been sent\r\nThank you';
lang_msg['no_position'] = 'You have not filled the job field';
lang_msg['no_name'] = 'You have not filled the name field';
lang_msg['no_surname'] = 'You have not filled the surname field';
lang_msg['no_address'] = 'You have not filled the address field';
lang_msg['no_email'] = 'You have not filled the email field';
lang_msg['invalid_email'] = 'Email address you entered is not valid';
lang_msg['no_phone'] = 'You have not filled the phone number field';
lang_msg['no_english'] = 'You have not filled the job level of english language level field';
lang_msg['invalid_phone'] = 'Phone number is not valid';
lang_msg['no_comments'] = 'You have not entered comments';
lang_msg['message_send'] = 'Message has been succesfully sent';
lang_msg['message_not_send'] = 'Message has not been sent\r\nPlease try again';
lang_msg['server_error'] = 'Server error';
lang_msg['no_transaction_type'] = 'You have not chosen the transaction type';
lang_msg['no_imobil_type'] = 'You have not chosen the building type';
lang_msg['no_city'] = 'You have not filled the city field';
lang_msg['no_zone'] = 'You have not filled the area field';
lang_msg['no_price'] = 'You have not filled the price field';

}


function return_validate_cv_en(){
	setEng();
	return return_validate_cv();
}

function validate(email)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(reg.test(email) == false)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function news_validate_en()
{
	setEng();
	return news_validate();
}

function news_validate()
{
	if (!validate($('email').value))
	{
		alert(lang_msg['invalid_email']);
		return false;
	}
	
	document.my_form.submit();
}

// echivalentul functiei implode din PHP
function implode(chunk, array)
{
	var maxim = array.length;
	var response = '';
	for (I=0; I<maxim; I++)
	{
		response += array[I];
		if (I < (maxim-1))
		{
			response += chunk;
		}
	}
	return response;
}

function return_validate_cv()
{
	//var campuri = new Array('nume', 'telefon', 'email');
	
	var err = new Array();
	
	var I = 0;

	if ($('pozitie').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_position'];
		I++;
	}	
	if ($('nume').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_name'];
		I++;
	}
	if ($('prenume').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_surname'];
		I++;
	}
	if ($('adresa').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_address'];
		I++;
	}		
	if ($('telefon').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_phone'];
		I++;
	}
	if ($('email').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_email'];
		I++;
	}
	if ($('engleza').value.length < 1)
	{
		err[I] = ' '+lang_msg['no_english'];
		I++;
	}	
	else
	{
		if (!validate($('email').value))
		{
			err[I] = ' '+lang_msg['invalid_email'];
			I++;
		}
	}
	
	if (err.length > 0)
	{
		alert(implode("\r\n", err));
	}
	else
	{
		document.my_form.submit();
	}
}
