function check_profile()
{

	if(!document.getElementById('AccountAccountTypeId').value) {
		alert("Выберите тип покупателя");
		document.getElementById('AccountAccountTypeId').focus();
		return false;
	}
	

	
	

	
	
	if(document.getElementById('AccountAccountTypeId').value==1)
	{
		if(document.getElementById('AccountOwnershipTypeId').value==1) {
			alert("Выберите тип собственности");
			document.getElementById('AccountOwnershipTypeId').focus();
			return false;
		}
		//alert(array_perform);
		for (var i=0; i<array_perform.length;i++){
			if (array_perform[i]!=-1) {
				if (_trim($('Performer'+array_perform[i]+'Name').value)=='') {alert('Введите имя исполнителя.'); $('Performer'+array_perform[i]+'Name').focus(); return false;}
				UserEmailOrg = $('Performer'+array_perform[i]+'Email').value;
				if (!check_email2(UserEmailOrg)) {$('Performer'+array_perform[i]+'Email').focus(); alert("Введен некорректный email исполнителя\n\rПример: test@test.ru"); return false;}
			}
		}
		for (var i=0; i<array_perform.length;i++){
			if (array_perform[i]!=-1) {
				UserNameOrg = _trim($('Performer'+array_perform[i]+'Name').value);
				UserEmailOrg = $('Performer'+array_perform[i]+'Email').value;
				break;
			}
		}
		$('name_user').value=UserNameOrg;
		$('email_user').value=UserEmailOrg;
		if (_trim(document.getElementById('AccountCompany').value) == '') {document.getElementById('AccountCompany').focus(); alert('Введите назвавние организации'); return false;}
		if (_trim(document.getElementById('AccountInn').value) == '') {document.getElementById('AccountInn').focus(); alert('Введите ИНН'); return false;}
		/*if (document.getElementById('AccountKpp').value.length == 0) {document.getElementById('AccountKpp').focus(); alert('Введите КПП'); return false;}*/
		if (document.getElementById('AccountInn').value.length > 0)
		{
			 if (!/^\d+$/.test(document.getElementById('AccountInn').value)) {document.getElementById('AccountInn').focus(); alert('Вы не ввели корректный "ИНН"!'); return false;}
			 if(document.getElementById('AccountInn').value.length != 10) {document.getElementById('AccountInn').focus(); alert('ИНН должно состоять из 10 знаков'); return false;}
		}

		if (document.getElementById('AccountKpp').value.length > 0)
		{
			if (!/^\d+$/.test(document.getElementById('AccountKpp').value)) {document.getElementById('AccountKpp').focus(); alert('Вы ввели некорректное значение в поле "КПП"!'); return false;}
		 	if(document.getElementById('AccountKpp').value.length != 9) {document.getElementById('AccountKpp').focus(); alert('КПП должно состоять из 9 знаков'); return false;}
		}
		
		
	}

	
	if(document.getElementById('AccountAccountTypeId').value==3)
	{
		if (_trim(document.getElementById('UserSurname').value)=='') {document.getElementById('UserSurname').focus(); alert('Введите фамилию'); return false;}
		if (_trim(document.getElementById('UserFirstname').value)=='') {document.getElementById('UserFirstname').focus(); alert('Введите имя'); return false;}
		if (_trim(document.getElementById('UserMiddlename').value)=='') {document.getElementById('UserMiddlename').focus(); alert('Введите отчество'); return false;}
	
		document.getElementById('name_user').value=document.getElementById('UserSurname').value+" "+document.getElementById('UserFirstname').value+" "+document.getElementById('UserMiddlename').value;
	
		if (_trim(document.getElementById('AccountInn').value) == '') {document.getElementById('AccountInn').focus(); alert('Введите ИНН'); return false;}
		if (document.getElementById('AccountInn').value.length > 0)
		{
			 if (!/^\d+$/.test(document.getElementById('AccountInn').value)) {document.getElementById('AccountInn').focus(); alert('Вы не ввели корректный "ИНН"!'); return false;}
			 if(document.getElementById('AccountInn').value.length != 12) {document.getElementById('AccountInn').focus(); alert('ИНН должно состоять из 12 знаков'); return false;}
		}
		
		
		document.getElementById('email_user').value=document.getElementById('email_contact_fiz_input').value;
	
		
		var email = document.getElementById("email_contact_fiz_input").value;
		if (!check_email2(email)) {document.getElementById('email_contact_fiz_input').focus(); alert("Введен некорректный email контактного лица\n\rПример: test@test.ru"); return false;}
	}
	
	if(document.getElementById('AccountAccountTypeId').value==2)
	{
		if (_trim(document.getElementById('UserSurname').value)=='') {document.getElementById('UserSurname').focus(); alert('Введите фамилию'); return false;}
		if (_trim(document.getElementById('UserFirstname').value)=='') {document.getElementById('UserFirstname').focus(); alert('Введите имя'); return false;}
		
		document.getElementById('name_user').value=document.getElementById('UserSurname').value+" "+document.getElementById('UserFirstname').value+" "+document.getElementById('UserMiddlename').value;
		document.getElementById('email_user').value=document.getElementById('email_contact_fiz_input').value;
		var email = document.getElementById("email_contact_fiz_input").value;
		if (_trim(email)=='') {document.getElementById('email_contact_fiz_input').focus(); alert('Введите email контактного лица'); return false;}
		if (!check_email2(email)) {document.getElementById('email_contact_fiz_input').focus(); alert("Введен некорректный email контактного лица\n\rПример: test@test.ru"); return false;}
	}
	
	if(document.getElementById('AccountAddrZipcode').value.length > 0)
	{
		if(document.getElementById('AccountAddrZipcode').value.length != 6) {document.getElementById('AccountAddrZipcode').focus(); alert('Введите почтовый индекс'); return false;}
	}

	/*Проверка телефона*/
	if (document.getElementById('AccountPhoneCode').value.length > 0 || document.getElementById('AccountPhone').value.length > 0)
	{	
		if (document.getElementById('AccountPhoneCountryCode').value.length == 0 ) document.getElementById('AccountPhoneCountryCode').value = 7;
		if ((document.getElementById('AccountPhoneCode').value.length+document.getElementById('AccountPhone').value.length) != 10 ) {document.getElementById('AccountPhone').focus(); alert('Телефон и телефонный код должен состоять из 10 цифр!'); return false;}
		if (!/^\d+$/.test(document.getElementById('AccountPhoneCountryCode').value)) {document.getElementById('AccountPhoneCountryCode').focus(); alert('Телефонный код страны должен состоять только из цифр!'); return false;}
		if (!/^\d+$/.test(document.getElementById('AccountPhoneCode').value)) {document.getElementById('AccountPhoneCode').focus(); alert('Телефонный код должен состоять только из цифр!'); return false;}
		if (!/^\d+$/.test(document.getElementById('AccountPhone').value)) {document.getElementById('AccountPhone').focus(); alert('Телефон должен состоять только из цифр!'); return false;}
		//if (!/\d{1,3}-\d{2}-\d{2}$/.test(document.getElementById('AccountPhone').value)) {document.getElementById('AccountPhone').focus(); alert('Введите номер телефона в формате XXX-XX-XX или X-XX-XX'); return false;}
	}

	/*Проверка факса*/
	if (document.getElementById('AccountFaxCode').value.length > 0 || document.getElementById('AccountFax').value.length > 0)
	{	
		if (document.getElementById('AccountFaxCountryCode').value.length == 0 ) document.getElementById('AccountFaxCountryCode').value = 7;
		if ((document.getElementById('AccountFaxCode').value.length+document.getElementById('AccountFax').value.length) != 10 ) {document.getElementById('AccountFax').focus(); alert('Факс и код должен состоять из 10 цифр!'); return false;}
		if (!/^\d+$/.test(document.getElementById('AccountFaxCountryCode').value)) {document.getElementById('AccountFaxCountryCode').focus(); alert('Телефонный код страны должен состоять только из цифр!'); return false;}
		if (!/^\d+$/.test(document.getElementById('AccountFaxCode').value)) {document.getElementById('AccountFaxCode').focus(); alert('Телефонный код должен состоять только из цифр!'); return false;}
		if (!/^\d+$/.test(document.getElementById('AccountFax').value)) {document.getElementById('AccountFax').focus(); alert('Телефон должен состоять только из цифр!'); return false;}
		//if (!/\d{1,3}-\d{2}-\d{2}$/.test(document.getElementById('AccountPhone').value)) {document.getElementById('AccountPhone').focus(); alert('Введите номер телефона в формате XXX-XX-XX или X-XX-XX'); return false;}
	}

document.getElementById("AccountTypeContact_").value="";
if (document.getElementById("AccountTypeContact1").checked) {
	/*Проверка мобильный телелфон*/
	var m = "+"+document.getElementById("AccountMobileCountryCode").value+document.getElementById("AccountMobileCode").value+document.getElementById("AccountMobile").value;
	if (!check_mobile(m)) {document.getElementById('AccountMobile').focus(); alert("Введен некорректный номер мобильного телефона\n\rПример: + 7 950 1111111"); return false;}
	document.getElementById("AccountTypeContact_").value+="1";
}

if (document.getElementById("AccountTypeContact2").checked) {
	/*Проверка email*/
	var email = document.getElementById("AccountEmail").value;
	if (!check_email2(email)) {document.getElementById('AccountEmail').focus(); alert("Введен некорректный email\n\rПример: test@test.ru"); return false;}
	document.getElementById("AccountTypeContact_").value+="2";
}

if (document.getElementById("AccountTypeContact3").checked) {
	/*Проверка телефон*/
	if (document.getElementById('AccountPhoneCountryCodeContact').value.length == 0 ) document.getElementById('AccountPhoneCountryCodeContact').value = 7;
	if ((document.getElementById('AccountPhoneCodeContact').value.length+document.getElementById('AccountPhoneContact').value.length) != 10 ) {document.getElementById('AccountPhoneContact').focus(); alert('Телефон и телефонный код должен состоять из 10 цифр!'); return false;}
	if (!/^\d+$/.test(document.getElementById('AccountPhoneCountryCodeContact').value)) {document.getElementById('AccountPhoneCountryCodeContact').focus(); alert('Телефонный код страны должен состоять только из цифр!'); return false;}
	if (!/^\d+$/.test(document.getElementById('AccountPhoneCodeContact').value)) {document.getElementById('AccountPhoneCodeContact').focus(); alert('Телефонный код должен состоять только из цифр!'); return false;}
	if (!/^\d+$/.test(document.getElementById('AccountPhoneContact').value)) {document.getElementById('AccountPhoneContact').focus(); alert('Телефон должен состоять только из цифр!'); return false;}	
	document.getElementById("AccountTypeContact_").value+="3";
}

if (document.getElementById("AccountTypeContact4").checked) {
	document.getElementById("AccountTypeContact_").value="4";
}

/*switch (document.getElementById("AccountTypeContact_").value){
case "0":
	//Проверка мобильный телелфон
	var m = "+"+document.getElementById("AccountMobileCountryCode").value+document.getElementById("AccountMobileCode").value+document.getElementById("AccountMobile").value;
	if (!check_mobile(m)) {document.getElementById('AccountMobile').focus(); alert("Введен некорректный номер мобильного телефона\n\rПример: + 7 950 1111111"); return false;}
	document.getElementById("AccountTypeContact_").value="1";
	break;
case "1":
	//Проверка мобильный телелфон
	var m = "+"+document.getElementById("AccountMobileCountryCode").value+document.getElementById("AccountMobileCode").value+document.getElementById("AccountMobile").value;
	if (!check_mobile(m)) {document.getElementById('AccountMobile').focus(); alert("Введен некорректный номер мобильного телефона\n\rПример: + 7 950 1111111"); return false;}
	break;
case "2":
	var email = document.getElementById("AccountEmail").value;
	if (!check_email2(email)) {document.getElementById('AccountEmail').focus(); alert("Введен некорректный email\n\rПример: test@test.ru"); return false;}
	break;
case "3":
	if (document.getElementById('AccountPhoneCountryCodeContact').value.length == 0 ) document.getElementById('AccountPhoneCountryCodeContact').value = 7;
	if (!/^\d+$/.test(document.getElementById('AccountPhoneCountryCodeContact').value)) {document.getElementById('AccountPhoneCountryCodeContact').focus(); alert('Телефонный код страны должен состоять только из цифр!'); return false;}
	if (!/^\d+$/.test(document.getElementById('AccountPhoneCodeContact').value)) {document.getElementById('AccountPhoneCodeContact').focus(); alert('Телефонный код должен состоять только из цифр!'); return false;}
	if (!/^\d+$/.test(document.getElementById('AccountPhoneContact').value)) {document.getElementById('AccountPhoneContact').focus(); alert('Телефон должен состоять только из цифр!'); return false;}
	if ((document.getElementById('AccountPhoneCodeContact').value.length+document.getElementById('AccountPhoneContact').value.length) != 10 ) {document.getElementById('AccountPhoneContact').focus(); alert('Телефон и телефонный код должен состоять из 10 цифр!'); return false;}
}*/

  return true;
}

