whichFormat = 1; //latlon = 47.1245643544; function initLatLonWidget(latlonCtrl){ self[latlonCtrl+'_opt1'] = document.getElementById(latlonCtrl+'_opt1x'); self[latlonCtrl+'_opt1_1'] = document.getElementById(latlonCtrl+'_opt1_1x'); self[latlonCtrl+'_opt1_2'] = document.getElementById(latlonCtrl+'_opt1_2x'); self[latlonCtrl+'_opt1_3'] = document.getElementById(latlonCtrl+'_opt1_3x'); self[latlonCtrl+'_opt1_4'] = document.getElementById(latlonCtrl+'_opt1_4x'); self[latlonCtrl+'_opt2'] = document.getElementById(latlonCtrl+'_opt2x'); self[latlonCtrl+'_opt2_1'] = document.getElementById(latlonCtrl+'_opt2_1x'); self[latlonCtrl+'_opt2_2'] = document.getElementById(latlonCtrl+'_opt2_2x'); self[latlonCtrl+'_opt2_3'] = document.getElementById(latlonCtrl+'_opt2_3x'); self[latlonCtrl+'_opt3'] = document.getElementById(latlonCtrl+'_opt3x'); self[latlonCtrl+'_opt3_1'] = document.getElementById(latlonCtrl+'_opt3_1x'); //self[latlonCtrl+'_arrowLatLon'] = document.getElementById(latlonCtrl+'_arrowx'); //arrowLatLon.style.left = opt1.offsetLeft+opt1.offsetWidth+2+"px"; self[latlonCtrl+'_opt2_3'].style.width = (self[latlonCtrl+'_opt1'].offsetWidth-self[latlonCtrl+'_opt2_1'].offsetWidth-self[latlonCtrl+'_opt2_2'].offsetWidth-4)+"px"; self[latlonCtrl+'_opt3_1'].style.width = (self[latlonCtrl+'_opt1'].offsetWidth-4)+"px"; } function latLonWidgetVisibility(){ self["lat0_opt"+whichFormat].style.visibility = "hidden"; self["lat1_opt"+whichFormat].style.visibility = "hidden"; self["lon0_opt"+whichFormat].style.visibility = "hidden"; self["lon1_opt"+whichFormat].style.visibility = "hidden"; whichFormat = 4-degreeDisplayMode; self["lat0_opt"+whichFormat].style.visibility = "visible"; self["lat1_opt"+whichFormat].style.visibility = "visible"; self["lon0_opt"+whichFormat].style.visibility = "visible"; self["lon1_opt"+whichFormat].style.visibility = "visible"; } changed2_3 = false; //setOpt1(); setOpt2(); setOpt3(); function setFixed(ctrl){ setOpt1(); setOpt2(); setOpt3(); changed2_3 = false; } // Dir / degrees / minutes / seconds input change function opt1_1Change(newVal, latlonCtrl){ self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } function opt1_2Change(newVal, latlonCtrl){ if(isNaN(newVal)||(newVal<0)) { alert("Degrees must be greater than 0.0"); self[latlonCtrl+'_opt1_2'].value=saveVal; return false; } if(latlonCtrl.indexOf("lat")>=0) { degLimit = 90; } else { degLimit = 180; } newVal = newVal%degLimit; self[latlonCtrl+"_latlon"] = Number(newVal) + Number(self[latlonCtrl+'_opt2_3'].value)/60.0; if(self[latlonCtrl+'_opt1_1'].options[1].selected) { self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; } //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } function opt1_3Change(newVal, latlonCtrl){ if(isNaN(newVal)||(newVal<0)||(newVal>59)) { alert("Minutes must be between 0 and 60"); self[latlonCtrl+'_opt1_3'].value=saveVal; return false; } self[latlonCtrl+"_latlon"] = Number(self[latlonCtrl+'_opt1_2'].value) + Number(newVal)/60.0 + Number(self[latlonCtrl+'_opt1_4'].value)/3600.0; if(self[latlonCtrl+'_opt1_1'].options[1].selected) { self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; } //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } function opt1_4Change(newVal, latlonCtrl){ if(isNaN(newVal)||(newVal<0)||(newVal>59.99)) { alert("Seconds must be between 0 and 60"); self[latlonCtrl+'_opt1_4'].value=saveVal; return false; } self[latlonCtrl+"_latlon"] = Number(self[latlonCtrl+'_opt1_2'].value) + Number(self[latlonCtrl+'_opt1_3'].value)/60.0 + Number(newVal)/3600.0; if(self[latlonCtrl+'_opt1_1'].options[1].selected) { self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; } //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } // Dir / degrees / decimal minutes input change function opt2_1Change(newVal, latlonCtrl){ self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } function opt2_2Change(newVal, latlonCtrl){ if(isNaN(newVal)||(newVal<0)) { alert("Degrees must be greater than 0.0"); self[latlonCtrl+'_opt2_2'].value=saveVal; return false; } if(latlonCtrl.indexOf("lat")>=0) { degLimit = 90; } else { degLimit = 180; } newVal = newVal%degLimit; self[latlonCtrl+"_latlon"] = Number(newVal) + Number(self[latlonCtrl+'_opt2_3'].value)/60.0; if(self[latlonCtrl+'_opt2_1'].options[1].selected) { self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; } //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } function opt2_3Change(newVal, latlonCtrl){ if(isNaN(newVal)||(newVal<0)||(newVal>59.9999999)) { alert("Minutes must be between 0 and 60"); self[latlonCtrl+'_opt2_3'].value=saveVal; return false; } if(newVal.substr(-1)==".") { return; } self[latlonCtrl+"_latlon"] = Number(self[latlonCtrl+'_opt2_2'].value) + Number(newVal)/60.0; if(self[latlonCtrl+'_opt2_1'].options[1].selected) { self[latlonCtrl+"_latlon"] = -self[latlonCtrl+"_latlon"]; } //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } // Decimal degrees input change function opt3Change(newVal, latlonCtrl){ if(isNaN(newVal)) { return false; } self[latlonCtrl+"_latlon"] = newVal%180; //setOpt1(latlonCtrl); setOpt2(latlonCtrl); setOpt3(latlonCtrl); } function setOpt1(latlonCtrl){ if(self[latlonCtrl+"_latlon"]=="") { // Create New AOI if(latlonCtrl.substr(0,3)=="lon") { // Set N/S E/W to initial values of N & W self[latlonCtrl+'_opt1_1'].options[1].selected = true; }else { self[latlonCtrl+'_opt1_1'].options[0].selected = true; } } else { // Edit an AOI if(self[latlonCtrl+"_latlon"]<0) { // Set N/S E/W based on latlon value self[latlonCtrl+'_opt1_1'].options[1].selected = true; }else { self[latlonCtrl+'_opt1_1'].options[0].selected = true; } } self[latlonCtrl+'_opt1_2'].value = Math.floor(Math.abs(self[latlonCtrl+"_latlon"])); var minutes = ((Math.abs(self[latlonCtrl+"_latlon"])-self[latlonCtrl+'_opt1_2'].value)*60.0).toFixed(4); self[latlonCtrl+'_opt1_3'].value = Math.floor(minutes); self[latlonCtrl+'_opt1_4'].value = ((minutes-Number(self[latlonCtrl+'_opt1_3'].value))*60.0).toFixed(2); } function setOpt2(latlonCtrl){ if(self[latlonCtrl+"_latlon"]<0) { self[latlonCtrl+'_opt2_1'].options[1].selected = true; }else { self[latlonCtrl+'_opt2_1'].options[0].selected = true; } self[latlonCtrl+'_opt2_2'].value = Math.floor(Math.abs(self[latlonCtrl+"_latlon"])); self[latlonCtrl+'_opt2_3'].value = Math.round(((Math.abs(self[latlonCtrl+"_latlon"])-self[latlonCtrl+'_opt2_2'].value)*60.0)*Math.pow(10,4))/Math.pow(10,4); } function setOpt3(latlonCtrl){ self[latlonCtrl+'_opt3_1'].value = Math.round(self[latlonCtrl+"_latlon"]*Math.pow(10,6))/Math.pow(10,6); }