﻿<!--

/*
* 1 deklarace globalnich promennych
* 2 errortrap - chybova rutina
* 3 Main - natazeni stranky
* 4 ChangeFormat - pri vyberu polozky z rozeviraciho seznamu
* 5 RefreshDisplay - zobrazi vypocitane souradnice
* 6 RefreshLat - zobrazi vypocitane souradnice
* 7 RefreshLon - zobrazi vypocitane souradnice
* 8 fDecVal - desetinou hodnotu desetinneho cisla prevede na text	bez "0."
* 9 CalcCoord - prevod vstupnich dat na objekt tridy clsGPSCoord + Execute
* 10 HomeCoord - nastaveni vychozich souradnic clsGPSCoord + Execute
* 11 Execute - vypocet a zobrazeni souradnic dat objektu tridy clsGPSCoord
* 12 ShowErrMsg - chybove hlaseni pri neplatnem zadani hodnot
* 13 Clear - vyprazdneni hodnot
* 14 RefreshUrlMaps - nastaveni odkazu na mapy
* 15 ReadUrl - read input params from document.location
* 16 SetLanguage
* 17 Msg
* 18 OpenWeb
*
* CLASSES
* 100 clsGPSViewer - prevod ciselnych GPS dat do ruznych textovych formatu
*
*/


/*
* 1
*/
var gintOptFormat 	= 3;	// default setting for SELECT id="optformat")
				// 0 = DDD.DDDD
				// 1 = DDD MM.MMM
				// 2 = DDD MM SS.SSSS
				// 3 = one line/jeden řádek

var gstrLatitude 		= "N";	//default setting 
				// "N" = Nord
				// "S" = South

var gstrLongitude 	= "E";	//default setting 
				// W = West
				// E = East

var gstrLocation		= "";

var gbolLoaded		= false;
var gobjCoordinates=null;

/*
* 2
*/
function errortrap(msg,url,l){
	var txt="V programu vznikla chyba.\n\n";
	txt+="Error: " + msg + "\n";
	txt+="URL: " + url + "\n";
	txt+="Line: " + l;
	alert(txt);
	return true;
}
onerror=errortrap;

/*
* 3
*/
function Main(){


	document.getElementById("jstest").style.visibility="hidden";
	document.getElementById("kontejner").style.visibility="visible";
	document.getElementById("optformat").value=gintOptFormat;

	gstrLn=AppsGetLang(location.href);
	if(gstrLn!="cs")gstrLn="en";
	SetLanguage(gstrLn);
	webInitOptLang();

	gstrLatitude=AppsReadCookie("gstrLatitude", gstrLatitude);
	gstrLongitude=AppsReadCookie("gstrLongitude", gstrLongitude);

	ChangeFormat();

	RefreshUrlMaps(null,null);
	gbolLoaded = true;

	ReadUrl();

	//gobjCoordinates=new txtester.gpscoordcalc.Coordinates(null,null,null);
}

/*
* 4
*/
function ChangeFormat(){
	document.getElementById("dec").style.display="none";
	document.getElementById("dm").style.display="none";
	document.getElementById("dms").style.display="none";
	document.getElementById("div-ol").style.display="none";

	gintOptFormat = parseInt(document.getElementById("optformat").value);
	switch(gintOptFormat){
		case 0 :
			document.getElementById("dec").style.display="block";
			document.getElementById("decoptlat").value=gstrLatitude;
			document.getElementById("decoptlon").value=gstrLongitude;
			break;
		case 1 :
			document.getElementById("dm").style.display="block";
			document.getElementById("dmoptlat").value=gstrLatitude;
			document.getElementById("dmoptlon").value=gstrLongitude;
			break;
		case 2 :
			document.getElementById("dms").style.display="block";
			document.getElementById("dmsoptlat").value=gstrLatitude;
			document.getElementById("dmsoptlon").value=gstrLongitude;
			break;
		default :
			gintOptFormat = 3;
			document.getElementById("div-ol").style.display="block";
			break;
	}
	RefreshDisplay(gintOptFormat, gobjCoordinates);
	AppsSaveCookie("gintOptFormat",gintOptFormat);
}