function check_profile_order(){
if ($('account_id').value=='') {alert('Не выбран контрагент.');  return false;}
if ($('OrderShippingMethodId').value=='') {alert('Не выбран способ доставки.');  return false;}
if ($('OrderPaymentMethodId').value=='') {alert('Не выбран способ оплаты.');  return false;}
if (this_type==1){
	if ($('OrderPerformerId')){
		if ($('OrderPerformerId').value==''){alert('Не выбран исполнитель.');  return false;}
	} else {
		if ($('OrderPerformerIdSelect')){
			if ($('OrderPerformerIdSelect').options[$('OrderPerformerIdSelect').selectedIndex].text==''){alert('Не выбран исполнитель.');  return false;}
		}
	}
}
if (_trim($('uploaded_order_file').value)==''&&_trim($('OrderContent').value)==''){
	alert('Выберите файл или заполните контент заявки в текстовом виде.');  return false;	
}
}

function toggleAccountType(value)
{
//alert(sh_met);
try{
        account_type = value;
		toggleShippingMethod(sh_met);
}catch(e){
      
}


  var b = getBrowserInfo();

  //организация
  if (value==1){
	//Основная информация
	//скрыть
	$('UserSurname').disabled = true; $('surname').style.display = "none";
	$('UserFirstname').disabled = true; $('firstname').style.display = "none";
	$('UserMiddlename').disabled = true; $('middlename').style.display = "none";
	$('email_contact_fiz_input').disabled = true; $('email_contact_fiz').style.display = "none";
	//показать
	$('AccountCompany').disabled = false; $('company').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('AccountInn').disabled = false; $('inn').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('AccountInn').maxLength = 10;
	$('AccountKpp').disabled = false;  $('kpp').style.display = (b.type+""+b.version=="IE6")?"block":"table-cell";
	$('kpp_label').style.display = (b.type+""+b.version=="IE6")?"block":"table-cell";
	$('AccountOwnershipTypeId').disabled = false; $('ownership_type').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('performers_main_div').style.display = "block";
	//Контактная информация
	contact_info_inputs=$('account_contact_info_div').getElementsByTagName("input");
	for (var i=0; i<contact_info_inputs.length; i++){
		contact_info_inputs[i].disabled = true;
	}
	$('account_contact_info_div').style.display = "none";
  }
  //Индивидуальный предприниматель
   if (value==3){
	//Основная информация
	//скрыть
	$('AccountCompany').disabled = true;  $('company').style.display = "none";
	$('AccountOwnershipTypeId').disabled = true;  $('ownership_type').style.display = "none";
	$('AccountKpp').disabled = true; $('kpp').style.display = "none";
	$('kpp_label').style.display = "none";
	$('performers_main_div').style.display = "none";
	//показать
	$('UserSurname').disabled = false; $('surname').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('UserFirstname').disabled = false; $('firstname').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('UserMiddlename').disabled = false; $('middlename').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('email_contact_fiz_input').disabled = false; $('email_contact_fiz').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('AccountInn').disabled = false; $('inn').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('AccountInn').maxLength = 12;
	$('red_mark').style.visibility = "visible";
	//Контактная информация
	contact_info_inputs=$('account_contact_info_div').getElementsByTagName("input");
	for (var i=0; i<contact_info_inputs.length; i++){
		contact_info_inputs[i].disabled = false;
	}
	$('account_contact_info_div').style.display = "block";
  }
  //Частное лицо
   if (value==2){
	//Основная информация
	//скрыть
	$('AccountCompany').disabled = true;  $('company').style.display = "none";
	$('AccountOwnershipTypeId').disabled = true;  $('ownership_type').style.display = "none";
	$('AccountInn').disabled = true;  $('inn').style.display = "none";
	$('AccountKpp').disabled = true; $('kpp').style.display = "none";
	$('kpp_label').style.display = "none";
	$('performers_main_div').style.display = "none";
	//показать
	$('UserSurname').disabled = false; $('surname').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('UserFirstname').disabled = false; $('firstname').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('UserMiddlename').disabled = false; $('middlename').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('email_contact_fiz_input').disabled = false; $('email_contact_fiz').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	$('red_mark').style.visibility = "hidden";
	//Контактная информация
	contact_info_inputs=$('account_contact_info_div').getElementsByTagName("input");
	for (var i=0; i<contact_info_inputs.length; i++){
		contact_info_inputs[i].disabled = false;
	}
	$('account_contact_info_div').style.display = "block";
  }
  
  document.getElementById('AccountAccountTypeId').value=value;
}
var isCheckPhoneCheckOut = false;
var SM_PM_fiz_ip = new Array(
			[1,0,1,0,1,1,0,0,0],
			[0,1,1,0,1,1,0,0,0],
			[1,1,1,0,1,1,0,0,0],
			[1,1,1,0,1,1,0,0,0],
			[1,1,1,0,1,1,0,1,0],
			[0,0,0,0,0,0,0,0,0],
			[1,1,1,0,1,1,0,1,0],
			[1,0,1,0,1,1,0,1,0]
			);
			
