<?php
if(!defined('IN_MYMPS')) exit('FORBIDDEN');
define('CURSCRIPT','select_where');

$action 	= isset($action) 	? trim($action)		: '';
$parentid 	= isset($parentid) 	? intval($parentid)	: '';
$currentid 	= isset($currentid) ? intval($currentid): '';
$delcity	= isset($delcity) ? intval($delcity): '';
$delarea 	= isset($delarea) ? intval($delarea): '';
$delstreet 	= isset($delstreet) ? intval($delstreet): '';

$mymps_global = NULL;

switch($action){
	case 'getcity':
		echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showarea\").innerHTML='';
			//-->
			</SCRIPT>";
		if($parentid){
			$view=select_where("city","'cityid' onChange=\"choose_where('getarea',this.options[this.selectedIndex].value,'',1,1,1)\"",$currentid,$parentid);
			$view=str_replace("\r","",$view);
			$view=str_replace("\n","",$view);
			$view=str_replace("'","\'",$view);
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showcity\").innerHTML='$view';
			//-->
			</SCRIPT>";
		}
		if($delcity){
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showscity\").innerHTML='';
			//-->
			</SCRIPT>";
		}
		if($delarea){
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showsarea\").innerHTML='';
			//-->
			</SCRIPT>";
		}
		if($delstreet){
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showstreet\").innerHTML='';
			//-->
			</SCRIPT>";
		}
		if(!$parentid){
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showarea\").innerHTML='';
			//-->
			</SCRIPT>";
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showcity\").innerHTML='';
			//-->
			</SCRIPT>";
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showstreet\").innerHTML='';
			//-->
			</SCRIPT>";
		}
	break;
	case 'getarea':
		if($parentid){
			$view=select_where("area","'areaid' onChange=\"choose_where('getstreet',this.options[this.selectedIndex].value,'',1,1,1)\"",$currentid,$parentid);
			$view=str_replace("\r","",$view);
			$view=str_replace("\n","",$view);
			$view=str_replace("'","\'",$view);
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showarea\").innerHTML='$view';
			//-->
			</SCRIPT>";
		}
		if($delstreet){
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showstreet\").innerHTML='';
			//-->
			</SCRIPT>";
		}
		if(!$parentid){
			echo "<SCRIPT LANGUAGE=\"JavaScript\">
			<!--
			parent.document.getElementById(\"showarea\").innerHTML='';
			//-->
			</SCRIPT>";
		}
	break;
	case 'getstreet':
		$view=select_where("street","'streetid'",$currentid,$parentid);
		$view=str_replace("\r","",$view);
		$view=str_replace("\n","",$view);
		$view=str_replace("'","\'",$view);
		echo "<SCRIPT LANGUAGE=\"JavaScript\">
		<!--
		parent.document.getElementById(\"showstreet\").innerHTML='$view';
		//-->
		</SCRIPT>";
	break;
}
?>