var g=1;
var re1=0;
var re2=0;
var re3=0;
var re4=0;
var re5=0;
var re6=0;
var re9=1;
var re7=0;
var re8=0;
var re10=0;
var ban=0;


function load_banners(){
	document.getElementById("ban1").style.height = "92px";
	document.getElementById("ban1").src = "http://www.kanzas.ua/baners/1.php";

	document.getElementById("ban2").style.height = "62px";
	document.getElementById("ban2").src = "http://www.kanzas.ua/baners/2.php";
	
	document.getElementById("ban3").style.height = "352px";
	document.getElementById("ban3").src = "http://www.kanzas.ua/baners/3.php";
}


function edit_user(){
	document.forms["reg_form"].submit();
}




function change_pass_form_submit(){
	
	if(re2==1){
	document.forms["reg_form"].submit();

}}




function regi_form_submit(){
	
	if((re2==1) && (re5==1)){
	document.forms["reg_form"].submit();

}}


function change_user_pass(){
	
	if((re2==1) && (re3==1) && (re4==1) && (re5==1)){
	document.forms["reg_form"].submit();

}}


function change_subscribe(){
	
	if(re5==1){
	document.forms["reg_form"].submit();

}}




function show_logo(){
	url=document.getElementById("file").value;
	alert(url);
}

function show_informer(){
	//alert();
	//document.getElementById("addthis").style.display='none';
	var type;
	var view;
	if(document.getElementById("type_1").checked == true){type=1;}
	if(document.getElementById("type_2").checked == true){type=2;}
	if(document.getElementById("type_3").checked == true){type=3;}


	if(document.getElementById("view_1").checked == true){view=1;}else{view=2;}
	
	//var view=document.getElementById("view_1").value;
	var title_size=document.getElementById("title_size").value;
	var title_color=document.getElementById("title_color").value;
	var border_type=document.getElementById("border_type").value;
	var border_width=document.getElementById("border_width").value;
	var border_color=document.getElementById("border_color").value;
	
	
		
		var url='http://www.kanzas.ua/informer.js?type='+type+'&view='+view+'&border_type='+border_type+'&border_width='+border_width+'&border_color='+border_color+'&title_color='+title_color+'&title_size='+title_size; 
	
		document.getElementById("informer_code").value='<script src="'+url+'" type="text/javascript" language=javascript></script>';
		
	//informer = document.getElementById('informer'); 
	document.getElementById("informer").src = 'http://www.kanzas.ua/informer_view.php?type='+type+'&view='+view+'&border_type='+border_type+'&border_width='+border_width+'&border_color='+border_color+'&title_color='+title_color+'&title_size='+title_size; 
	// iframe.reload(true);
	
	
	//alert(type);
}


function ava(n) {

	document.getElementById("ava_1").style.border = '2px solid #ffffff';
	document.getElementById("ava_2").style.border = '2px solid #ffffff';
	document.getElementById("ava_3").style.border = '2px solid #ffffff';
	document.getElementById("ava_4").style.border = '2px solid #ffffff';
	document.getElementById("ava_5").style.border = '2px solid #ffffff';
	document.getElementById("ava_6").style.border = '2px solid #ffffff';
	document.getElementById("ava_7").style.border = '2px solid #ffffff';
	document.getElementById("ava_8").style.border = '2px solid #ffffff';
	document.getElementById("ava_9").style.border = '2px solid #ffffff';
	document.getElementById("ava_10").style.border = '2px solid #ffffff';
	
	document.getElementById("ava_"+n).style.border = '2px solid #990000';
	
	document.getElementById("ava_num").value=n;
	
    
}
function hide_imgset() {
	
	document.getElementById("imgset").style.display='none';
}


function change_ava() {
	document.forms["avatar"].submit();

}

function answer101() {
    if (req101.readyState == 4) {
        if (req101.status == 200) {
        	req101_ressults = req101.responseText;
            if(req101_ressults==1){
            	document.getElementById("addthis").style.display='none';
            	document.getElementById("addedthis").style.display='block';}
            
        } else {
           //alert(req101.statusText);
        }
    }
	
	//alert(1);
    
}


function add_article(cat, link){
	
	document.getElementById("addthis").style.display='none';
	document.getElementById("addedthis").style.display='block';

	
	url101='http://www.kanzas.ua/components/login/add_article.php?cat='+cat+'&link='+link;
	
	//alert(url101);
    if (window.XMLHttpRequest) {
        req101 = new XMLHttpRequest();
        req101.onreadystatechange = function() {res101=answer101();};
        req101.open("GET", url101, true);
        req101.send(null);
    } else if (window.ActiveXObject) {
        req101 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req101) {
            req101.onreadystatechange = function() {res101=answer101();};
            req101.open("GET", url101, true);
            req101.send();
        }
    }
	
}




function add_property_favourite(link){
	
	document.getElementById("addthis").style.display='none';
	document.getElementById("addedthis").style.display='block';

	//alert(link);
	url101='http://www.kanzas.ua/components/login/add_property.php?link='+link;
	
	//alert(url101);
    if (window.XMLHttpRequest) {
        req101 = new XMLHttpRequest();
        req101.onreadystatechange = function() {res101=answer101();};
        req101.open("GET", url101, true);
        req101.send(null);
    } else if (window.ActiveXObject) {
        req101 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req101) {
            req101.onreadystatechange = function() {res101=answer101();};
            req101.open("GET", url101, true);
            req101.send();
        }
    }
	
}







function room_tab(tab){
	if(tab==1){	document.getElementById("tab_1").style.display='block';
				document.getElementById("tab_2").style.display='none';
				document.getElementById("tab_3").style.display='none';
				document.getElementById("tab_4").style.display='none';
				document.getElementById("tab_5").style.display='none';
	}
	
	if(tab==2){	document.getElementById("tab_1").style.display='none';
				document.getElementById("tab_2").style.display='block';
				document.getElementById("tab_3").style.display='none';
				document.getElementById("tab_4").style.display='none';
				document.getElementById("tab_5").style.display='none';
	}
	
	if(tab==3){	document.getElementById("tab_1").style.display='none';
				document.getElementById("tab_2").style.display='none';
				document.getElementById("tab_3").style.display='block';
				document.getElementById("tab_4").style.display='none';
				document.getElementById("tab_5").style.display='none';
	}
	
	if(tab==4){	document.getElementById("tab_1").style.display='none';
				document.getElementById("tab_2").style.display='none';
				document.getElementById("tab_3").style.display='none';
				document.getElementById("tab_4").style.display='block';
				document.getElementById("tab_5").style.display='none';
	}
	
	if(tab==5){	document.getElementById("tab_1").style.display='none';
				document.getElementById("tab_2").style.display='none';
				document.getElementById("tab_3").style.display='none';
				document.getElementById("tab_4").style.display='none';
				document.getElementById("tab_5").style.display='block';
}
	
	
	url100='http://www.kanzas.ua/components/login/tab.php?tab='+tab;
    if (window.XMLHttpRequest) {
        req100 = new XMLHttpRequest();
        req100.onreadystatechange = function() {};
        req100.open("GET", url100, true);
        req100.send(null);
    } else if (window.ActiveXObject) {
        req100 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req100) {
            req100.onreadystatechange = function() {};
            req100.open("GET", url100, true);
            req100.send();
        }
    }
	
}

function search_articles(page_cat){
	//alert(document.forms["search_box"].search.value);
	search=document.getElementById("search").value;
	if(search.length>3 && search.length<30){
		window.location = "http://www.kanzas.ua/"+page_cat+"/search/-1/"+search+"/";
	}
}

function search_articles2(page_cat){
	//alert(document.forms["search_box"].search.value);
	search=document.getElementById("search2").value;
	if(search.length>3 && search.length<30){
		window.location = "http://www.kanzas.ua/"+page_cat+"/search/-1/"+search+"/";
	}
}

function search_articles3(page_cat){
	//alert(document.forms["search_box"].search.value);
	search=document.getElementById("search3").value;
	if(search.length>3 && search.length<30){
		window.location = "http://www.kanzas.ua/"+page_cat+"/search/-1/"+search+"/";
	}
}

function poolchange(){
	ch=document.chose_pool.pool.value;
	window.location = "http://www.kanzas.ua/service_polls/pool/"+ch+"/";
	//alert(ch);
}

function upload_photo(){
	document.forms["add_img_form"].submit();
}

function reg_form_submit(){
	if((re1==1) && (re2==1) && (re3==1) && (re5==1) && (re6==1)&& (re7==1)&&  (re9==1)){
	document.forms["reg_form"].submit();
}else{

	
	if(re9!=1){document.getElementById('registration_error').innerHTML='Вам необходимо ознакомиться и согласиться с правилами поведения на портале.';
	document.getElementById('registration_error').style.visibility='visible';}
			
	if(re5!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, введите проверочные символы расположенные выше в поле напротив.';
	document.getElementById('registration_error').style.visibility='visible';}
	
	if(re6!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, введите ваш контактный номер телефона.';
	document.getElementById('registration_error').style.visibility='visible';}
	
	
	if(re8!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, повторите ввод вашего пароля.';
	document.getElementById('registration_error').style.visibility='visible';}
	
	if(re7!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, введите ваш пароль.';
	document.getElementById('registration_error').style.visibility='visible';}
	
		
	if(re1!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, введите вашу фамилию.';
	document.getElementById('registration_error').style.visibility='visible';}
	
	if(re3!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, введите ваше имя.';
	document.getElementById('registration_error').style.visibility='visible';}
	
	if(re2!=1){document.getElementById('registration_error').innerHTML='Пожалуйста, введите ваш e-mail.';
	document.getElementById('registration_error').style.visibility='visible';}
	
}
	
}


function form_submit(){
	
	document.forms["reg_form"].submit();
}

function add_property_form_submit(){
	//alert('re5='+re5);
	if(re5==1){
	document.forms["add_property_form"].submit();
}}

function subscribe_form_submit(){
	//if(re8==1){
	
	mail=document.subscribe_form.mail.value;
	name=document.subscribe_form.name.value;
		window.location = "http://www.kanzas.ua/service_mailer/"+mail+"/"+name+"/1";
		//document.forms["subscribe_form"].submit()
		

	
}



function subscribe2_form_submit(){
	if((re8==1)&& (re5==1)){
	document.forms["reg_form"].submit();
}}

function change_form_submit(){
	if((re7==1)&& (re5==1)){
	document.forms["reg_form"].submit();
}}

function change_me_form_submit(){
	if((re3==1)&&(re4==1)&& (re5==1)){
		document.forms["reg_form"].submit();
	}}

function change_me_form_submit2(){
	if((re7==1)&&(re7==1)){
		document.forms["reg_form"].submit();
	}}

var active_property_tab=1;
function change_tab_1(i){
	if(active_property_tab==i){
		if(i==1){window.open("http://www.kanzas.ua/nedvizhimost/prodazha-kvartir/", "_self");}
		if(i==2){window.open("http://www.kanzas.ua/nedvizhimost/arenda-kvartir/", "_self");}
	}
	else{
		if (i==1){
			document.getElementById("sell_box").style.display = 'block';
			document.getElementById("rent_box").style.display = 'none';
			
			document.getElementById("sell_btn").style.background = 'url(/sprites/middle.gif) 0 -220px';
			document.getElementById("rent_btn").style.background = 'url(/sprites/middle.gif) 0 -296px';
		}
		if (i==2){
			document.getElementById("sell_box").style.display = 'none';
			document.getElementById("rent_box").style.display = 'block';
			
			document.getElementById("sell_btn").style.background = 'url(/sprites/middle.gif) 0 -296px';
			document.getElementById("rent_btn").style.background = 'url(/sprites/middle.gif) 0 -220px';
		}
	}
	active_property_tab=i;
	
}

var active_news_tab=1;

function change_tab_2(i){
	
	if(active_news_tab==i){
		if(i==1){window.open("http://www.kanzas.ua/news/", "_self");}
		if(i==2){window.open("http://www.kanzas.ua/articles/", "_self");}
		if(i==3){window.open("http://www.kanzas.ua/overview/", "_self");}
		
	}
	else{
		for (var k=1; k<5; k++)
		{ if (i==k) { disp='block'; bP='0 -220px' }
		  else { disp='none'; bP='0 -296px' }
		  document.getElementById("block_"+k).style.display=disp;
		  document.getElementById("article_tab_"+k).style.backgroundPosition = bP;
		}
	}
	active_news_tab=i;
}

var active_news_tab2=1;
function change_tab_3(i){
	
	if(active_news_tab2==i){
		if(i==1){window.open("http://www.kanzas.ua/news/", "_self");}
		if(i==2){window.open("http://www.kanzas.ua/articles/", "_self");}
		if(i==3){window.open("http://www.kanzas.ua/overview/", "_self");}
		
	}
	else{
	
		if (i==1){
			document.getElementById("news_box").style.display='block';
			document.getElementById("articles_box").style.display='none';
			document.getElementById("views_box").style.display='none';
			document.getElementById("news_btn").style.background = 'url(/images/tab_btn_3_active.gif)';
			document.getElementById("articles_btn").style.background = 'url(/images/tab_btn_3_center.gif)';
			document.getElementById("views_btn").style.background = 'url(/images/tab_btn_3_right.gif)';
		}
			if (i==2){
			document.getElementById("news_box").style.display='none';
			document.getElementById("articles_box").style.display='block';
			document.getElementById("views_box").style.display='none';
			document.getElementById("news_btn").style.background = 'url(/images/tab_btn_3_left.gif)';
			document.getElementById("articles_btn").style.background = 'url(/images/tab_btn_3_active.gif)';
			document.getElementById("views_btn").style.background = 'url(/images/tab_btn_3_right.gif)';
		}	if (i==3){
			document.getElementById("news_box").style.display='none';
			document.getElementById("articles_box").style.display='none';
			document.getElementById("views_box").style.display='block';
			document.getElementById("news_btn").style.background = 'url(/images/tab_btn_3_left.gif)';
			document.getElementById("articles_btn").style.background = 'url(/images/tab_btn_3_center.gif)';
			document.getElementById("views_btn").style.background = 'url(/images/tab_btn_3_active.gif)';
		}
	}
	active_news_tab2=i;
}
var active_new_building_tab=1;
function change_tab_4(i){
	if(active_new_building_tab==i){
		if(i==1){window.open("http://www.kanzas.ua/new_building/", "_self");}
		if(i==2){window.open("http://www.kanzas.ua/new_building/developers/", "_self");}
	}
	else{
		if (i==1){
			document.getElementById("new_b_box").style.display = 'block';
			document.getElementById("dev_box").style.display = 'none';
			
			document.getElementById("new_b_btn").style.background = 'url(/sprites/middle.gif) 0 -220px';
			document.getElementById("dev_btn").style.background = 'url(/sprites/middle.gif) 0 -296px';
		}
		if (i==2){
			document.getElementById("new_b_box").style.display = 'none';
			document.getElementById("dev_box").style.display = 'block';
			
			document.getElementById("new_b_btn").style.background = 'url(/sprites/middle.gif) 0 -296px';
			document.getElementById("dev_btn").style.background = 'url(/sprites/middle.gif) 0 -220px';
		}
	}
	active_new_building_tab=i;
}

function check_ban() {
	var results30;
    if (req30.readyState == 4) {
        if (req30.status == 200) {
            results30 = req30.responseText;
            //ban= results30;
            //alert(ban);
            
        	var ban=new Array();
        	ban = results30.split(',');
        	//alert(user[0]);

        	//ban[0];
        	//ban[1];
            
            
            
            if (ban[0]==1){
            	//alert('show');
            	   var k = document.getElementById("btn_ban_cheker");
            	   if(ban[1]==1){ 
            	   k.setAttribute("src", "/images/off_ban.jpg");}
            	   else if(ban[1]==2){ 
                	   k.setAttribute("src", "/images/off_ban_ua.jpg");}
            	   else if(ban[1]==3){ 
                	   k.setAttribute("src", "/images/off_ban_en.jpg");}
            	   else{k.setAttribute("src", "/images/off_ban.jpg");}
            	   
            	document.getElementById('baner_1').style.display='block';
        		document.getElementById('baner_2').style.display='block';
        		document.getElementById('baner_3').style.display='block';
        		document.getElementById('baner_4').style.display='block';
        		document.getElementById('baner_5').style.display='block';
        		document.getElementById('baner_6').style.display='block';
        		document.getElementById('baner_7').style.display='block';
        		document.getElementById('baner_8').style.display='block';
        		document.getElementById('baner_9').style.display='block';
        		
             
        		
        		
            	
            }
            else{
            	//alert('hide');
            	var k = document.getElementById("btn_ban_cheker");
         	   		if(ban[1]==1){ 
         	   			k.setAttribute("src", "/images/on_ban.jpg");}
         	   		else if(ban[1]==2){ 
                	   k.setAttribute("src", "/images/on_ban_ua.jpg");}
         	   		else if(ban[1]==3){ 
                	   k.setAttribute("src", "/images/on_ban_en.jpg");}
         	   		else{k.setAttribute("src", "/images/on_ban.jpg");}
         	   		
            	document.getElementById('baner_1').style.display='none';
        		document.getElementById('baner_2').style.display='none';
        		document.getElementById('baner_3').style.display='none';
        		document.getElementById('baner_4').style.display='none';
        		document.getElementById('baner_5').style.display='none';
        		document.getElementById('baner_6').style.display='none';
        		document.getElementById('baner_7').style.display='none';
        		document.getElementById('baner_8').style.display='none';
        		document.getElementById('baner_9').style.display='none';
        		
        		
            	
            }
            
            
            
            
        } else {
            //alert(req30.statusText);
        }
    }
    return results30;
}