var SM_PM_org = new Array(
			[1,0,0,0,0,0,0,0,1],
			[0,1,0,0,0,0,0,0,1],
			[1,1,0,0,0,0,0,0,1],
			[1,1,0,0,0,0,0,0,1],
			[1,1,0,0,0,0,0,0,1],
			[0,0,0,0,0,0,0,0,0],
			[1,1,0,0,0,0,0,0,1],
			[1,0,0,0,1,1,0,1,1]
			);
function toggleShippingMethod(sm){

/*отобразить контактный телефон*/
if (sm==3||sm==4){
	if (document.getElementById('phone_shipping')){
		var b = getBrowserInfo();
		document.getElementById('phone_shipping').style.display = (b.type+""+b.version=="IE6")?"block":"table-row";
	}
	isCheckPhoneCheckOut = true;	
} else {
	isCheckPhoneCheckOut = false;
	if (document.getElementById('phone_shipping')){
		document.getElementById('phone_shipping').style.display = "none";
	}
}
/*******************************/

first = (sm==-1)?true:false;
sh_met = sm;
sm = (first)?3:sm;

		
//var SM_adr = new Array(0,0,1,1,1,1);
	
if (account_type==1) {
//убираем наложный платеж
document.getElementById('shipping_method_5').style.display="none";
if (document.getElementById('shipping_method_5').getElementsByTagName('input')[0].checked){
	document.getElementById('shipping_method_5').getElementsByTagName('input')[0].checked=false;
	sh_met = -1;
	sm = 3;
	first=true;
}
	for (i=0;i<9; i++){
		d = document.getElementById('payment_method_'+i);
		if (SM_PM_org[sm][i]==0) {
				d.style.display="none";
				d.getElementsByTagName('input')[0].checked=false;
				d.getElementsByTagName('input')[0].disabled=(first)?true:false;
			}
		else 
			d.style.display="block";
			d.getElementsByTagName('input')[0].disabled=(first)?true:false;
	}
}
else {
//document.getElementById('shipping_method_5').style.display="block";
//убираем наложный платеж
document.getElementById('shipping_method_5').style.display="none";
if (document.getElementById('shipping_method_5').getElementsByTagName('input')[0].checked){
	document.getElementById('shipping_method_5').getElementsByTagName('input')[0].checked=false;
	sh_met = -1;
	sm = 3;
	first=true;
}
	for (i=0;i<9; i++){
		d = document.getElementById('payment_method_'+i);
		if (SM_PM_fiz_ip[sm][i]==0) {
				d.style.display="none";
				d.getElementsByTagName('input')[0].checked=false;
				d.getElementsByTagName('input')[0].disabled=(first)?true:false;
			}
		else 
			d.style.display="block";
			d.getElementsByTagName('input')[0].disabled=(first)?true:false;
	}
}

}

