function init() {  
google.earth.createInstance("map3d", initCallback, failureCallback);
}
function initCallback(object) {  
ge = object;  ge.getWindow().setVisibility(true);

var oldFlyToSpeed = ge.getOptions().getFlyToSpeed();
ge.getOptions().setFlyToSpeed(ge.SPEED_TELEPORT); 

// Initial view of 
var la = ge.createCamera('');
la.set(54.46176, -2.99557,2210.63099, ge.ALTITUDE_RELATIVE_TO_GROUND,-76.08183,59.69066,0);   
ge.getView().setAbstractView(la);        
ge.getOptions().setFlyToSpeed(.25); 
document.getElementById("inf").innerHTML="3D Map of the Easedale Fells.";

// *************************** Network Link **************************************************
var networkLink = ge.createNetworkLink("");
networkLink.setDescription("NetworkLink open to fetched content");
networkLink.setName("Open NetworkLink");
networkLink.setFlyToView(false);  

// create a Link object
var link = ge.createLink("");
link.setHref("http://english-lake-district.info" +
             "/geo-content/easedale-fells.kml");

// attach the Link to the NetworkLink
networkLink.setLink(link);

// add the NetworkLink feature to Earth
ge.getFeatures().appendChild(networkLink);

// *************************** end **************************************************

var navControl = ge.getNavigationControl();
navControl.setVisibility(ge.VISIBILITY_SHOW);
}
//***********************************************************************************

function failureCallback(object) {
}

//************************************************************************************
//************************ hide navigation control ***********************************
function navigationc(){
var navControl = ge.getNavigationControl();
navControl.setVisibility(ge.VISIBILITY_HIDE);
}
//************************************************************************************
//************************* display new views and text *******************************
function test(x,y,ht,hd,an,ds,tx){
 var la = ge.createLookAt('');
la.set(x, y,ht, ge.ALTITUDE_RELATIVE_TO_GROUND, 
     hd,an, ds);
          document.getElementById("inf").innerHTML=tx;
ge.getView().setAbstractView(la);       
}
//************************************************************************************

function vCapture()
{
    var la=ge.getView().copyAsCamera(ge.ALTITUDE_RELATIVE_TO_GROUND)
	var tilt=la.getTilt();
	var lat=la.getLatitude(); 
	var lon=la.getLongitude();
	var al=la.getAltitude();
	var head=la.getHeading()
	//var range=la.getRange()
	var text="Latitude: " + lat.toFixed(5) +  '\n' + "Longitude: " + lon.toFixed(5) + '\n' + "Altitude: "+ al.toFixed(5) + '\n' + "Heading: " + head.toFixed(5) + '\n' + "Tilt: " + tilt.toFixed(5) 
	alert(text)
  
//document.getElementById("inf").innerHTML=text;
}
// from Grasmere to Calf Crag via Helm Crag
function fire1() {test(54.45907,  -3.02360,  332.17316, -157.55559,  1.49989,  0,'Grasmere Village.<br/><br/><form action="#" name="myform2"><input type="button" class="bt" value="next" onclick="fire2()"/></form>')} 
function fire2() {test(54.46347,  -3.03835,  213.50913,   0.38241,  72.29693,  0,'Ascent to Helm Crag from Easedale.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire3()"/><input type="button" class="bt" value="previous" onclick="fire1()"/></form>')}  
function fire3() {test(54.47001,  -3.04234,  527.39505,  51.67916,  29.99726,  0,'To the Lion and the Lamb.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire4()"/><input type="button" class="bt" value="previous" onclick="fire2()"/></form>')}  
function fire4() {test(54.47831,  -3.04000,  419.12017, -172.86894, 54.89752,  0,'Helm Crag summit.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire5()"/><input type="button" class="bt" value="previous" onclick="fire3()"/></form>')}  
function fire5() {test(54.47397,  -3.04422,  303.65982,  -32.02238, 64.79594,  0,'To Gibson Knott.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire6()"/><input type="button" class="bt" value="previous" onclick="fire4()"/></form>')}  
function fire6() {test(54.47735,  -3.04890,  340.61403,  -41.47619, 56.70077,  0,'Gibson Knott.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire7()"/><input type="button" class="bt" value="previous" onclick="fire5()"/></form>')}  
function fire7() {test(54.47573,  -3.05339,  851.09511,  -41.47984, 56.69691,  0,'Ridge path to Calf Crag.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire8()"/><input type="button" class="bt" value="previous" onclick="fire6()"/></form>')}  
function fire8() {test(54.48551,  -3.08762,  495.28330,   99.99760, 56.86133,  0,'Calf Crag.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="Start Again?" onclick="fire1()"/><input type="button" class="bt" value="previous" onclick="fire6()"/></form>')}  

