function GKtoGeo(p1, p2) {

	var GKRight, GKHeight;
	var GeoDezRight, GeoDezHeight;
	var arrResult = new Array(2);
	
	GKRight = parseInt(p1);
	GKHeight = parseInt(p2);
	
	if (!((GKRight > 1000000) && (GKHeight > 1000000))) {
		return arrResult;
	}
	
	var bII, bf, co, g2, g1, t, fa, dl, min, sek, rho, e2 = 0.0067192188, c = 6398786.849;
	
	rho = 180 / Math.PI;
	bII = (GKHeight / 10000855.7646) * (GKHeight / 10000855.7646);
	bf = 325632.08677 * (GKHeight / 10000855.7646) * ((((((0.00000562025 * bII + 0.00022976983) * bII - 0.00113566119) * bII + 0.00424914906) * bII - 0.00831729565) * bII + 1));
	bf /= 3600 * rho;
	co = Math.cos(bf);
	g2 = e2 * (co * co);
	g1 = c / Math.sqrt(1 + g2);
	t = Math.tan(bf);
	fa = (GKRight - Math.floor(GKRight / 1000000) * 1000000 - 500000) / g1;
	GeoDezRight = ((bf - fa * fa * t * (1 + g2) / 2 + fa * fa * fa * fa * t * (5 + 3 * t * t + 6 * g2 - 6 * g2 * t * t) / 24) * rho);
	dl = fa - fa * fa * fa * (1 + 2 * t * t + g2) / 6 + fa * fa * fa * fa * fa * (1 + 28 * t * t + 24 * t * t * t * t) / 120;
	GeoDezHeight = dl * rho / co + Math.floor(GKRight / 1000000) * 3;
	
	var CartesianXMeters, CartesianYMeters, CartesianZMeters, n, aBessel = 6377397.155, eeBessel = 0.0066743722296294277832, CartOutputXMeters, CartOutputYMeters, CartOutputZMeters, ScaleFactor = 0.00000982, RotXRad = -7.16069806998785E-06, RotYRad = 3.56822869296619E-07, RotZRad = 7.06858347057704E-06, ShiftXMeters = 591.28, ShiftYMeters = 81.35, ShiftZMeters = 396.39, aWGS84 = 6378137, eeWGS84 = 0.0066943799;
	var Latitude, LatitudeIt;
	
	GeoDezRight = (parseFloat(GeoDezRight) / 180) * Math.PI;
	GeoDezHeight = (parseFloat(GeoDezHeight) / 180) * Math.PI;

	n = eeBessel * Math.sin(parseFloat(GeoDezRight)) * Math.sin(parseFloat(GeoDezRight));
	n = 1 - n;
	n = Math.sqrt(n)
	n = aBessel / n

	CartesianXMeters = n * Math.cos(parseFloat(GeoDezRight)) * Math.cos(parseFloat(GeoDezHeight));
	CartesianYMeters = n * Math.cos(parseFloat(GeoDezRight)) * Math.sin(parseFloat(GeoDezHeight));
	CartesianZMeters = n * (1 - eeBessel) * Math.sin(parseFloat(GeoDezRight));
	
	CartOutputXMeters = (1 + ScaleFactor) * CartesianXMeters + RotZRad * CartesianYMeters - RotYRad * CartesianZMeters + ShiftXMeters;
	CartOutputYMeters = -RotZRad * CartesianXMeters + (1 + ScaleFactor) * CartesianYMeters + RotXRad * CartesianZMeters + ShiftYMeters;
	CartOutputZMeters = RotYRad * CartesianXMeters - RotXRad * CartesianYMeters + (1 + ScaleFactor) * CartesianZMeters + ShiftZMeters;
	
	GeoDezHeight = Math.atan((CartOutputYMeters / CartOutputXMeters));

	Latitude = (CartOutputXMeters * CartOutputXMeters) + (CartOutputYMeters * CartOutputYMeters);
	Latitude = Math.sqrt(Latitude);
	Latitude = CartOutputZMeters / Latitude;
	Latitude =  Math.atan(Latitude);
	LatitudeIt = 99999999;

	do {
		LatitudeIt = Latitude;
	    
	    n = 1 - eeWGS84 * Math.sin(Latitude) * Math.sin(Latitude);
	    n = Math.sqrt(n);
	    n = aWGS84 / n;
	    Latitude = CartOutputXMeters * CartOutputXMeters + CartOutputYMeters * CartOutputYMeters;
	    Latitude = Math.sqrt(Latitude);
	    Latitude = (CartOutputZMeters + eeWGS84 * n * Math.sin(LatitudeIt)) / Latitude;
	    Latitude = Math.atan(Latitude);
	} while (Math.abs(Latitude - LatitudeIt) >= 0.000000000000001);
	
	GeoDezRight = (Latitude / Math.PI) * 180;
	GeoDezHeight = (parseFloat(GeoDezHeight) / Math.PI) * 180;
	
	/*
		alert('GeoDezRight:' + GeoDezRight);
		alert('GeoDezHeight:' + GeoDezHeight);
	
		GeoDezRightStr = GetGeoStringFromGeoDez(parseFloat(GeoDezRight));
		GeoDezHeightStr = GetGeoStringFromGeoDez(parseFloat(GeoDezHeight));
		alert('GeoDezRightStr:' + GeoDezRightStr);
		alert('GeoDezHeightStr:' + GeoDezHeightStr);
	*/
	arrResult[0] = GeoDezRight;
	arrResult[1] = GeoDezHeight;
	
	return arrResult;
}
	
function GetGeoStringFromGeoDez(GeoDez) {

	var SecondsAbs, ShortedSecondsRest;

	SecondsAbs = (GeoDez - Math.floor(GeoDez) - Math.floor((GeoDez - Math.floor(GeoDez)) * 60) / 60) * 60 * 60;
	ShortedSecondsRest = SecondsAbs - Math.floor(SecondsAbs)
	SecondsAbs = Math.floor(SecondsAbs)
	ShortedSecondsRest = Math.floor(ShortedSecondsRest * 100) // -> Zwei Stellen

	return(Math.floor(GeoDez) + "°" + Math.floor((GeoDez - Math.floor(GeoDez)) * 60) + "'" + SecondsAbs + "." + ShortedSecondsRest + '"');
}