function toggleStreet()
{
  if (document.getElementById('AccountStreetManual').checked)
  {
    clearStreet();
    document.getElementById('AccountAddrStreetText').disabled = false;
	document.getElementById("AccountAddrStreetText").parentNode.className="nth-corners_input_white";
    //document.getElementById('AccountAddrStreetText').style.background = '#FFFFFF';
    //document.getElementById('AccountAddrStreetId').style.background = '#CCCCCC';
    document.getElementById('AccountAddrStreetId').disabled = true;
    document.getElementById('AccountAddrStreetText').focus();
  }
  else
  {
    document.getElementById('AccountAddrStreetText').value = '';
    document.getElementById('AccountAddrStreetText').disabled = true;
	document.getElementById("AccountAddrStreetText").parentNode.className="nth-corners_input_white_disabled";
    //document.getElementById('AccountAddrStreetText').style.background = '#CCCCCC';
    //document.getElementById('AccountAddrStreetId').style.background = '#FFFFFF';
    document.getElementById('AccountAddrStreetId').disabled = false;
  }
}

function openwnd( url, target, param, wnd , default_param)
{
  default_param = 'width=300,height=500,toolbar=0,status=0,scrollbars=yes,top=20,left=20,screenY=20,screenX=20'
  param = (param) ? ','+param : '';
  param =  default_param + param;
  wnd=open( url, target, param );
  wnd.focus();
  return wnd;
}

