﻿<!--

/*
* 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;

	gweb.ln=gweb.GetLang(location.href);
	if(gweb.ln!="cs")gweb.ln="en";
	SetLanguage(gweb.ln);
	gweb.InitOptLang();

	gstrLatitude=gweb.ReadCookie("gstrLatitude", gstrLatitude);
	gstrLongitude=gweb.ReadCookie("gstrLongitude", gstrLongitude);

	ChangeFormat();

	RefreshUrlMaps(null,null);
	gbolLoaded = true;

	ReadUrl();

}

/*
* 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);
	gweb.SaveCookie("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 = "";//N 48° 58.085 E 014° 28.949"; 
				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 = parseInt(objCoordinates.LatLonDec.lat.deg);
				document.getElementById("dec-lat-dddddd").value = fDecVal(objCoordinates.LatLonDec.lat.deg,6);
				document.getElementById("dec-lon-ddd").value = parseInt(objCoordinates.LatLonDec.lon.deg);
				document.getElementById("dec-lon-dddddd").value = fDecVal(objCoordinates.LatLonDec.lon.deg,6);
				break;
			case 1:
				document.getElementById("dm-lat-ddd").value = objCoordinates.LatLonDM.lat.deg;
				document.getElementById("dm-lat-mm").value = parseInt(objCoordinates.LatLonDM.lat.min);
				document.getElementById("dm-lat-mmm").value = fDecVal(objCoordinates.LatLonDM.lat.min,3);
				document.getElementById("dm-lon-ddd").value = parseInt(objCoordinates.LatLonDM.lon.deg);
				document.getElementById("dm-lon-mm").value = parseInt(objCoordinates.LatLonDM.lon.min);
				document.getElementById("dm-lon-mmm").value = fDecVal(objCoordinates.LatLonDM.lon.min,3);
				break;
			case 2:
				document.getElementById("dms-lat-ddd").value = parseInt(objCoordinates.LatLonDMS.lat.deg);
				document.getElementById("dms-lat-mm").value = objCoordinates.LatLonDMS.lat.min;
				document.getElementById("dms-lat-ss").value = parseInt(objCoordinates.LatLonDMS.lat.sec);
				document.getElementById("dms-lat-ssss").value = fDecVal(objCoordinates.LatLonDMS.lat.sec,4);
				document.getElementById("dms-lon-ddd").value = parseInt(objCoordinates.LatLonDMS.lon.deg);
				document.getElementById("dms-lon-mm").value = objCoordinates.LatLonDMS.lon.min;
				document.getElementById("dms-lon-ss").value = parseInt(objCoordinates.LatLonDMS.lon.sec);
				document.getElementById("dms-lon-ssss").value = fDecVal(objCoordinates.LatLonDMS.lon.sec,4);
				break;
			//case 3:
			default:
				document.getElementById("ol").value = strDec; 
				break;
		}
	}
}
objGPSViewer = null;
}

/*
* 6
*/
function RefreshLat(opt){
gstrLatitude = opt.value;
gweb.SaveCookie("gstrLatitude", gstrLatitude);
}

/*
* 7
*/
function RefreshLon(opt){
gstrLongitude = opt.value;
gweb.SaveCookie("gstrLongitude", gstrLongitude);
}

/*
* 8
*/
function fDecVal(myNum,optional_intDigits){
myNum=parseFloat(myNum,10);
myNum = myNum-parseInt(myNum);

//The number of digits after the decimal point
if(!isNaN(parseInt(optional_intDigits))) {
	myNum=myNum.toFixed(optional_intDigits);
}

myNum = myNum.toString();
myNum = myNum.substr(2,myNum.length-2);

return(myNum);
}


