// global check for the retarded browser (IE) // $Revision: 1.173 $ var uA = navigator.userAgent; var prefWin; var ie = false; if(uA.indexOf("MSIE") != -1){ ie = true; } function newWindow(event, dcontent, dwidth, dheight, dx, dy, name) { var posX = event.screenX; var posY = event.screenY; if(dx == ''){ dx = 15; } if(dy == ''){ dy = 15; } posX = posX + 15; posY = posY + 15; name = name + ""; var win = window.open(dcontent, name, 'status, resizable'); win.resizeTo(dwidth,dheight); win.moveTo(posX,posY); win.focus(); return win; } // IGUI functions function newPrefWindow(event, dcontent, dwidth, dheight, dx, dy, name) { var wsidElm = document.myForm.prefWSID; var showSecondSet = document.getElementById("showSecondSet").value; //alert(dcontent); if(wsidElm != null){ var wsid = wsidElm.value; //alert(wsid); if(wsid != ""){ var pair = dcontent.split("wsid="); //alert(pair[1]); var after = pair[1]; var idx = after.indexOf("&"); after = after.substring(idx); after = "wsid=" + wsid + "&" + after; dcontent = pair[0] + after; //alert(dcontent); } } if(showSecondSet != ""){ if(dcontent.indexOf("showSecondSet") > -1){ var pair = dcontent.split("showSecondSet="); var after = pair[1]; var idx = after.indexOf("&"); after = after.substring(idx); after = "showSecondSet=" + showSecondSet + "&" + after; dcontent = pair[0] + after; }else{ dcontent += "&showSecondSet=" + showSecondSet; } } prefWin = newWindow(event, dcontent, dwidth, dheight, dx, dy, name); } function updateSelectionAndControlsUI() { var iid = content.document.myForm.instance_id.value; var wsid = content.document.myForm.wsid.value; var app = content.document.myForm.app.value; var gsid = content.document.myForm.gsid.value; var initq = content.location.search; //alert(iid + ", " + wsid); var queryStr = 'instance_id='+iid+'&wsid='+wsid+'&app='+app+'&gsid='+gsid; if(initq.indexOf("selection=true") < 0){ selection.location.search = queryStr; } controls.location.search = queryStr; //scrollRight(); } function updateSelectionUI() { var iid = content.document.myForm.instance_id.value; var wsid = content.document.myForm.wsid.value; var app = content.document.myForm.app.value; var gsid = content.document.myForm.gsid.value; var queryStr = 'instance_id='+iid+'&wsid='+wsid+'&app='+app+'&gsid='+gsid; selection.location.search = queryStr; } function submitForm(frameId) { if( validate() ){ //var uiForm; //if(frameId == 'constraints'){ // uiForm = constraints.document.myForm; //}else{ var uiForm = document.getElementById('myForm'); //} //alert( document.getElementById('prefWSID').value ); uiForm.action = '/daac-bin/G3/iExecute.pl'; uiForm.target = 'content'; uiForm.submit(); uiForm.action = '/daac-bin/G3/constraints.pl'; uiForm.target = ''; //if(!ie){ window.opener.focus(); //} } } function editPreferences() { //var east = document.getElementById('East').value; //var west = document.getElementById('West').value; //var north = document.getElementById('North').value; //var south = document.getElementById('South').value; //var byrElm = document.getElementById('byr'); //var bmoElm = document.getElementById('bmo'); //var bdyElm = document.getElementById('bdy'); //var bhrElm = document.getElementById('bhr'); //var bminElm = document.getElementById('bmin'); //var bsecElm = document.getElementById('bsec'); //var eyrElm = document.getElementById('eyr'); //var emoElm = document.getElementById('emo'); //var edyElm = document.getElementById('edy'); //var ehrElm = document.getElementById('ehr'); //var eminElm = document.getElementById('emin'); //var esecElm = document.getElementById('esec'); var uiForm = document.myForm; uiForm.target = ''; uiForm.action = '/daac-bin/G3/plotPrefs.cgi'; uiForm.submit(); } function editCriteria() { var uiForm = document.getElementById('myForm'); uiForm.action = '/daac-bin/G3/constraints.pl'; uiForm.submit(); } // works only for select lists function selectAll(elmId,select){ var elm = document.getElementById(elmId); var type = elm.type; if( type.indexOf('select-mult') > -1 ){ var options = elm.options; if(select){ for(var i=0;i -1 ? action = 'show' : action = 'hide'; if(action == 'show'){ contentElm.style.display = 'block'; contentElm.style.visibility = 'visible'; button.value = 'Remove Second Set of Criteria'; if(contentId == 'secondSet'){ document.getElementById('showSecondSet').value = '1'; document.getElementById('experiments2').disabled = false; document.getElementById('models2').disabled = false; document.getElementById('diagnostics2').disabled = false; document.getElementById('variables2').disabled = false; } }else if(action == 'hide'){ contentElm.style.display = 'none'; contentElm.style.visibility = 'hidden'; button.value = 'Select Second Set of Criteria'; if(contentId == 'secondSet'){ document.getElementById('showSecondSet').value = '0'; document.getElementById('experiments2').disabled = true; document.getElementById('models2').disabled = true; document.getElementById('diagnostics2').disabled = true; document.getElementById('variables2').disabled = true; } } } function clearPrefWSID() { document.getElementById("prefWSID").value = ""; document.getElementById("prefMessageDIV").innerHTML = ""; try{ prefWin.close(); }catch(err){} } function newVPDescWindow() { alert("Vertical Profile description text is TBD"); } function validate() { var drvRetVal = validateDateRange(); var retVal = testForParamServiceMismatch(); var vpRetVal = validateVertPickerSel(); var spRetVal = validateSpatialRange(); var climRetVal = validateClimatologySelections(); if ( drvRetVal == false || retVal == false || vpRetVal == false || spRetVal == false || climRetVal == false ) { return false; } else { return true; } } function toggleImageSize () { var btn = document.getElementById("imageSize"); var psearch = window.location.search; var imgStr = "&imageSizeOverride=1"; var images = document.images; var newWidth = 0; if(btn.value == "Enlarge Images"){ //document.getElementById("imageSizeOverride").value = 1; btn.value = "Shrink Images"; //psearch = psearch + imgStr; for(var i=0;i - 1){ //alert(images[i].width); newWidth = images[i].width*2; images[i].height = (newWidth * images[i].height) / images[i].width;; images[i].width = newWidth; //alert(images[i].width); } } }else{ //document.getElementById("imageSizeOverride").value = 0; btn.value = "Enlarge Images" //psearch = psearch.replace(imgStr,""); for(var i=0;i - 1){ newWidth = images[i].width/2; images[i].height = (newWidth * images[i].height) / images[i].width;; images[i].width = newWidth; } } } //window.document.myForm.submit(); } // END IGUI functions function showInElement(elemID){ document.getElementById(elemID).style.border = 'thin solid red'; } function showOutOfElement(elemID){ document.getElementById(elemID).style.border = 'thin solid rgb(235,235,235)'; } function hover(bannerMenuElem) { var elemId = bannerMenuElem.id; document.getElementById(elemId).className = 'bannerMenuTD_hover'; document.getElementById(elemId + 'URL').className = 'bannerMenuAnchor_hover'; } function dehover(bannerMenuElem) { var elemId = bannerMenuElem.id; document.getElementById(elemId).className = 'bannerMenuTD'; document.getElementById(elemId + 'URL').className = 'bannerMenuAnchor'; } function imageHover(imgElem){ var elemId = imgElem.id; var srcURL = document.getElementById(elemId).src; srcURL = srcURL.replace(".gif","_hover.gif"); document.getElementById(elemId).src = srcURL; } function imageDeHover(imgElem){ var elemId = imgElem.id; var srcURL = document.getElementById(elemId).src; srcURL = srcURL.replace("_hover.gif",".gif"); document.getElementById(elemId).src = srcURL; } function formImageHover(imgElem){ //var elemId = imgElem.name; var srcURL = imgElem.src; srcURL = srcURL.replace(".gif","_hover.gif"); imgElem.src = srcURL; } function formImageDeHover(imgElem){ //var elemId = imgElem.name; var srcURL = imgElem.src; srcURL = srcURL.replace("_hover.gif",".gif"); imgElem.src = srcURL; } function formImagePressed(imgElem){ var srcURL = imgElem.src; srcURL = srcURL.replace("_hover",""); srcURL = srcURL.replace(".gif","_dn.gif"); imgElem.src = srcURL; } function formImageDePressed(imgElem){ var srcURL = imgElem.src; srcURL = srcURL.replace("_dn.gif",".gif"); imgElem.src = srcURL; } function simpleHover(elem){ var elemId = elem.id; document.getElementById(elemId).className = 'pickerHeaderHover'; } function simpleDeHover(elem){ var elemId = elem.id; document.getElementById(elemId).className = 'pickerHeader'; } // this function will only work if the passed in elem has an id that // matches the NAME of the form element and it is a checkbox. function selectAllParameters(event, elem){ // find all elements with the passed in name/id and type = 'checkbox' var elemId = elem.id; var elemForm = elem.form; var groupParams = document.getElementByName(elemId); // if the ctrlKey was selected, un-check all the paramaters; // otherwise, check all of the parameters if(event.ctrlKey == 1){ for(i=0;i eyr) || ((byr == eyr) && (bm > em)) || ((byr == eyr) && (bm == em) && (parseInt(bd) > parseInt(ed))) || ((byr == eyr) && (bm == em) && (parseInt(bd) > parseInt(ed)) && (parseInt(bhr) > parseInt(ehr))) || ((byr == eyr) && (bm == em) && (parseInt(bd) > parseInt(ed)) && (parseInt(bhr) > parseInt(ehr)) && (parseInt(bmin) > parseInt(emin))) ){ alert("The ending date-time must be more recent than the beginning date-time"); retv = false; } }else if( bhr != null && emin != null ){ if( (byr > eyr) || ((byr == eyr) && (bm > em)) || ((byr == eyr) && (bm == em) && (parseInt(bd) > parseInt(ed))) || ((byr == eyr) && (bm == em) && (parseInt(bd) > parseInt(ed)) && (parseInt(bhr) > parseInt(ehr))) ){ alert("The ending date-time must be more recent than the beginning date-time"); retv = false; } }else if( bd != null && ed != null ){ //alert(byr +","+eyr+","+bm+","+em+","+bd + "," + ed); if( (byr > eyr) || ((byr == eyr) && (bm > em)) || ((byr == eyr) && (bm == em) && (parseInt(bd) > parseInt(ed))) ){ alert("The ending date must be more recent than the beginning date"); retv = false; } }else if( bm != null && em != null ){ if( (byr > eyr) || ((byr == eyr) && (bm > em)) ){ alert("The ending date must be more recent than the beginning date"); retv = false; } }else if( byr != null && eyr != null ){ if( byr > eyr ){ alert("The ending date must be more recent than the beginning date"); retv = false; } }else{ // something is seriously wrong alert("ERROR: No date fields were found on this page. Please contact the site administrator"); return false; } if(service == 'hovemollerlatt' || service == 'hovemollerlont' || service == 'timeseries' || service == 'latlonplot_corr' || service == 'timeseries_diff' || service == 'timestats' ){ if(bmin != null){ // minutely dataset if( (byr == eyr) && (bm == em) && (ed == bd) && (bhr == ehr) && (bmin == emin) ){ alert("Beginning and ending dates are an exact match. Please select a RANGE"); retv = false; } }else if(bhr != null){ // hourly dataset if( (byr == eyr) && (bm == em) && (ed == bd) && (bhr == ehr) ){ alert("Beginning and ending dates are an exact match. Please select a RANGE"); retv = false; } }else if(bd != null){ // daily dataset if( (byr == eyr) && (bm == em) && (ed == bd) ){ alert("Beginning and ending dates are an exact match. Please select a RANGE"); retv = false; } }else if(bm != null){ // monthly dataset if( (byr == eyr) && (bm == em) ){ alert("Beginning and ending years and months are an exact match. Please select a RANGE"); retv = false; } }else if(byr != null){ if( byr == eyr ){ alert("Beginning and ending years and months are an exact match. Please select a RANGE"); retv = false; } } } // if the product date check is good, check the date range restrictions based on the intervals //if(bd != null && bhr == null){ // daily data - subject to range restriction // if( !(validateDailyDataLimit(byr,bm,bd,eyr,em,ed)) ){ // alert("We are sorry for the inconvenience, but due to extremely high data volume, queries for daily data are being restricted to approximately one year. Please reduce your time range to one year or less and re-submit. Thank you for your patience as we work to increase Giovanni's capacity."); // retv = false; // } //} if(bd != null && bhr != null ){ // hourly or minutely data - subject to range restriction if( !(validateHourlyDataLimit(byr,bm,bd,bhr,bmin,eyr,em,ed,ehr,emin)) ){ alert("We are sorry for the inconvenience, but due to extremely high data volume, queries for hourly and shorter interval data are being restricted to approximately six months. Please reduce your time range to six months or less and re-submit. Thank you for your patience as we work to increase Giovanni's capacity."); retv = false; } }else{ // if the date entries are good so far, check the user entered dates against the dates // for the selected product(s) if( retv == true ){ retv = checkProductDates(byr,bm,bd,bhr,bmin,eyr,em,ed,ehr,emin); } } return retv; } function monthToNumber( month ){ var months = new Array( 'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec' ); for( var idx = 0; idx < months.length; idx++ ){ if( month == months[idx] ){ return idx; } } } // Compares the parameter product dates to the entered dates to see if // there is no intersection at all; also checks to see if the entered // date range is overly large given the timeInterval (if any of the // parameters has something other than a yearly or monthly interval AND // the entered range is at least a year, a confirmation dialog will // be shown). function checkProductDates(byr,bm,bd,bhr,bmin,eyr,em,ed,ehr,emin){ // for each selected parameter, check it's product begin and end dates; // make sure the user selection intersects with those dates, if not, // alert the user to make a change // flag indicating daily data var dailyFlag = false; if( bd != null ){ dailyFlag = true; } // set beginning date var userBD = new Date(); if(bd == null){ bd = getEndDate(byr,bm); } userBD.setFullYear(byr,bm,bd); if(bhr != "" && bhr != null){ userBD.setHours(bhr); }else{ userBD.setHours(0); } if(bmin != "" && bmin != null){ userBD.setMinutes(bmin); }else{ userBD.setMinutes(0); } userBD.setSeconds(0); // set ending date var userED = new Date(); if(ed == null){ ed = getEndDate(eyr,em); } userED.setFullYear(eyr,em,ed); //userED.setMonth(em); if(ehr != "" && ehr != null){ userED.setHours(ehr); }else{ userED.setHours(0); } if(emin != "" && emin != null){ userED.setMinutes(emin); }else{ userED.setMinutes(0); } userED.setSeconds(0); // user entered date strings for display only var ub = byr+"/"+(bm+1); var ue = eyr+"/"+(em+1); if( (bd != "" && ed != "") && (bd != null && ed != null) ){ ub = ub + "/" + bd; ue = ue + "/" + ed; } if( (bhr != "" && ehr != "") && (bhr != null && ehr != null) ){ ub = ub + ":" + bhr; ue = ue + ":" + ehr; } if( (bmin != "" && emin != "") && (bmin != null && emin != null) ){ ub = ub + ":" + bmin; ue = ue + ":" + emin; } // look for all of the check controls having an associated hidden field // with a value of *_DATERANGE var controls = document.getElementsByTagName("input"); var cElm; // control element var rawDR = ""; // raw date range var rawA; // array of date range values var sn = "" // associated paramter shortname var cid; // control element id var drid; // date range id var dA; // parameter date array var pb; // parameter begin date var pe; // parameter end date var eM = ""; // error message string var retv = true; // return value var smallInterval = false; // set true when interval is less than monthly var oneDay = 1000 * 3600 * 24; for(var idx = 0; idx < controls.length; idx++){ cElm = controls[idx]; cid = cElm.id; if( cElm.type == 'checkbox' && cElm.checked == true && (cid.indexOf("PK_") > -1 || cid.indexOf("Parameter_") > -1) && cid.indexOf("CB_") < 0 ){ //process try{ drid = cid + "_DATERANGE"; rawDR = document.getElementById(drid).value; //alert(cid + " date range: " + rawDR); if(rawDR != ""){ rawA = rawDR.split(':'); sn = rawA[0]; rawA[1] = rawA[1].replace(' ',''); dA = rawA[1].split('-'); pb = dA[0]; pe = dA[1]; dateFields = pb.split("/"); if( dateFields.length < 3 ){ pb = pb + "/" + daysOfTheMonth(pb); pe = pe + "/" + daysOfTheMonth(pe); } pb = Date.parse(pb); pe = Date.parse(pe); // if the pe < userBD or pb > userED, // collect the parameter and condition // alert( "pe: " +pe+ ", userBD: " + Date.parse(userBD) + ", pb: " + pb + ", userED: " + Date.parse(userED) ); if( Date.parse(userBD) < pb ){ // the user-entered begin date is more recent than the data begin date eM = eM + "\n\nThe user-entered begin date (" + ub + ") is older than the product ("+sn+") begin date ("+dA[0]+")"; retv = false; }else if( Date.parse(userED) < pb ){ eM = eM + "\n\nThe user-entered begin date (" + ub + ") is older than the product ("+sn+") begin date ("+dA[0]+")"; retv = false; }else if( Date.parse(userBD) > pe ){ eM = eM + "\n\nThe user-entered begin date ("+ub+") is more recent than the product ("+sn+") end date ("+dA[1]+")"; retv = false; }else if( Date.parse(userED) > pe ){ eM = eM + "\n\nThe user-entered end date ("+ue+") is more recent than the product ("+sn+") end date ("+dA[1]+")"; retv = false; } // check the interval if(rawA[2] != 'monthly' || rawA[2] != 'yearly'){ smallInterval = true; } } }catch(err){ alert("couldn't find DR for "+cid); } } // ignore } if(eM != ""){ eM = eM + "\n\n\nPlease remove the out-of-range parameters or modify the entered date range\n"; alert(eM); } if(dailyFlag){ var ubUTC = userBD.getTime(); var ueUTC = userED.getTime(); var oneYearMS = 1000 * 3600 * 24 *365; if( ((ueUTC - ubUTC) > oneYearMS) && ( smallInterval == true ) ){ retv = confirm( "The date range you entered covers more than one year, but at least one parameter in your query has a small time interval (i.e., it is repeated daily, hourly, minutely, etc.). This could result in a great many data being returned in the query (and could take more than a few minutes). Are you sure you want to submit this large query?" ); if(retv == true){ alert("Ok. Go grab some coffee."); } } } return retv; } function daysOfTheMonth(dateString){ var dateFields = dateString.split("/"); var year = dateFields[0]; // big assumption var month = dateFields[1]; // big assumption var dd = new Date(year, month, 0); return dd.getDate(); } function checkForSouthernHemisphere(){ var retv = true; var minLat = parseFloat(document.myForm.South.value); var maxLat = parseFloat(document.myForm.North.value); if(minLat < 0 || maxLat < 0 ){ alert("Neither Snow nor Ice products have coordinates in the Southern Hemisphere. Please pick latitudes in the Northern Hemisphere"); retv = false; } return retv; } function checkOrbitTimeRange(){ var valid = true; var startHour = document.myForm.startHour.value; if( startHour == "" ){ alert( "Start hour field is blank"); return false; } var startMin = document.myForm.startMin.value; if( startMin == "" ){ alert( "Start minute field is blank"); return false; } var startSec = document.myForm.startSec.value; if( startSec == "" ){ alert( "Start second field is blank"); return false; } var stopHour = document.myForm.stopHour.value; if( stopHour == "" ){ alert( "Stop hour field is blank"); return false; } var stopMin = document.myForm.stopMin.value; if( stopMin == "" ){ alert( "Stop minute field is blank"); return false; } var stopSec = document.myForm.stopSec.value; if( stopSec == "" ){ alert( "Stop second field is blank"); return false; } startSeconds = startHour*3600 + startMin*60 + startSec; stopSeconds = stopHour*3600 + stopMin*60 + stopSec; var diff = stopSeconds - startSeconds; if(diff >= 45){ valid = true; }else{ alert("Please enter an orbit time range that is at least 45 seconds long"); valid = false; } return valid; } function writeMapInstructions(minLat,maxLat,minLon,maxLon){ var minLat_ = minLat; var maxLat_ = maxLat; var minLon_ = minLon; var maxLon_ = maxLon; if(navigator.javaEnabled()){ document.write("Click and drag to select area\; or input latitudes \("+minLat_+", "+maxLat_+ "\) and longitudes \("+minLon_+", "+maxLon_+"\)"); } } function checkJava(){ if(navigator.javaEnabled()) { return true; }else{ return false; } } function generateMap(javaEnabled, spatialImage, minLon, maxLon, minLat, maxLat, imageX, imageY, userMinLon, userMaxLon, userMinLat, userMaxLat, mapFormString){ var x = navigator; var ua = x.userAgent; if( ua.indexOf('IE') == -1 && ua.indexOf('Safari') == -1 ){ if(javaEnabled == true){ document.write("
If you enabled Java, you\'d get a more interactive map. If you have not installed the Java Runtime Environment, you can get it here.
"); }else{ document.write( mapFormString ); document.write( "
If you enabled Java, you\'d get a more interactive map. If you have not installed the Java Runtime Environment locally on your computer, you can do so here.
" ); } }else{ if(javaEnabled == true){ document.write("
If you enabled Java, you\'d get a more interactive map. If you have not installed the Java Runtime Environment, you can get it here.
"); }else{ document.write( mapFormString ); document.write( "
If you enabled Java, you\'d get a more interactive map. If you have not installed the Java Runtime Environment locally on your computer, you can do so here.
" ); } } } function enableCustomColorBar(pElm,palette,minVal,maxVal){ var pickerId = pElm.id; var palElm = document.getElementById(palette); var minValElm = document.getElementById(minVal); var maxValElm = document.getElementById(maxVal); var palElmLbl = document.getElementById(palette + 'Lbl'); //alert(pickerId); if(pElm.id == 'custom'){ palElm.disabled = false; minValElm.disabled = false; maxValElm.disabled = false; }else{ palElm.disabled = true; minValElm.disabled = true; maxValElm.disabled = true; } } function checkSpatialFields(){ var w = document.myForm.West.value; var e = document.myForm.East.value; var n = document.myForm.North.value; var s = document.myForm.South.value; if(w == "" || e == "" || n == "" || s == ""){ alert( "Some of the spatial fields are empty. Please re-load your page and submit again."); return false; }else{ return true; } } function showCBDIV(cb){ var cbid = cb.id; var divid = cbid.replace(/CB/,'DIV'); var cbDIV = document.getElementById(divid); if( cb.checked == true ){ cbDIV.style.display = 'block'; cbDIV.style.visibility = 'visible'; }else{ cbDIV.style.display = 'none'; cbDIV.style.visibility = 'hidden'; } } function checkForCloudSat(){ var iid = document.getElementById("instance_id").value; if(iid.search(/a-train/i) != -1 || iid.search(/atrain/i) != -1){ var x=document.getElementsByTagName("input"); //var cbs; //var xcount = 0; //for(xidx=0;xidx