function clearRegion()
{
  document.getElementById('AccountAddrRegionId').value = '';
  document.getElementById('AddrRegionName').value = '';
  clearCity();
  clearCountry();
  clearStreet();
  return false;
}

function clearCity() {
  document.getElementById('AccountAddrCityId').value = '';
  document.getElementById('AddrCityName').value = '';
  clearStreet();
  return false;
}

function clearCountry() {
  document.getElementById('AccountAddrCountryId').value = '';
  document.getElementById('AddrCountryName').value = '';
  clearStreet();
  return false;
}

function clearStreet() {
	if(document.getElementById('AccountAddrStreetId')) {
		document.getElementById('AccountAddrStreetId').value = '';
	}
	if(document.getElementById('AccountAddrStreetText')) {
  		document.getElementById('AccountAddrStreetText').value = '';
  	}
  	return false;
}

function showRegions()
{
  clearCity();
  clearCountry();
  clearStreet();

  openwnd('/addresses/regions/');

  return false;
}

function showCity()
{
  clearCountry();
  clearStreet();

  if (document.getElementById('AccountAddrRegionId').value > 0)
  {
    if (document.getElementById('AccountAddrCountryId').value > 0)  alert('Вы не можете выбрать город, так как у Вас выбран населённый пункт!');
    else openwnd('/addresses/cities/'+document.getElementById('AccountAddrRegionId').value);
  }
  else { alert('Необходимо выбрать регион!'); }
  return false;
}