/*
* 9
*/
function CalcCoord(){
var deg,min,sec;
var objLat;
var objLon;
var objLatLon=null;

switch(gintOptFormat){
	case 0 :
		latlonChar = document.getElementById("decoptlat").value;
		deg = document.getElementById("dec-lat-ddd").value;
		deg +="."+ document.getElementById("dec-lat-dddddd").value;	
		objLat=new txtester.gpscoordcalc.CoordDec(latlonChar,deg);

		latlonChar = document.getElementById("decoptlon").value;
		deg = document.getElementById("dec-lon-ddd").value;
		deg +="."+ document.getElementById("dec-lon-dddddd").value;
		objLon=new txtester.gpscoordcalc.CoordDec(latlonChar,deg);

		objLatLon=new txtester.gpscoordcalc.LatLon(objLat,objLon);
		break;

	case 1 :
		latlonChar = document.getElementById("dmoptlat").value;
		deg = document.getElementById("dm-lat-ddd").value;
		min = document.getElementById("dm-lat-mm").value;
		min +="."+ document.getElementById("dm-lat-mmm").value;
		objLat=new txtester.gpscoordcalc.CoordDM(latlonChar,deg,min);

		latlonChar = document.getElementById("dmoptlon").value;
		deg = document.getElementById("dm-lon-ddd").value;
		min = document.getElementById("dm-lon-mm").value;
		min +="."+ document.getElementById("dm-lon-mmm").value;
		objLon=new txtester.gpscoordcalc.CoordDM(latlonChar,deg,min);

		objLatLon=new txtester.gpscoordcalc.LatLon(objLat,objLon);
		break;

	case 2 :
		latlonChar = document.getElementById("dmsoptlat").value;
		deg = document.getElementById("dms-lat-ddd").value;
		min = document.getElementById("dms-lat-mm").value;
		sec =document.getElementById("dms-lat-ss").value;
		sec +="."+  document.getElementById("dms-lat-ssss").value;
		objLat=new txtester.gpscoordcalc.CoordDMS(latlonChar,deg,min,sec);		

		latlonChar = document.getElementById("dmsoptlon").value;
		deg = document.getElementById("dms-lon-ddd").value;
		min = document.getElementById("dms-lon-mm").value;
		sec = document.getElementById("dms-lon-ss").value;
		sec +="."+  document.getElementById("dms-lon-ssss").value;
		objLon=new txtester.gpscoordcalc.CoordDMS(latlonChar,deg,min,sec);	

		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_CHAR:
					break;
				case LON_CHAR:
					break;
				case LAT_OVERFLOWE:
					break;
				case LON_OVERFLOWE:
					break;
				case LAT_DEG:
					break;
				case LON_DEG:
					break;
				case LAT_MIN:
					break;
				case LON_MIN:
					break;
				case LAT_SEC:
					break;
				case LON_SEC:
					break;
				case GETLATLON_NO_COORDINATES:
					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_street","http://www.mapquest.com");
arr[9]= new Array("mapquest_com_aerial","http://www.mapquest.com");
arr[10]= new Array("mapquest_com_hybrid","http://www.mapquest.com");
arr[11]= new Array("openstreetmap_org","http://www.openstreetmap.org");
arr[12]= new Array("yahoo_com_m","http://maps.yahoo.com");
arr[13]= new Array("yahoo_com_s","http://maps.yahoo.com");
arr[14]= new Array("yahoo_com_h","http://maps.yahoo.com");
arr[15]= new Array("geocaching_nearest_map","http://www.geocaching.com");
arr[16]= 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=arr[i][1];
		strUrl = objGPSViewer.getUrl(objCoordinates, 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=gweb.GetUrlParam(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){

gweb.ln=ln;
gweb.SaveCookie("ln", gweb.ln);
gweb.RefreshUrl();

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("mapquest_com_street").innerHTML=LoadResString(16);
	getElementById("mapquest_com_aerial").innerHTML=LoadResString(17);
	getElementById("mapquest_com_hybrid").innerHTML=LoadResString(18);

	getElementById("yahoo_com_m").innerHTML=LoadResString(16);
	getElementById("yahoo_com_s").innerHTML=LoadResString(17);
	getElementById("yahoo_com_h").innerHTML=LoadResString(18);

	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=gweb.ln;

//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 + deg.toString() + "° " + m_fCorNum(min,2,3) + "'";
		}
		with(objCoordDM.lon){
			strDM += "   " + latlonChar + deg.toString() + "° " + m_fCorNum(min,2,3) + "'";
		}
		return(strDM);
	}

	this.fDM2_String 			= function(objCoordDM){
		with(objCoordDM.lat){
			var strDM = latlonChar + deg.toString() + " " + m_fCorNum(min,2,3);
		}
		with(objCoordDM.lon){
			strDM += "   " + latlonChar + deg.toString() + " " + m_fCorNum(min,2,3);
		}
		return(strDM);
	}
	
	this.fDMS_String 			= function(objCoordDMS){
		var U = String.fromCharCode(34);
		with(objCoordDMS.lat){
			var strDMS = latlonChar + deg.toString() + "° " + m_fCorNum(min,2,0) + "' " + m_fCorNum(sec,2,4) + U;
		}
		with(objCoordDMS.lon){
			strDMS += "   " + latlonChar + deg.toString() + "° " + m_fCorNum(min,2,0) + "' " + m_fCorNum(sec,2,4) + U;
		}
		return(strDMS);
	}

	this.fDMS2_String 		= function(objCoordDMS){
		with(objCoordDMS.lat){
			var strDMS = latlonChar + deg.toString() + " " + m_fCorNum(min,2,0) + " " + m_fCorNum(sec,2,4);
		}
		with(objCoordDMS.lon){
			strDMS += "   " + latlonChar + deg.toString() + " " + m_fCorNum(min,2,0) + " " + m_fCorNum(sec,2,4);
		}
		return(strDMS);
	}

	this.f_mapy_cz			= function(objCoordDMS){
		var U = String.fromCharCode(34);
		with(objCoordDMS.lat){
			var strDMS = "Loc: " + deg.toString() + "°" + m_fCorNum(min,2,0) + "'" + m_fCorNum(sec,2,2) + U + latlonChar + ", ";
		}
		with(objCoordDMS.lon){
			strDMS += deg.toString() + "°" + m_fCorNum(min,2,0) + "'" + m_fCorNum(sec,2,2) + U + latlonChar;
		}
		return(strDMS);
	}

	this.f_amapy_cz			= function(objCoordDMS){
		var U = String.fromCharCode(34);
		with(objCoordDMS.lat){
			var strDMS = deg.toString() + "°" + m_fCorNum(min,2,0) + "'" + m_fCorNum(sec,2,2) + U + latlonChar + ";";
		}
		with(objCoordDMS.lon){
			strDMS += deg.toString() + "°" + m_fCorNum(min,2,0) + "'" + m_fCorNum(sec,2,2) + U + latlonChar;
		}
		return(strDMS);
	}

	this.getUrl				= function(objCoordinates,target){
		var strUrl = "";

		with(objCoordinates){
			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";
					txtester.gpscoordcalc.getMapUrl("mapy.cz",objCoordinates,txtester.gpscoordcalc.MapType.BASIC,13,function(result){
						strUrl=result.url;
					});
					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";
					txtester.gpscoordcalc.getMapUrl("mapy.cz",objCoordinates,txtester.gpscoordcalc.MapType.TOURIST,13,function(result){
						strUrl=result.url;
					});
					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";
					txtester.gpscoordcalc.getMapUrl("mapy.cz",objCoordinates,txtester.gpscoordcalc.MapType.PHOTO,13,function(result){
						strUrl=result.url;
					});
					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(objCoordinates.LatLonDMS.lat)strUrl += deg + "%C2%B0" + min + "'" + m_fCorNum(sec,0,2) + "%22" + latlonChar + "%3B%20";
					with(objCoordinates.LatLonDMS.lon)strUrl += deg + "%C2%B0" + min + "'" + m_fCorNum(sec,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(objCoordinates.CoordDMS.lat)strUrl += deg + "%C2%B0" + min + "'" + m_fCorNum(sec,0,2) + "%22" + latlonChar + "%3B%20";
					with(objCoordinates.CoordDMS.lon)strUrl += deg + "%C2%B0" + min + "'" + m_fCorNum(sec,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(sec,0,2) + "%22" + latlonChar + "%3B%20";
					//with(objCoordDMS.longitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(sec,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(objCoordinates.CoordDMS.latitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(sec,0,2) + "%22" + latlonChar + "%3B%20";
					//with(objCoordinates.CoordDMS.longitude)strUrl += ddd + "%C2%B0" + mm + "'" + m_fCorNum(sec,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 += deg + "%C2%B0" + min + "'" + m_fCorNum(sec,0,2) + "%22" + latlonChar + "%3B+";
					with(objCoordDMS.lon)strUrl += deg + "%C2%B0" + min + "'" + m_fCorNum(sec,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);
					txtester.gpscoordcalc.getMapUrl("google.com",objCoordinates,txtester.gpscoordcalc.MapType.BASIC,16,function(result){
						strUrl=result.url;
					});
					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);
					txtester.gpscoordcalc.getMapUrl("google.com",objCoordinates,txtester.gpscoordcalc.MapType.SATELLITE,16,function(result){
						strUrl=result.url;
					});
					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);
					txtester.gpscoordcalc.getMapUrl("google.com",objCoordinates,txtester.gpscoordcalc.MapType.HYBRID,16,function(result){
						strUrl=result.url;
					});
					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);
					txtester.gpscoordcalc.getMapUrl("google.com",objCoordinates,txtester.gpscoordcalc.MapType.TERRAIN,14,function(result){
						strUrl=result.url;
					});
					break;
				case "mapquest_com_street":
					//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"
					txtester.gpscoordcalc.getMapUrl("mapquest.com",objCoordinates,txtester.gpscoordcalc.MapType.STREET,14,function(result){
						strUrl=result.url;
					});
					break;
				case "mapquest_com_aerial":
					//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"
					txtester.gpscoordcalc.getMapUrl("mapquest.com",objCoordinates,txtester.gpscoordcalc.MapType.AERIAL,14,function(result){
						strUrl=result.url;
					});
					break;
				case "mapquest_com_hybrid":
					//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"
					txtester.gpscoordcalc.getMapUrl("mapquest.com",objCoordinates,txtester.gpscoordcalc.MapType.HYBRID,14,function(result){
						strUrl=result.url;
					});
					break;
				case "openstreetmap_org":

					//strUrl= "http://www.openstreetmap.org/?mlat=" + m_fLatLon(objCoordinates.LatLonDec.lat,false,6) + "&mlon=" + m_fLatLon(lon,false,6) + "&zoom=15";
					txtester.gpscoordcalc.getMapUrl("openstreetmap.org",objCoordinates,txtester.gpscoordcalc.MapType.BASIC,18,function(result){
						strUrl=result.url;
					});		
					break;
				case "yahoo_com_m":
					//strUrl= "http://maps.yahoo.com/#mvt=m&lat=" + m_fLatLon(lat,false,6) + "&lon=" + m_fLatLon(lon,false,6) + "&zoom=15";
					txtester.gpscoordcalc.getMapUrl("yahoo.com",objCoordinates,txtester.gpscoordcalc.MapType.MAP,15,function(result){
						strUrl=result.url;
					});
					break;
				case "yahoo_com_s":
					//strUrl= "http://maps.yahoo.com/#mvt=s&lat=" + m_fLatLon(lat,false,6) + "&lon=" + m_fLatLon(lon,false,6) + "&zoom=15";
					txtester.gpscoordcalc.getMapUrl("yahoo.com",objCoordinates,txtester.gpscoordcalc.MapType.SATELLITE,14,function(result){
						strUrl=result.url;
					});
					break;
				case "yahoo_com_h":
					//strUrl= "http://maps.yahoo.com/#mvt=h&lat=" + m_fLatLon(lat,false,6) + "&lon=" + m_fLatLon(lon,false,6) + "&zoom=15";
					txtester.gpscoordcalc.getMapUrl("yahoo.com",objCoordinates,txtester.gpscoordcalc.MapType.HYBRID,14,function(result){
						strUrl=result.url;
					});
					break;
				case "geocaching_nearest_map":
					strUrl = "http://www.geocaching.com/seek/gmnearest.aspx?lat=" + m_fLatLon(objCoordinates.LatLonDec.lat,false,6) + "&lon=" + m_fLatLon(objCoordinates.LatLonDec.lon,false,6);
					break;
				case "geocaching_nearest_lst":
					strUrl = "http://www.geocaching.com/seek/nearest.aspx?lat=" + m_fLatLon(objCoordinates.LatLonDec.lat,false,6) + "&lon=" + m_fLatLon(objCoordinates.LatLonDec.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(num, len1, len2){

		var _num;
		var L=parseInt(num,10);

		var s="";
		var i=0;

		var R=num-L;
		R=R.toFixed(len2);

		L=L.toString();
		R=R.toString();
		R=R.substr(2,R.length-2);

		len1=len1-L.length;
		if(len1>0){
			for(i=0;i<len1;i++){
				s+="0";
			}			
		}

		_num=s+L;
		if(len2>0) _num+="."+R;
		return(_num);

	}

	function m_fLatLon(objDec, bolWritePlus, optional_intCharPerDec){
		if(isNaN(parseInt(optional_intCharPerDec)))optional_intCharPerDec = 6;


		with(objDec){
			var a = deg.toFixed(optional_intCharPerDec);
			a=a.toString();
			if((latlonChar == "S") || (latlonChar == "W")|| (latlonChar == "-")) a = "-" + a;
			if((bolWritePlus) && ((latlonChar == "N") || (latlonChar == "E"))) a = "+" + a; 
		}
		return(a);
	}

}//clsGPSViewer



-->
