$(document).ready(function() {

	$("#fiberlink_form").submit(check_fiber_form);}
);
var errors_list = new Array();
errors_list["fio"] = "Introduceţi numele şi prenumele utilizatorului";
errors_list["district"] = "Indicaţi raionul oraşului";
errors_list["street_id"] = "Întroduceţi denumirea străzii";
errors_list["bloc_id"] = "Indicaţi Nr. blocului";
errors_list["apartament"] = "Indicaţi nr. apartament";
errors_list["phone_fix"] = "Nu este indicat nr. telefonului staţionar";
errors_list["phone_mob"] = "Lipseşte numarul telefonului mobil ";
errors_list["email"] = "Nu este indicată adresa poştei electronice";


var fiber_form_valid = true;
function check_fiber_form()
{
	
fiber_form_valid = true;
$("#fiberlink_form :input").each(chk_fld);
return fiber_form_valid;
}

function chk_fld()
{


if((this.name=="phone_fix" ||this.name=="phone_fax" || this.name=="phone_mob" || this.name=="phone_other")  && !isPhoneValid(this.value)){alert("Numărul de telefon este greşit"); this.focus(); fiber_form_valid=false; return false;};
if(this.name=="email" && jQuery.trim(this.value)!="" &&!isEmailValid(this.value)){alert("Adresa email este greşită"); this.focus(); fiber_form_valid=false; return false;};

if((this.name=="apartament" ||this.name=="scara" || this.name=="etaj")  && !isNumberValid(this.value)){alert("Valoare inadmisibilă a cîmpului"); this.focus(); fiber_form_valid=false; return false;};


if($("#jur").attr("checked") && this.name=="company_name") {if(jQuery.trim(this.value)=="") {alert("Nu este indicată denumirea companiei"); this.focus(); fiber_form_valid=false; return false;}}
	

if(!errors_list[this.name]) return;
if(!fiber_form_valid) return;

if(jQuery.trim(this.value)=="") {alert(errors_list[this.name]); this.focus(); fiber_form_valid=false; return false;}


}