/*
* 5
*/
function RefreshDisplay(intOptFormat, objCoordinates){
var bolNull = false;
var strDec="";
var strT = "";

if(objCoordinates){
	if(!objCoordinates.LatLonDec) bolNull = true;
	if(!objCoordinates.LatLonDM) bolNull = true;
	if(!objCoordinates.LatLonDMS) bolNull = true;
}
else bolNull=true;

var objGPSViewer = new clsGPSViewer;

with(objGPSViewer){
	if(bolNull){

		document.getElementById("td-poi").innerHTML = "";
		document.getElementById("td-dec").innerHTML = "";
		document.getElementById("td-dm").innerHTML = "";
		document.getElementById("td-dms").innerHTML = "";
		document.getElementById("td-dm2").innerHTML = "";
		document.getElementById("td-dms2").innerHTML = "";
		document.getElementById("td-mapy-cz").innerHTML = "";
		document.getElementById("td-amapy-cz").innerHTML = "";

		switch(intOptFormat){
			case 0:
				document.getElementById("dec-lat-ddd").value = "";
				document.getElementById("dec-lat-dddddd").value = "";
				document.getElementById("dec-lon-ddd").value = "";
				document.getElementById("dec-lon-dddddd").value = "";
				break;
			case 1:
				document.getElementById("dm-lat-ddd").value = "";
				document.getElementById("dm-lat-mm").value = "";
				document.getElementById("dm-lat-mmm").value = "";
				document.getElementById("dm-lon-ddd").value = "";
				document.getElementById("dm-lon-mm").value = "";
				document.getElementById("dm-lon-mmm").value = "";
				break;
			case 2:
				document.getElementById("dms-lat-ddd").value = "";
				document.getElementById("dms-lat-mm").value = "";
				document.getElementById("dms-lat-ss").value = "";
				document.getElementById("dms-lat-ssss").value = "";
				document.getElementById("dms-lon-ddd").value = "";
				document.getElementById("dms-lon-mm").value = "";
				document.getElementById("dms-lon-ss").value = "";
				document.getElementById("dms-lon-ssss").value = "";
				break;
			default:
				document.getElementById("ol").value = ""; 
				break;
		}
	}
	else{

		strDec = fDec_String(objCoordinates.LatLonDec);
		document.getElementById("td-dec").innerHTML = strDec;
	
		strT = fDM_String(objCoordinates.LatLonDM);
		document.getElementById("td-dm").innerHTML = strT;

		strT = fDMS_String(objCoordinates.LatLonDMS);
		document.getElementById("td-dms").innerHTML = strT;

		strT = fDM2_String(objCoordinates.LatLonDM);
		document.getElementById("td-dm2").innerHTML = strT;

		strT = fDMS2_String(objCoordinates.LatLonDMS);
		document.getElementById("td-dms2").innerHTML = strT;

		strT = f_mapy_cz(objCoordinates.LatLonDMS);
		document.getElementById("td-mapy-cz").innerHTML = strT;

		strT = f_amapy_cz(objCoordinates.LatLonDMS);
		document.getElementById("td-amapy-cz").innerHTML = strT;

		switch(intOptFormat){
			case 0:
				document.getElementById("dec-lat-ddd").value = objCoordinates.LatLonDec.lat.ddd;
				document.getElementById("dec-lat-dddddd").value = fDecVal(objCoordinates.LatLonDec.lat.dddddd);
				document.getElementById("dec-lon-ddd").value = objCoordinates.LatLonDec.lon.ddd;
				document.getElementById("dec-lon-dddddd").value = fDecVal(objCoordinates.LatLonDec.lon.dddddd);
				break;
			case 1:
				document.getElementById("dm-lat-ddd").value = objCoordinates.LatLonDM.lat.ddd;
				document.getElementById("dm-lat-mm").value = objCoordinates.LatLonDM.lat.mm;
				document.getElementById("dm-lat-mmm").value = fDecVal(objCoordinates.LatLonDM.lat.mmm);
				document.getElementById("dm-lon-ddd").value = objCoordinates.LatLonDM.lon.ddd;
				document.getElementById("dm-lon-mm").value = objCoordinates.LatLonDM.lon.mm;
				document.getElementById("dm-lon-mmm").value = fDecVal(objCoordinates.LatLonDM.lon.mmm);
				break;
			case 2:
				document.getElementById("dms-lat-ddd").value = objCoordinates.LatLonDMS.lat.ddd;
				document.getElementById("dms-lat-mm").value = objCoordinates.LatLonDMS.lat.mm;
				document.getElementById("dms-lat-ss").value = objCoordinates.LatLonDMS.lat.ss;
				document.getElementById("dms-lat-ssss").value = fDecVal(objCoordinates.LatLonDMS.lat.ssss);
				document.getElementById("dms-lon-ddd").value = objCoordinates.LatLonDMS.lon.ddd;
				document.getElementById("dms-lon-mm").value = objCoordinates.LatLonDMS.lon.mm;
				document.getElementById("dms-lon-ss").value = objCoordinates.LatLonDMS.lon.ss;
				document.getElementById("dms-lon-ssss").value = fDecVal(objCoordinates.LatLonDMS.lon.ssss);
				break;
			//case 3:
			default:
				document.getElementById("ol").value = strDec; 
				break;
		}
	}
}
objGPSViewer = null;
}

