    //<![CDATA[

	google.load("maps", "2.x");
	var dataUrl;
	var map;
	var newMap;
	var zoomDelayId;
	var maxZoom = 19; 
	var marker;
	var gmarkers = [];
	var gmarkersHTML = [];
	var customIcons = [];
	
   
  // Call this function when the page has been loaded
	function initialize() {
		var greenPlantIcon = new GIcon(); 
		greenPlantIcon.image = 'http://www.wildcrafting.net/forage/images/greenPlantIcon.png';
		greenPlantIcon.iconSize = new GSize(20, 34);
		greenPlantIcon.iconAnchor = new GPoint(6, 20);
		greenPlantIcon.infoWindowAnchor = new GPoint(5, 1);
		
		var greenSroomIcon = new GIcon(); 
		greenSroomIcon.image = 'http://www.wildcrafting.net/forage/images/greenSroomIcon.png';
		greenSroomIcon.iconSize = new GSize(20, 34);
		greenSroomIcon.iconAnchor = new GPoint(6, 20);
		greenSroomIcon.infoWindowAnchor = new GPoint(5, 1);
		
		var redPlantIcon = new GIcon(); 
		redPlantIcon.image = 'http://www.wildcrafting.net/forage/images/redPlantIcon.png';
		redPlantIcon.iconSize = new GSize(20, 34);
		redPlantIcon.iconAnchor = new GPoint(6, 20);
		redPlantIcon.infoWindowAnchor = new GPoint(5, 1);
	
		var redSroomIcon = new GIcon(); 
		redSroomIcon.image = 'http://www.wildcrafting.net/forage/images/redSroomIcon.png';
		redSroomIcon.iconSize = new GSize(20, 34);
		redSroomIcon.iconAnchor = new GPoint(6, 20);
		redSroomIcon.infoWindowAnchor = new GPoint(5, 1);
		
		customIcons['plantn'] = greenPlantIcon;
		customIcons['planty'] = redPlantIcon;
		customIcons['mushroomy'] = redSroomIcon;
		customIcons['mushroomy'] = greenSroomIcon;	
		
		//map = new GMap2(document.getElementById("plantTab2"))
		map = new google.maps.Map2(document.getElementById("plantTab2"));
		map.checkResize();
		map.setCenter(new google.maps.LatLng(41.771313 , -95.273438), 3, G_HYBRID_MAP);
		//map.checkResize();
		//map.setCenter(new google.maps.LatLng(41.771313 , -95.273438), 3, G_SATELLITE_MAP);
		map.addMapType(G_PHYSICAL_MAP);
		map.removeMapType(G_NORMAL_MAP);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		setTimeout('loadData();', 50);
		
	}
	
	function loadData() {
		var bogusNum = new Date().getTime();
		dataUrl = "http://www.wildcrafting.net/forage/include/googlemapsdata.php";
		GDownloadUrl(dataUrl + "?plantId=" + plantId + "&userId=" + userId + '&bogus=' + bogusNum, function(data) {
			  var xml = GXml.parse(data);
			  var markers = xml.documentElement.getElementsByTagName("marker");
			  for (var i = 0; i < markers.length; i++) {
				var id = markers[i].getAttribute("id");
				var name = markers[i].getAttribute("name");
				var info = markers[i].getAttribute("info");
				var createdBy = markers[i].getAttribute("createdBy");
				var plantType = markers[i].getAttribute("plantType");
				var private = markers[i].getAttribute("private");
				var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
										parseFloat(markers[i].getAttribute("lng")));
				var newMarker = createMarker(point, id, name, info, createdBy, plantType, private);
				//map.addOverlay(newMarker);
			  }
			   //clusterer options - http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/docs/reference.html
			  var mcOptions = {gridSize: 60, maxZoom: 10};
			 var markcluster = new MarkerClusterer(map, gmarkers, mcOptions);
		});
	}
	
	function initAddMap() {
		
		newMap = new google.maps.Map2(document.getElementById("addMapDiv"));
		newMap.addMapType(G_PHYSICAL_MAP);
		newMap.removeMapType(G_NORMAL_MAP);
		newMap.setCenter(new google.maps.LatLng(38.54816542304656, -95.09765625), 3, G_SATELLITE_MAP);
		newMap.addControl(new GSmallMapControl());
		newMap.addControl(new GMapTypeControl());
		
		google.maps.MapType.prototype.getErrorMessage = google.maps.MapType.prototype.getErrorMessage.wrap(function(proceed) {
			var z = newMap.getZoom();
			if (z > 8) {
				if (!zoomDelayId) {
					zoomDelayId = changeZoom.delay(0.8, z-1);
					maxZoom = z-1;
				}
				return "Scaling map..."
			}
			return proceed();
		});
	}
	
	function getCommentsList (id, userId) {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=listComments&id='+id+'&userId='+userId+'&uGroup='+userGroup;
		var target = "commentsWindow";
		var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars});
	}
	
	function getPhotoList (id, userId) {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=getPhotos&id='+id+'&userId='+userId+'&uGroup='+userGroup;
		var target = "infoWindowTabPhotos";
		var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars});
	}

	function addFavs (id, uid) {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=addFavs&id='+id+'&userId='+uid;
		var target = "locFavs";
		var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars, onComplete:updateWindow(id, uid)});
	}
	
	 function createMarker(point, id, name, info, createdBy, plantType, private) {
		var Type = plantType+private
		Type = Type.toLowerCase(); 
		var newMarker = new GMarker(point, customIcons[Type]);
		
		var html = [new GInfoWindowTab('About','<div class="aboutLoc"><div id="aboutInfo"></div><div id="removeBtn"></div><div id="locFavs"></div></div>'), new GInfoWindowTab('Comments', '<div id="commentsWindow"></div><input id="addCom-btn" value="Add Comment" type="button" onClick="getInfoBox('+id+');">'), new GInfoWindowTab('Photos', '<div id="infoWindowTabPhotos"></div><input id="addPhoto-btn" value="Add Photo" type="button" onClick="addPhoto('+id+', '+createdBy+');">')];
		gmarkers.push(newMarker);
		gmarkersHTML.push(html);
		  
		GEvent.addListener(newMarker, 'click', function () {
			map.openInfoWindowTabsHtml(point, html);
			
			var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
			setTimeout("getAbout("+id+", "+userId+", "+userGroup+")",400);
			setTimeout("getCommentsList("+id+", "+userId+")",400);
			setTimeout("getPhotoList("+id+", "+userId+")",400);
			setTimeout("getToolBar("+id+", "+userId+", "+userGroup+")",500);
			
		});
		
		return newMarker;
    }
	
	function getToolBar(id, uid, ugroup) {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=getToolBar&id='+id+'&userId='+uid+'&ugroup='+ugroup;
		var target = "toolBar";
		var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars});
	}
	
	function getAbout(id, uid, ugroup) {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=getAboutInfo&id='+id+'&userId='+uid+'&uGroup='+ugroup;
		var target = "aboutInfo";
		var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars});
	}
	
	function addressPan() {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=addressPan&address='+$('address').value;
		var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete:function(o) {
			var cords = o.responseText.split(",");
			map.setCenter(new GLatLng(parseFloat(cords[0]), parseFloat(cords[1])), 12);
		}});
	}
	
	function removeLoc(id, uId) {
		var sure = confirm('Are you sure you wish to delete this location?');
		if(sure) {
			var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
			var pars = 'action=removeLoc&locId='+id+'&userId='+uId;;
			var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars});
			initialize();
		}
		
	}
	
	function remFavs(id, locId, uid) {
		var sure = confirm('Are you sure you wish to remove this location from your favorites?');
		if(sure) {
			var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
			var pars = 'action=remFav&id='+id;;
			var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete:updateWindow(locId, uid)});
		}
		
	}
	
	
	function delCom(id, locId) {
		var sure = confirm('Are you sure you wish to delete this comment?');
		if(sure){
			var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
			var pars = 'action=delComments&id='+id+'&locId='+locId+'&userId='+userId;
			var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars});
			setTimeout("getCommentsList("+locId+", "+userId+")",200);
			//getCommentsList(locId, userId);
		}
	}
	
	function delPhoto(id, locId) {
		var sure = confirm('Are you sure you wish to delete this photo?');
		if(sure){
			var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
			var pars = 'action=delPhoto&id='+id;
			var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars});
			getPhotoList(locId, userId);
		}
	}
	
	function addRating(locId, uid, type) {
		var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
		var pars = 'action=addRating&locId='+locId+'&userId='+userId+'&type='+type;
		var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete:updateWindow(locId, uid)});
	}
	
	function updateWindow(id, uid) {
		setTimeout("getAbout("+id+", "+uid+", "+userGroup+")",100);
		setTimeout("getToolBar("+id+", "+uid+", "+userGroup+")",200);
	}
	
	function changeZoom(zoom) {
		newMap.setZoom(zoom);
		zoomDelayId = 0;
	}
	
		//google.setOnLoadCallback(initialize);
    //]]>
	
	Ext.namespace('Ext.exampledata');
	Ext.exampledata.closed = [
		['Y', 'No, keep this private for me only.'],
		['N', 'Yes, let the community view my info.']
		];
	Ext.exampledata.plantType = [
		['Plant', 'Plant'],
		['Mushroom', 'Mushroom']
		];

