function getRegions() {
	var req=new JsHttpRequest();
	var region=1;
	req.open('get', 'http://domkadrov.com.ua/console/change_city.php', true);
	req.onreadystatechange=function() {
		if(req.readyState==1) {
			document.getElementById('popup_grc').innerHTML='<div class="ar pdtop100"><img src="/client/scin/orange/img/loading.gif" width="16px" height="16px" alt="Обработка запроса" /></div>';
		} else if (req.readyState==4) {
			if (req.responseJS.result==1) {
				document.getElementById('popup_grc').innerHTML=req.responseJS.value;
			} else {
				document.getElementById('popup_grc').innerHTML='<p class="ac pdtop20">Ошибка. Нет соединения с сервером.</p>';
			}
		}
	}
    req.send({"region":region});
}
//additional properties for jQuery object
jQuery(document).ready(function(){
   //align element in the middle of the screen
   jQuery.fn.alignCenter=function() {
      var marginLeft= - jQuery(this).width()/2 + 'px';//get margin left
      var marginTop= - jQuery(this).height()/2 + 'px';//get margin top
      return jQuery(this).css({'margin-left':marginLeft, 'margin-top':marginTop});//return updated element
   };
   jQuery.fn.togglePopup=function(){
     //detect whether popup is visible or not
     if(jQuery('#popup').hasClass('hidden')){
       //hidden - then display
       //when IE - fade immediately
       if(jQuery.browser.msie) {
         jQuery('#opaco').height(jQuery(document).height()).toggleClass('hidden').click(function(){jQuery(this).togglePopup();});
         getRegions();
         //document.getElementById('popup_grc').innerHTML='34543';
       } else {
         //in all the rest browsers - fade slowly
         jQuery('#opaco').height(jQuery(document).height()).toggleClass('hidden').fadeTo('slow', 0.7).click(function(){jQuery(this).togglePopup();});
         //document.getElementById('popup_grc').innerHTML='34543';
         getRegions();
       }
       jQuery('#popup')
         .html(jQuery(this).html())
         .alignCenter()
         .toggleClass('hidden');
     } else {
       //visible - then hide
       jQuery('#opaco').toggleClass('hidden').removeAttr('style').unbind('click');
       jQuery('#popup').toggleClass('hidden');
     }
   };
});
if (document.getElementById('change_city_lnk')) {document.getElementById('change_city_lnk').href='javascript:void(0)';}
function setRegion(rid,url) {
	var req=new JsHttpRequest();
	req.open('get', url+'/console/change_city.php', true);
	req.onreadystatechange=function() {
		if(req.readyState==1) {
			document.getElementById('popup_grc').innerHTML='<div class="ar pdtop100"><img src="/client/scin/orange/img/loading.gif" width="16px" height="16px" alt="Обработка запроса" /></div>';
		} else if (req.readyState==4) {
			if (req.responseJS.result==1) {
				document.getElementById('popup_grc').innerHTML=req.responseJS.value;
			} else {
				document.getElementById('popup_grc').innerHTML='<p class="ac pdtop20">Ошибка. Нет соединения с сервером.</p>';
			}
		}
	}
    req.send({"id":rid});
}

