<?php
# $Id$ 
# http://www.mapbender.org/index.php/mod_setPOI2Scale.php
# Copyright (C) 2002 CCGIS 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

require_once(dirname(__FILE__)."/../php/mb_validateSession.php");

$sql = "SELECT e_target FROM gui_element WHERE e_id = 'setPOI2Scale' AND fkey_gui_id = $1";
$v = array($gui_id);
$t = array("s");
$res = db_prep_query($sql, $v, $t);
$cnt = 0;

while($row = db_fetch_array($res)){ 
	$e_target = $row["e_target"];
	$cnt++;
}
if($cnt > 1){
	echo "alert('setPOI2SCale: ID not unique!');";
}
echo "var mod_setPOI2Scale_target = '".$e_target."';";
$e_id_css = 'setPOI2Scale';
include("../include/dyn_js.php");

?>

try{
	if (mod_setPOI2Scale_defScale){}
}
catch(e){
	mod_setPOI2Scale_defScale = 5000;
}

mb_registerInitFunctions("mod_setPOI2Scale()");

function mod_setPOI2Scale(){
	var my_target = mod_setPOI2Scale_target.split(",");
	var myPOI = "<?php echo $_SESSION['mb_myPOI2SCALE'] ?>";
	if(myPOI && myPOI != ""){
		var coord = myPOI.split(",");
		if(coord.length == 2){
			coord[2] = mod_setPOI2Scale_defScale; 	
		}
		for(var i=0; i<my_target.length; i++){		
			if(myPOI != ""){							
				mb_repaintScale(my_target[i], coord[0], coord[1], coord[2]);			
			}
		}
	}
}