<?php
# $Id$
# http://www.mapbender.org/index.php/mod_scaleSel.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_src, e_target FROM gui_element WHERE e_id = 'scaleSelect' 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++;
}
echo "var mod_scaleSelect_target = '".$e_target."';";
if($cnt > 1){
	echo "alert('scaleSelect: ID not unique!');";
}
?>
mb_registerSubFunctions("mod_scaleSelect_val(frameName)");
function mod_scaleSelect(obj){
	var ind = obj.selectedIndex;
	mb_repaintScale(mod_scaleSelect_target,null,null,obj.options[ind].value);
}
function mod_scaleSelect_val(frameName){
	if(frameName == mod_scaleSelect_target){
		var scale = mb_getScale(frameName);
		document.getElementById("scaleSelect").options[0].text = "1 : " + scale;
		document.getElementById("scaleSelect").options[0].selected = true;
	}
}