<?
$base_path="../";
$w=intval($_GET['w'])+1;
$id_region=intval($_GET['id_reg']);
$glob=intval($_GET['glob']);
$m=intval($_GET['m']);

include_once($base_path.'cashe_region/_svod_region_0.php');
if(file_exists($base_path.'cashe_region/_svod_region_'.$glob.'.php'))
include_once($base_path.'cashe_region/_svod_region_'.$glob.'.php');

if($id_region)
	{
	$u=$arr_regions[$m][$id_region];
	
	if($u)
		{
		?>
		<script language="javascript">
		document.getElementById('name_reg_<?=($w-1)?>').value = '<?=$u?>'; 
		</script>				
		<?
		}
	}
else
	{
		?>
		<script language="javascript">
		document.getElementById('name_reg_<?=($w-1)?>').value = ''; 
		</script>				
		<?
	}


if($id_region && count($arr_regions[$id_region]))
	{
	?>
	<select style="width: 150px" name="region_<?=$w?>" onChange="search_reg(<?=$w?>, this.value, <?=$glob?>, <?=$id_region?>); return false">
	<option value="0"> - - - </option>
	<?
	foreach($arr_regions[$id_region] as $index=>$reg)
		{
		?>
		<option value="<?=$index?>"><?=$reg?></option>
		<?
		}
	?>
	</select>
	<input type="hidden" name="name_reg_<?=$w?>" id="name_reg_<?=$w?>" value="">
	<?
	} 
	
	?>
	
<script language="javascript">

var zz=<?=$w?>;
var txt='';
var x1='';
var y1='';

for (i=0; i<zz; i++)
	{
	x1 = document.getElementById('name_reg_'+i).value; 
	if(y1)
	y1=y1+", "+x1;
	else
	y1=x1;
	}
if(!y1) y1='Москва';
y1=encodeURIComponent(y1);
document.getElementById('adr').value=y1;
</script>