/*
* 6
*/
function RefreshLat(opt){
gstrLatitude = opt.value;
AppsSaveCookie("gstrLatitude", gstrLatitude);
}

/*
* 7
*/
function RefreshLon(opt){
gstrLongitude = opt.value;
AppsSaveCookie("gstrLongitude", gstrLongitude);
}

/*
* 8
*/
function fDecVal(myNum){
myNum = parseFloat(myNum);
if ((myNum>0)&&(myNum<1)){
	myNum = myNum.toString();
	myNum = myNum.substr(2,myNum.length-2);
}
return(myNum);
}

/*
* 9
*/
function CalcCoord(){

var ddd,dddddd,mm,mmm,ss,ssss;
var objLat;
var objLon;
var objLatLon=null;

switch(gintOptFormat){
	case 0 :
		latlonChar = document.getElementById("decoptlat").value;
		ddd = document.getElementById("dec-lat-ddd").value;
		dddddd = document.getElementById("dec-lat-dddddd").value;
		objLat=new txtester.gpscoordcalc.CoordDec(latlonChar,ddd,dddddd);

		latlonChar = document.getElementById("decoptlon").value;
		ddd = document.getElementById("dec-lon-ddd").value;
		dddddd = document.getElementById("dec-lon-dddddd").value;
		objLon=new txtester.gpscoordcalc.CoordDec(latlonChar,ddd,dddddd);

		objLatLon=new txtester.gpscoordcalc.LatLon(objLat,objLon);
		break;

	case 1 :
		latlonChar = document.getElementById("dmoptlat").value;
		ddd = document.getElementById("dm-lat-ddd").value;
		mm = document.getElementById("dm-lat-mm").value;
		mmm = document.getElementById("dm-lat-mmm").value;
		objLat=new txtester.gpscoordcalc.CoordDM(latlonChar,ddd,mm,mmm);

		latlonChar = document.getElementById("dmoptlon").value;
		ddd = document.getElementById("dm-lon-ddd").value;
		mm = document.getElementById("dm-lon-mm").value;
		mmm = document.getElementById("dm-lon-mmm").value;
		objLon=new txtester.gpscoordcalc.CoordDM(latlonChar,ddd,mm,mmm);

		objLatLon=new txtester.gpscoordcalc.LatLon(objLat,objLon);
		break;

	case 2 :
		latlonChar = document.getElementById("dmsoptlat").value;
		ddd = document.getElementById("dms-lat-ddd").value;
		mm = document.getElementById("dms-lat-mm").value;
		ss = document.getElementById("dms-lat-ss").value;
		ssss = document.getElementById("dms-lat-ssss").value;
		objLat=new txtester.gpscoordcalc.CoordDMS(latlonChar,ddd,mm,ss,ssss);		

		latlonChar = document.getElementById("dmsoptlon").value;
		ddd = document.getElementById("dms-lon-ddd").value;
		mm = document.getElementById("dms-lon-mm").value;
		ss = document.getElementById("dms-lon-ss").value;
		ssss = document.getElementById("dms-lon-ssss").value;
		objLon=new txtester.gpscoordcalc.CoordDMS(latlonChar,ddd,mm,ss,ssss);	

		objLatLon=new txtester.gpscoordcalc.LatLon(objLat,objLon);
		break;
	//case 3:
	default:
		gintOptFormat = 3;
		txtester.gpscoordcalc.getLatLon(document.getElementById("ol").value,function(result){
			if(!result.error){
				objLatLon=result.LatLon;
			}
			else{
				alert(LoadResString(40) + "\n\n(txtester.gpscoordcalc.getLatLon: result.error=" + result.error.code + ")");
				return;	
			}

		});
}//end-of-switch


txtester.gpscoordcalc.validate(objLatLon,function(result){
	if(!result.error){
		objLatLon=result.LatLon;
		Execute(objLatLon);
	}
	else{
		alert(LoadResString(40) + "\n\n(txtester.gpscoordcalc.validate: result.error=" + result.error.code + ")");
/*
		with(txtester.gpscoordcalc.errorcode){
			switch(result.error.code){
				case NAO_LATLON:
					break;
				case LAT_DDD:
					break;
				case LON_DDD:
					break;
				case LAT_DDDDDD:
					break;
				case LON_DDDDDD:
					break;
				case LAT_OVERFLOWE:
					break;
				case LON_OVERFLOWE:
					break;
				case LAT_MM:
					break;
				case LON_MM:
					break;
				case LAT_MMM:
					break;
				case LON_MMM:
					break;
				case LAT_SS:
					break;
				case LON_SS:
					break;
				case LAT_SSSS:
					break;
				case LON_SSSS:
					break;
				default:
			}//switch
		}//with
*/
	}//else
});

}