function ban_cheker(){
	
	url30='http://www.kanzas.ua/components/baner_switcher/check_ban.php';
    if (window.XMLHttpRequest) {
        req30 = new XMLHttpRequest();
        req30.onreadystatechange = function() {res30=check_ban();};
        req30.open("GET", url30, true);
        req30.send(null);
    } else if (window.ActiveXObject) {
        req30 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req30) {
            req30.onreadystatechange = function() {res30=check_ban();};
            req30.open("GET", url30, true);
            req30.send();
        }
    }
    return res30;
	
}

function hide_ban(){
	
	ban_cheker();

}

function clearMe(formfield){
	  if (formfield.defaultValue==formfield.value)
	   formfield.value = "";
	 }

function change_pool(id){
	sid=id;
	
	pool_url='http://www.kanzas.ua/components/pool/change_ajax.php?sid='+sid;
	
    if (window.XMLHttpRequest) {
        pool_req = new XMLHttpRequest();
        pool_req.onreadystatechange = function() {pool_res=get_pool();};
        pool_req.open("GET", pool_url, true);
        pool_req.send(null);
    } else if (window.ActiveXObject) {
    	pool_req = new ActiveXObject("Microsoft.XMLHTTP");
        if (pool_req) {
        	pool_req.onreadystatechange = function() {pool_res=get_pool();};
        	pool_req.open("GET", pool_url, true);
        	pool_req.send();
        }
    }
}

function get_pool() {
    if (pool_req.readyState == 4) {
        if (pool_req.status == 200) {
            pool_ressults = pool_req.responseText;
            //alert(pool_ressults);
            
            document.getElementById('pool_div').innerHTML=pool_ressults;
            
        } else {
           // alert(pool_req.statusText);
        }
    }
    
}



function logoutform(){
	url11='http://www.kanzas.ua/components/login/end_session.php';
    if (window.XMLHttpRequest) {
        req11 = new XMLHttpRequest();
        req11.onreadystatechange = function() {res11=check_logout();};
        req11.open("GET", url11, true);
        req11.send(null);
    } else if (window.ActiveXObject) {
        req11 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req11) {
            req11.onreadystatechange = function() {res11=check_logout();};
            req11.open("GET", url11, true);
            req11.send();
        }
    }

}

function check_logout() {
    if (req11.readyState == 4) {
        if (req11.status == 200) {
            results11 = req11.responseText;
            if(results11==0){
            	//document.getElementById('login_form_1').style.display='block';
            	//document.getElementById('login_form_2').style.display='none';
            	
            	
            	//document.getElementById('reg_pl2').style.display='block';
            	//document.getElementById('reg_pl').style.display='block';
            	document.location.reload(true);

            }
            else {
            	
            }
        } else {
          //  alert(req11.statusText);
        }
    }
    
}


function loginform()
{
	//alert('1');
	//alert();
	
	var login = document.getElementById('form_login').value;
	var pass = document.getElementById('form_pass').value;
	
	//var login=document.auth.login.value;
	//var pass=document.auth.password.value;	
	//alert(password);
	
	url10='http://www.kanzas.ua/components/login/auth.php?log='+login+'&pass='+pass;
    if (window.XMLHttpRequest) {
        req10 = new XMLHttpRequest();
        req10.onreadystatechange = function() {res10=check_login();};
        req10.open("GET", url10, true);
        req10.send(null);
    } else if (window.ActiveXObject) {
        req10 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req10) {
            req10.onreadystatechange = function() {res10=check_login();};
            req10.open("GET", url10, true);
            req10.send();
        }
    }	
}



function calendar_change(date,cat){
	
	//alert(date);
	podcat=document.calendar.podcat.value;
	
	url15='http://www.kanzas.ua/components/calendar/calendar_ajax.php?month='+date+'&cat='+cat+'&podcat='+podcat;
	//alert(url15);
    if (window.XMLHttpRequest) {
        req15 = new XMLHttpRequest();
        req15.onreadystatechange = function() {res15=ajax_change_calendar();};
        req15.open("GET", url15, true);
        req15.send(null);
    } else if (window.ActiveXObject) {
        req15 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req15) {
            req15.onreadystatechange = function() {res15=ajax_change_calendar();};
            req15.open("GET", url15, true);
            req15.send();
        }
    }
}



function ajax_change_calendar() {
if (req15.readyState == 4) {
    if (req15.status == 200) {
        results15 = req15.responseText;
        //alert(results15);
        document.getElementById('calendar_div').innerHTML=results15;

		  
    } else {
    }
}

}



function show_btn_enter(){
	document.getElementById('enter_btn').style.display='block';
	document.getElementById('login_error').style.display='none';
}

function check_login() {
    if (req10.readyState == 4) {
        if (req10.status == 200) {
            results10 = req10.responseText;
            //alert(results10);
            if(results10==1){
            	//document.auth.login.value='';
            	//document.auth.password.value='';
            	//var login = document.getElementById('form_login').value;
            	document.getElementById('form_pass').value='';
            	//document.getElementById('form_login').value='';
            	
            	//login_error
            	document.getElementById('enter_btn').style.display='none';
      		  	document.getElementById('login_error').innerHTML='Пароль неверный';
      		  	document.getElementById('login_error').style.display='block';
            }
            else if(results10==2){
            	document.getElementById('form_pass').value='';
            	document.getElementById('form_login').value='';
            	document.getElementById('enter_btn').style.display='none';
        		document.getElementById('login_error').innerHTML='E-mail неверный';
          		document.getElementById('login_error').style.display='block';
            }
            else {
            	document.location.reload(true);
            	//document.getElementById('login_form_1').style.display='none';
            	//document.getElementById('login_form_2').style.display='block';
            	//var user=new Array();
            	//user = results10.split(',');
            	//alert(user[0]);
            	//document.getElementById('reg_pl2').style.display='none';
            	//document.getElementById('reg_pl').style.display='none';
            	//document.getElementById('sp_login').innerHTML=user[0];
            	//document.getElementById('sp_email').innerHTML=user[1];
            	


            }
        } else {
          //  alert(req10.statusText);
        }
    }
    //return results10;
}



function validateKcaptcha_comment(){
	kcaptcha=document.comment_form.kcaptcha.value;
	url4='http://www.kanzas.ua/components/register/kcaptcha_res.php';
    if (window.XMLHttpRequest) {
        req4 = new XMLHttpRequest();
        req4.onreadystatechange = function() {res4=check_ajax_kcaptcha(kcaptcha);};
        req4.open("GET", url4, true);
        req4.send(null);
    } else if (window.ActiveXObject) {
        req4 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req4) {
            req4.onreadystatechange = function() {res4=check_ajax_kcaptcha(kcaptcha);};
            req4.open("GET", url4, true);
            req4.send();
        }
    }
}  

function validateKcaptcha(){
	kcaptcha=document.reg_form.kcaptcha.value;
	url4='http://www.kanzas.ua/components/register/kcaptcha_res.php';
    if (window.XMLHttpRequest) {
        req4 = new XMLHttpRequest();
        req4.onreadystatechange = function() {res4=check_ajax_kcaptcha(kcaptcha);};
        req4.open("GET", url4, true);
        req4.send(null);
    } else if (window.ActiveXObject) {
        req4 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req4) {
            req4.onreadystatechange = function() {res4=check_ajax_kcaptcha(kcaptcha);};
            req4.open("GET", url4, true);
            req4.send();
        }
    }
}  



function validateKcaptcha2(){
	kcaptcha=document.getElementById('kcaptcha_str').value;
	
	
	url4='http://www.kanzas.ua/components/register/kcaptcha_res.php';
    if (window.XMLHttpRequest) {
        req4 = new XMLHttpRequest();
        req4.onreadystatechange = function() {res4=check_ajax_kcaptcha(kcaptcha);};
        req4.open("GET", url4, true);
        req4.send(null);
    } else if (window.ActiveXObject) {
        req4 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req4) {
            req4.onreadystatechange = function() {res4=check_ajax_kcaptcha(kcaptcha);};
            req4.open("GET", url4, true);
            req4.send();
        }
    }
}  






function comment_form_submit(){
	//alert('1');
	if(re5==1){
		//alert('2');
	//	getElementById('registration_error')
		comment=document.getElementById('input_comment').value;
		
		mylogin=document.getElementById('input_mylogin').value;
		article=document.getElementById('input_article').value;
		//alert('3');
		
		url12='http://www.kanzas.ua/components/article/comment_me.php?login='+mylogin+'&article='+article+'&comment='+comment;
	    if (window.XMLHttpRequest) {
	        req12 = new XMLHttpRequest();
	        req12.onreadystatechange = function() {res12=ajax_send_comment(article);};
	        req12.open("GET", url12, true);
	        req12.send(null);
	    } else if (window.ActiveXObject) {
	        req12 = new ActiveXObject("Microsoft.XMLHTTP");
	        if (req12) {
	            req12.onreadystatechange = function() {res12=ajax_send_comment(article);};
	            req12.open("GET", url12, true);
	            req12.send();
	        }
	    }
		
		
		
		}
	
}


  

function ajax_send_comment(article) {
    if (req12.readyState == 4) {
        if (req12.status == 200) {
            results12 = req12.responseText;
            //alert(results12);
            if(results12==1){change_comments(article);
            document.getElementById('comment_error').style.display='none';
            change_kcaptcha();
            document.comment_form.kcaptcha.value='';}
            else if(results12==3){
            	document.getElementById('comment_error').style.display='block';
            	change_kcaptcha();
            	
            	document.comment_form.kcaptcha.value='';
        		//change_comments(article);
        		}
            else {
        		//alert(results12);
        		//change_comments(article);
        		}
            
        } else {
        	
        }
    }
    
}




function change_comments(article){
				
		
		url14='http://www.kanzas.ua/components/article/ajax_comments.php?article='+article;
		
	    if (window.XMLHttpRequest) {
	        req14 = new XMLHttpRequest();
	        req14.onreadystatechange = function() {res14=ajax_change_comments();};
	        req14.open("GET", url14, true);
	        req14.send(null);
	    } else if (window.ActiveXObject) {
	        req14 = new ActiveXObject("Microsoft.XMLHTTP");
	        if (req14) {
	            req14.onreadystatechange = function() {res14=ajax_change_comments();};
	            req14.open("GET", url14, true);
	            req14.send();
	        }
	    }
}



function ajax_change_comments() {
    if (req14.readyState == 4) {
        if (req14.status == 200) {
            results14 = req14.responseText;
            //alert(results14);
            document.getElementById('comments_array').innerHTML=results14;
    		document.comment_form.comment.value='';
    		document.comment_form.kcaptcha.value='';
    		change_kcaptcha();
    		re5=0;
    		var g = document.getElementById("kcaptcha_check_img");
  		  	g.setAttribute("src", "/images/reg_img_star.gif");
  		  	document.getElementById('kcaptcha_error').style.visibility='hidden';
  		  
        } else {
        }
    }
    
}


function check_ajax_kcaptcha(kcaptcha) {
	results4=0;
	if (req4.readyState == 4) {
        if (req4.status == 200) {
            results4 = req4.responseText;
            if (kcaptcha==results4){
             var g = document.getElementById("kcaptcha_check_img");
      		 g.setAttribute("src", "/images/reg_img_ok.gif");
      		 document.getElementById('kcaptcha_error').style.visibility='hidden';
      		re5=1;
      		//document.getElementById('registration_error').style.visibility='hidden';
            }else{
            	var g = document.getElementById("kcaptcha_check_img");
        		  g.setAttribute("src", "/images/reg_img_star.gif");
        		  document.getElementById('kcaptcha_error').style.visibility='visible';
        		  re5=0;
            }
        } else {
          //  alert(req4.statusText);
        }
    }
    return results4;
}

function change_kcaptcha(){
	url3='http://www.kanzas.ua/components/register/kcaptcha_string.php';
    if (window.XMLHttpRequest) {
        req3 = new XMLHttpRequest();
        req3.onreadystatechange = function() {res3=change_ajax_kcaptcha();};
        req3.open("GET", url3, true);
        req3.send(null);
    } else if (window.ActiveXObject) {
        req3 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req3) {
            req3.onreadystatechange = function() {res3=change_ajax_kcaptcha();};
            req3.open("GET", url3, true);
            req3.send();
        }
    }
}    

function change_ajax_kcaptcha() {
    if (req3.readyState == 4) {
        if (req3.status == 200) {
            results3 = req3.responseText;
            document.getElementById('p_kcaptcha').innerHTML=results3;
            document.getElementById('input_kcaptcha').value='';
            
        } else {
         //   alert(req.statusText);
        }
    }
}

function validateRulles(){
	if(document.reg_form.rulles.checked){
		document.getElementById('rulles_error').style.visibility='hidden';
		var x = document.getElementById("img_rulles_check");
  		  x.setAttribute("src", "/images/reg_img_ok.gif");
  		document.getElementById('registration_error').style.visibility='hidden';
		re9=1;}
	else{
		  document.getElementById('rulles_error').innerHTML='&nbsp;&nbsp;Вы должны согласиться с правилами портала.';
		  document.getElementById('rulles_error').style.visibility='visible';
		  re9=0;
		 
   		 
   		  var x = document.getElementById("img_rulles_check");
   		  x.setAttribute("src", "/images/reg_img_star.gif");
   		  re9=0;
		  
		  
}
}

function ajax_checkuserinfo_login(login) {
	url2='http://www.kanzas.ua/components/register/logincheck.php?login='+login;
    if (window.XMLHttpRequest) {
        req2 = new XMLHttpRequest();
        req2.onreadystatechange = function() {res2=check_ajax_login();};
        req2.open("GET", url2, true);
        req2.send(null);
    } else if (window.ActiveXObject) {
        req2 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req2) {
            req2.onreadystatechange = function() {res2=check_ajax_login();};
            req2.open("GET", url2, true);
            req2.send();
        }
    }
    return res2;
}    















function ajax_checkuserinfo_email(mail) {
	var res;
	var url='http://www.kanzas.ua/components/register/mailcheck.php?mail='+mail;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() { res=check_ajax_mail();}
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() { res=check_ajax_mail();}
            req.open("GET", url, true);
            req.send();
        }
    }
    return res;
}    

function check_ajax_mail() {
	var results;
    if (req.readyState == 4) {
        if (req.status == 200) {
            results = req.responseText;
            //alert(results);
            
            
            if(results==1){
      		  document.getElementById('mail_error').style.visibility='hidden';
      		  var x = document.getElementById("img_mail_check");
      		  x.setAttribute("src", "/images/reg_img_ok.gif");
      		  re2=1;
      		document.getElementById('registration_error').style.visibility='hidden';
      	  	}
      	  	
      	 if(results==2){
      			  document.getElementById('mail_error').innerHTML='Такой меил уже зарегистрирован';
      	  		  document.getElementById('mail_error').style.visibility='visible';
      	  		  var x = document.getElementById("img_mail_check");
      	  		  x.setAttribute("src", "/images/reg_img_star.gif");
      	  		  re2=0;
      	  	  	} 	
      	 
        } else {
        	document.getElementById('mail_error').innerHTML='Системная ошибка. Повторите ввод.';
   		  document.getElementById('mail_error').style.visibility='visible';
   		  var x = document.getElementById("img_mail_check");
   		  x.setAttribute("src", "/images/reg_img_star.gif");
   		  re2=0;
        }
    }
    return results;
}