//via Sergeant Man via Tarn Crag
function fire10() {test(54.45907, -3.02360,  332.17316, -157.55559,   1.49989,  0,'Grasmere Village<br/><br/><form action="#" name="myform2"><input type="button" class="bt" value="next" onclick="fire11()"/></form>')} 
function fire11() {test(54.46598, -3.03952,  349.46294, -48.21856,  64.79683,  0,'Take path into Far Easedale.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire12()"/><input type="button" class="bt" value="previous" onclick="fire10()"/></form>')}  
function fire12() {test(54.47616, -3.05182,  249.45352, -153.97856,  47.70145,  0,'Cross Easedale Beck and take path towards the Tarn.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire13()"/><input type="button" class="bt" value="previous" onclick="fire11()"/></form>')}  
function fire13() {test(54.46757, -3.05486,  825.85089,  -35.71737,  49.21064,  0,'Ascend the East Ridge of Tarn Crag.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire14()"/><input type="button" class="bt" value="previous" onclick="fire12()"/></form>')}  
function fire14() {test(54.47634, -3.08619,  465.11070,  109.15714,  49.81064,  0,'Tarn Crag<br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire15()"/><input type="button" class="bt" value="previous" onclick="fire13()"/></form>')}  
function fire15() {test(54.47633, -3.07484, 1093.93785, -120.78363,  43.80549,  0,'Ascent to Sergeant Man across rough and sometimes boggy terrain.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire16()"/><input type="button" class="bt" value="previous" onclick="fire14()"/></form>')}  
function fire16() {test(54.46513, -3.10930,  836.32726,   39.83831,  43.20518,  0,'Sergeant Man.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="Start Again?" onclick="fire10()"/><input type="button" class="bt" value="previous" onclick="fire15()"/></form>')}  

// Sergeant Man via Easedale Tarn
function fire20() {test(54.45907, -3.02360,  332.17316, -157.55559,   1.49989,  0,'Grasmere Village<br/><br/><form action="#" name="myform2"><input type="button" class="bt" value="next" onclick="fire21()"/></form>')} 
function fire21() {test(54.46184, -3.03110,  414.55079,  -63.06168,  55.39660,  0,'Follow sign to Easdale Tarn towards the end of Easdale Road.  Cross bridge under trees.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire22()"/><input type="button" class="bt" value="previous" onclick="fire20()"/></form>')}  
function fire22() {test(54.46632, -3.04488,  895.62020, -68.92290,   33.49114,  0,'Climb path beside Sour Milk Gill towards Easedale Tarn.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire23()"/><input type="button" class="bt" value="previous" onclick="fire21()"/></form>')}  
function fire23() {test(54.46797, -3.05865,  501.35335, -70.73410,   58.09002,  0,'Easedale Tarn.<br/><br/> <form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire24()"/><input type="button" class="bt" value="previous" onclick="fire22()"/></form>')}  
function fire24() {test(54.47164, -3.06567,  538.72867, -126.08982,  60.48699,  0,'Take the path up to Blea Rigg and follow the ridge west - or continue along the path adjacent to Easedale Tarn and ascend the ridge by Belles Knott.<br/><br/> <form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire25()"/><input type="button" class="bt" value="previous" onclick="fire23()"/></form>')}  
function fire25() {test(54.46766, -3.09995,  1010.15995,   3.03228,  10.39269,  0,'Final Ascent to Sergeant Man.<br/><br/> <form action="#" name="myform3"><input type="button" class="bt" value="Start Again?" onclick="fire20()"/><input type="button" class="bt" value="previous" onclick="fire24()"/></form>')}  

// from Grasmere to High Raise via Sergeant Man
function fire31() {test(54.45907,  -3.02360,  332.17316, -157.55559,  1.49989,  0,'Grasmere Village.<br/><br/><form action="#" name="myform2"><input type="button" class="bt" value="next" onclick="fire32()"/></form>')} 
function fire32() {test(54.46548,  -3.03745,  124.92055,  -50.22004, 62.56148,  0,'Passing through Easedale.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire33()"/><input type="button" class="bt" value="previous" onclick="fire31()"/></form>')}  
function fire33() {test(54.47428,  -3.04925,  281.60327,  -62.37965, 61.36013,  0,'Cross bridge and take the right hand path into Far Easedale.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire34()"/><input type="button" class="bt" value="previous" onclick="fire32()"/></form>')}  
function fire34() {test(54.47648,  -3.04910,  631.06980,  -79.92953, 61.05327,  0,'Head to the top end of Far Easedale where 4 paths cross.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire35()"/><input type="button" class="bt" value="previous" onclick="fire33()"/></form>')}  
function fire35() {test(54.48433,  -3.08788,   97.45205, -158.11979, 73.44923,  0,'Take the left hand path and ascend the norther slopes of Sergeant Man.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire36()"/><input type="button" class="bt" value="previous" onclick="fire34()"/></form>')}  
function fire36() {test(54.47344,  -3.09641,  222.36368, -140.57673, 65.94260,  0,'Sergeant Man.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire37()"/><input type="button" class="bt" value="previous" onclick="fire35()"/></form>')}  
function fire37() {test(54.46726,  -3.10079,  491.03788,  -19.53030, 58.44029,  0,'Cross Moorland to High White Stones and High Raise.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="next" onclick="fire38()"/><input type="button" class="bt" value="previous" onclick="fire36()"/></form>')}  
function fire38() {test(54.47443,  -3.12640,  766.79602,   77.64886, 55.74278,  0,'High White Stone and High Raise.<br/><br/><form action="#" name="myform3"><input type="button" class="bt" value="Start Again?" onclick="fire31()"/><input type="button" class="bt" value="previous" onclick="fire37()"/></form>')}  



	