Ext.onReady(function(){
					 
	Ext.QuickTips.init();
    
    var msg = function(title, msg){
        Ext.Msg.show({
            title: title, 
            msg: msg,
            minWidth: 200,
            modal: true,
            icon: Ext.Msg.INFO,
            buttons: Ext.Msg.OK
        });
    };

    // basic tabs 1, built from existing content
	if(usdaLink == 1){
		if(mapPic == 1) {
			var tabs = new Ext.TabPanel({
				renderTo: 'plantTabs',
				width:670,
				height:520,
				activeTab: 0,
				defaults:{height:520, width:670, autoScroll:true},
				items:[
					{contentEl:'plantTab1', title: 'Image', listeners: {activate: hideSearch}},
					{contentEl:'plantTab2', title: 'Locations', listeners: {activate: check}},
					{contentEl:'plantTab3', title: 'All Images', listeners: {activate: hideSearch}},
					{contentEl:'usdaInfoTab', title: 'USDA Info', listeners: {activate: hideSearch}},
					{contentEl:'usdaMapTab', title: 'USDA Coverage Map', listeners: {activate: hideSearch}}
				]
			});
		} else {
			var tabs = new Ext.TabPanel({
				renderTo: 'plantTabs',
				width:670,
				height:520,
				activeTab: 0,
				defaults:{height:520, width:670, autoScroll:true},
				items:[
					{contentEl:'plantTab1', title: 'Image', listeners: {activate: hideSearch}},
					{contentEl:'plantTab2', title: 'Locations', listeners: {activate: check}},
					{contentEl:'plantTab3', title: 'All Images', listeners: {activate: hideSearch}},
					{contentEl:'usdaInfoTab', title: 'USDA Info', listeners: {activate: hideSearch}}
				]
			});
		}
	} else {
		var tabs = new Ext.TabPanel({
			renderTo: 'plantTabs',
			width:670,
			height:520,
			activeTab: 0,
			defaults:{height:520, width:670, autoScroll:true},
			items:[
				{contentEl:'plantTab1', title: 'Image', listeners: {activate: hideSearch}},
				{contentEl:'plantTab2', title: 'Locations', listeners: {activate: check}},
				{contentEl:'plantTab3', title: 'All Images', listeners: {activate: hideSearch}}
			]
		});
	}
	
	function check() {
		initialize();
		map.checkResize();
		$("addressSearch").show();
	}
	
	function hideSearch(){
		$("addressSearch").hide();
	}
	
	function checkNewMap() {
		newMap.checkResize();
	}

		
		window.addLocWin = function(){
			if (map) {
				var mapCen = map.getCenter();
				var mapZoom = map.getZoom();
				var mapType = map.getCurrentMapType();
			} else {
				var mapCen = new google.maps.LatLng(41.771313 , -95.273438)
				var mapZoom = 3
				var mapType = G_HYBRID_MAP;
			}
			
			var addLocWinDiv = document.createElement('div');
			addLocWinDiv.id='addWin';
			addLocWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(addLocWinDiv);
			
			var addMapDiv = document.createElement('div');
			addMapDiv.id='addMapDiv';
			document.getElementById('addWin').appendChild(addMapDiv);
			
			
			var addForm = '';
			addForm = new Ext.FormPanel({
				id: 'addForm',
				height:200,
				defaults: {allowBlank: false, width: 230},
				defaultType: 'textfield',
				items: [{
						xtype: 'label',
						text: 'Currently adding a marker for ' + plantName,
						cls: 'formTitleLabel',
						width: 500
					},{
						fieldLabel: 'Name',
						id: 'name',
						name: 'name',
						width:300
					},{
						xtype: 'label',
						text: 'Title of your location, ie "Park Hilltop"',
						cls: 'fieldHelpLabel',
						width: 300
					},{
						fieldLabel: 'Info',
						name: 'info',
						xtype: 'textarea',
						height: 50,
						width:300
					},{
						xtype: 'label',
						text: 'How to find the location, what is there, etc. ',
						cls: 'fieldHelpLabel',
						width: 300
					},{
						fieldLabel: 'GPS Cords.',
						id: 'gpsData',
						name: 'gpsData',
						xtype: 'hidden',
						width:300
					},
					new Ext.form.ComboBox({
						id:'cboAddclosed',
						fieldLabel: 'Shared?',
						hiddenName:'private',
						store: new Ext.data.SimpleStore({
							fields: ['value', 'name'],
							data : Ext.exampledata.closed // from states.js
						 }),
						valueField:'value',
						displayField:'name',
						typeAhead: true,
						mode: 'local',
						triggerAction: 'all',
						emptyText:'Select One...',
						width:100,
						selectOnFocus:true
					}),
					{
						xtype: 'label',
						text: 'Click "Add Marker to Map" below to manually plot a location, zoom in all the way first for accuracy. You can also add using GPS if you know the exact coordinates. Don\'t forget to "SAVE" when finished.',
						cls: 'formTitleLabel2',
						width: 480
					}
				],
				buttons: [{
					text: 'Add Marker to Map',
					type: 'button',	
					id: 'addMarkerBut',
					handler: function() { 
							if(newMap.getZoom() < maxZoom){
								var zoomInAmt = maxZoom - newMap.getZoom();
								alert('Please zoom in to the max level');
							} else {
								var center = newMap.getCenter();
								marker = new GMarker(center, {draggable: true});
								newMap.addOverlay(marker);
								
								GEvent.addListener(marker, "dragstart", function() {
									newMap.closeInfoWindow();
								});
								
								GEvent.addListener(marker, "dragend", function() {
									var point = marker.getLatLng();
									document.getElementById("gpsData").value = point.toString();
								});
								var point = marker.getLatLng();
								document.getElementById("gpsData").value = point.toString();
								
								var addMarkerBtn = Ext.getCmp('addMarkerBut');
								addMarkerBtn.setDisabled(!addMarkerBtn.disabled);
								
								var addMarkerBtn2 = Ext.getCmp('addMarkerGPSBut');
								addMarkerBtn2.setDisabled(!addMarkerBtn2.disabled);
								
								var delMarkerBtn = Ext.getCmp('delMarkerBut');
								delMarkerBtn.setDisabled(!delMarkerBtn.disabled);
			
							}
						}
					},{
					text: 'Add Marker by GPS',
					type: 'button',	
					id: 'addMarkerGPSBut',
					handler: function() { 
								addGPSMarker();
						}
					},{
					text: 'Delete Location Marker',
					type: 'button',	 
					id: 'delMarkerBut',
					disabled: 'true',
					handler: function() { 
							newMap.removeOverlay(marker);
							var addMarkerBtn = Ext.getCmp('addMarkerBut');
							addMarkerBtn.setDisabled(!addMarkerBtn.disabled);
							
							var addMarkerBtn2 = Ext.getCmp('addMarkerGPSBut');
							addMarkerBtn2.setDisabled(!addMarkerBtn2.disabled);
							
							var delMarkerBtn = Ext.getCmp('delMarkerBut');
							delMarkerBtn.setDisabled(!delMarkerBtn.disabled);
						
						}
					},{
					text: 'Save',
					type: 'submit',
					handler: function() { 
							if(addForm.getForm().isValid()){
								addForm.getForm().submit({
									method: 'POST',
									url:'http://www.wildcrafting.net/forage/include/ajax.php',
									params:{
										action: 'add',
										createdBy: userId,
										plantId: plantId
									},
									waitMsg:'Saving...',
									success: function(fp, o){
										initialize();
										win.close();
									}
								})
								
							}
						}
					}] 
			});
			
			
			
			// create the window on the first click and reuse on subsequent clicks
			if(!win){
				var win = new Ext.Window({
					applyTo     : 'addWin',
					title: plantName + ' Location Information',
					y			: 200,
					layout      : 'fit',
					width       : 600,
					height      : 340,
					plain       : true,
					items		:	addForm,

					buttons: [{
						text     : 'Pan To Address',
						handler  : function(){
							panToAddress();
							}
						},{
						text     : 'Close',
						handler  : function(){
							win.close();
						}
					}]

				});
			}
			
			win.show();
			initAddMap();
			newMap.setCenter(mapCen, mapZoom, mapType);
			checkNewMap();
		}
		
		//start add marker by GPS window
		function addGPSMarker(){
			var addMarkerGPSWinDiv = document.createElement('div');
			addMarkerGPSWinDiv.id='addMarkerGPSWin';
			addMarkerGPSWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(addMarkerGPSWinDiv);
			
			var addMarkerGPSForm = '';
			addMarkerGPSForm = new Ext.FormPanel({
				title: 'Add Marker by GPS',
				defaults: {allowBlank: false, width: 230},
				defaultType: 'textfield',
				items: [{
						fieldLabel: 'Latitude',
						id:'lat'
				},{
					xtype: 'label',
					text: 'Latitude of location, ie "42.753780"',
					cls: 'fieldHelpLabel',
					width: 300
				},{
						fieldLabel: 'Longitude',
						id:'lng'
				},{
					xtype: 'label',
					text: 'Longitude of location, ie "-84.488014"',
					cls: 'fieldHelpLabel',
					width: 300
				}],
				buttons: [{
							text: 'Add Marker',
							handler: function() { 
									if(addMarkerGPSForm.getForm().isValid()){
										var lat = Ext.getDom('lat');
										var lng = Ext.getDom('lng');
										
										var center = new GLatLng(parseFloat(lat.value), parseFloat(lng.value));
										newMap.setCenter(center);
										newMap.setZoom(19);
										
										marker = new GMarker(center, {draggable: true});
										newMap.addOverlay(marker);
										
										GEvent.addListener(marker, "dragstart", function() {
											newMap.closeInfoWindow();
										});
										
										GEvent.addListener(marker, "dragend", function() {
											var point = marker.getLatLng();
											document.getElementById("gpsData").value = point.toString();
										});
										var point = marker.getLatLng();
										document.getElementById("gpsData").value = point.toString();
										
										var addMarkerBtn = Ext.getCmp('addMarkerBut');
										addMarkerBtn.setDisabled(!addMarkerBtn.disabled);
										
										var addMarkerBtn2 = Ext.getCmp('addMarkerGPSBut');
										addMarkerBtn2.setDisabled(!addMarkerBtn2.disabled);
										
										var delMarkerBtn = Ext.getCmp('delMarkerBut');
										delMarkerBtn.setDisabled(!delMarkerBtn.disabled);
										
										addMarkerGPSWin.close();
										

									}
								}
						
							},{
							text     : 'Close',
							handler  : function(){
								addMarkerGPSWin.close();
								
							}
						}]
			});
			
			// create the window on the first click and reuse on subsequent clicks
				if(!addMarkerGPSWin){
					var addMarkerGPSWin = new Ext.Window({
						applyTo     : 'addMarkerGPSWin',
						y			: 400,
						layout      : 'fit',
						width       : 450,
						height      : 190,
						plain       : true,
						items		:	addMarkerGPSForm
					});
				}
				addMarkerGPSWin.show();
		}
	//end add marker by gps window
	
	
	//start pan address window
		function panToAddress(){
			var panAddressWinDiv = document.createElement('div');
			panAddressWinDiv.id='panAddressWin';
			panAddressWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(panAddressWinDiv);
			
			var panAddressForm = '';
			panAddressForm = new Ext.FormPanel({
				title: 'Pan to Address',
				defaults: {allowBlank: false, width: 230},
				defaultType: 'textfield',
				items: [{
						fieldLabel: 'Address',
						id:'addressSub'
				}],
				buttons: [{
							text: 'Pan',
							handler: function() { 
									
									if(panAddressForm.getForm().isValid()){
										var url = 'http://www.wildcrafting.net/forage/include/ajax.php';
										var pars = 'action=addressPan&address='+$('addressSub').value;
										var myAjax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete:function(o) {
											var cords = o.responseText.split(",");
											newMap.setCenter(new GLatLng(parseFloat(cords[0]), parseFloat(cords[1])), 12);
										}});
										
										
										panAddressWin.close();
										

									}
								}
						
							},{
							text     : 'Close',
							handler  : function(){
								panAddressWin.close();
								
							}
						}]
			});
			
			// create the window on the first click and reuse on subsequent clicks
				if(!panAddressWin){
					var panAddressWin = new Ext.Window({
						applyTo     : 'panAddressWin',
						y			: 400,
						layout      : 'fit',
						width       : 450,
						height      : 120,
						plain       : true,
						items		:	panAddressForm
					});
				}
				panAddressWin.show();
		}
	//end pan address window
	

		window.getInfoBox = function (id){
			var addComWinDiv = document.createElement('div');
			addComWinDiv.id='addComWin';
			addComWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(addComWinDiv);
			var addComForm = '';
			addComForm = new Ext.FormPanel({
				title: 'Add Plant Location Comment',
				defaults: {allowBlank: false, width: 230},
				defaultType: 'textfield',
				url:'http://www.wildcrafting.net/forage/include/ajax.php',
				items: [{
						fieldLabel: 'Comment',
						name: 'commentText',
						xtype: 'textarea',
						height: 100,
						width: 250
				}],
				buttons: [{
							text: 'Save',
							type: 'submit',
							handler: function() { 
									if(addComForm.getForm().isValid()){
										addComForm.getForm().submit({
											method: 'POST',
											params:{
												action: 'addCom',
												createdBy: userId,
												locId: id
											},
											waitMsg:'Saving...',
											success: function(fp, o){
												addComWin.close();
												getCommentsList(id, userId);
											}
										})
									}
								}
						
							},{
							text     : 'Close',
							handler  : function(){
								addComWin.close();
								
							}
						}]
			});
			
			// create the window on the first click and reuse on subsequent clicks
				if(!addComWin){
					var addComWin = new Ext.Window({
						applyTo     : 'addComWin',
						y			: 450,
						layout      : 'fit',
						width       : 400,
						height      : 190,
						plain       : true,
						items		:	addComForm
					});
				}
				addComWin.show();
	};
	
	
		window.addPhoto = function (locId, uId){
			var addPhotoWinDiv = document.createElement('div');
			addPhotoWinDiv.id='addPhotoWin';
			addPhotoWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(addPhotoWinDiv);
			
			var addPhotoForm = '';
			addPhotoForm = new Ext.FormPanel({
				fileUpload: true,
				width: 300,
				frame: true,
				title: 'File Upload Form',
				autoHeight: true,
				bodyStyle: 'padding: 10px 10px 0 10px;',
				labelWidth: 50,
				defaults: {
					anchor: '95%',
					allowBlank: false
				},
				items: [{
					xtype: 'fileuploadfield',
					width: 250,
					id: 'form-file',
					emptyText: 'Select an image',
					fieldLabel: 'Photo',
					name: 'photo-path',
					buttonCfg: {
						text: '',
						iconCls: 'upload-icon'
					}
				}],
				buttons: [{
							text: 'Save',
							handler: function(){
								if(addPhotoForm.getForm().isValid()){
									addPhotoForm.getForm().submit({
										waitMsg: 'Uploading your photo...',
										url:'http://www.wildcrafting.net/forage/include/ajax.php',
										params:{
												action: 'addPhoto',
												userId: userId,
												locId: locId
										},
										success: function(fp, o){
											
											//msg('Success', 'uploaded file "'+o.result.file+'" to the server');
											addPhotoWin.close();
											getPhotoList(locId, uId);
										}
									});
									
								}
							}
						},{
							text: 'Reset',
							handler: function(){
								addPhotoForm.getForm().reset();
							}
						}]
			});

			
			// create the window on the first click and reuse on subsequent clicks
				if(!addPhotoWin){
					var addPhotoWin = new Ext.Window({
						applyTo     : 'addPhotoWin',
						y			: 450,
						layout      : 'fit',
						width       : 400,
						height      : 190,
						plain       : true,
						items		:	addPhotoForm
						
					});
				}
				addPhotoWin.show();
	};
	
		window.editLoc = function (id){
			var editLocWinDiv = document.createElement('div');
			editLocWinDiv.id='editLocWin';
			editLocWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(editLocWinDiv);

			var editLocForm ='';
			editLocForm = new Ext.FormPanel({
				frame: true,
				title: 'Edit Plant Location',
				waitMsgTarget: true,
				reader : new Ext.data.XmlReader({
					record : 'location',
					success: '@success'
				}, [
					{name: 'name', mapping:'name'},
					'info', 'private', 'plantType'// custom mapping
				]),
				items: [ 
					new Ext.form.FieldSet({
						title: 'Location Information',
						autoHeight: true,
						defaultType: 'textfield',
						items: [{
								fieldLabel: 'Name',
								name: 'name',
								width:300
							},{
								fieldLabel: 'Info',
								name: 'info',
								xtype: 'textarea',
								height: 50,
								width:300
							},
							new Ext.form.ComboBox({
								fieldLabel: 'Private',
								hiddenName:'private',
								store: new Ext.data.SimpleStore({
									fields: ['value', 'name'],
									data : Ext.exampledata.closed // from states.js
								 }),
								valueField:'value',
								displayField:'name',
								typeAhead: true,
								mode: 'local',
								triggerAction: 'all',
								emptyText:'Select One...',
								width:100,
								selectOnFocus:true
							})
						]
					})
				],
				buttons: [{
					text: 'Save',
					type: 'submit',
					handler: function() { 
							editLocForm.getForm().submit({
								url: '/forage/include/ajax.php',
								method: 'POST',
								params:{
									action: 'editLoc',
									id: id
								},
								waitMsg:'Saving...',
								success: function(fp, o){
									
									editLocWin.close();
									getAbout(id, userId, userGroup);
									setTimeout("getToolBar("+id+", "+userId+", "+userGroup+")",100);
								}
								
							})
							
							
						}
		
					},{
					text     : 'Close',
					handler  : function(){
						editLocWin.close();
					}
				}]
			});
			
			// create the window on the first click and reuse on subsequent clicks
				if(!editLocWin){
					var editLocWin = new Ext.Window({
						applyTo     : 'editLocWin',
						y			: 450,
						layout      : 'fit',
						width       : 500,
						height      : 250,
						plain       : true,
						items		:	editLocForm
					});
				}
				editLocWin.show();
				editLocForm.getForm().load({url:'http://www.wildcrafting.net/forage/include/data.php?id='+id, waitMsg:'Loading'});
	};
	
	
	window.viewImg = function (img){
			var viewImgWinDiv = document.createElement('div');
			viewImgWinDiv.id='viewImgWin';
			viewImgWinDiv.setAttribute('class','x-hidden');
			document.body.appendChild(viewImgWinDiv);

			
			// create the window on the first click and reuse on subsequent clicks
				if(!viewImgWin){
					var viewImgWin = new Ext.Window({
						applyTo     : 'viewImgWin',
						y			: 400,
						layout      : 'fit',
						width       : 700,
						height      : 500,
						plain       : true,
						bodyCfg: { tag: 'iframe', src: img, style: "border:0px none;"}
					});
				}
				viewImgWin.show();
	};
	
	
});
/*
autoWidth: true,
autoHeight: true,
plain       : true,
bodyCfg: { tag: 'iframe', src: img, style: "min-width: 600px; min-height: 350px; border:0px none;"}
//items		:	new Ext.ux.Image ({ id: 'imgPreview', url: img })
*/


