﻿var arrGroups = new Array(); //pole skupin vrstev (plní se automaticky)
var arrLayers = new Array(); //pole vrstev (plní se automaticky)
var arrTextLayers = new Array(); //pole názvů vrstev (plní se automaticky)
var histRadio = ""; //oddělení skupin radiobuttonu
var flagChck = false; //příznak výběru vrstvy
var arrParams=new Array();
var objFull=new Object();
var objModul=new Object();
var objTema=new Object();
objModul.value="false";
objTema.value="Vše";
//var srcIframe=strAdr+strAdrMap+"&s=v&zoomdir=1&mapext=&imgext=&map=&mode=browse&zoomsize=2&QUERY_PARAMS=&QUERY_ID=&vrstvy=&layers=&scale=&gsasker=1&gsstring=&imgsrc=&map_web_template=../html/Form.html&tema=&";

function DefItem(Id, Val){
	document.writeln('<input type="hidden" id="'+Id+'" name="'+Id+'" value="'+Val+'">');
}


/*function SetItem(Id, Val){
	if(Val.indexOf("[")==-1){
	//	intLen=arrGroups.length;
	/*	arrParams[arrParams.length]=Id;
		eval(Id+"="+Val+";");*/
/*		if(srcIframe.indexOf("&"+Id+"=")!=-1) srcIframe=srcIframe.replace(srcIframe.substr(srcIframe.indexOf("&"+Id+"="),srcIframe.indexOf("&",srcIframe.indexOf("&"+Id+"=")+1)-srcIframe.indexOf("&"+Id+"=")),"&"+Id+"="+Val+"");
		else srcIframe+=Id+"="+Val+"&";
		
		switch (Id.toLowerCase()){
		case "full": objFull.value=Val;
		case "modul": objModul.value=Val;
		case "tema": objTema.value=Val;
		default:;
	}
}*/
//alert("Id.toLowerCase():"+Id.toLowerCase()+"\nobjFull.value:"+objFull.value+"\n Val:"+Val);
/*if (Id=="full") full=Val;
	objFull.value="false";
objModul.value="false";*/
//	document.writeln('<input type="hidden" id="'+Id+'" name="'+Id+'" value="'+Val+'">');
/*}*/

//function OptionHead(){				document.write('<SELECT id="selTema" onchange="SetTemaId();" class="selTema">'); }
//function OptionItem(value,page){	document.write('<option value="'+page+'">'+value+''); }
function OptionItem(value,page){
	var tag;
	if (ie5){
		tag=document.createElement("OPTION");
		tag.setAttribute('value',page);
		tag.setAttribute('text',value);
		document.getElementById('selTema').add(tag);
	}else{
		tag = new Option(value,page);
		document.getElementById('selTema').appendChild(tag);
	}

//document.getElementById('selTema').appendChild(tag);
//document.getElementById('selTema').innerHTML=document.getElementById('selTema').innerHTML+tag;
//obj.appendChild(tag);
//obj.lastChild.setAttribute('id','cross');
//alert(document.getElementById('selTema').innerHTML);
//document.write('<option value="'+page+'">'+value+'');
}
//function OptionFoot(){				document.write('</SELECT>'); }

function MenuHead(Id){
	document.write('<div id="'+Id+'" class="'+Id+'" onmouseout="checkUserInput(300);">');
}

function MenuNodeHead(Id,Level){
	document.write('<div class="navilayer" id="'+Id+'">'); // style="border-right:1px solid black;"
}

function MenuLeaf(Type,Id,Level,Name,IdQuery,ModeQuery,Layers){
	var atr1=atr2=atr3="";
	/*if (Level==""){
	document.write('<div class="fill"><a>&nbsp;</a></div>');
	}else{*/
	//alert("Type="+Type+" IdQuery="+IdQuery+" IdQuery!='':"+(IdQuery!="")+" IdQuery!=null:"+(IdQuery!=null));
	if (Type=="q"){
		atr1='onclick="EventB(\'q\');return false;"';
		atr3='style="color:green;"';
	}else if (IdQuery!=''){ //href doesn't work
		if (IdQuery!=-1){
			if (Type=="i")	atr1='onclick="SetQueryId('+IdQuery+',\''+ModeQuery+'\',\''+Layers+'\'); return false;" style="cursor: pointer;" ';
			else if (Type=="l")	atr1='onclick="SetQueryId('+IdQuery+',\''+ModeQuery+'\',\''+Layers+'\'); OpenLoc();return false;" style="cursor: pointer;" ';
		}else{ atr3='style="cursor: default;" title="nevyužito"'; }
	}else{
		atr1='style="cursor: default;" onClick="return false;"';
		atr2=' width="20px" height="18px"><img src="Menu_Node.gif" width="12" height="18" alt=""';
		//atr2=' background: url(Menu_Node.gif) top right no-repeat;';
	}
//	alert("atr2"+atr2);
	document.write('<div ><a href="" onmouseover="show(\''+Id+'\',\''+Level+'\',this);" '+atr1+'><table class="tbl100p-100p" style="height:18px;"><tr><td class="amenu" '+atr3+'>&nbsp;'+Name+'</td><td '+atr2+'></td></tr></table></a></div>');
	//document.writeln('<div style="height:22px; margin:0px; "><a '+atr1+' onmouseover="show(\''+Id+'\',\''+Level+'\',this);" class="amenu"><div class="tbl100p-100p" style="border:none; margin:0px; padding-top:2px; '+atr2+'">&nbsp;'+Name+'</div></a></div>');	
	//}
}