function showCountry()
{
  clearCity();
  clearStreet();
  if (document.getElementById('AccountAddrRegionId').value > 0)
  {
    if (document.getElementById('AccountAddrCityId').value > 0) alert('Вы не можете выбрать населённый пункт, так как у Вас выбран город!');
    else openwnd('/addresses/countries/'+document.getElementById('AccountAddrRegionId').value);
  }
  else { alert('Необходимо выбрать регион!'); }
  return false;
}

function showStreet()
{
  if (document.getElementById('toggleStr').checked)
  {
    alert("Необходимо снять галочку ввода улицы вручную!");
    return false;
  }
  else
  {
    if (document.getElementById('AccountAddrRegionId').value > 0)
    {
      if (document.getElementById('AccountAddrCityId').value > 0 || document.getElementById('AccountAddrCountryId').value > 0)
          openwnd('/addresses/streets/'+document.getElementById('AccountAddrCityId').value + '/'+ document.getElementById('AccountAddrCountryId').value);
    }
    else alert('Необходимо выбрать регион!');
  }
  return false;
}

function setRegion(id, title) {
  document.getElementById('AccountAddrRegionId').value = id;
  document.getElementById('AddrRegionName').value = title;
}

function setCity(id, title) {
  document.getElementById('AccountAddrCityId').value = id;
  document.getElementById('AddrCityName').value = title;
}