/*
* 10
*/
function HomeCoord(){

//N48 58.469 E14 28.459

gstrLatitude = "N";
gstrLongitude = "E";

document.getElementById("optformat").value = 1;
ChangeFormat();

var objLat=new txtester.gpscoordcalc.CoordDM("N",48,58,469);
var objLon=new txtester.gpscoordcalc.CoordDM("E",14,28,459);
var objLatLon=new txtester.gpscoordcalc.LatLon(objLat,objLon);

//execute
Execute(objLatLon);

//poi link
document.getElementById("td-poi").innerHTML = "POI: <a href='http://www.c-budejovice.cz' alt='' target='_blank'>Budweis / České Budějovice</a>";
}


/*
* 11
*/
function Execute(objLatLon){
txtester.gpscoordcalc.calculate(objLatLon,function(result){
	if(!result.error){
		gobjCoordinates=result.Coordinates;
	}
	else{
		alert("Calculate, error: "+result.error.code);
	}
});

RefreshDisplay(gintOptFormat, gobjCoordinates);
RefreshUrlMaps(gobjCoordinates);
}


/*
* 12
*/
function ShowErrMsg(ErrNum){
alert("Invalid position.\t[ENG] \nNeplatné zadání.\t[CZE]")
}


/*
* 13
*/
function Clear(){
gobjCoordinates=null;
RefreshDisplay(gintOptFormat, gobjCoordinates);
RefreshUrlMaps(null, null);
}


/*
* 14
*/
function RefreshUrlMaps(objCoordinates){
var i = 0;
var strUrl = "";
var arr = new Array();
arr[0]= new Array("google_com_m","http://maps.google.com");
arr[1]= new Array("google_com_k","http://maps.google.com");
arr[2]= new Array("google_com_h","http://maps.google.com");
arr[3]= new Array("google_com_p","http://maps.google.com");
arr[4]= new Array("mapy_cz_zp","http://www.mapy.cz");
arr[5]= new Array("mapy_cz_tp","http://www.mapy.cz");
arr[6]= new Array("mapy_cz_fp","http://www.mapy.cz");
arr[7]= new Array("amapy_cz_zp","http://www.amapy.cz");
arr[8]= new Array("mapquest_com","http://www.mapquest.com");
arr[9]= new Array("geocaching_nearest_map","http://www.geocaching.com");
arr[10]= new Array("geocaching_nearest_lst","http://www.geocaching.com");

var intL = arr.length;
var objGPSViewer = new clsGPSViewer;
for(i=0;i<intL;i++){
	if (objCoordinates==null || objCoordinates.LatLonDec ==null){
		strUrl =arr[i][1];
	}
	else {
		strUrl = objGPSViewer.getUrl(objCoordinates.LatLonDec, objCoordinates.LatLonDMS, arr[i][0]);
	}
	document.getElementById(arr[i][0]).href = strUrl;
}
objGPSViewer = null;
}