function MenuNodeFoot(){ 
	document.write('</div>');
}

function MenuFoot(){
	MenuNodeFoot();
}

function LayersHead(Id,Name){ //hlavicka menu
	var intLen=0;
	intLen=arrGroups.length;
	arrGroups[intLen]=Id;	//napln pole skupinami layeru
	
	document.write('<table>');
	document.write('<tr>');
	document.write('<td>');
	document.write('<div class="hd-layer1 cur-pointer" id="A'+Id+'" title="Rozbalit" onclick="Unpack(\''+Id+'\');">');
	document.write('	<div class="hd-layer2">');
	document.write('		<div class="hd-layer3" id="B'+Id+'">');
	document.write('			<div class="hd-layer4"><div class="padd4">'+Name+'</div></div>');
	document.write('		</div>');
	document.write('	</div>');
	document.write('</div>');
	document.write('<div id="'+Id+'" name="'+Id+'" class="bookmark">');
	document.write('<table class="tbl-border td-border-b">');
	
	//document.write('<table><tr><td><div class="hd-layer1 cur-pointer" id="A'+Id+'" title="Rozbalit" onclick="Unpack(\''+Id+'\');"><div class="hd-layer2"><div class="hd-layer3" id="B'+Id+'"><div class="hd-layer4">'+Name+'</div></div></div></div><div id="'+Id+'" name="'+Id+'" class="bookmark"><table class="tbl-border td-border-b">');
}

function LayersItem(Id,Name,Max,Min,Radio,Legend,Navig){ //polozka menu
	var intLen=0;
	var str="";
	var img="";
	var classBrd="";
//	var classGray="";
	intLen=arrLayers.length;
	arrLayers[intLen]=Id;	//napln pole layery
	arrTextLayers[intLen]=Name;
	//var flagChecked="";?
	document.write('<tr><td');
/*	if (Max!=""&&Min!=""){
		document.write(' title="Max:'+Max+' Min:'+(Min-1)+'"');
		//alert(document.getElementById("scale").value);
		/*if (scale){ resit po loadu form
			if (Max>Math.round(scale)||Min<=Math.round(scale))
				classGray="gray";
		}*/
	/*}*/
	document.write(' class="td-18 margin0');
	if (Radio!=''){
		if (histRadio!=Radio&&histRadio!="") classBrd=" td-border-t";
		document.write(' '+classBrd+'"><div class="margin2 td-13 float-left"><input type="radio" title="'+Radio+'" ');
			if (typeof(Id)=='number'){
				//document.write(' onclick="OpenElem('+Id+');"'); pripraveno (v gshtml)  class="margin:0 0 0 0px;"
				Id="radio"+Id;	//napln pole layery
			}
			histRadio=Radio;
	}else{
		document.write(' "><div style=" background:blue;" class="margin2 td-13 float-left"><input type="checkbox"'); //+flagChecked?
	}
	document.write(' onClick="SetGifRefresh();" ');
	/*if(typeof(document.getElementById("vrstvy").value)!="undefined"&&document.getElementById("vrstvy").value.indexOf("[")==-1&&document.getElementById("vrstvy").value.indexOf(Id)!=-1) { /*type of*/
/*		document.write('checked');
	}*/
	document.write(' class="radio" id="'+Id+'" name="'+Radio+'" value="'+Min+' '+Max+'"></div><div style="margin-top:2px;"><span class="td-13">'); // value="'+Min+' '+Max+'"
//	arrLayers[arrLayers.length]=Id;	//napln pole layery
//	if (typeof(Id)=='number') {
	//alert("test:"+(typeof(Id)=='number'));
	if (Navig!="") document.write('<a class="margin2 " href="javascript:OpenInNewWindow(\'../legend/'+Navig+'\',\'\',\'\',\'\',\'100\');">'+Name+'</a>'); //MAX="'+Max+'" MIN="'+Min+'" value="'+Id+'" '+classGray+'
	else document.write('<a class="">'+Name+'</a>'); //'+classGray+'
	document.write('</span></div></td>'); //</div>?
	if (Legend=="maplegend"){
		str=strAdr+strAdrMap+"&layers="+Id+"&gsasker=1&mode=legend"; //"+document.getElementById("gsasker").value+"
		img="legend1";
	}else if (Legend!=""){
		str="../legend/"+Legend;
		img="legend";
	}
	if (str!="") document.write('<td class="right td-17 padd2 '+classBrd+'"><a href="javascript:OpenInNewWindow(\''+str+'\',\'\',\'\');" title="Legenda"><img src="'+img+'.gif" width="14" height="14" border="0" alt="Legenda" onmouseover="javascript:this.src=\'legendon.gif\';" onmouseout="MOut(\'a\',this,\''+img+'.gif\');"></a>&nbsp;&nbsp;</td>');
	else document.write('<td class="td-17 '+classBrd+'"></td>');
	document.write('</tr>');
}

function LayersFoot(){
	document.write('</table>');
	document.write('</div>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	//document.writeln('	<!-- END Další podmenu -->');
}