             var map;
            function init(){
                var tabView = new YAHOO.widget.TabView('search-flow'); 
                map = new OpenLayers.Map('map');
                
                map.addControl(new OpenLayers.Control.MousePosition());
                var control = new OpenLayers.Control();
                OpenLayers.Util.extend(control, {
                    draw: function(){
                        // this Handler.Box will intercept the shift-mousedown
                        // before Control.MouseDefault gets to see it
                        this.box = new OpenLayers.Handler.Box(control, {
                            "done": this.setAOI
                        }, {
                            keyMask: OpenLayers.Handler.MOD_NONE
                        });
                        this.box.activate();
                    },
                    
                    setAOI: function(position){
                        if (!this.out) {
                            var minXY = this.map.getLonLatFromPixel(new OpenLayers.Pixel(position.left, position.bottom));
                            var maxXY = this.map.getLonLatFromPixel(new OpenLayers.Pixel(position.right, position.top));
                            var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat, maxXY.lon, maxXY.lat);
                        }
                        else {
                            var pixWidth = Math.abs(position.right - position.left);
                            var pixHeight = Math.abs(position.top - position.bottom);
                            var zoomFactor = Math.min((this.map.size.h / pixHeight), (this.map.size.w / pixWidth));
                            var extent = this.map.getExtent();
                            var center = this.map.getLonLatFromPixel(position.getCenterPixel());
                            var xmin = center.lon - (extent.getWidth() / 2) * zoomFactor;
                            var xmax = center.lon + (extent.getWidth() / 2) * zoomFactor;
                            var ymin = center.lat - (extent.getHeight() / 2) * zoomFactor;
                            var ymax = center.lat + (extent.getHeight() / 2) * zoomFactor;
                            var bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);
                        }
                        // this.map.zoomToExtent(bounds);
                        document.advsearch.westBL.value = bounds.left;
                        document.advsearch.southBL.value = bounds.bottom;
                        document.advsearch.eastBL.value = bounds.right;
                        document.advsearch.northBL.value = bounds.top;
                        while(AOI_vector.getFeatureById('aoi')!=null){
                        AOI_vector.removeFeatures(AOI_vector.getFeatureById('aoi'));}
                        AOI_vector.addFeatures({geometry: bounds.toGeometry(), id: 'aoi'});
                        
                    }
                });
                map.addControl(control);
                map.addControl(new OpenLayers.Control.LayerSwitcher({
                    'ascending': false
                }));
                map.addControl(new OpenLayers.Control.PanZoomBar());

                var AOI_vector = new OpenLayers.Layer.Vector("Area of Interest");
                
                var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {
                    layers: 'basic'
                });
                
                /* var nasa_wms = new OpenLayers.Layer.WMS("NASA Blue Marble WMS", "http://onearth.jpl.nasa.gov/browse.cgi", {
                    layers: 'modis,global_mosaic', wms_server: 'wms.cgi'
                }); */
                
                var jpl_wms = new OpenLayers.Layer.WMS("NASA Global Mosaic", "http://t1.hypercube.telascience.org/cgi-bin/landsat7", {
                    layers: "landsat7"
                });
                jpl_wms.setVisibility(true);
                
                /* var rd_wms = new OpenLayers.Layer.WMS("ESRI Roads", "http://lat.lib.virginia.edu:8080/geoserver/ows", {
                    layers: "ESRI_USA:Freeway_System"
                });
                rd_wms.isBaseLayer=false; */
                
                var lyrs = [ol_wms, jpl_wms, AOI_vector];
                map.addLayers(lyrs);
                
                //map.zoomToExtent(newWMS.getTilesBounds());
                map.zoomTo(1);
            }
            
                YAHOO.namespace("geo.calendar");

    YAHOO.geo.calendar.init = function() {
        function fromHandleSelect(type,args,obj) {
		var fdates = args[0]; 
		var fdate = fdates[0];
		var fyear = fdate[0], fmonth = fdate[1], fday = fdate[2];
		if (fmonth < 10)
		{
			fmonth="0" + fmonth;
		}

		if (fday < 10)
		{
			fday="0" + fday;
		}
			
		var fromDate = document.getElementById("datefrom");
		fromDate.value = fyear + "-" + fmonth + "-" + fday;
		}
    	function toHandleSelect(type,args,obj) {
		var tdates = args[0]; 
		var tdate = tdates[0];
		var tyear = tdate[0], tmonth = tdate[1], tday = tdate[2];
		if (tmonth < 10)
		{
			tmonth="0" + tmonth;
		}

		if (tday < 10)
		{
			tday="0" + tday;
		}			
		var toDate = document.getElementById("dateto");
		toDate.value = tyear + "-" + tmonth + "-" + tday;
		}
        // Enable navigator with the default configuration
        YAHOO.geo.calendar.fromCal = new YAHOO.widget.Calendar("fromCal", "fromCalContainer", {navigator:true});
        YAHOO.geo.calendar.fromCal.selectEvent.subscribe(fromHandleSelect, YAHOO.geo.calendar.fromCal, true);
        YAHOO.geo.calendar.fromCal.render();
        
        YAHOO.geo.calendar.toCal = new YAHOO.widget.Calendar("toCal", "toCalContainer", {navigator:true});
        YAHOO.geo.calendar.toCal.selectEvent.subscribe(toHandleSelect, YAHOO.geo.calendar.toCal, true);
        YAHOO.geo.calendar.toCal.render();
        
    }
    

    YAHOO.util.Event.onDOMReady(YAHOO.geo.calendar.init);