/*
* 15
*/
function ReadUrl(){
var loc=unescape(document.location.toString());

//var loc = "http://www.txtester.com/gpscoordcalc/index?loc=N 48° 58.331 E 014° 28.474";
loc=AppsGetUrlParam(loc,"loc");

if(loc!=""){
	gstrLocation=loc;
	document.getElementById("optformat").value = 3;
	ChangeFormat();
	document.getElementById("ol").value=gstrLocation;
	document.getElementById("btnOK").click();
}


}



/*
* 16
*/
function SetLanguage(ln){

gstrLn=ln;
AppsSaveCookie("ln", gstrLn);
AppsRefreshUrl();

with(document){
	getElementById("ln-chordtrans").innerHTML=LoadResString(2);

	getElementById("optformat-ol").innerHTML=LoadResString(10);
	getElementById("btnHC").value=LoadResString(11);
	getElementById("btnCL").value=LoadResString(12);
	getElementById("btnOK").value=LoadResString(13);
	getElementById("maps").innerHTML=LoadResString(14);

	getElementById("td_maps_other").innerHTML=LoadResString(15);

	getElementById("google_com_m").innerHTML=LoadResString(16);
	getElementById("google_com_k").innerHTML=LoadResString(17);
	getElementById("google_com_h").innerHTML=LoadResString(18);
	getElementById("google_com_p").innerHTML=LoadResString(19);

	getElementById("mapy_cz_zp").innerHTML=LoadResString(16);
	getElementById("mapy_cz_tp").innerHTML=LoadResString(20);
	getElementById("mapy_cz_fp").innerHTML=LoadResString(21);
}//end with

}



/*
* 17
*/
function Msg(id){
var t="GPS Coord Calc - undefined error.";

switch(id){
	case 1:
		t=LoadResString(31);
		break;
	case 2:
		t =LoadResString(32);
		break;
	case 3:
		t=LoadResString(33);
		t+="\n\n1. " + LoadResString(34);
		t+="\n2. " + LoadResString(35);
		t+="\n3. " + LoadResString(36);
		break;

	default: break;
}
alert(t);
}


/*
* 18
*/
function OpenWeb(id){
var u;
switch(id){
	case 'seznam_cz':
		u="http://www.seznam.cz";
		break;
	default: return;
}
window.open(u,"gpsccwindow");
}


/*
* 19
*/
function LoadResString(id,lng){

if(lng==undefined)lng=gstrLn;

//CZECH
if(lng=="cs"){
	switch(id){

		case 1:return("Promile");
		case 2:return("Transponer akordů");

		case 10:return("Zkusit štěstí");
		case 11:return("Příklad");
		case 12:return("Smazat");
		case 13:return("Spočítat");
		case 14:return("Online mapy");
		case 15:return("Ostatní");
		case 16: return("základní");
		case 17: return("satelitní");
		case 18: return("hybridní");
		case 19: return("terénní");
		case 20: return("turistická");
		case 21: return("fotomapa");

		case 31:return("Souřadnice v libovolném WGS84 tvaru.");
		case 32:return("Pro prohlížeč MSIE - při nezobrazení mapy na www.mapy.cz stiskni CTRL+F5.");
		case 33:return("Bookmarklet 'GPSCC Send Data' pošle souřadnice zobrazené cache programu 'GPS Coord Calc', který je automaticky zpracuje.");
		case 34:return("Ulož 'GPSCC Send Data' jako záložku.");
		case 35:return("Jdi na stránku s detailem požadované cache (http://www.geocaching.com/seek/cache_detail.aspx...).");
		case 36:return("Klikni na záložku 'GPSCC Send Data'.");

		//errors
		case 40:return("Neplatná hodnota.");

		//SYSTEM ERROR: UNDEFINED ID
		default:return("LoadResString: nedefinované id=" + id);

	}//end-of-switch
}//end-of-if

//NOT ENGLISH
if(lng!="en"){
	var strEn=LoadResString(id,"en");
	try{
		google.language.translate(strEn,"en",lng,function(result){
			if(!result.error)return(result.translation);
		});
		return(strEn);
	}
	catch(err){
		return(strEn);
	}
}

//ENGLISH = ENGLISH + SOURCE LANGUAGE FOR TRANSLATING
if(lng=="en"){
	switch(id){

		case 1:return("Promile");
		case 2:return("Chord Transposer");

		case 10: return("Try one's luck");
		case 11: return("Sample");
		case 12: return("Clear");
		case 13: return("Calculate");
		case 14: return("Maps online");
		case 15: return("Other");
		case 16: return("basic");
		case 17: return("satellite");
		case 18: return("hybrid");
		case 19: return("terrain");
		case 20: return("tourist");
		case 21: return("photomaps");

		case 31:return("Coordinates in an arbitrary WGS84 conformation.");
		case 32:return("Have you browser MSIE and a problem on www.mapy.cz? Push hotkey CTRL+F5.");
		case 33:return("Bookmarklet 'GPSCC Send Data' will send a cache's coordinates to 'GPS Coord Calc' for an automatically processing.");
		case 34:return("Save 'GPSCC Send Data' as a bookmark.");
		case 35:return("Go to a cache's detail view page (http://www.geocaching.com/seek/cache_detail.aspx...).");
		case 36:return("Click on bookmark 'GPSCC Send Data'.");

		//errors
		case 40:return("Invalid value.");

		//SYSTEM ERROR: UNDEFINED ID
		default:return("LoadResString: undefined id=" + id);

	}//switch

}//if

}//LoadResString