function validateEmail(){
	var	mail=document.getElementById('input_mail').value;

 if(!mail.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('mail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('mail_error').style.visibility='visible';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re2=0;
 }
 else {
 
	 ajax_checkuserinfo_email(mail);
 }
}


function valmail(){
	var	mail=document.getElementById('input_mail').value;

 if(!mail.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('mail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('mail_error').style.visibility='visible';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re2=0;
 }
 else {
 		document.getElementById('mail_error').style.visibility='hidden';
  		var x = document.getElementById("img_mail_check");
  		x.setAttribute("src", "/images/reg_img_ok.gif");
  		re2=1;
  		document.getElementById('registration_error').style.visibility='hidden';
 }
}





function validateCode(){
	var	code=document.getElementById('input_code1').value;
	var	phone=document.getElementById('input_phone1').value;

	 if(!code.match(/^[0-9]{2,5}$/)){
		  document.getElementById('phone_error').innerHTML='Введите корректный код оператора или города. Только цифры.';
		  document.getElementById('phone_error').style.visibility='visible';
	 	  var x = document.getElementById("img_phone_check");
		  x.setAttribute("src", "/images/reg_img_star.gif");
		  re6=0;
	 }
	 else{
		 
		 if(!phone.match(/^[0-9]{4,8}$/)){
			  document.getElementById('phone_error').innerHTML='Введите корректный номер телефона. Только цифры.';
			  document.getElementById('phone_error').style.visibility='visible';
		 	  var x = document.getElementById("img_phone_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re6=0;
		 }else{
		 
		  document.getElementById('phone_error').style.visibility='hidden';
		  var y = document.getElementById("img_phone_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re6=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		 }
	 }
 }



function validateSourname(){
	var	sourname=document.getElementById('input_sourname').value;

if(sourname.length==0){
  document.getElementById('sourname_error').innerHTML='Введите вашу фамилию';
  document.getElementById('sourname_error').style.visibility='visible';
  var y = document.getElementById("img_sourname_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re1=0;
 }
 else if(sourname.length<4){
  document.getElementById('sourname_error').innerHTML='Впишите вашу фамилию полностью';
  document.getElementById('sourname_error').style.visibility='visible';
  var y = document.getElementById("img_sourname_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re1=0;
 }
 else {
	 
	
  document.getElementById('sourname_error').style.visibility='hidden';
  var y = document.getElementById("img_sourname_check");
  y.setAttribute("src", "/images/reg_img_ok.gif");
  re1=1;
  document.getElementById('registration_error').style.visibility='hidden';}
	
 
 
}



function validateName(){
	var	name=document.getElementById('input_name').value;

if(name.length==0){
  document.getElementById('name_error').innerHTML='Введите ваше имя';
  document.getElementById('name_error').style.visibility='visible';
  var y = document.getElementById("img_name_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re3=0;
 }
 else if(name.length<3){
  document.getElementById('name_error').innerHTML='Впишите ваше имя полностью';
  document.getElementById('name_error').style.visibility='visible';
  var y = document.getElementById("img_name_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re3=0;
 }
 else {
	 
	
  document.getElementById('name_error').style.visibility='hidden';
  var y = document.getElementById("img_name_check");
  y.setAttribute("src", "/images/reg_img_ok.gif");
  re3=1;
  document.getElementById('registration_error').style.visibility='hidden';}
	
 
 
}



function validateDate(){
	var	date1=document.getElementById('date1').value;
	var	date2=document.getElementById('date2').value;
	var	date3=document.getElementById('date3').value;

	if(date1==0){
		document.getElementById('date_error').innerHTML='Выбирите день вашего раждения';
		document.getElementById('date_error').style.visibility='visible';
		var y = document.getElementById("img_date_check");
		y.setAttribute("src", "/images/reg_img_star.gif");
		re4=0;
	}
	else{
		if(date2==0){
			document.getElementById('date_error').innerHTML='Выбирите месяц вашего раждения';
			document.getElementById('date_error').style.visibility='visible';
			var y = document.getElementById("img_date_check");
			y.setAttribute("src", "/images/reg_img_star.gif");
			re4=0;
		}
		else{
			if(date3==0){
				document.getElementById('date_error').innerHTML='Выбирите год вашего раждения';
				document.getElementById('date_error').style.visibility='visible';
				var y = document.getElementById("img_date_check");
				y.setAttribute("src", "/images/reg_img_star.gif");
				re4=0;
			}
			else{
				document.getElementById('date_error').style.visibility='hidden';
				var y = document.getElementById("img_date_check");
				y.setAttribute("src", "/images/reg_img_ok.gif");
				re4=1;
				document.getElementById('registration_error').style.visibility='hidden';
			}
		}
	}
}


function validateState(){
	
				document.getElementById('state_error').style.visibility='hidden';
				var y = document.getElementById("img_state_check");
				y.setAttribute("src", "/images/reg_img_ok.gif");
				re10=1;
				document.getElementById('registration_error').style.visibility='hidden';

}




function validateEmail3(){
	var email=document.add_property_form.email.value;
	//alert(email);

 if(!email.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('mail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('mail_error').style.visibility='visible';
	  document.getElementById('mail_error').style.color='#990000';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re2=0;
 }
 else {
 	  //document.getElementById('mail_error').style.visibility='hidden';
	  document.getElementById('mail_error').innerHTML='Будет использоваться для редактирования обьявления.';
	  document.getElementById('mail_error').style.color='#666666';
	  document.getElementById('mail_error').style.visibility='visible';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_ok.gif");
	  re2=1;
 
 }
}


function validatelogin3(){
	var fio=document.add_property_form.fio.value;
	//alert(email);

 if(fio.length<4 || fio.length>20){
	  document.getElementById('login_error').innerHTML='Не менее 4 символов';
	  document.getElementById('login_error').style.visibility='visible';
	  document.getElementById('login_error').style.color='#990000';
 	  var x = document.getElementById("img_login_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re1=0;
 }
 else {
 	  //document.getElementById('mail_error').style.visibility='hidden';
	  document.getElementById('login_error').innerHTML='Будет отображаться как контактное лицо обьявления.';
	  document.getElementById('login_error').style.color='#666666';
	  document.getElementById('login_error').style.visibility='visible';
 	  var x = document.getElementById("img_login_check");
	  x.setAttribute("src", "/images/reg_img_ok.gif");
	  re1=1;
 
 }
}


function check_user_password() {
    if (req2.readyState == 4) {
        if (req2.status == 200) {
            results2 = req2.responseText;
        } else {
        }
    }
    return results2;
}


function checke_user_password(pass0){
	var password=pass0;
	
	url2='http://www.kanzas.ua/components/profile/password_cheak.php?pass='+password;
    if (window.XMLHttpRequest) {
        req2 = new XMLHttpRequest();
        req2.onreadystatechange = function() {res2=check_user_password();};
        req2.open("GET", url2, true);
        req2.send(null);
    } else if (window.ActiveXObject) {
        req2 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req2) {
            req2.onreadystatechange = function() {res2=check_user_password();};
            req2.open("GET", url2, true);
            req2.send();
        }
    }
    return res2;
	
	
	//return 2;
}


function cheak(i, objid){
	id='counter'+i;
	document.getElementById('counter1').style.border='none';
	document.getElementById('counter2').style.border='none';
	document.getElementById('counter3').style.border='none';
	document.getElementById('counter4').style.border='none';
	document.getElementById('counter5').style.border='none';
	document.getElementById('counter6').style.border='none';
	document.getElementById('counter7').style.border='none';
	document.getElementById('counter8').style.border='none';
	document.getElementById(id).style.border='3px solid #990000';
	
	text='<script type="text/javascript"  language="javascript">document.write(\'<a href="http://www.kanzas.ua/" target="_blank"><img src="http://www.kanzas.ua/counter/'+objid+'/'+i+'" width="88" height="31" alt="KANZAS.UA - информационно аналитический портал" title="KANZAS.UA - информационно аналитический портал" border="0" /></a>\');</script><noscript><a href="http://www.kanzas.ua/" target="_blank"><img src="http://www.kanzas.ua/counter/'+objid+'/'+i+'" width="88" height="31" alt="KANZAS.UA - информационно аналитический портал" title="KANZAS.UA - информационно аналитический портал" border="0" /></a></noscript>';
	
	document.getElementById('counter_text').value=text;
	
	
	
	 //document.getElementById(id).style.visibility='none';
	 //alert(id);
	//return 2;
}


function validateoldPass(){
	var pass0=document.reg_form.old_pass.value;

if(pass0.length==0){
  document.getElementById('pass0_error').innerHTML='Введите пароль';
  document.getElementById('pass0_error').style.visibility='visible';
  var y = document.getElementById("img_pass0_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re2=0;
 }
 else if(pass0.length<6){
  document.getElementById('pass0_error').innerHTML='Длина пароля меньше необходимой';
  document.getElementById('pass0_error').style.visibility='visible';
  var y = document.getElementById("img_pass0_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re2=0;
 }
 else {
	 
	 if(checke_user_password(pass0)==1){
  document.getElementById('pass0_error').style.visibility='hidden';
  var y = document.getElementById("img_pass0_check");
  y.setAttribute("src", "/images/reg_img_ok.gif");
  re2=1;}
	 else{
		 document.getElementById('pass0_error').innerHTML='Неверный пароль';
		  document.getElementById('pass0_error').style.visibility='visible';
		  var y = document.getElementById("img_pass0_check");
		  y.setAttribute("src", "/images/reg_img_star.gif");
		  re2=0;
	 }
 }

 
}

function validatePass(){
	var pass1=document.reg_form.pass1.value;
	


 if(pass1.length==0){
  document.getElementById('pass1_error').innerHTML='Введите пароль';
  document.getElementById('pass1_error').style.visibility='visible';
  var y = document.getElementById("img_pass1_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re7=0;
 }
 else if(pass1.length<6){
  document.getElementById('pass1_error').innerHTML='Длина пароля меньше необходимой';
  document.getElementById('pass1_error').style.visibility='visible';
  var y = document.getElementById("img_pass1_check");
  y.setAttribute("src", "/images/reg_img_star.gif");
  re7=0;
 }
 else {
  document.getElementById('pass1_error').style.visibility='hidden';
  var y = document.getElementById("img_pass1_check");
  y.setAttribute("src", "/images/reg_img_ok.gif");
  re7=1;
  document.getElementById('registration_error').style.visibility='hidden';
 }


}


















function ajax_checkuserinfo_email2(mail) {
	var res;
	var url='http://www.kanzas.ua/components/register/mailcheck.php?mail='+mail;
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() { res=check_ajax_mail2();}
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() { res=check_ajax_mail2();}
            req.open("GET", url, true);
            req.send();
        }
    }
    return res;
}    

function check_ajax_mail2() {
	var results;
    if (req.readyState == 4) {
        if (req.status == 200) {
            results = req.responseText;
            //alert(results);
            
            
            if(results==1){
      		  
      		
      		document.getElementById('mail_error').innerHTML='Такой НЕ зарегистрирован';
	  		  document.getElementById('mail_error').style.visibility='visible';
	  		  var x = document.getElementById("img_mail_check");
	  		  x.setAttribute("src", "/images/reg_img_star.gif");
	  		  re2=0;
      	  	}
      	  	
      	 if(results==2){
      		document.getElementById('mail_error').style.visibility='hidden';
    		  var x = document.getElementById("img_mail_check");
    		  x.setAttribute("src", "/images/reg_img_ok.gif");
    		  re2=1;
    		document.getElementById('registration_error').style.visibility='hidden';
      	  	  	} 	
      	 
        } else {
        	document.getElementById('mail_error').innerHTML='Системная ошибка. Повторите ввод.';
   		  document.getElementById('mail_error').style.visibility='visible';
   		  var x = document.getElementById("img_mail_check");
   		  x.setAttribute("src", "/images/reg_img_star.gif");
   		  re2=0;
        }
    }
    return results;
}







function validateEmail2(){
	var email=document.reg_form.mail.value;

 if(!email.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('mail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('mail_error').style.visibility='visible';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re7=0;
 }
 else {
 if(ajax_checkuserinfo_email2(email)==1){
	  document.getElementById('mail_error').innerHTML='Такой меил НЕ зарегистрирован';
	  document.getElementById('mail_error').style.visibility='visible';
	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re7=0; 
  	};
if(ajax_checkuserinfo_email2(email)==2){
	  	document.getElementById('mail_error').style.visibility='hidden';
	  	var x = document.getElementById("img_mail_check");
	  	x.setAttribute("src", "/images/reg_img_ok.gif");
	  	re7=1;
  	  	}; 	
 }
}


function delayedValidateEmail2(){
	validateEmail2();
}







function check_ajax_smail() {
	
    if (req25.readyState == 4) {
        if (req25.status == 200) {
            results = req25.responseText;
        } else {
        }
    }
    return results;
}

function ajax_checkuserinfo_semail(semail) {
	//alert(semail);
	url25='http://www.kanzas.ua/components/subscribe/mailcheck.php?mail='+semail;
    if (window.XMLHttpRequest) {
        req25 = new XMLHttpRequest();
        req25.onreadystatechange = function() {res25=check_ajax_smail();};
        req25.open("GET", url25, true);
        req25.send(null);
    } else if (window.ActiveXObject) {
        req25 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req25) {
            req25.onreadystatechange = function() {res25=check_ajax_smail();};
            req25.open("GET", url25, true);
            req25.send();
        }
    }
    //alert(res25);
    return res25;
} 



function validateSEmail(){
	var	semail=document.subscribe_form.mail.value;

 if(!semail.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('smail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('smail_error').style.visibility='visible';
 	  //var x = document.getElementById("img_mail_check");
	  //x.setAttribute("src", "/images/reg_img_star.gif");
	  re8=0;
 }
 else {
 if(ajax_checkuserinfo_semail(semail)==1){
	  document.getElementById('smail_error').innerHTML='Такой уже подписан';
	  document.getElementById('smail_error').style.visibility='visible';
	  //var x = document.getElementById("img_mail_check");
	  //x.setAttribute("src", "/images/reg_img_star.gif");
	  re8=0; 
  	};
if(ajax_checkuserinfo_semail(semail)==2){
	  	document.getElementById('smail_error').style.visibility='hidden';
	  	//var x = document.getElementById("img_mail_check");
	  	//x.setAttribute("src", "/images/reg_img_ok.gif");
	  	re8=1;
  	  	}; 	
  	  	
  	  	// alert('ok');
 }
	
}

function delayedValidateSEmail(){
	validateSEmail();
}


function validateSEmail2(){
	var	semail=document.reg_form.mail.value;

 if(!semail.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('smail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('smail_error').style.visibility='visible';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re8=0;
 }
 else {
 if(ajax_checkuserinfo_semail(semail)==1){
	  document.getElementById('smail_error').innerHTML='Такой e-mail уже подписан';
	  document.getElementById('smail_error').style.visibility='visible';
	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re8=0; 
  	};
if(ajax_checkuserinfo_semail(semail)==2){
	  	document.getElementById('smail_error').style.visibility='hidden';
	  	var x = document.getElementById("img_mail_check");
	  	x.setAttribute("src", "/images/reg_img_ok.gif");
	  	re8=1;
  	  	}; 	
  	  	
  	  	// alert('ok');
 }
	
}


function validateSEmail3(){
	var semail=document.reg_form.mail.value;

 if(!semail.match(/^[a-zA-Z0-9_\.\-]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/)){
	  document.getElementById('smail_error').innerHTML='Введите корректный e-mail';
	  document.getElementById('smail_error').style.visibility='visible';
 	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re8=0;
 }
 else {
 if(ajax_checkuserinfo_semail(semail)==1){
	 document.getElementById('smail_error').style.visibility='hidden';
	  	var x = document.getElementById("img_mail_check");
	  	x.setAttribute("src", "/images/reg_img_ok.gif");
	  	re8=1; 
	 
	 
  	};
if(ajax_checkuserinfo_semail(semail)==2){
	document.getElementById('smail_error').innerHTML='Такого e-mail\'a нет в базе';
	  document.getElementById('smail_error').style.visibility='visible';
	  var x = document.getElementById("img_mail_check");
	  x.setAttribute("src", "/images/reg_img_star.gif");
	  re8=0;   	
	
	
  	  	}; 	
  	  	
  	  	// alert('ok');
 }
	
}


function delayedValidateSEmail2(){
	validateSEmail2();
}

function delayedValidateSEmail3(){
	validateSEmail3();
}



















function change_property_details() {
	
    if (req30.readyState == 4) {
        if (req30.status == 200) {
            results = req30.responseText;
            document.getElementById('property_details').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function change_add_property_details(type){
	url30='http://www.kanzas.ua/components/add_property/details.php?type='+type;
    if (window.XMLHttpRequest) {
        req30 = new XMLHttpRequest();
        req30.onreadystatechange = function() {res30=change_property_details();};
        req30.open("GET", url30, true);
        req30.send(null);
    } else if (window.ActiveXObject) {
        req30 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req30) {
            req30.onreadystatechange = function() {res30=change_property_details();};
            req30.open("GET", url30, true);
            req30.send();
        }
    }
    return 0;
}




function change_property_adress_line() {
	
    if (req31.readyState == 4) {
        if (req31.status == 200) {
            results = req31.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function change_add_property_adress_line(type){
	url31='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type;
    if (window.XMLHttpRequest) {
        req31 = new XMLHttpRequest();
        req31.onreadystatechange = function() {res31=change_property_adress_line();};
        req31.open("GET", url31, true);
        req31.send(null);
    } else if (window.ActiveXObject) {
        req31 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req31) {
            req31.onreadystatechange = function() {res31=change_property_adress_line();};
            req31.open("GET", url31, true);
            req31.send();
        }
    }
    return 0;
}





function change_property_adress_line2() {
	
    if (req70.readyState == 4) {
        if (req70.status == 200) {
        	
            results70 = req70.responseText;
            //alert(results70);
            document.getElementById('adress_line').innerHTML=results70;
        } else {
        }
    }
    return 0;
}

function change_add_property_adress_line2(type){
	url70='http://www.kanzas.ua/components/profile/subscribe_adress.php?type='+type;
    if (window.XMLHttpRequest) {
        req70 = new XMLHttpRequest();
        req70.onreadystatechange = function() {res70=change_property_adress_line2();};
        req70.open("GET", url70, true);
        req70.send(null);
    } else if (window.ActiveXObject) {
        req70 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req70) {
            req70.onreadystatechange = function() {res70=change_property_adress_line2();};
            req70.open("GET", url70, true);
            req70.send();
        }
    }
    return 0;
}




function change_property_contacts() {
	
    if (req32.readyState == 4) {
        if (req32.status == 200) {
            results = req32.responseText;
         //   document.getElementById('contacts').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function change_add_property_contacts(type){
	url32='http://www.kanzas.ua/components/add_property/contacts.php?type='+type;
    if (window.XMLHttpRequest) {
        req32 = new XMLHttpRequest();
        req32.onreadystatechange = function() {res32=change_property_contacts();};
        req32.open("GET", url32, true);
        req32.send(null);
    } else if (window.ActiveXObject) {
        req32 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req32) {
            req32.onreadystatechange = function() {res32=change_property_contacts();};
            req32.open("GET", url32, true);
            req32.send();
        }
    }
    return 0;
}





function hide_add_property_map(type){
	//url32='http://www.kanzas.ua/components/add_property/map.php?type='+type;
	document.getElementById('map').style.display='none';
    return 0;
}

function show_add_property_map(type){
	//url32='http://www.kanzas.ua/components/add_property/map.php?type='+type;
	document.getElementById('map').style.display='block';
    return 0;
}




function add_property(){
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	unvalid();
	
	if(s_type==1){
		
		if(p_type==1){	//alert('Продать квартиру');
						change_add_property_details(11);
						change_add_property_adress_line(11);
						show_add_property_map(11);
						change_add_property_contacts(11);
						}
		if(p_type==2){	//alert('Продать дом/коттедж');
						change_add_property_details(12);
						change_add_property_adress_line(12);
						show_add_property_map(12);
						change_add_property_contacts(12);
						}
		if(p_type==3){	//alert('Продать земельный участок');
						change_add_property_details(13);
						change_add_property_adress_line(13);
						show_add_property_map(13);
						change_add_property_contacts(13);
						}
		if(p_type==4){	//alert('Продать офис');
						change_add_property_details(14);
						change_add_property_adress_line(14);
						show_add_property_map(14);
						change_add_property_contacts(14);
						}
		if(p_type==5){	//alert('Продать торговое помещение');
						change_add_property_details(15);
						change_add_property_adress_line(15);
						show_add_property_map(15);
						change_add_property_contacts(15);
						}
		if(p_type==6){	//alert('Продать склад');
						change_add_property_details(16);
						change_add_property_adress_line(16);
						show_add_property_map(16);
						change_add_property_contacts(16);
						}
		if(p_type==7){	//alert('Продать гараж');
						change_add_property_details(17);
						change_add_property_adress_line(17);
						show_add_property_map(17);
						change_add_property_contacts(17);
						}
		if(p_type==8){	//alert('Продать бизнес');
						change_add_property_details(18);
						change_add_property_adress_line(18);
						show_add_property_map(18);
						change_add_property_contacts(18);
						}
		if(p_type==9){	//alert('Продать зарубежную недвижимость');
						change_add_property_details(19);
						change_add_property_adress_line(19);
						hide_add_property_map(19);
						change_add_property_contacts(19);}
	}
	if(s_type==2){
		
		if(p_type==1){	//alert('Купить квартиру');
						change_add_property_details(21);
						change_add_property_adress_line(21);
						hide_add_property_map(21);
						change_add_property_contacts(21);
						}
		if(p_type==2){	//alert('Купить дом/коттедж');
						change_add_property_details(22);
						change_add_property_adress_line(22);
						hide_add_property_map(22);
						change_add_property_contacts(22);
						}
		if(p_type==3){	//alert('Купить земельный участок');
						change_add_property_details(23);
						change_add_property_adress_line(23);
						hide_add_property_map(23);
						change_add_property_contacts(23);
						}
		if(p_type==4){	//alert('Купить офис');
						change_add_property_details(24);
						change_add_property_adress_line(24);
						hide_add_property_map(24);
						change_add_property_contacts(24);
						}
		if(p_type==5){	//alert('Купить торговое помещение');
						change_add_property_details(25);
						change_add_property_adress_line(25);
						hide_add_property_map(25);
						change_add_property_contacts(25);
						}
		if(p_type==6){	//alert('Купить склад');
						change_add_property_details(26);
						change_add_property_adress_line(26);
						hide_add_property_map(26);
						change_add_property_contacts(26);
						}
		if(p_type==7){	//alert('Купить гараж');
						change_add_property_details(27);
						change_add_property_adress_line(27);
						hide_add_property_map(27);
						change_add_property_contacts(27);
						}
		if(p_type==8){	//alert('Купить бизнес');
						change_add_property_details(28);
						change_add_property_adress_line(28);
						hide_add_property_map(28);
						change_add_property_contacts(28);
						}
		if(p_type==9){	//alert('Купить зарубежную недвижимость');
						change_add_property_details(29);
						change_add_property_adress_line(29);
						hide_add_property_map(29);
						change_add_property_contacts(29);
						}
	}
	if(s_type==3){
		
		if(p_type==1){	//alert('Снять квартиру');
						change_add_property_details(31);
						change_add_property_adress_line(31);
						hide_add_property_map(31);
						change_add_property_contacts(31);
						}
		if(p_type==2){	//alert('Снять дом/коттедж');
						change_add_property_details(32);
						change_add_property_adress_line(32);
						hide_add_property_map(32);
						change_add_property_contacts(32);
						}
		if(p_type==3){	//alert('Снять земельный участок');
						change_add_property_details(33);
						change_add_property_adress_line(33);
						hide_add_property_map(33);
						change_add_property_contacts(33);
						}
		if(p_type==4){	//alert('Снять офис');
						change_add_property_details(34);
						change_add_property_adress_line(34);
						hide_add_property_map(34);
						change_add_property_contacts(34);
						}
		if(p_type==5){	//alert('Снять торговое помещение');
						change_add_property_details(35);
						change_add_property_adress_line(35);
						hide_add_property_map(35);
						change_add_property_contacts(35);
						}
		if(p_type==6){	//alert('Снять склад');
						change_add_property_details(36);
						change_add_property_adress_line(36);
						hide_add_property_map(36);
						change_add_property_contacts(36);
						}
		if(p_type==7){	//alert('Снять гараж');
						change_add_property_details(37);
						change_add_property_adress_line(37);
						hide_add_property_map(37);
						change_add_property_contacts(37);
						}
		if(p_type==8){	//alert('Снять бизнес');
						change_add_property_details(38);
						change_add_property_adress_line(38);
						hide_add_property_map(38);
						change_add_property_contacts(38);
						}
		if(p_type==9){	//alert('Снять зарубежную недвижимость');
						change_add_property_details(39);
						change_add_property_adress_line(39);
						hide_add_property_map(39);
						change_add_property_contacts(39);}
		
	}
	if(s_type==4){
		
		if(p_type==1){	//alert('Здать квартиру');
						change_add_property_details(41);
						change_add_property_adress_line(41);
						show_add_property_map(41);
						change_add_property_contacts(41);
						}
		if(p_type==2){	//alert('Здать дом/коттедж');
						change_add_property_details(42);
						change_add_property_adress_line(42);
						show_add_property_map(42);
						change_add_property_contacts(42);
						}
		if(p_type==3){	//alert('Здать земельный участок');
						change_add_property_details(43);
						change_add_property_adress_line(43);
						show_add_property_map(43);
						change_add_property_contacts(43);
						}
		if(p_type==4){	//alert('Здать офис');
						change_add_property_details(44);
						change_add_property_adress_line(44);
						show_add_property_map(44);
						change_add_property_contacts(44);
						}
		if(p_type==5){	//alert('Здать торговое помещение');
						change_add_property_details(45);
						change_add_property_adress_line(45);
						show_add_property_map(45);
						change_add_property_contacts(45);
						}
		if(p_type==6){	//alert('Здать склад');
						change_add_property_details(46);
						change_add_property_adress_line(46);
						show_add_property_map(46);
						change_add_property_contacts(46);
						}
		if(p_type==7){	//alert('Здать гараж');
						change_add_property_details(47);
						change_add_property_adress_line(47);
						show_add_property_map(47);
						change_add_property_contacts(47);
						}
		if(p_type==8){	//alert('Здать бизнес');
						change_add_property_details(48);
						change_add_property_adress_line(48);
						show_add_property_map(48);
						change_add_property_contacts(48);
						}
		if(p_type==9){	//alert('Здать зарубежную недвижимость');
						change_add_property_details(49);
						change_add_property_adress_line(49);
						hide_add_property_map(49);
						change_add_property_contacts(49);}
	}

}




function add_subscribe_property(){
	s_type=document.reg_form.s_type.value;
	p_type=document.reg_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){change_add_property_adress_line2(11);}
		if(p_type==2){change_add_property_adress_line2(12);}
		if(p_type==3){change_add_property_adress_line2(13);}
		if(p_type==4){change_add_property_adress_line2(14);}
		if(p_type==5){change_add_property_adress_line2(15);}
		if(p_type==6){change_add_property_adress_line2(16);}
		if(p_type==7){change_add_property_adress_line2(17);}
		if(p_type==8){change_add_property_adress_line2(18);}
		if(p_type==9){change_add_property_adress_line2(19);}
	}
	if(s_type==2){
		if(p_type==1){change_add_property_adress_line2(21);}
		if(p_type==2){change_add_property_adress_line2(22);}
		if(p_type==3){change_add_property_adress_line2(23);}
		if(p_type==4){change_add_property_adress_line2(24);}
		if(p_type==5){change_add_property_adress_line2(25);}
		if(p_type==6){change_add_property_adress_line2(26);}
		if(p_type==7){change_add_property_adress_line2(27);}
		if(p_type==8){change_add_property_adress_line2(28);}
		if(p_type==9){change_add_property_adress_line2(29);}
	}
	if(s_type==3){
		if(p_type==1){change_add_property_adress_line2(31);}
		if(p_type==2){change_add_property_adress_line2(32);}
		if(p_type==3){change_add_property_adress_line2(33);}
		if(p_type==4){change_add_property_adress_line2(34);}
		if(p_type==5){change_add_property_adress_line2(35);}
		if(p_type==6){change_add_property_adress_line2(36);}
		if(p_type==7){change_add_property_adress_line2(37);}
		if(p_type==8){change_add_property_adress_line2(38);}
		if(p_type==9){change_add_property_adress_line2(39);}
	}
	if(s_type==4){
		if(p_type==1){change_add_property_adress_line2(41);}
		if(p_type==2){change_add_property_adress_line2(42);}
		if(p_type==3){change_add_property_adress_line2(43);}
		if(p_type==4){change_add_property_adress_line2(44);}
		if(p_type==5){change_add_property_adress_line2(45);}
		if(p_type==6){change_add_property_adress_line2(46);}
		if(p_type==7){change_add_property_adress_line2(47);}
		if(p_type==8){change_add_property_adress_line2(48);}
		if(p_type==9){change_add_property_adress_line2(49);}
	}
	

}





function change_al_region() {
	
    if (req33.readyState == 4) {
        if (req33.status == 200) {
            results = req33.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_region(type, al_region){
	if(type==10){url33='http://www.kanzas.ua/components/add_new_building/adress_line.php?region='+al_region;}
	else{
	url33='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region;
	}
	if (window.XMLHttpRequest) {
        req33 = new XMLHttpRequest();
        req33.onreadystatechange = function() {res33=change_al_region();};
        req33.open("GET", url33, true);
        req33.send(null);
    } else if (window.ActiveXObject) {
        req33 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req33) {
            req33.onreadystatechange = function() {res33=change_al_region();};
            req33.open("GET", url33, true);
            req33.send();
        }
    }	
    return 0;
}

function refresh_adress_line_region(r){
	if (r==1) {validateRegion();}
	if (r==0) {unvalid();}
	
	al_region=document.add_property_form.region.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_region(type, al_region);
	
	

	
}


function to_refresh_adress_line_region(type){
	al_region=document.getElementById('region_ver').value;
	//alert(al_region);//document.getElementById('otype').value;
	refresh_al_region(type, al_region);	
}







function change_al_region2() {
	
    if (req33.readyState == 4) {
        if (req33.status == 200) {
            results = req33.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_region2(type, al_region){
	url33='http://www.kanzas.ua/components/profile/subscribe_adress.php?type='+type+'&region='+al_region;
    if (window.XMLHttpRequest) {
        req33 = new XMLHttpRequest();
        req33.onreadystatechange = function() {res33=change_al_region2();};
        req33.open("GET", url33, true);
        req33.send(null);
    } else if (window.ActiveXObject) {
        req33 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req33) {
            req33.onreadystatechange = function() {res33=change_al_region2();};
            req33.open("GET", url33, true);
            req33.send();
        }
    }
    return 0;
}




function refresh_adress_line_region2(){
	al_region=document.reg_form.region.value;
	s_type=document.reg_form.s_type.value;
	p_type=document.reg_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_region2(type, al_region);
	
	
}




function change_user_region() {
	
    if (req33.readyState == 4) {
        if (req33.status == 200) {
            results = req33.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_user_region(al_region){
	url33='http://www.kanzas.ua/components/profile/adress_line.php?region='+al_region;
    if (window.XMLHttpRequest) {
        req33 = new XMLHttpRequest();
        req33.onreadystatechange = function() {res33=change_user_region();};
        req33.open("GET", url33, true);
        req33.send(null);
    } else if (window.ActiveXObject) {
        req33 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req33) {
            req33.onreadystatechange = function() {res33=change_user_region();};
            req33.open("GET", url33, true);
            req33.send();
        }
    }
    return 0;
}





function refresh_user_adress(){
	al_region=document.reg_form.region.value;
	//alert(al_region);
	refresh_user_region(al_region);
	
	
}



function change_al_city() {
    if (req34.readyState == 4) {
        if (req34.status == 200) {
            results = req34.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_city(type, al_region, al_city){
	if(type==10){url34='http://www.kanzas.ua/components/add_new_building/adress_line.php?region='+al_region+'&city='+al_city;}else{
	url34='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city;}
    if (window.XMLHttpRequest) {
        req34 = new XMLHttpRequest();
        req34.onreadystatechange = function() {res34=change_al_city();};
        req34.open("GET", url34, true);
        req34.send(null);
    } else if (window.ActiveXObject) {
        req34 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req34) {
            req34.onreadystatechange = function() {res34=change_al_city();};
            req34.open("GET", url34, true);
            req34.send();
        }
    }
    return 0;
}



function refresh_adress_line_city(r){
	if (r==0) {unvalid();}
	
	al_region=document.add_property_form.region.value;
	al_city=document.add_property_form.city.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_city(type, al_region, al_city);
	
	
}



function to_refresh_adress_line_city(){
	al_region=document.getElementById('region_ver').value;
	al_city=document.getElementById('city_ver').value;

	
	refresh_al_city(10, al_region, al_city);
	
	
}







function change_al_city2() {
    if (req34.readyState == 4) {
        if (req34.status == 200) {
            results = req34.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_city2(type, al_region, al_city){
	url34='http://www.kanzas.ua/components/profile/subscribe_adress.php?type='+type+'&region='+al_region+'&city='+al_city;
    if (window.XMLHttpRequest) {
        req34 = new XMLHttpRequest();
        req34.onreadystatechange = function() {res34=change_al_city2();};
        req34.open("GET", url34, true);
        req34.send(null);
    } else if (window.ActiveXObject) {
        req34 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req34) {
            req34.onreadystatechange = function() {res34=change_al_city2();};
            req34.open("GET", url34, true);
            req34.send();
        }
    }
    return 0;
}



function refresh_adress_line_city2(){
	al_region=document.reg_form.region.value;
	al_city=document.reg_form.city.value;
	s_type=document.reg_form.s_type.value;
	p_type=document.reg_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_city2(type, al_region, al_city);
	
	
}










function change_al_district() {
    if (req35.readyState == 4) {
        if (req35.status == 200) {
            results = req35.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_district(type, al_region, al_city, al_district){
	if(type==10){url35='http://www.kanzas.ua/components/add_new_building/adress_line.php?region='+al_region+'&city='+al_city+'&district='+al_district;}
	else{url35='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&district='+al_district;}
    if (window.XMLHttpRequest) {
        req35 = new XMLHttpRequest();
        req35.onreadystatechange = function() {res35=change_al_district();};
        req35.open("GET", url35, true);
        req35.send(null);
    } else if (window.ActiveXObject) {
        req35 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req35) {
            req35.onreadystatechange = function() {res35=change_al_district();};
            req35.open("GET", url35, true);
            req35.send();
        }
    }
    return 0;
}



function refresh_adress_line_district(r){
	if (r==0) {unvalid();}
	al_region=document.add_property_form.region.value;
	al_city=document.add_property_form.city.value;
	al_district=document.add_property_form.district.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_district(type, al_region, al_city, al_district);
	
	
}



function to_refresh_adress_line_district(){
	
	al_region=document.getElementById('region_ver').value;
	al_city=document.getElementById('city_ver').value;
	al_district=document.getElementById('district_ver').value;
		
	refresh_al_district(10, al_region, al_city, al_district);
	
	
}











function change_al_array() {
    if (req36.readyState == 4) {
        if (req36.status == 200) {
            results = req36.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_array(type, al_region, al_city, al_district){
	url36='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&district='+al_district;
    if (window.XMLHttpRequest) {
        req36 = new XMLHttpRequest();
        req36.onreadystatechange = function() {res36=change_al_array();};
        req36.open("GET", url36, true);
        req36.send(null);
    } else if (window.ActiveXObject) {
        req36 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req36) {
            req36.onreadystatechange = function() {res36=change_al_array();};
            req36.open("GET", url36, true);
            req36.send();
        }
    }
    return 0;
}



function refresh_adress_line_array(){
//	alert('ok');
	al_region=document.add_property_form.region.value;
	al_city=document.add_property_form.city.value;
	al_district=document.add_property_form.district.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_array(type, al_region, al_city, al_district);
	
	
}








function change_al_street() {
    if (req37.readyState == 4) {
        if (req37.status == 200) {
            results = req37.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_street(type, al_region, al_city, al_district, al_array, al_street){
	url37='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&district='+al_district+'&array='+al_array+'&street='+al_street;
    if (window.XMLHttpRequest) {
        req37 = new XMLHttpRequest();
        req37.onreadystatechange = function() {res37=change_al_street();};
        req37.open("GET", url37, true);
        req37.send(null);
    } else if (window.ActiveXObject) {
        req37 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req37) {
            req37.onreadystatechange = function() {res37=change_al_street();};
            req37.open("GET", url37, true);
            req37.send();
        }
    }
    return 0;
}




function refresh_adress_line_street(){
	
	//alert('ok');
	al_region=document.add_property_form.region.value;
	al_city=document.add_property_form.city.value;
	al_district=document.add_property_form.district.value;
	al_array=document.add_property_form.array.value;
	al_street=document.add_property_form.street.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_street(type, al_region, al_city, al_district, al_array, al_street);
	
	
}








function change_al_street2() {
    if (req38.readyState == 4) {
        if (req38.status == 200) {
            results = req38.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_street2(type, al_region, al_city, al_district, al_street){
	url38='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&district='+al_district+'&street='+al_street;
    if (window.XMLHttpRequest) {
        req38 = new XMLHttpRequest();
        req38.onreadystatechange = function() {res38=change_al_street2();};
        req38.open("GET", url38, true);
        req38.send(null);
    } else if (window.ActiveXObject) {
        req38 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req38) {
            req38.onreadystatechange = function() {res38=change_al_street2();};
            req38.open("GET", url38, true);
            req38.send();
        }
    }
    return 0;
}

function refresh_al_street2(type, al_region, al_city, al_district, al_street){
	if(type==10){url38='http://www.kanzas.ua/components/add_new_building/adress_line.php?region='+al_region+'&city='+al_city+'&district='+al_district+'&street='+al_street;}
	else{url38='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&district='+al_district+'&street='+al_street;}
    if (window.XMLHttpRequest) {
        req38 = new XMLHttpRequest();
        req38.onreadystatechange = function() {res38=change_al_street2();};
        req38.open("GET", url38, true);
        req38.send(null);
    } else if (window.ActiveXObject) {
        req38 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req38) {
            req38.onreadystatechange = function() {res38=change_al_street2();};
            req38.open("GET", url38, true);
            req38.send();
        }
    }
    return 0;
}

function refresh_al_street3(type, al_region, al_city, al_street){
	if(type==10){url38='http://www.kanzas.ua/components/add_new_building/adress_line.php?region='+al_region+'&city='+al_city+'&street='+al_street;}
	else{url38='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&street='+al_street;}
    if (window.XMLHttpRequest) {
        req38 = new XMLHttpRequest();
        req38.onreadystatechange = function() {res38=change_al_street2();};
        req38.open("GET", url38, true);
        req38.send(null);
    } else if (window.ActiveXObject) {
        req38 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req38) {
            req38.onreadystatechange = function() {res38=change_al_street2();};
            req38.open("GET", url38, true);
            req38.send();
        }
    }
    return 0;
}



function refresh_adress_line_street2(){
	unvalid();
	//alert('ok');
	al_region=document.add_property_form.region.value;
	al_city=document.add_property_form.city.value;
	al_district=document.add_property_form.district.value;
	al_street=document.add_property_form.street.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_street2(type, al_region, al_city, al_district, al_street);

}



function to_refresh_adress_line_street2(){
	//alert('ok');
	al_region=document.getElementById('region_ver').value;
	al_city=document.getElementById('city_ver').value;
	al_district=document.getElementById('district_ver').value;
	al_street=document.getElementById('street_ver').value;

	

	
	refresh_al_street2(10, al_region, al_city, al_district, al_street);

}













function change_al_street3() {
    if (req39.readyState == 4) {
        if (req39.status == 200) {
            results = req39.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_street3(type, al_region, al_city, al_street){
	if(type==10){url39='http://www.kanzas.ua/components/add_new_building/adress_line.php?region='+al_region+'&city='+al_city+'&street='+al_street;}
	else{	url39='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&region='+al_region+'&city='+al_city+'&street='+al_street;}
    if (window.XMLHttpRequest) {
        req39 = new XMLHttpRequest();
        req39.onreadystatechange = function() {res39=change_al_street3();};
        req39.open("GET", url39, true);
        req39.send(null);
    } else if (window.ActiveXObject) {
        req39 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req39) {
            req39.onreadystatechange = function() {res39=change_al_street3();};
            req39.open("GET", url39, true);
            req39.send();
        }
    }
    return 0;
}



function refresh_adress_line_street3(){
	unvalid();
	al_region=document.add_property_form.region.value;
	al_city=document.add_property_form.city.value;
	al_street=document.add_property_form.street.value;
	s_type=document.add_property_form.s_type.value;
	p_type=document.add_property_form.property_type.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_street3(type, al_region, al_city, al_street);
	
	
}


function to_refresh_adress_line_street3(){
	//alert('ok');

	
	
	al_region=document.getElementById('region_ver').value;
	al_city=document.getElementById('city_ver').value;
	
	al_street=document.getElementById('street_ver').value;


	
	refresh_al_street3(10, al_region, al_city, al_street);
	
	
}






function change_al_country() {
    if (req40.readyState == 4) {
        if (req40.status == 200) {
            results = req40.responseText;
            document.getElementById('adress_line').innerHTML=results;
        } else {
        }
    }
    return 0;
}

function refresh_al_country(type, al_country){
	url40='http://www.kanzas.ua/components/add_property/adress_line.php?type='+type+'&country='+al_country;
    if (window.XMLHttpRequest) {
        req40 = new XMLHttpRequest();
        req40.onreadystatechange = function() {res40=change_al_country();};
        req40.open("GET", url40, true);
        req40.send(null);
    } else if (window.ActiveXObject) {
        req40 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req40) {
            req40.onreadystatechange = function() {res40=change_al_country();};
            req40.open("GET", url40, true);
            req40.send();
        }
    }
    return 0;
}




function refresh_adress_line_country(){
	//alert('ok');
	al_country=document.add_property_form.country.value;
	
	if(s_type==1){
		if(p_type==1){type=11;}
		if(p_type==2){type=12;}
		if(p_type==3){type=13;}
		if(p_type==4){type=14;}
		if(p_type==5){type=15;}
		if(p_type==6){type=16;}
		if(p_type==7){type=17;}
		if(p_type==8){type=18;}
		if(p_type==9){type=19;}
	}
	if(s_type==2){
		if(p_type==1){type=21;}
		if(p_type==2){type=22;}
		if(p_type==3){type=23;}
		if(p_type==4){type=24;}
		if(p_type==5){type=25;}
		if(p_type==6){type=26;}
		if(p_type==7){type=27;}
		if(p_type==8){type=28;}
		if(p_type==9){type=29;}
	}
	if(s_type==3){
		if(p_type==1){type=31;}
		if(p_type==2){type=32;}
		if(p_type==3){type=33;}
		if(p_type==4){type=34;}
		if(p_type==5){type=35;}
		if(p_type==6){type=36;}
		if(p_type==7){type=37;}
		if(p_type==8){type=38;}
		if(p_type==9){type=39;}
	}
	if(s_type==4){
		if(p_type==1){type=41;}
		if(p_type==2){type=42;}
		if(p_type==3){type=43;}
		if(p_type==4){type=44;}
		if(p_type==5){type=45;}
		if(p_type==6){type=46;}
		if(p_type==7){type=47;}
		if(p_type==8){type=48;}
		if(p_type==9){type=49;}
	}
	
	refresh_al_country(type, al_country);
}












function remove_vblock(img_num) {
    if (req50.readyState == 4) {
        if (req50.status == 200) {
              	results = req50.responseText;
              	if(results==1){
              		//alert(results);
              		document.getElementById('img_'+img_num).style.display='none';}
              
  
        } else {
        }
    }
    return 0;
}

function rem_video(img_num){
	url50='http://www.kanzas.ua/components/add_new_building/remove_video.php?img='+img_num;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_vblock(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_vblock(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_video(img_num){
	//alert('rem');
	rem_video(img_num);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}





function remove_iblock(img_num) {
    if (req50.readyState == 4) {
        if (req50.status == 200) {
              	results = req50.responseText;
              	if(results==1){
              		//alert(results);
              		document.getElementById('img_'+img_num).style.display='none';}
              
  
        } else {
        }
    }
    return 0;
}

function remove_kblock(img_num) {
    if (req50.readyState == 4) {
        if (req50.status == 200) {
              	results = req50.responseText;
              	if(results==1){
              		//alert(results);
              		document.getElementById('imgk_'+img_num).style.display='none';}
              
  
        } else {
        }
    }
    return 0;
}

function rem_installment(img_num){
	url50='http://www.kanzas.ua/components/add_new_building/remove_installment.php?img='+img_num;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_iblock(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_iblock(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_installment(img_num){
	//alert('rem');
	rem_installment(img_num);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}



function rem_credit(img_num){
	url50='http://www.kanzas.ua/components/add_new_building/remove_credit.php?img='+img_num;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_iblock(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_iblock(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_credit(img_num){
	//alert('rem');
	rem_credit(img_num);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}

function rem_nbappartment(img_num){
	url50='http://www.kanzas.ua/components/add_new_building/remove_appartment.php?img='+img_num;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_iblock(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_iblock(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_nbappartment(img_num){
	//alert('rem');
	rem_nbappartment(img_num);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}

function rem_placement(img_num){
	url50='http://www.kanzas.ua/components/add_new_building/remove_placement.php?img='+img_num;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_kblock(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_kblock(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_placement(img_num){
	//alert('rem');
	rem_placement(img_num);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}










function remove_block(img_num) {
    if (req50.readyState == 4) {
        if (req50.status == 200) {
              	results = req50.responseText;
              	if(results==1){
              		//alert(results);
              		document.getElementById('img_'+img_num).style.display='none';}
              
  
        } else {
        }
    }
    return 0;
}

function rem_photo(img_num, hash_code){
	url50='http://www.kanzas.ua/components/edit_property/remove_img.php?img='+img_num+'&code='+hash_code;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_block(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_block(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_photo(img_num,hash_code){
	//alert('rem');
	rem_photo(img_num,hash_code);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}



function remove_block2(img_num) {
    if (req50.readyState == 4) {
        if (req50.status == 200) {
              	results = req50.responseText;
              	if(results==1){
              		//alert(results);
              		document.getElementById('img_'+img_num).style.display='none';}
              
  
        } else {
        }
    }
    return 0;
}

function rem_photo2(img_num, id, email){
	url50='http://www.kanzas.ua/components/add_new_building/remove_img.php?img='+img_num+'&id='+id;
    if (window.XMLHttpRequest) {
        req50 = new XMLHttpRequest();
        req50.onreadystatechange = function() {res50=remove_block(img_num);};
        req50.open("GET", url50, true);
        req50.send(null);
    } else if (window.ActiveXObject) {
        req50 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req50) {
            req50.onreadystatechange = function() {res50=remove_block(img_num);};
            req50.open("GET", url50, true);
            req50.send();
        }
    }
    return 0;
}

function remove_photo2(img_num,id,email){
	//alert('rem');
	rem_photo2(img_num,id,email);
	//document.getElementById('img_'+img_num).style.display='none';
	
	
	
}


//////////////////////////////////


function refresh_adress_line(rej){
	//alert(document.getElementById('price_1').value);

	rent_type=-1;
	price_min=document.getElementById('price_1').value;
	//price_min=document.filter_property_form.price_1.value;
	price_max=document.getElementById('price_2').value;
	s_min=document.getElementById('area_1').value;
	s_max=document.getElementById('area_2').value;
	region=document.getElementById('region').value;
	city=document.getElementById('city').value;
	district=document.getElementById('district').value;
	street=document.getElementById('street').value;
	motype=document.getElementById('otype').value;
	objtype=document.getElementById('objtype').value;
	rent_type=document.getElementById('rent_type').value;

	sort_by=2;
	if(rej==1){street=-1; district=-1; city=-1;}
	if(rej==2){street=-1; district=-1; }
	if(rej==3){street=-1; }
	if(rej==4){street=-1; }
	
	url='http://www.kanzas.ua/'+objtype+'/'+motype+'/f-1f'+price_min+'f'+price_max+'f'+s_min+'f'+s_max+'f'+region+'f'+city+'f'+district+'f-1f'+street+'f'+rent_type+'f'+sort_by;

	window.location = url;


}

function refresh_filter(rej){
	price_min=document.filter_property_form.price_1.value;
	price_max=document.filter_property_form.price_2.value;
	s_min=document.filter_property_form.area_1.value;
	s_max=document.filter_property_form.area_2.value;
	region=document.filter_property_form.region.value;
	city=document.filter_property_form.city.value;
	district=document.filter_property_form.district.value;
	motype=document.filter_property_form.motype.value;
	

	
	//alert (document.location.href);
	//document.write (document.location.href); 
	sort_by=2;
	if(rej==1){street=-1; district=-1; city=-1;}
	if(rej==2){street=-1; district=-1; }
	if(rej==3){street=-1; }
	if(rej==4){street=-1; }
	
	url='http://www.kanzas.ua/new_building/'+motype+'/-1/'+price_min+'/'+price_max+'/'+s_min+'/'+s_max+'/'+region+'/'+city+'/'+district+'/-1/';
	//alert(url);
	window.location = url;


}

function refresh_filter2(rej){
	price_min=document.filter_property_form.price_1.value;
	price_max=document.filter_property_form.price_2.value;
	s_min=document.filter_property_form.area_1.value;
	s_max=document.filter_property_form.area_2.value;
	region=document.filter_property_form.region.value;
	city=document.filter_property_form.city.value;
	district=document.filter_property_form.district.value;
	motype=document.filter_property_form.motype.value;
	

	
	//alert (document.location.href);
	//document.write (document.location.href); 
	sort_by=2;
	if(rej==1){street=-1; district=-1; city=-1;}
	if(rej==2){street=-1; district=-1; }
	if(rej==3){street=-1; }
	if(rej==4){street=-1; }
	
	url='http://www.kanzas.ua/new_building_proposition/'+motype+'/-1/'+price_min+'/'+price_max+'/'+s_min+'/'+s_max+'/'+region+'/'+city+'/'+district+'/-1/';
	//alert(url);
	window.location = url;


}

function refresh_country(rej){
	
	price_min=document.filter_property_form.price_1.value;
	price_max=document.filter_property_form.price_2.value;
	s_min=document.filter_property_form.area_1.value;
	s_max=document.filter_property_form.area_2.value;
	region=document.filter_property_form.region.value;
	objtype=document.filter_property_form.objtype.value;
	city=-1;
	district=-1;
	array=-1;
	street=-1;
	number=-1;
	motype=document.filter_property_form.otype.value;
	
	//alert(region);
	if(number==''){number=-1;}

	//alert (document.location.href);
	//document.write (document.location.href); 
	sort_by=2;

	
	url='http://www.kanzas.ua/'+objtype+'/'+motype+'/-1/'+price_min+'/'+price_max+'/'+s_min+'/'+s_max+'/'+region+'/'+city+'/'+district+'/'+array+'/'+street+'/'+number+'/'+sort_by+'/1';
	//alert(url);
	window.location = url;
	//echo 

}


function add_prop_own(){
	
	var honor_bright=document.add_property_form.owner.value;
	if(honor_bright==1){document.getElementById('div_honor_bright').style.display='block';}
	if(honor_bright==2){document.getElementById('div_honor_bright').style.display='none';}
	//alert(honor_bright);

}


function show_result(){
	
	view_type=document.getElementById('_view_type').value;
	if((view_type==1) || (view_type==2)){
	
		document.getElementById('result_div').style.height="auto";
		document.getElementById('sort_panel').style.visibility = 'visible';
			
			$('#result_div').css('opacity',0.5).fadeIn('slow');
			//document.getElementById('result_div').innerHTML="<div align='center' style='margin-top:100px'><img src='http://www.kanzas.ua/usr_img/loading.gif'></div>";
			var ajaxRequest;  // The variable that makes Ajax possible!
			
			try{
				// Opera 8.0+, Firefox, Safari
				ajaxRequest = new XMLHttpRequest();
			} catch (e){
				// Internet Explorer Browsers
				try{
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e){
						// Something went wrong
						//alert("Your browser broke!");
						document.getElementById('result_div').innerHTML="Internal error";
						return false;
					}
				}
			}
			// Create a function that will receive data sent from the server
			ajaxRequest.onreadystatechange = function(){
				if(ajaxRequest.readyState == 4){
					//alert(ajaxRequest.responseText);
					document.getElementById('result_div').innerHTML=ajaxRequest.responseText;
					$('#result_div').css('opacity',1).fadeIn('slow');
				}
			}

			
			var s_type=document.getElementById('_s_type').value;
			var p_type=document.getElementById('_p_type').value;
			var view_type=document.getElementById('_view_type').value;
			var sort=document.getElementById('_sort').value;
			var page=document.getElementById('_page').value;
			var btype=document.getElementById('_btype').value;
			var daily=document.getElementById('_daily').value;
			var owner=document.getElementById('_owner').value;
			var realtor=document.getElementById('_realtor').value;
			var no_commission=document.getElementById('_no_commission').value;
			var region=document.getElementById('_region').value;
			var city=document.getElementById('_city').value;
			var city_district=document.getElementById('_city_district').value;
			var street=document.getElementById('_street').value;
			var price_min=document.getElementById('_price_min').value;
			var price_max=document.getElementById('_price_max').value;
			var area_min=document.getElementById('_area_min').value;
			var area_max=document.getElementById('_area_max').value;
			var room_min=document.getElementById('_room_min').value;
			var room_max=document.getElementById('_room_max').value;
			var page=document.getElementById('_page').value;
			var country=document.getElementById('_country').value;
			var with_photo=document.getElementById('_with_photo').value;
			

			my_url="http://www.kanzas.ua/components/property_board/result.php?" +
					"s_type="+s_type+
					"&p_type="+p_type+
					"&view_type="+view_type+
					"&sort="+sort+
					"&region="+region+
					"&city="+city+
					"&city_district="+city_district+
					"&street="+street+
					"&price_min="+price_min+
					"&price_max="+price_max+
					"&area_min="+area_min+
					"&area_max="+area_max+
					"&room_min="+room_min+
					"&room_max="+room_max+
					"&page="+page+
					"&country="+country+
					"&btype="+btype+
					"&daily="+daily+
					"&owner="+owner+
					"&realtor="+realtor+
					"&no_commission="+no_commission+
					"&with_photo="+with_photo;
					//alert(my_url);
					
					ajaxRequest.open("GET", my_url, true);
					ajaxRequest.send(null); 
			
			
			
			
	}
	else{
		//alert('map');
		document.getElementById('sort_panel').style.visibility = 'hidden'; 
		document.getElementById('result_div').style.height="800px";
		
			var ajaxRequest;  // The variable that makes Ajax possible!
			
			try{
				// Opera 8.0+, Firefox, Safari
				ajaxRequest = new XMLHttpRequest();
			} catch (e){
				// Internet Explorer Browsers
				try{
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e){
						// Something went wrong
						//alert("Your browser broke!");
						//document.getElementById('result_div').innerHTML="Internal error";
						return false;
					}
				}
			}
			// Create a function that will receive data sent from the server
			ajaxRequest.onreadystatechange = function(){
				if(ajaxRequest.readyState == 4){
					//alert(ajaxRequest.responseText);
					show_my_markers(ajaxRequest.responseText);
					
					
				}
			}
			
			
			var s_type=document.getElementById('_s_type').value;
			var p_type=document.getElementById('_p_type').value;
			var view_type=document.getElementById('_view_type').value;
			var sort=document.getElementById('_sort').value;
			var page=document.getElementById('_page').value;
			var btype=document.getElementById('_btype').value;
			var daily=document.getElementById('_daily').value;
			var owner=document.getElementById('_owner').value;
			var realtor=document.getElementById('_realtor').value;
			var no_commission=document.getElementById('_no_commission').value;
			var region=document.getElementById('_region').value;
			var city=document.getElementById('_city').value;
			var city_district=document.getElementById('_city_district').value;
			var street=document.getElementById('_street').value;
			var price_min=document.getElementById('_price_min').value;
			var price_max=document.getElementById('_price_max').value;
			var area_min=document.getElementById('_area_min').value;
			var area_max=document.getElementById('_area_max').value;
			var room_min=document.getElementById('_room_min').value;
			var room_max=document.getElementById('_room_max').value;
			var page=document.getElementById('_page').value;
			var country=document.getElementById('_country').value;
			var with_photo=document.getElementById('_with_photo').value;
			
			my_url="http://www.kanzas.ua/components/property_board/map_result.php?" +
			"s_type="+s_type+
			"&p_type="+p_type+
			"&view_type="+view_type+
			"&sort="+sort+
			"&region="+region+
			"&city="+city+
			"&city_district="+city_district+
			"&street="+street+
			"&price_min="+price_min+
			"&price_max="+price_max+
			"&area_min="+area_min+
			"&area_max="+area_max+
			"&room_min="+room_min+
			"&room_max="+room_max+
			"&page="+page+
			"&country="+country+
			"&btype="+btype+
			"&daily="+daily+
			"&owner="+owner+
			"&realtor="+realtor+
			"&no_commission="+no_commission+
			"&with_photo="+with_photo;
			ajaxRequest.open("GET", my_url, true);
			ajaxRequest.send(null); 
		
	}
}



function getBalloonData(id) {
    var result="error";
    var myurl="http://www.kanzas.ua/components/property_board/balloon_data.php?id="+id;
    $.ajax({
    	
      url:myurl,
      async: false,  
      success:function(data) {
         result = data; 
      }
   });
   return result;
}

function getUrlData(url) {
    var result="error";
    var myurl=url;
    $.ajax({
    	
      url:myurl,
      async: false,  
      success:function(data) {
         result = data; 
      }
   });
   return result;
}

var displayMap = 1;

function mapscenter(){
	//alert('ok');
	map.setCenter(new YMaps.GeoPoint(30.308514, 50.278255), 10);
}

function getMapCenter(){
	
	region=document.getElementById('_region').value;
	city=document.getElementById('_city').value;
	city_district=document.getElementById('_city_district').value;
	street=document.getElementById('_street').value;
	ptype=document.getElementById('_p_type').value;
	country=document.getElementById('_country').value;
	my_url="http://www.kanzas.ua/components/property_board/map_center.php?region="+region+"&city="+city+"&city_district="+city_district+"&street="+street+"&ptype="+ptype+"&country="+country;
	mapCenter=getUrlData(my_url);
	
	return mapCenter;
}


var livemap=0;
var map;
function show_my_markers(coord_str) {
	
	if(livemap==0){
		livemap=1;
			//alert(displayMap);
			
			var $ = YMaps.jQuery,
		    clusterer = null,
		    msie = $.browser.msie,
		    markers = [];
		
			// load map
			map = new YMaps.Map(YMaps.jQuery("#result_div")[0]);

		    map.addControl(new YMaps.TypeControl());
		    map.addControl(new YMaps.Zoom());
		    
	}
	var my_mapCenter=new Array();
	var mapCenter = getMapCenter();
	my_mapCenter=mapCenter.split(',');
	map.setCenter(new YMaps.GeoPoint(my_mapCenter[0], my_mapCenter[1]), my_mapCenter[2]);
	
//if(isset(map)){alert("true");}else{alert("false");}
    

    // create clusterer object with some options
    var opts = {
      centered: msie ? false : true, // if not IE use centered clusters
      grid: msie ? 70 : 50 // for IE grid is bigger
    };
    clusterer = new YandexClusterer(map, [], opts);
    
    
	var bounds = map.getBounds(),
	pointLb = bounds.getLeftBottom(),
	span = bounds.getSpan(),
	use_cluster =  true;
    
    markers = [];
    if (clusterer) clusterer.clearMarkers(); // clear cluster markers

	var coord_arr=new Array();
	
	coord_arr=coord_str.split(';');
	
	
	var styleKeys = [
	        "default#lightbluePoint", "default#yellowPoint", "default#greenPoint",
	        "default#redPoint", "default#orangePoint",
	        "default#darkbluePoint", "default#nightPoint",
	        "default#greyPoint", "default#bluePoint",
	        "default#whitePoint", "default#darkorangePoint",
	        "default#pinkPoint", "default#violetPoint"
	    ];
	

		
	var s = new YMaps.Style();
	s.balloonContentStyle = new YMaps.BalloonContentStyle(
	    new YMaps.Template("$[description]")
	);
	
	var my_coord_arr=new Array();
	
	for(var i=0;i<coord_arr.length;i++){
		my_coord=coord_arr[i];
		my_coord_arr=my_coord.split(',');
		var k=0;
		if(my_coord_arr[3]==1){k=1;}
		if(my_coord_arr[3]==2){k=2;}
		if(my_coord_arr[3]==3){k=3;}
		if(my_coord_arr[3]==4){k=4;}
		if(my_coord_arr[3]==5){k=5;}
		if(my_coord_arr[3]==6){k=6;}
		//my_coord_arr[i]=my_coord.split(',');
	    var point = new YMaps.GeoPoint(my_coord_arr[0],my_coord_arr[1]);
	    var placemark = new YMaps.Placemark(point, {style:styleKeys[k]}, {style: s});
	    placemark.objectId = my_coord_arr[2];
	    placemark.description='<img src="http://www.kanzas.ua/usr_img/loading.gif">';
	    YMaps.Events.observe(placemark, placemark.Events.BalloonOpen, function (obj) {
	    	//getBalloonData(obj.objectId);
			obj.setBalloonContent(getBalloonData(obj.objectId));
			obj.update();
		});
	    
	    // map.addOverlay(placemark);
	    markers.push(placemark);
	}
	
	if (use_cluster) {
	    //clusterer = new YandexClusterer(map, markers, opts);
	    clusterer.setMarkers(markers); // add markers to clusterer
	    clusterer.repaint(); // update clusterer on map
	}
	


}




function table_result(){
	livemap=0;
	document.getElementById('view_table_button').style.color="#990000";
	document.getElementById('view_geo_button').style.color="#000000";
	document.getElementById('view_album_button').style.color="#000000";
	document.getElementById('_view_type').value=2;
	document.getElementById('_page').value=1;
	show_result();
	refresh_url();
	//alert('2');

}

function album_result(){
	livemap=0;
	document.getElementById('view_table_button').style.color="#000000";
	document.getElementById('view_geo_button').style.color="#000000";
	document.getElementById('view_album_button').style.color="#990000";
	document.getElementById('_view_type').value=1;
	document.getElementById('_page').value=1;
	show_result();
	refresh_url();
	//alert('1');

}

function map_result(){
	document.getElementById('view_table_button').style.color="#000000";
	document.getElementById('view_geo_button').style.color="#990000";
	document.getElementById('view_album_button').style.color="#000000";
	document.getElementById('_view_type').value=3;
	show_result();
	refresh_url();

}

function mouse_on_block(block){
	var s98='s98_'+block;
	var s99='s99_'+block;
	var s100='s100_'+block;
	var s101='s101_'+block;
	var s102='s102_'+block;
	var s103='s103_'+block;
	var s104='s104_'+block;
	
	document.getElementById(s98).setAttribute("class", "n98");
	document.getElementById(s99).setAttribute("class", "n99");
	document.getElementById(s100).setAttribute("class", "n100");
	document.getElementById(s101).setAttribute("class", "n101");
	document.getElementById(s102).setAttribute("class", "n102");
	document.getElementById(s103).setAttribute("class", "n103");
	document.getElementById(s104).setAttribute("class", "n104");
}

function mouse_out_block(block){
	var s98='s98_'+block;
	var s99='s99_'+block;
	var s100='s100_'+block;
	var s101='s101_'+block;
	var s102='s102_'+block;
	var s103='s103_'+block;
	var s104='s104_'+block;
	
	document.getElementById(s98).setAttribute("class", "s98");
	document.getElementById(s99).setAttribute("class", "s99");
	document.getElementById(s100).setAttribute("class", "s100");
	document.getElementById(s101).setAttribute("class", "s101");
	document.getElementById(s102).setAttribute("class", "s102");
	document.getElementById(s103).setAttribute("class", "s103");
	document.getElementById(s104).setAttribute("class", "s104");
}

function set_page(i){
	document.getElementById('_page').value=i;
	show_result();
	refresh_url();
//	alert(i);
}


function refresh_filter_country(){
	//show_country(region);
	country=document.getElementById('country').value;
	document.getElementById('_country').value=country;
	show_result();
	refresh_url();
}

function refresh_owner(th){
	if (document.getElementById('owner').checked){document.getElementById('_owner').value=1;}
	else{document.getElementById('_owner').value=0;}
	if (document.getElementById('realtor').checked){document.getElementById('_realtor').value=1;}
	else{document.getElementById('_realtor').value=0;}
	if (document.getElementById('no_commission').checked){document.getElementById('_no_commission').value=1;}
	else{document.getElementById('_no_commission').value=0;}
	if (document.getElementById('with_photo').checked){document.getElementById('_with_photo').value=1;}
	else{document.getElementById('_with_photo').value=0;}
	
	show_result();
	refresh_url();
}

function refresh_daily(){
	if (document.getElementById('daily').checked){document.getElementById('_daily').value=1;}
	else{document.getElementById('_daily').value=0;}

	show_result();
	refresh_url();
}


function refresh_region(){
	p_type=document.getElementById('_p_type').value;
	document.getElementById('_page').value=1;
	region = document.getElementById('region').value;
	document.getElementById('_region').value=region;
	view_type=document.getElementById('_view_type').value;
	
	if((p_type!=2)&&(p_type!=3)){
		document.getElementById('city_select').innerHTML='<select name="city" id="city" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		document.getElementById('city_district_select').innerHTML='<select name="city_district" id="city_district" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		document.getElementById('street_select').innerHTML='<select name="street" id="street" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		document.getElementById('_city').value=0;
		document.getElementById('_city_district').value=0;
		document.getElementById('_street').value=0;
		
		show_city(region);
		show_result();
		refresh_url();
		}
	else{
		document.getElementById('zone_select').innerHTML='<select name="zone" id="zone" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		document.getElementById('punct_select').innerHTML='<select name="punct" id="punct" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		document.getElementById('_city').value=0;
		document.getElementById('_city_district').value=0;
		document.getElementById('_street').value=0;
		show_zone(region);
		show_result();
		refresh_url();
	}
}

function refresh_zone(){
	p_type=document.getElementById('_p_type').value;
	document.getElementById('_page').value=1;
	region = document.getElementById('region').value;
	document.getElementById('_region').value=region;
	zone = document.getElementById('zone').value;
	document.getElementById('_city_district').value=zone;
	
	//alert(zone);
	
	document.getElementById('punct_select').innerHTML='<select name="punct" id="punct" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
	document.getElementById('_city').value=0;
	document.getElementById('_street').value=0;
	show_punct(zone);
	show_result();
	refresh_url();
	
}

function refresh_punct(){

	punct = document.getElementById('punct').value;
	document.getElementById('_city').value=punct;
	
	//alert(zone);
	
	
	//show_punct(zone);
	show_result();
	refresh_url();
	
}


function refresh_city(){
	document.getElementById('_page').value=1;
	p_type=document.getElementById('_p_type').value;
	city = document.getElementById('city').value;
	document.getElementById('_city').value=city;
	view_type=document.getElementById('_view_type').value;
	document.getElementById('city_district_select').innerHTML='<select name="city_district" id="city_district" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
	document.getElementById('_city_district').value=0;
	
	city_district = document.getElementById('city_district').value;
	if((p_type!=2)&&(p_type!=3)){
		document.getElementById('_street').value=0;
		document.getElementById('street_select').innerHTML='<select name="street" id="street" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		show_city_district(city);
		//show_street(city,city_district);
		
		show_result();
		refresh_url();
	}else{
		show_punct(city);
		show_result();
	}
}

function refresh_city_district(){
	document.getElementById('_page').value=1;
	p_type=document.getElementById('_p_type').value;
	city_district = document.getElementById('city_district').value;
	document.getElementById('_city_district').value=city_district;
	if((p_type!=2)&&(p_type!=3)){
		document.getElementById('_street').value=0;
		document.getElementById('street_select').innerHTML='<select name="street" id="street" disabled="disabled" style="width:100%"><option value="0">Все</option></select>';
		city = document.getElementById('_city').value;
		show_street(city,city_district);
		
		show_result();
		refresh_url();
	}
	else{
		show_result();
		
	}
	
}

function refresh_street(){
	document.getElementById('_page').value=1;
	view_type=document.getElementById('_view_type').value;
	street = document.getElementById('street').value;
	document.getElementById('_street').value=street;
	show_result();
	refresh_url();
}


function refresh_room_min(){
	livemap=0;
	room_min = document.getElementById('room_min').value;
	document.getElementById('_room_min').value=room_min;
	show_room_max(room_min);

	show_result();
	refresh_url();
}

function refresh_area_min(){
	livemap=0;
	area_min = document.getElementById('area_min').value;
	document.getElementById('_area_min').value=area_min;
	show_area_max(area_min);
	show_result();
	refresh_url();
}

function refresh_area_min2(){
	livemap=0;
	area_min = document.getElementById('area_min').value;
	document.getElementById('_area_min').value=area_min;
	show_area_max2(area_min);
	show_result();
	refresh_url();
}

function IsNumeric(val) {

    if (isNaN(val)) {

          return false;

     }

     return true;

}

	

function number_format (number, decimals, dec_point, thousands_sep) {

    number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
    var n = !isFinite(+number) ? 0 : +number,
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);            return '' + Math.round(n * k) / k;
        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');    }
    return s.join(dec);
}


function refresh_price_min(){
	livemap=0;
	price_min = document.getElementById('price_min').value;
	price_min=price_min.replace(' ','');
	price_min=price_min.replace(' ','');
	price_min=price_min.replace(' ','');
	price_min=price_min.replace(' ','');
	price_min=price_min.replace(' ','');
	if(IsNumeric(price_min)){
		if(price_min>0){price_min=parseInt(price_min,10);
		
		
		document.getElementById('price_min').value=number_format(price_min, 0, ',', ' ');
		document.getElementById('_price_min').value=price_min;
		
		}else{document.getElementById('price_min').value='';}
		
		}else{document.getElementById('price_min').value='';}
	
	
	if(document.getElementById('_price_max').value<price_min){document.getElementById('price_max').value='';document.getElementById('_price_max').value=0;}

	show_result();
	refresh_url();
}



function refresh_room_max(){
	livemap=0;
	room_max = document.getElementById('room_max').value;
	document.getElementById('_room_max').value=room_max;
	show_result();
	refresh_url();
}

function refresh_area_max(){
	livemap=0;
	area_max = document.getElementById('area_max').value;
	document.getElementById('_area_max').value=area_max;
	show_result();
	refresh_url();
}

function refresh_price_max(){
	livemap=0;
	price_max = document.getElementById('price_max').value;
	price_max=price_max.replace(' ','');
	price_max=price_max.replace(' ','');
	price_max=price_max.replace(' ','');
	price_max=price_max.replace(' ','');
	price_max=price_max.replace(' ','');
	if(IsNumeric(price_max)){
		if(price_max>0){price_max=parseInt(price_max,10);
		
		
		document.getElementById('price_max').value=number_format(price_max, 0, ',', ' ');
		document.getElementById('_price_max').value=price_max;
		
		}else{document.getElementById('price_max').value='';}
		
		}else{document.getElementById('price_max').value='';}
	
	if(document.getElementById('_price_min').value>price_max){document.getElementById('price_min').value='';document.getElementById('_price_min').value=0;}

	show_result();
	refresh_url();
}

function refresh_btype(){
	livemap=0;
	btype = document.getElementById('btype').value;
	document.getElementById('_btype').value=btype;
	show_result();
	refresh_url();
}


function sort_result(i){

	document.getElementById('sort1').className ="sort_by_disabled";
	document.getElementById('sort2').className ="sort_by_disabled";
	document.getElementById('sort3').className ="sort_by_disabled";
	document.getElementById('sort4').className ="sort_by_disabled";
	document.getElementById('sort5').className ="sort_by_disabled";
	
	sort = document.getElementById('_sort').value;
	//alert(i + ' sort = ' + sort);
	if(i==1){if(sort==1){iy=0;}else{iy=1;}}
	if(i==2){if(sort==3){iy=2;}else{iy=3;}}
	if(i==3){if(sort==5){iy=4;}else{iy=5;}}
	if(i==4){if(sort==7){iy=6;}else{iy=7;}}
	if(i==5){if(sort==9){iy=8;}else{iy=9;}}
	//alert('iy = '+iy);
	if(iy==0){document.getElementById('sort1').className ="sort_by_up";}
	if(iy==1){document.getElementById('sort1').className ="sort_by_down";}
	
	if(iy==2){document.getElementById('sort2').className ="sort_by_up";}
	if(iy==3){document.getElementById('sort2').className ="sort_by_down";}
	
	if(iy==4){document.getElementById('sort3').className ="sort_by_up";}
	if(iy==5){document.getElementById('sort3').className ="sort_by_down";}
	
	if(iy==6){document.getElementById('sort4').className ="sort_by_up";}
	if(iy==7){document.getElementById('sort4').className ="sort_by_down";}
	
	if(iy==8){document.getElementById('sort5').className ="sort_by_up";}
	if(iy==9){document.getElementById('sort5').className ="sort_by_down";}
	
	document.getElementById('_sort').value=iy;
	//alert('iy = '+iy);
	//alert(document.getElementById('sort').value);
	show_result();
	refresh_url();
}


function show_price_max(price_min){

	var ajaxRequest; 
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				document.getElementById('select_price_max').innerHTML="Internal error";
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('select_price_max').innerHTML=ajaxRequest.responseText;

		}
	}
		
	my_url="http://www.kanzas.ua/components/property_board/ajax_price_max.php?price_min="+price_min;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_area_max(area_min){

	var ajaxRequest; 
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				document.getElementById('select_area_max').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('select_area_max').innerHTML=ajaxRequest.responseText;
			

		}
	}
		

	my_url="http://www.kanzas.ua/components/property_board/ajax_area_max.php?area_min="+area_min;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}



function show_area_max2(area_min){

	var ajaxRequest; 
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				document.getElementById('select_area_max').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('select_area_max').innerHTML=ajaxRequest.responseText;
			

		}
	}
		

	my_url="http://www.kanzas.ua/components/property_board/ajax_area_max2.php?area_min="+area_min;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_room_max(room_min){

	var ajaxRequest; 
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				document.getElementById('select_room_max').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('select_room_max').innerHTML=ajaxRequest.responseText;
			

		}
	}
		

	my_url="http://www.kanzas.ua/components/property_board/ajax_room_max.php?room_min="+room_min;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_city(region){

	var ajaxRequest; 
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				document.getElementById('city_select').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('city_select').innerHTML=ajaxRequest.responseText;
			
			//refresh_city();
			//refresh_city_district();
			//refresh_street();

		}
	}
		
	var s_type=document.getElementById('_s_type').value;
	var p_type=document.getElementById('_p_type').value;
	my_url="http://www.kanzas.ua/components/property_board/ajax_city_select.php?region="+region+"&s_type="+s_type+"&p_type="+p_type;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_zone(region){

	var ajaxRequest; 
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				document.getElementById('zone_select').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('zone_select').innerHTML=ajaxRequest.responseText;
			
			//refresh_city();
			//refresh_city_district();
			//refresh_street();

		}
	}
		
	var s_type=document.getElementById('_s_type').value;
	var p_type=document.getElementById('_p_type').value;
	my_url="http://www.kanzas.ua/components/property_board/ajax_zone_select.php?region="+region+"&s_type="+s_type+"&p_type="+p_type;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_city_district(city){
	//alert(city);
	//document.getElementById('result_div').innerHTML="<div align='center' style='margin-top:100px'><img src='http://www.kanzas.ua/usr_img/loading.gif'></div>";
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				//alert("Your browser broke!");
				document.getElementById('city_district_select').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('city_district_select').innerHTML=ajaxRequest.responseText;
			//refresh_city_district();
			//refresh_street();

		}
	}
		
	var s_type=document.getElementById('_s_type').value;
	var p_type=document.getElementById('_p_type').value;
	my_url="http://www.kanzas.ua/components/property_board/ajax_city_district_select.php?city="+city+"&s_type="+s_type+"&p_type="+p_type;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_punct(city){
	//alert(city);
	//document.getElementById('result_div').innerHTML="<div align='center' style='margin-top:100px'><img src='http://www.kanzas.ua/usr_img/loading.gif'></div>";
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				//alert("Your browser broke!");
				document.getElementById('punct_select').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('punct_select').innerHTML=ajaxRequest.responseText;
			//refresh_city_district();
			//refresh_street();
		}
	}


	var s_type=document.getElementById('_s_type').value;
	var p_type=document.getElementById('_p_type').value;
	my_url="http://www.kanzas.ua/components/property_board/ajax_punct_select.php?city="+city+"&s_type="+s_type+"&p_type="+p_type;

	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function show_street(city,city_disctrict){
	//alert(city);
	//alert('ok');
	//document.getElementById('result_div').innerHTML="<div align='center' style='margin-top:100px'><img src='http://www.kanzas.ua/usr_img/loading.gif'></div>";
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				//alert("Your browser broke!");
				document.getElementById('street_select').innerHTML="Internal error";
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//alert(ajaxRequest.responseText);
			document.getElementById('street_select').innerHTML=ajaxRequest.responseText;
			

		}
	}
		
	var s_type=document.getElementById('_s_type').value;
	var p_type=document.getElementById('_p_type').value;
	my_url="http://www.kanzas.ua/components/property_board/ajax_street_select.php?city="+city+"&city_district="+city_district+"&s_type="+s_type+"&p_type="+p_type;
	
	ajaxRequest.open("GET", my_url, true);
	ajaxRequest.send(null); 
}


function go(main_url, property_id){ 
	window.location = main_url+'view_property/'+property_id+'/'; }


function make_export(){
myurl='http://www.kanzas.ua/export/';
	
	s_type=document.getElementById('_s_type').value; 
	p_type=document.getElementById('_p_type').value;
	view_type=document.getElementById('_view_type').value;
	sort=document.getElementById('_sort').value;
	region=document.getElementById('_region').value;
	city=document.getElementById('_city').value;
	city_district=document.getElementById('_city_district').value;
	street=document.getElementById('_street').value;
	price_min=document.getElementById('_price_min').value;
	price_max=document.getElementById('_price_max').value;
	area_min=document.getElementById('_area_min').value;
	area_max=document.getElementById('_area_max').value;
	room_min=document.getElementById('_room_min').value;
	room_max=document.getElementById('_room_max').value;
	page=document.getElementById('_page').value;
	country=document.getElementById('_country').value;
	btype=document.getElementById('_btype').value;
	daily=document.getElementById('_daily').value;
	owner=document.getElementById('_owner').value;
	realtor=document.getElementById('_realtor').value;
	no_commission=document.getElementById('_no_commission').value;
	country=document.getElementById('_country').value;
	with_photo=document.getElementById('_with_photo').value;
//alert(btype);
 	
	//alert(price_min);

	
	if(s_type==1){s_type_name='prodazha';}
	else if(s_type==2){s_type_name='pokupka';}
	else if(s_type==3){s_type_name='sdacha';}
	else if(s_type==4){s_type_name='arenda';}
	else{s_type_name='prodazha';}
	myurl=myurl+s_type_name;
	
	
	if(p_type==1){p_type_name='-kvartir';}
	else if(p_type==2){p_type_name='-domov';}
	else if(p_type==3){p_type_name='-zemli';}
	else if(p_type==4){p_type_name='-ofisov';}
	else if(p_type==5){p_type_name='-torgovuh_pomesheniy';}
	else if(p_type==6){p_type_name='-skladov';}
	else if(p_type==7){p_type_name='-garagey';}
	else if(p_type==8){p_type_name='-biznesa';}
	else if(p_type==9){p_type_name='-zarubezhnoj_nedvizhumosti';}
	myurl=myurl+p_type_name;
	
	if(city!=0){
		city_name=getUrlData('http://www.kanzas.ua/components/property_board/get_name.php?city='+city);
		city_name_array=explode(';', city_name, 2);
		myurl=myurl+'-'+city_name_array[0];
	}
	if(street!=0){
		street_name=getUrlData('http://www.kanzas.ua/components/property_board/get_name.php?street='+street);
		street_name_array=explode(';', street_name, 2);
		myurl=myurl+'-'+street_name_array[0];
	}
	
	
	
	myurl=myurl+'/';
	var urlhash=''; 
	

	urlhash=urlhash+view_type;
	
	//urlhash=urlhash+'|';
	
	if(country==0){
		urlhash=urlhash+"000";	
	}else{
		if(country.length==2){urlhash=urlhash+"0"+country;}
		else if(country.length==3){urlhash=urlhash+country;}
	}
	
	//urlhash=urlhash+'|';
	
	if(region==0){
		urlhash=urlhash+"00";	
	}else{
		//alert(region.length);
		if(region.length==1){urlhash=urlhash+"0" + region;}
		else if(region.length==2){urlhash=urlhash+region;}
	}
	
	//urlhash=urlhash+'|';
	
	if(city_district==0){
		urlhash=urlhash+"000";	
	}else{
		//alert(city_district.length);
		if(city_district.length==1){urlhash=urlhash+"00"+city_district;}
		else if(city_district.length==2){urlhash=urlhash+"0"+city_district;}
		else if(city_district.length==3){urlhash=urlhash+city_district;}
	}
	
	//urlhash=urlhash+'|';
	
	if(sort.length==1){urlhash=urlhash+"0" + sort;}
	else if(sort.length==2){urlhash=urlhash+sort;}
	
	//urlhash=urlhash+'|';

	urlhash=urlhash+room_min;
	urlhash=urlhash+room_max;
	
	
	
	if(area_min==0){
		urlhash=urlhash+'00';	
	}else{
		//alert(city_district.length);
		if(area_min.length==1){urlhash=urlhash+'0'+area_min;}
		else if(area_min.length==2){urlhash=urlhash+area_min;}
	}
	if(area_max==0){
		urlhash=urlhash+'00';	
	}else{
		//alert(city_district.length);
		if(area_max.length==1){urlhash=urlhash+'0'+area_max;}
		else if(area_max.length==2){urlhash=urlhash+area_max;}
	}
	
	//urlhash=urlhash+'|';

	if(btype.length==1){urlhash=urlhash+"0" + btype;}
	else if(btype.length==2){urlhash=urlhash+btype;}
	
	//urlhash=urlhash+'|';
	
	if(owner==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(realtor==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(no_commission==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(daily==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(with_photo==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	//urlhash=urlhash+'|';
	
	//alert(urlhash);
	
	if(page==0){
		urlhash=urlhash+'00000';	
	}else{
		//alert(city_district.length);
		if(page.length==1){urlhash=urlhash+'0000'+page;}
		else if(page.length==2){urlhash=urlhash+'000'+page;}
		else if(page.length==3){urlhash=urlhash+'00'+page;}
		else if(page.length==4){urlhash=urlhash+'0'+page;}
		else if(page.length==5){urlhash=urlhash+page;}
	}
	
	urlhash=urlhash+'m';
	urlhash=urlhash+price_min;
	urlhash=urlhash+'m';
	urlhash=urlhash+price_max;
	
	//alert('owner='+owner+'; realtor='+realtor+'; no_commission='+no_commission+'; daily='+daily);
	//alert(urlhash);
	
	myhash=getUrlData('http://www.kanzas.ua/components/property_board/crypt_url.php?crypt='+urlhash);
	
	myurl=myurl+myhash+'/';
	
	//history.pushState(null, "Kanzas.ua", myurl);
	
	window.location = myurl;
	//window.open(url,'_blank');
}


function explode (delimiter, string, limit) {
    // Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/explode    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
    var emptyArray = {        0: ''
    };
 
    // third argument is not required
    if (arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined') {        return null;
    }
 
    if (delimiter === '' || delimiter === false || delimiter === null) {
        return false;    }
 
    if (typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object') {
        return emptyArray;
    } 
    if (delimiter === true) {
        delimiter = '1';
    }
     if (!limit) {
        return string.toString().split(delimiter.toString());
    }
    // support for limit argument
    var splitted = string.toString().split(delimiter.toString());    var partA = splitted.splice(0, limit - 1);
    var partB = splitted.join(delimiter.toString());
    partA.push(partB);
    return partA;
}



function refresh_crumbs(s_type,p_type,city,street,city_name_en,city_name_ru,street_name_en,street_name_ru){
	
	crumbs='<a href="http://www.kanzas.ua/"><img alt="kanzas.ua" class="s76" src="/sprites/x.gif" /></a>';
	
	if(s_type==1){s_type_name='prodazha'; 		s_type_sname='Продажа ';}
	else if(s_type==2){s_type_name='pokupka';	s_type_sname='Покупка ';}
	else if(s_type==3){s_type_name='sdacha'; 	s_type_sname='Сдача ';}
	else if(s_type==4){s_type_name='arenda'; 	s_type_sname='Аренда ';}
	else{s_type_name='prodazha';				s_type_sname='Продажа ';}
		
	
	if(p_type==1){p_type_name='-kvartir'; p_type_sname='квартир';}
	else if(p_type==2){p_type_name='-domov'; p_type_sname='домов';}
	else if(p_type==3){p_type_name='-zemli'; p_type_sname='земли';}
	else if(p_type==4){p_type_name='-ofisov'; p_type_sname='офисов';}
	else if(p_type==5){p_type_name='-torgovuh_pomesheniy'; p_type_sname='торговых помещений';}
	else if(p_type==6){p_type_name='-skladov'; p_type_sname='складов';}
	else if(p_type==7){p_type_name='-garagey'; p_type_sname='гаражей';}
	else if(p_type==8){p_type_name='-biznesa'; p_type_sname='бизнеса';}
	else if(p_type==9){p_type_name='-zarubezhnoj_nedvizhumosti'; p_type_sname='зарубежной недвижимости';}
	
	if(city_name_en!=0){
		
		if(street_name_en!=0){
			crumbs=crumbs+'<a href="http://www.kanzas.ua/nedvizhimost/'+s_type_name+p_type_name+'/">'+s_type_sname+p_type_sname+'</a> <img alt="arrow" class="s32" src="/images/arrow_2.gif" /> <a href="http://www.kanzas.ua/nedvizhimost/'+s_type_name+p_type_name+'-'+city_name_en+'/">'+city_name_ru+'</a> <img alt="arrow" class="s32" src="/images/arrow_2.gif" /> '+street_name_ru;
		}
		else{
			crumbs=crumbs+'<a href="http://www.kanzas.ua/nedvizhimost/'+s_type_name+p_type_name+'/">'+s_type_sname+p_type_sname+'</a> <img alt="arrow" class="s32" src="/images/arrow_2.gif" /> '+city_name_ru;
		}
	
	}
	else{
		crumbs=crumbs+''+s_type_sname+p_type_sname;
	}
	
	
	
	
	
	document.getElementById('bred_crumbs').innerHTML=crumbs;
}




function refresh_url(){
	
	
	
	document.getElementById('seo_text').innerHTML='';
	
	myurl='http://www.kanzas.ua/nedvizhimost/';
	
	s_type=document.getElementById('_s_type').value; 
	p_type=document.getElementById('_p_type').value;
	view_type=document.getElementById('_view_type').value;
	sort=document.getElementById('_sort').value;
	region=document.getElementById('_region').value;
	city=document.getElementById('_city').value;
	city_district=document.getElementById('_city_district').value;
	street=document.getElementById('_street').value;
	price_min=document.getElementById('_price_min').value;
	price_max=document.getElementById('_price_max').value;
	area_min=document.getElementById('_area_min').value;
	area_max=document.getElementById('_area_max').value;
	room_min=document.getElementById('_room_min').value;
	room_max=document.getElementById('_room_max').value;
	page=document.getElementById('_page').value;
	country=document.getElementById('_country').value;
	btype=document.getElementById('_btype').value;
	daily=document.getElementById('_daily').value;
	owner=document.getElementById('_owner').value;
	realtor=document.getElementById('_realtor').value;
	no_commission=document.getElementById('_no_commission').value;
	country=document.getElementById('_country').value;
	with_photo=document.getElementById('_with_photo').value;
	
//alert(btype);
 	
	//alert(price_min);

	
	if(s_type==1){s_type_name='prodazha';}
	else if(s_type==2){s_type_name='pokupka';}
	else if(s_type==3){s_type_name='sdacha';}
	else if(s_type==4){s_type_name='arenda';}
	else{s_type_name='prodazha';}
	myurl=myurl+s_type_name;
	
	
	
	if(p_type==1){p_type_name='-kvartir';}
	else if(p_type==2){p_type_name='-domov';}
	else if(p_type==3){p_type_name='-zemli';}
	else if(p_type==4){p_type_name='-ofisov';}
	else if(p_type==5){p_type_name='-torgovuh_pomesheniy';}
	else if(p_type==6){p_type_name='-skladov';}
	else if(p_type==7){p_type_name='-garagey';}
	else if(p_type==8){p_type_name='-biznesa';}
	else if(p_type==9){p_type_name='-zarubezhnoj_nedvizhumosti';}
	myurl=myurl+p_type_name;
	
	city_name=0;
	street_name=0;
	street_name_ru=0;
	street_name_en=0;
	city_name_ru=0;
	city_name_en=0;
	
	
	if((p_type==2)||(p_type==3)){
		//
		if(city!=0){
			city_name=getUrlData('http://www.kanzas.ua/components/property_board/get_name.php?punct='+city);
			city_name_array=explode(';', city_name, 2);
			myurl=myurl+'-'+city_name_array[0];	
			city_name_ru=city_name_array[1];
			city_name_en=city_name_array[0];
		}else{
			city_name_ru=0;
			city_name_en=0;
		}
	}else{
		if(city!=0){
			city_name=getUrlData('http://www.kanzas.ua/components/property_board/get_name.php?city='+city);
			city_name_array=explode(';', city_name, 2);
			myurl=myurl+'-'+city_name_array[0];	
			city_name_ru=city_name_array[1];
			city_name_en=city_name_array[0];
		}
		else{
			city_name_ru=0;
			city_name_en=0;
		}
	}
	
	if(street!=0){
		street_name=getUrlData('http://www.kanzas.ua/components/property_board/get_name.php?street='+street);
		street_name_array=explode(';', street_name, 2);
		myurl=myurl+'-'+street_name_array[0];
		street_name_ru=street_name_array[1];
		street_name_en=street_name_array[0];
	}else{
		street_name_ru=0;
		street_name_en=0;
	}
	
	refresh_crumbs(s_type,p_type,city,street,city_name_en,city_name_ru,street_name_en,street_name_ru);
	
	//if(p_type==2){alert(city_district);}
	
	myurl=myurl+'/';
	var urlhash=''; 
	

	urlhash=urlhash+view_type;
	
	//urlhash=urlhash+'|';
	
	if(country==0){
		urlhash=urlhash+"000";	
	}else{
		if(country.length==2){urlhash=urlhash+"0"+country;}
		else if(country.length==3){urlhash=urlhash+country;}
	}
	
	//urlhash=urlhash+'|';
	
	if(region==0){
		urlhash=urlhash+"00";	
	}else{
		//alert(region.length);
		if(region.length==1){urlhash=urlhash+"0" + region;}
		else if(region.length==2){urlhash=urlhash+region;}
	}
	
	//urlhash=urlhash+'|';
	
	if(city_district==0){
		urlhash=urlhash+"000";	
	}else{
		//alert(city_district.length);
		if(city_district.length==1){urlhash=urlhash+"00"+city_district;}
		else if(city_district.length==2){urlhash=urlhash+"0"+city_district;}
		else if(city_district.length==3){urlhash=urlhash+city_district;}
	}
	
	//urlhash=urlhash+'|';
	
	if(sort.length==1){urlhash=urlhash+"0" + sort;}
	else if(sort.length==2){urlhash=urlhash+sort;}
	
	//urlhash=urlhash+'|';

	urlhash=urlhash+room_min;
	urlhash=urlhash+room_max;
	
	
	
	if(area_min==0){
		urlhash=urlhash+'00';	
	}else{
		//alert(city_district.length);
		if(area_min.length==1){urlhash=urlhash+'0'+area_min;}
		else if(area_min.length==2){urlhash=urlhash+area_min;}
	}
	if(area_max==0){
		urlhash=urlhash+'00';	
	}else{
		//alert(city_district.length);
		if(area_max.length==1){urlhash=urlhash+'0'+area_max;}
		else if(area_max.length==2){urlhash=urlhash+area_max;}
	}
	
	//urlhash=urlhash+'|';

	if(btype.length==1){urlhash=urlhash+"0" + btype;}
	else if(btype.length==2){urlhash=urlhash+btype;}
	
	//urlhash=urlhash+'|';
	
	if(owner==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(realtor==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(no_commission==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(daily==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	if(with_photo==0){urlhash=urlhash+'0';}else{urlhash=urlhash+'1';}
	//urlhash=urlhash+'|';
	
	//alert(urlhash);
	
	if(page==0){
		urlhash=urlhash+'00000';	
	}else{
		//alert(city_district.length);
		if(page.length==1){urlhash=urlhash+'0000'+page;}
		else if(page.length==2){urlhash=urlhash+'000'+page;}
		else if(page.length==3){urlhash=urlhash+'00'+page;}
		else if(page.length==4){urlhash=urlhash+'0'+page;}
		else if(page.length==5){urlhash=urlhash+page;}
	}
	
	urlhash=urlhash+'m';
	urlhash=urlhash+price_min;
	urlhash=urlhash+'m';
	urlhash=urlhash+price_max;
	
	//alert('owner='+owner+'; realtor='+realtor+'; no_commission='+no_commission+'; daily='+daily);
	//alert(urlhash);
	
	myhash=getUrlData('http://www.kanzas.ua/components/property_board/crypt_url.php?crypt='+urlhash);
	
	myurl=myurl+myhash+'/';
	
	history.pushState(null, "Kanzas.ua", myurl);
}



function ckeak_phone(){
	
var phone=document.getElementById('phone').value;

phone=getUrlData('http://www.kanzas.ua/components/phone_base/format_number.php?phone='+phone);

document.getElementById('phone').value=phone;

document.getElementById('phone_result').innerHTML=getUrlData('http://www.kanzas.ua/components/phone_base/result.php?phone='+phone);

}


function subscribe_property(){
	
	s_type=document.getElementById('_s_type').value; 
	p_type=document.getElementById('_p_type').value;
	view_type=document.getElementById('_view_type').value;
	sort=document.getElementById('_sort').value;
	region=document.getElementById('_region').value;
	city=document.getElementById('_city').value;
	city_district=document.getElementById('_city_district').value;
	street=document.getElementById('_street').value;
	price_min=document.getElementById('_price_min').value;
	price_max=document.getElementById('_price_max').value;
	area_min=document.getElementById('_area_min').value;
	area_max=document.getElementById('_area_max').value;
	room_min=document.getElementById('_room_min').value;
	room_max=document.getElementById('_room_max').value;
	country=document.getElementById('_country').value;
	btype=document.getElementById('_btype').value;
	daily=document.getElementById('_daily').value;
	owner=document.getElementById('_owner').value;
	realtor=document.getElementById('_realtor').value;
	no_commission=document.getElementById('_no_commission').value;
	country=document.getElementById('_country').value;
	with_photo=document.getElementById('_with_photo').value;
	
	subscribe_url='http://www.kanzas.ua/components/subscribe/add_property.php?s_type='+s_type+
	'&p_type='+p_type+
	'&view_type='+view_type+
	'&sort='+sort+
	'&region='+region+
	'&city='+city+
	'&city_district='+city_district+
	'&street='+street+
	'&price_min='+price_min+
	'&price_max='+price_max+
	'&area_min='+area_min+
	'&area_max='+area_max+
	'&room_min='+room_min+
	'&room_max='+room_max+
	'&country='+country+
	'&btype='+btype+
	'&daily='+daily+
	'&owner='+owner+
	'&realtor='+realtor+
	'&no_commission='+no_commission+
	'&country='+country+
	'&with_photo='+with_photo;
		
	myhash=getUrlData(subscribe_url);
	
	if(myhash==2){alert('Вам необходимо зарегистироваться или авторизироваться.');}
	else{alert('Вы подписаны на еженедельную рассылку.');}

}





function validatePhone(){
	var	phone=document.getElementById('input_phone').value;

	 if(!phone.match(/^[0-9\+\-\)\(\ ]{7,19}$/)){
			  document.getElementById('phone_error').innerHTML='Введите корректный номер телефона (с кодом).';
			  document.getElementById('phone_error').style.visibility='visible';
		 	  var x = document.getElementById("img_phone_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re1=0;
		 }
	 
	 else{		 
		  document.getElementById('phone_error').style.visibility='hidden';
		  var y = document.getElementById("img_phone_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re1=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		  phone=getUrlData('http://www.kanzas.ua/components/phone_base/format_number.php?phone='+phone);
		  document.getElementById('input_phone').value=phone;
		 }
 }


function validateRegion(){	
	
	var	region=document.getElementById('select_region').value;
	
	if(region==0){
			  document.getElementById('adress_error').innerHTML='Введите полный адрес.';
			  document.getElementById('adress_error').style.visibility='visible';
		 	  var x = document.getElementById("img_adress_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re2=0;
		 }
	 
	 else{		  
		  document.getElementById('adress_error').style.visibility='hidden';
		  var y = document.getElementById("img_adress_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re2=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		 }
 }



function validateForeign(){	
	
	var	city=document.getElementById('input_city').value;
	var	adress=document.getElementById('input_adress').value;
	 
	if ((city.length>2) && (adress.length>2)){		 
		  document.getElementById('adress_error').style.visibility='hidden';
		  var y = document.getElementById("img_adress_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re2=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		 }
	
	else {
			  document.getElementById('adress_error').innerHTML='Введите полный адрес.';
			  document.getElementById('adress_error').style.visibility='visible';
		 	  var x = document.getElementById("img_adress_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re2=0;
		 }

 }



function validateHouse(){
	var	adress=document.getElementById('input_house').value;

	 if(!adress.match(/^[а-яА-Яa-zA-Z0-9\/\ \.]{1,6}$/)){
			  document.getElementById('adress_error').innerHTML='Введите корректный полный адрес.';
			  document.getElementById('adress_error').style.visibility='visible';
		 	  var x = document.getElementById("img_adress_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re2=0;
		 }
	 
	 else{		 
		  document.getElementById('adress_error').style.visibility='hidden';
		  var y = document.getElementById("img_adress_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re2=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		 }
 }



function unvalid()
{	document.getElementById('adress_error').style.visibility='hidden';
	var x = document.getElementById("img_adress_check");
	x.setAttribute("src", "/images/reg_img_star.gif");
	re2=0
}



function validatePrice(){
	var	price=document.getElementById('input_price').value;

	 if(!price.match(/^[0-9]{2,9}$/)){
			  document.getElementById('price_error').innerHTML='Укажите корректную сумму.';
			  document.getElementById('price_error').style.visibility='visible';
		 	  var x = document.getElementById("img_price_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re3=0;
		 }
	 
	 else{
		  if (price.length==9) 
		  { document.getElementById('price_error').innerHTML='Не дороговато ли? ))';
		    document.getElementById('price_error').style.visibility='visible' }
		  else { document.getElementById('price_error').style.visibility='hidden' }
		  var y = document.getElementById("img_price_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re3=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		 }
 }



function validateArea(){
	var	area=document.getElementById('input_area').value;

	 if(!area.match(/^[0-9\.\,]{1,5}$/)){
			  document.getElementById('area_error').innerHTML='Укажите корректную площадь.';
			  document.getElementById('area_error').style.visibility='visible';
		 	  var x = document.getElementById("img_area_check");
			  x.setAttribute("src", "/images/reg_img_star.gif");
			  re4=0;
		 }
	 
	 else{
		  document.getElementById('area_error').style.visibility='hidden'
		  var y = document.getElementById("img_area_check");
		  y.setAttribute("src", "/images/reg_img_ok.gif");
		  re4=1;
		  document.getElementById('registration_error').style.visibility='hidden';
		 }
 }




function add_property_form_submit1(){
	//alert('re5='+re5);
	if((re1==1) && (re2==1) && (re3==1) && (re4==1) && (re5==1))
	{ document.forms["add_property_form"].submit(); }
	else {
		if(re5!=1) {document.getElementById('registration_error').innerHTML='Пожалуйста, введите правильно проверочный код.';
		document.getElementById('registration_error').style.visibility='visible';}

		if(re4!=1) {document.getElementById('registration_error').innerHTML='Пожалуйста, укажите корректную площадь.';
		document.getElementById('registration_error').style.visibility='visible';}
		
		if(re3!=1) {document.getElementById('registration_error').innerHTML='Пожалуйста, укажите корректную сумму.';
		document.getElementById('registration_error').style.visibility='visible';}
		
		if(re2!=1) {document.getElementById('registration_error').innerHTML='Пожалуйста, введите полный адрес объекта.';
		document.getElementById('registration_error').style.visibility='visible';}
		
		if(re1!=1) {document.getElementById('registration_error').innerHTML='Пожалуйста, введите ваш контактный номер телефона в регистрационную форму.';
		document.getElementById('registration_error').style.visibility='visible';}				
	}
}



function add_property_form_submit(){
	//alert('re5='+re5);
	if (re5==1)
	{ document.forms["add_property_form"].submit(); }
	else {
		if(re5!=1) {document.getElementById('registration_error').innerHTML='Пожалуйста, введите правильно проверочный код.';
		document.getElementById('registration_error').style.visibility='visible';}
	}
}