function setCountry(id, title) {
  document.getElementById('AccountAddrCountryId').value = id;
  document.getElementById('AddrCountryName').value = title;
}

function setStreet(id, title) {
  document.getElementById('AccountAddrStreetId').value = id;
  document.getElementById('AddrStreetName').value = title;
}

function checkAccountForm()
{
  if (document.getElementById('account_type_toggle').value == 1 && document.getElementById('AccountCompany').value.length == 0) {document.getElementById('AccountCompany').focus(); alert('Вы не заполнили обязательное поле "Организация"!'); return false;}

  if (document.getElementById('AccountLastName').value.length == 0) {document.getElementById('AccountLastName').focus(); alert('Вы не заполнили обязательное поле "Фамилия"!'); return false;}
  if (document.getElementById('AccountFirstName').value.length == 0) {document.getElementById('AccountFirstName').focus(); alert('Вы не заполнили обязательное поле "Имя"!'); return false;}
  if (document.getElementById('AccountAddrRegionId').value.length == 0) {document.getElementById('AddrRegionName').focus(); alert('Вы не заполнили обязательное поле "Регион"!'); return false;}
  if (document.getElementById('AccountAddrCityId').value.length == 0
   && document.getElementById('AccountAddrCountryId').value.length == 0
   && document.getElementById('AccountAddrRegionId').value != 45
   && document.getElementById('AccountAddrRegionId').value != 62)
  {
    document.getElementById('AccountAddrCityId').focus();
    alert('Необходимо отметить Город либо населенный Пункт!');
    return false;
  }

  //проверка пароля и email
  if (document.getElementById('AccountEmail').value.length == 0) {document.getElementById('AccountEmail').focus(); alert('Вы не заполнили обязательное поле "Email"!'); return false;}
  if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(document.getElementById('AccountEmail').value)) {document.getElementById('AccountEmail').focus(); alert('Вы не ввели корректный "Email"!'); return false;}
  if (document.getElementById('AccountPassword').value.length == 0)   {document.getElementById('AccountPassword').focus(); alert('Вы не заполнили обязательное поле "Пароль"!'); return false;}
  if (document.getElementById('AccountPassword2').value.length == 0)  {document.getElementById('AccountPassword2').focus(); alert('Вы не заполнили обязательное поле "Подтверждение пароля"!'); return false;}
  if (document.getElementById('AccountPassword').value != document.getElementById('AccountPassword2').value) {document.getElementById('AccountPassword2').value=''; document.getElementById('AccountPassword2').focus(); alert('Пароль и подтверждение пароля не совпадают!'); return false;}

  return true;
}

function checkProfileForm()
{
  if (document.getElementById('account_type_toggle').value == 1 && document.getElementById('AccountCompany').value.length == 0) {document.getElementById('AccountCompany').focus(); alert('Вы не заполнили обязательное поле "Организация"!'); return false;}
  if (document.getElementById('AccountLastName').value.length == 0) {document.getElementById('AccountLastName').focus(); alert('Вы не заполнили обязательное поле "Фамилия"!'); return false;}
  if (document.getElementById('AccountFirstName').value.length == 0) {document.getElementById('AccountFirstName').focus(); alert('Вы не заполнили обязательное поле "Имя"!'); return false;}
  if (document.getElementById('AccountAddrRegionId').value.length == 0) {document.getElementById('AddrRegionName').focus(); alert('Вы не заполнили обязательное поле "Регион"!'); return false;}
  if (document.getElementById('AccountAddrCityId').value.length == 0
   && document.getElementById('AccountAddrCountryId').value.length == 0
   && document.getElementById('AccountAddrRegionId').value != 45
   && document.getElementById('AccountAddrRegionId').value != 62)
  {
    document.getElementById('AccountAddrCityId').focus();
    alert('Необходимо отметить Город либо населенный Пункт!');
    return false;
  }

  return true;
}

function open_window_pos(a){
myWindow=window.open(a.href,'','width=800,height=575,top=10;left=10; resizable=yes;');
myWindow.focus();
return false;
}