/*
* 100
*/
function clsGPSViewer(){
	this.className			= "clsGPSViewer";

	this.fDec_String 			= function (objCoordDec){
		var strDec = m_fLatLon(objCoordDec.lat, false);
		strDec += "   ";
		strDec += m_fLatLon(objCoordDec.lon, false); 
		return(strDec);

		
	}

	this.fDM_String 			= function (objCoordDM){
		with(objCoordDM.lat){
			var strDM = latlonChar + ddd.toString() + "° " + m_fCorNum(mm, mmm,2,3) + "'";
		}
		with(objCoordDM.lon){
			strDM += "   " + latlonChar + ddd.toString() + "° " + m_fCorNum(mm , mmm,2,3) + "'";
		}
		return(strDM);
	}

	this.fDM2_String 			= function(objCoordDM){
		with(objCoordDM.lat){
			var strDM = latlonChar + ddd.toString() + " " + m_fCorNum(mm,mmm,2,3);
		}
		with(objCoordDM.lon){
			strDM += "   " + latlonChar + ddd.toString() + " " + m_fCorNum(mm,mmm,2,3);
		}
		return(strDM);
	}
	
	this.fDMS_String 			= function(objCoordDMS){
		var U = String.fromCharCode(34);
		with(objCoordDMS.lat){
			var strDMS = latlonChar + ddd.toString() + "° " + m_fCorNum(mm,0,2,0) + "' " + m_fCorNum(ss,ssss,2,4) + U;
		}
		with(objCoordDMS.lon){
			strDMS += "   " + latlonChar + ddd.toString() + "° " + m_fCorNum(mm,0,2,0) + "' " + m_fCorNum(ss,ssss,2,4) + U;
		}
		return(strDMS);
	}

	this.fDMS2_String 		= function(objCoordDMS){
		with(objCoordDMS.lat){
			var strDMS = latlonChar + ddd.toString() + " " + m_fCorNum(mm,0,2,0) + " " + m_fCorNum(ss,ssss,2,4);
		}
		with(objCoordDMS.lon){
			strDMS += "   " + latlonChar + ddd.toString() + " " + m_fCorNum(mm,0,2,0) + " " + m_fCorNum(ss,ssss,2,4);
		}
		return(strDMS);
	}

	this.f_mapy_cz			= function(objCoordDMS){
		var U = String.fromCharCode(34);
		with(objCoordDMS.lat){
			var strDMS = "Loc: " + ddd.toString() + "°" + m_fCorNum(mm,0,2,0) + "'" + m_fCorNum(ss,ssss,2,2) + U + latlonChar + ", ";
		}
		with(objCoordDMS.lon){
			strDMS += ddd.toString() + "°" + m_fCorNum(mm,0,2,0) + "'" + m_fCorNum(ss,ssss,2,2) + U + latlonChar;
		}
		return(strDMS);
	}

	this.f_amapy_cz			= function(objCoordDMS){
		var U = String.fromCharCode(34);
		with(objCoordDMS.lat){
			var strDMS = ddd.toString() + "°" + m_fCorNum(mm,0,2,0) + "'" + m_fCorNum(ss,ssss,2,2) + U + latlonChar + ";";
		}
		with(objCoordDMS.lon){
			strDMS += ddd.toString() + "°" + m_fCorNum(mm,0,2,0) + "'" + m_fCorNum(ss,ssss,2,2) + U + latlonChar;
		}
		return(strDMS);
	}

	this.getUrl				= function(objCoordDec, objCoordDMS, target){
		var strUrl = "";
		with(objCoordDec){
			switch(target){
				case "mapy_cz_zp":		
					//strUrl = "http://www.mapy.cz/#z=13@mm=ZP@sa=s@st=s@ssq=Loc:%20" + m_fLatLon(lat,false,4) + ", " + m_fLatLon(lon,false,4) + "@sss=1";
					strUrl = "http://www.mapy.cz/#mm=ZP@st=s@ssq=Loc: " + m_fLatLon(lat,false,4) + ", " + m_fLatLon(lon,false,4) + "@z=13";
					break;
				case "mapy_cz_tp":		
					//strUrl = "http://www.mapy.cz/#z=13@mm=TP@sa=s@st=s@ssq=Loc:%20" + m_fLatLon(lat,false,4) + ",%20" + m_fLatLon(lon,false,4) + "@sss=1";
					strUrl = "http://www.mapy.cz/#mm=TP@st=s@ssq=Loc: " + m_fLatLon(lat,false,4) + ", " + m_fLatLon(lon,false,4) + "@z=13";
					break;
				case "mapy_cz_fp":		
					//strUrl = "http://www.mapy.cz/#z=16@mm=FP@sa=s@st=s@ssq=Loc:%20" + m_fLatLon(lat,false,4) + ",%20" + m_fLatLon(lon,false,4) + "@sss=1";
					strUrl = "http://www.mapy.cz/#mm=FP@st=s@ssq=Loc: " + m_fLatLon(lat,false,4) + ", " + m_fLatLon(lon,false,4) + "@z=16";
					break;


				case "amapy_cz_zp":
					//strUrl="http://amapy.atlas.cz/#cs=1@sidx=13@pg=1@pl=@app=0@q=";
					strUrl="http://amapy.centrum.cz/#sidx=13@app=0@q=";
					with(objCoordDMS.lat)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar + "%3B%20";
					with(objCoordDMS.lon)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar;
					//49°0'30.34"N; 14°28'42.79"E;


					break;
				case "amapy_cz_tp":
					strUrl="http://amapy.atlas.cz/#cs=1@sidx=13@pg=2@pl=@app=5@q=";
					with(objCoordDMS.lat)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar + "%3B%20";
					with(objCoordDMS.lon)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar;
					//49°0'30.34"N; 14°28'42.79"E;
					break;
				case "amapy_cz_fp":
					//strUrl="http://amapy.atlas.cz/?sidx=12@app=2@gps=";
					//with(objCoordDMS.latitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar + "%3B%20";
					//with(objCoordDMS.longitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar;
					//49°0'30.34"N; 14°28'42.79"E;
//name=Praha&gps=50%c2%b05'7.35%22N%3b+14%c2%b025'26.68 %22E

					//strUrl="http://amapy.atlas.cz/#name=a@sidx=12@app=2@gps=";
					//with(objCoordDMS.latitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar + "%3B%20";
					//with(objCoordDMS.longitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar;
					//49°0'30.34"N; 14°28'42.79"E;

					strUrl="http://amapy.atlas.cz/#cs=1@sidx=13@pg=1@pl=@app=2@q=";
					with(objCoordDMS.lat)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar + "%3B+";
					with(objCoordDMS.lon)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(ss,ssss,0,2) + "%22" + latlonChar;
					strUrl+="@ms=1";

					break;
				case "google_com_m":
					strUrl = "http://maps.google.com/maps?t=m&z=16&q=" + m_fLatLon(lat,false,6) + "+" + m_fLatLon(lon,true,6);
					break;
				case "google_com_k":
					strUrl = "http://maps.google.com/maps?t=k&z=16&q=" + m_fLatLon(lat,false,6) + "+" + m_fLatLon(lon,true,6);
					break;
				case "google_com_h":
					strUrl = "http://maps.google.com/maps?t=h&z=16&q=" + m_fLatLon(lat,false,6) + "+" + m_fLatLon(lon,true,6);
					break;
				case "google_com_p":
					strUrl = "http://maps.google.com/maps?t=p&z=14&q=" + m_fLatLon(lat,false,6) + "+" + m_fLatLon(lon,true,6);
					break;


				case "mapquest_com":
					strUrl = "http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=latlong&latlongtype=decimal&latitude="  + m_fLatLon(lat,false,6) + "&longitude=" + m_fLatLon(lon,false,6) + "&zoom=14"
					break;
				case "geocaching_nearest_map":
					strUrl = "http://www.geocaching.com/seek/gmnearest.aspx?lat=" + m_fLatLon(lat,false,6) + "&lon=" + m_fLatLon(lon,false,6);
					break;
				case "geocaching_nearest_lst":
					strUrl = "http://www.geocaching.com/seek/nearest.aspx?lat=" + m_fLatLon(lat,false,6) + "&lon=" + m_fLatLon(lon,false,6) + "&f=1";
					break;			
			}
		}
		return(strUrl);
	}

/*
* String, funkce vrací text reprezentující číslo
* Integer,  myNumber je celé číslo
* Integer, myNumber2 je celé číslo reprezentující hodnotu za desetinou tečkou u plovoucího čísla
* funkce spojí myNumber + "0." + myNumber2
* Integer, intCharPerInt - počet míst čísla před desetinnou tečkou (intCharPerInt=2: "1.1234" -> "01.1234")
* Integer, intCharPerDec - počet míst čísla za desetinnou tečkou (intCharPerDec=2: "01.1234" -> "01.12")
*/
	function m_fCorNum(num1, num2, len1, len2){

		var i=0;
		var s= "";
		var l2=0;

		if(!isNaN(num1)){
			num1=parseInt(num1);
			num1=num1.toString();
			len1=len1-num1.length;
			if(len1>0){
				for(i=0;i<len1;i++){
					s+="0";
				}			
			}
			num1=s+num1;
		}

		s="";
		if(!isNaN(num2)){
			num2=parseInt(num2);
			num2=num2.toString();
			l2=len2-num2.length;
			if(l2>0){
				for(i=0;i<l2;i++){
					s+="0";
				}
				num2+=s;			
			}
			else{

				num2="0." + num2;
				num2=parseFloat(num2);
				num2=num2.toFixed(len2);
				num2=num2.toString();
				num2=num2.substr(2,num2.length-2);
			}

		}

		if(len2>0 && num2>0)num1+="." + num2;
		return(num1);

	}

	function m_fLatLonOLD(objDec, bolWritePlus, optional_intCharPerDec){

		if(isNaN(parseInt(optional_intCharPerDec)))optional_intCharPerDec = 6;

		with(objDec){
			var a = m_fCorNum(ddd,dddddd,0,optional_intCharPerDec);
			a = a.toString(); 
			if((latlonChar == "S") || (latlonChar == "W")) a = "-" + a;
			if((bolWritePlus) && ((latlonChar == "N") || (latlonChar == "E"))) a = "+" + a; 
		}
		return(a);
	}

	function m_fLatLon(objDec, bolWritePlus, optional_intCharPerDec){
		if(isNaN(parseInt(optional_intCharPerDec)))optional_intCharPerDec = 6;
		with(objDec){
			var a = ddd.toString() +"." + dddddd.toString();
			if((latlonChar == "S") || (latlonChar == "W")|| (latlonChar == "-")) a = "-" + a;
			if((bolWritePlus) && ((latlonChar == "N") || (latlonChar == "E"))) a = "+" + a; 
		}
		return(a);
	}

}//clsGPSViewer



-->