
// Browser Detection
	var browser=navigator.appName;
  var b_version=navigator.appVersion;
  var version=parseFloat(b_version);


//
// Generates Javascript to add markers in the Google map
//

//Globals

_mSvgEnabled = true;
_mSvgForced  = true;
_mPreferMetric=true;

//bookmarking

var config=[];
var hash = window.location.hash.substring(1);
var pairs = hash.split("&");
for (var i=0; i < pairs.length; i++) {
var apair = pairs[i].split("=");
if (apair[0]) { config[apair[0]] = apair[1]; }
}


//comment counter
var pn=0; //point number


side_bar_html3 = "";

var map;

//Marker List
var Marker_List_L0= new Array();
var Marker_List_L1= new Array();
var Marker_List_L2= new Array();


var slat=parseFloat(config['lat'])||20.593684;
var slng=parseFloat(config['lng'])||78.96288;
var szoom=parseInt(config['zoom'])||5;
var type=config['ty']||2;

var geocoder = null;


// Myclick Globals
gmarkers = [];
gm_index = 0;

// Add New Marker Globals
button=0;
nomore=1;
marker=[];
pint=[];

var pagingBar;

function updateMarkerCount() {
    mgr.refresh();
    document.getElementById("MarkerCount").innerHTML = mgr.getMarkerCount(map.getZoom());
    //document.getElementById("MarkerCount").innerHTML = mgr.getMarkerCount(map.getZoom());
}

function writeToInfoPane(info) {
    document.getElementById("InfoPane").innerHTML = info;
}



//Grand Init - Begin
function gmapload() {
		map = new GMap2(document.getElementById("map"),[G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]);
		
		map.setCenter(new GLatLng(slat,slng),szoom);
		map.addControl(new GLargeMapControl(0,1));
		map.addControl(new GMapTypeControl(1));
		map.enableScrollWheelZoom();
		map.addControl(new GScaleControl(300));
		new GKeyboardHandler(map);
 	  mini=new GOverviewMapControl(new GSize(150, 100));
		map.addControl(mini);
		omap=document.getElementById("map_overview");
		place=document.getElementById("map");
		map.hideControls();
		mgr = new MarkerManager(map,{trackMarkers:false});

    houseIcon = new GIcon();
    houseIcon.image = "/irmv2/images/gmarkers/house.png";
    houseIcon.iconAnchor = new GPoint(16, 16);
    houseIcon.infoWindowAnchor = new GPoint(16, 0);
    houseIcon.iconSize = new GSize(24, 24);
    houseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    houseIcon.shadowSize = new GSize(44, 24);

    rhouseIcon = new GIcon();
    rhouseIcon.image = "/irmv2/images/gmarkers/home-r.png";
    rhouseIcon.iconAnchor = new GPoint(16, 16);
    rhouseIcon.infoWindowAnchor = new GPoint(16, 0);
    rhouseIcon.iconSize = new GSize(24, 24);
    rhouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    rhouseIcon.shadowSize = new GSize(44, 24);

    ghouseIcon = new GIcon();
    ghouseIcon.image = "/irmv2/images/gmarkers/home-g.png";
    ghouseIcon.iconAnchor = new GPoint(16, 16);
    ghouseIcon.infoWindowAnchor = new GPoint(16, 0);
    ghouseIcon.iconSize = new GSize(24, 24);
    ghouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    ghouseIcon.shadowSize = new GSize(44, 24);

    bhouseIcon = new GIcon();
    bhouseIcon.image = "/irmv2/images/gmarkers/home-b.png";
    bhouseIcon.iconAnchor = new GPoint(16, 16);
    bhouseIcon.infoWindowAnchor = new GPoint(16, 0);
    bhouseIcon.iconSize = new GSize(24, 24);
    bhouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    bhouseIcon.shadowSize = new GSize(44, 24);

    yhouseIcon = new GIcon();
    yhouseIcon.image = "/irmv2/images/gmarkers/home-y.png";
    yhouseIcon.iconAnchor = new GPoint(16, 16);
    yhouseIcon.infoWindowAnchor = new GPoint(16, 0);
    yhouseIcon.iconSize = new GSize(24, 24);
    yhouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    yhouseIcon.shadowSize = new GSize(44, 24);

    vhouseIcon = new GIcon();
    vhouseIcon.image = "/irmv2/images/gmarkers/home-v.png";
    vhouseIcon.iconAnchor = new GPoint(16, 16);
    vhouseIcon.infoWindowAnchor = new GPoint(16, 0);
    vhouseIcon.iconSize = new GSize(24, 24);
    vhouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    vhouseIcon.shadowSize = new GSize(44, 24);

    phouseIcon = new GIcon();
    phouseIcon.image = "/irmv2/images/gmarkers/home-p.png";
    phouseIcon.iconAnchor = new GPoint(16, 16);
    phouseIcon.infoWindowAnchor = new GPoint(16, 0);
    phouseIcon.iconSize = new GSize(24, 24);
    phouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    phouseIcon.shadowSize = new GSize(44, 24);


    ohouseIcon = new GIcon();
    ohouseIcon.image = "/irmv2/images/gmarkers/home-grey.png";
    ohouseIcon.iconAnchor = new GPoint(16, 16);
    ohouseIcon.infoWindowAnchor = new GPoint(16, 0);
    ohouseIcon.iconSize = new GSize(24, 24);
    ohouseIcon.shadow = "/irmv2/images/gmarkers/house-shadow.png";
    ohouseIcon.shadowSize = new GSize(44, 24);


    newhouseIcon = new GIcon();
    newhouseIcon.image = "http://indiarealestatemap.com/irmv2/images/gmarkers/newhouse.png";
    newhouseIcon.iconAnchor = new GPoint(16, 16);
    newhouseIcon.infoWindowAnchor = new GPoint(16, 0);
    newhouseIcon.iconSize = new GSize(32, 32);
    newhouseIcon.shadow = "http://indiarealestatemap.com/irmv2/images/gmarkers/house-shadow.png";
    newhouseIcon.shadowSize = new GSize(59, 32);


    // Mgr Listeners

		GEvent.addListener(mgr, "changed", function(bounds, mc){
			//alert("got event: mgr changed");
			//turn_filter_on('refresh');
			//writeToInfoPane("Marker Count: "+mc);
		});
		
//addoverlay
    // Map Listeners

		GEvent.addListener(map, "zoomstart", function(){
		  //alert('zoomstart');
			turn_filter_on('refresh');
		});
		
		GEvent.addListener(map, "zoomend", function(){
		  //alert('zoomend');
			turn_filter_on('refresh');
		});
		
		GEvent.addListener(map, "mouseover", function(){
			map.showControls();
		});
		
		GEvent.addListener(map, "mouseout", function(){
			map.hideControls(); 
			map.closeInfoWindow();
		});


		GEvent.addListener(map, "dblclick",function(what,center){
			map.zoomIn();
			map.setCenter(center)
		});


		//'add marker' button
		
		////'mouseover' listener creates marker
		GEvent.addListener(map, "mouseover", function(edge){if (button ==1 &&
			nomore==0){
			marker[pn]=(new GMarker(new GLatLng(edge),newhouseIcon));
			map.addOverlay(marker[pn]);
			nomore=1;
		}});

		////dragging Icon
		GEvent.addListener(map, "mousemove", function(pnt){if (button ==1){ 
			marker[pn].setPoint(pnt);
		}});



////'click' on map stops dragging
////and creates event listeners and script
		GEvent.addListener(map, "click", function(overlay,  latlng){
			if (button ==1){
					document.getElementById("add").value = "Click on the marker";
					document.getElementById("add").disabled = "disabled";
					createMarkerListener(marker[pn]);
					var mn = pn+1;
					var pushpin = marker[pn];
					var url_pre = "/irmv2/admin/index2.php?action=add_listing_property_class&";
					//var gp = document.getElementById("coord").value.split(", ");
					var lan_lon ="lat="+marker[pn].getLatLng().lat()+"&lon="+marker[pn].getLatLng().lng() ;
					if(latlng) {
					 lan_lon = "lat="+latlng.getLat()+"&lon="+latlng.getLng();
					 }
					var mlink = "<a onclick=\"open_url_tab('"+url_pre+lan_lon+"');\">Add New Listing...</a>";
          // Marker Listener
					GEvent.addListener(marker[pn], "click", function(){
						pushpin.openInfoWindowHtml(mlink);
						});
					pn++;
			}
			button = 0; 
		});


		//Creating listeners for map and marker
		var event = [];
		var listen = '';
		var i = 0;
		
		function mapListener(listen){
			GEvent.addListener(map, listen, function(){
				//GLog.write('map.'+listen)
			});
		};

		function markerListener(listen,marker){
			GEvent.addListener(marker, listen,function()	{
				//GLog.write('marker.'+listen)
			});
		};

		event[0] = 'addmaptype';
		event[1] = 'addoverlay';
		event[2] = 'clearoverlays';
		event[3] = 'click';
		event[4] = 'contextmenu';
		event[5] = 'drag';
		event[6] = 'dragend';
		event[7] = 'dragstart';
		event[8] = 'infowindowclose';
		event[9] = 'infowindowopen';
		event[10] = 'maptypechanged';
		event[11] = 'mousedown';
		event[12] = 'mouseout';
		event[13] = 'mouseover';
		event[14] = 'mouseup';
		event[15] = 'move';
		event[16] = 'moveend';
		event[17] = 'movestart';
		event[18] = 'remove';
		event[19] = 'removemaptype';
		event[20] = 'removeoverlay';
		event[21] = 'resize';
		event[22] = 'zoom';
		event[23] = 'zoomend';
		event[24] = 'dblclick';
		event[25] = 'infowindowbeforeclose';
		event[26] = 'zoomstart';
		event[27] = 'changed';
		event[28] = 'visibilitychanged';
		
		
		for(var i=0; i<event.length; i++){
			listen = event[i];
			mapListener(listen);
		};
		
		function createMarkerListener(marker){
			for(var i=0; i<event.length; i++){
				listen = event[i];
				markerListener(listen,marker);
			};
		};

} 
// Grand Init - End

function addNewMarker(){
			button=1; 
			nomore=0;
			document.getElementById("add").value="Now, click on the map..";
};

function clearAllMarkers(){
			pint.length=0;
			map.clearOverlays(); 
			document.getElementById("add").value = "Add Listing \n (Zoom in first)"; 
			document.getElementById("add").disabled = "";
}


function zoom_to_city(zcity,zlat,zlng,zscale1,zlimit_start,zlimit_end) {
		mgr.clearMarkers();
		if (zcity == "India") {
			clearAllMarkers();
		} else {
			readXmlMarkers(zcity,zlimit_start,zlimit_end);
		}
		try {
			map.setCenter(new GLatLng(zlat,zlng),parseInt(zscale1));
		} catch (ex) {
			// do nothing
		} finally {
		   mgr.refresh();
		}
	  updateMarkerCount();
	  
	  ListingGrid.getView().scrollToTop();

}



function myclick(i,html) {
  	var ii = parseInt(i);
  	map.setCenter(gmarkers[ii].getLatLng());
  	//for (j=map.getZoom();j<=11;j++) {map.zoomIn();}
    //GEvent.trigger(gmarkers[ii], "click");
    var iwAnchor = gmarkers[ii].getIcon().infoWindowAnchor;
    var iconAnchor = gmarkers[ii].getIcon().iconAnchor;
    var offset = new GSize(iwAnchor.x-iconAnchor.x,iwAnchor.y-iconAnchor.y);
	  map.openInfoWindow(gmarkers[ii].getLatLng(), html, {pixelOffset:offset});
}

function readXmlMarkers(cityname,limit_start,limit_end) {

      side_bar_html = "<div style=\"font: small-caps 900 14px arial; color:black;\">Listings in "+cityname+"</div>";
      //var i = 0;
      
      function createMarker(rindex,class_id,point,prop_list,html) {
	        var marker;
	        
					switch (class_id)
					{
					  case '1': marker = new GMarker(point,rhouseIcon);
					            break;
					  case '2': marker = new GMarker(point,bhouseIcon);
					            break;
					  case '12': marker = new GMarker(point,ghouseIcon);
					            break;
					  case '8': marker = new GMarker(point,vhouseIcon);
					            break;
					  case '13': marker = new GMarker(point,yhouseIcon);
					            break;
					  case '9': marker = new GMarker(point,phouseIcon);
					            break;
					  case '999': marker = new GMarker(point,houseIcon);
					            break;
					  default:  marker = new GMarker(point,ohouseIcon);
					}
						        
	        //marker = new GMarker(point,houseIcon);
	        
	        
	        
	        GEvent.addListener(marker, "mouseover", function() {
	          marker.openInfoWindowHtml(html);
	        });
	        
	        GEvent.addListener(marker, "click", function() {
	          var iwAnchor = marker.getIcon().infoWindowAnchor;
	          var iconAnchor = marker.getIcon().iconAnchor;
	          var offset = new GSize(iwAnchor.x-iconAnchor.x,iwAnchor.y-iconAnchor.y);
	          map.openInfoWindow(marker.getLatLng(), html, {pixelOffset:offset});
	          ListingGrid.getView().focusRow(rindex);
	          ListingGrid.getSelectionModel().selectRow(rindex,false);
	        });
	        
//          GEvent.addListener(marker, "visibilitychanged", function(isVisible) {
//	           if (isVisible) {
//	           	//writeToInfoPane("Visible");   
//	           } else {
//	          	//writeToInfoPane("Invisible");
//	           }
//         });
 
	        GEvent.addListener(marker, "dblclick", function() {
	          marker.closeInfoWindowHtml();
	        });
	        
	        return marker;
      }


//  **************************************
//  **************************************
//  **************************************


     // Clear store/grid first
     store.removeAll();

//      var xmlrequest = GXmlHttp.create();
//      xmlrequest.open("GET", "/irmv2/include/lib_gen_js_gmap3.php?function=getXmlMarkersInCity2&whichcity="+cityname, true);
//      xmlrequest.onreadystatechange = function() {
//        	if (xmlrequest.readyState == 4) {
         GDownloadUrl("/irmv2/include/lib_gen_js_gmap3.php?function=getXmlMarkersInCity2&whichcity="+cityname+"&limit_start="+limit_start+"&limit_end="+limit_end, function(data, responseCode) {

        	    //alert(xmlrequest.responseText);
		          var xmlDoc = GXml.parse(data);
		          //var xmlDoc = GXml.parse(xmlrequest.responseText);
		          //doc->root->markergroups->childNodes
              var markergroups = xmlDoc.documentElement.firstChild.childNodes;
              
              //alert(markergroups[0].firstChild.textContent);
              
							// Variable to associate marker with the first corresponding row in the grid
              var first_row_index = 0;

              var str_count = 0;
              // For each group
              for (var mgcnt1=0; mgcnt1<markergroups.length;mgcnt1++) {
              	
              	var mglat; 
              	var mglon;

                if (browser == "Microsoft Internet Explorer")
    					  {
              	 mglat = markergroups[mgcnt1].firstChild.text;
              	 mglon = markergroups[mgcnt1].firstChild.nextSibling.text;
    					  } else {
              	 mglat = markergroups[mgcnt1].firstChild.textContent;
              	 mglon = markergroups[mgcnt1].firstChild.nextSibling.textContent;
    					  }

              	
              	
              	
              	//alert(mglat+","+mglon);
                
		            
                var marker_html ="<div style='overflow: auto; width: 200px; height:110px; '><table class=\"info_table\">";

              	var markers = markergroups[mgcnt1].lastChild.childNodes;

                var mgclass = 0;

                // For each Marker
                var first_row_index_cnt = 0;
                for (var mcnt1=0; mcnt1<markers.length;mcnt1++) {

										// Create Record to add in the store/grid
					          var myNewRecord = new TopicRecord({
										});
		                //myNewRecord.beginEdit();
				            myNewRecord.set("gmindex",gm_index);


			             	//alert(markers[mcnt1].nodeName+":"+mcnt1);
		              	var params = markers[mcnt1].childNodes;
			             	
			             	//for each Parameter
		                for (var pcnt1=0; pcnt1<params.length;pcnt1++) {
		                   //alert(params[pcnt1].nodeName+":"+params[pcnt1].textContent);
		                   //myNewRecord.set(params[pcnt1].nodeName,params[pcnt1].textContent);

		                if (browser == "Microsoft Internet Explorer")
		    					  {
		                   myNewRecord.set(params[pcnt1].nodeName,params[pcnt1].text);
		    					  } else {
		                   myNewRecord.set(params[pcnt1].nodeName,params[pcnt1].textContent);
		    					  }
		                } //pcnt


                   

                    //Add initial image 
                    var raw_image_xml = myNewRecord.get('images');
                    myNewRecord.set('limage', raw_image_xml);

				            var image_file = "nophoto.gif";
				            if( (raw_image_xml != undefined) && (raw_image_xml != "") ){
				            	image_file="thumb_"+raw_image_xml.split(".")[0]+".jpg";
				            }
				            var image_url = "/irmv2/images/listing_photos/"+image_file;
                    myNewRecord.set('Image_tag', "<img src="+image_url+">");


                                        
                    var htitle = myNewRecord.get('title');
                    var hid = myNewRecord.get('id');
				            marker_html = marker_html + "<tr><td><a onclick=\"open_details_tab('"+hid+"');\"><img src="+image_url+"></a></td><td><a onclick=\"open_details_tab('"+hid+"');\">#"+hid+":&nbsp;"+htitle+"</a></td></tr>";

										// Add to Store and Grid
		                //myNewRecord.endEdit();
									 	store.add(myNewRecord);
store.totalLength++;
									 	
									 	if (((str_count+1) % 25) == 0) {
pagingBar.pageSize= 25;
pagingBar.updateInfo();
//pagingBar.resize();
									 	  //ListingGrid.render();
											//store.load({params:{start:0, limit:25}});
	                    //store.load({params:{ limit:25}});
	                    //alert(str_count);
                    }
                    str_count++;


									 	//store.addSorted(myNewRecord);
									 	//store.commitChanges();

										// get class 
										mgclass = myNewRecord.get('class_id');
										
										//Increment row index
										first_row_index_cnt++;
                }//marker

								// marker_html
                marker_html += "</table></div>";

                // check if more than one prop type is listed in the same marker 
                // If so send specal class id as 999
                if(markers.length > 1) {
                	mgclass = '999';
                } 


                // Add a Marker to the Map
		            var point = new GLatLng(mglat,mglon);
		            var marker = createMarker(first_row_index,mgclass,point,"test",marker_html);
		            mgr.addMarker(marker,0,15);
				        gmarkers[gm_index] = marker;
                
				      	gm_index++; // Increment Marker index

								first_row_index +=first_row_index_cnt;
                
              }//markergroups

    // trigger the data store load
    //store.load({params:{start:0, limit:25}});

    // ListingGrid.bbar=pagingBar; 

				      

//        	} // readystate function
//      }
			  //alert(data);
			});
      //xmlrequest.send(null);
      

         

//  **************************************

Ext.getCmp('east_panel').expand(true);
	  
	          Ext.MessageBox.show({
           msg: 'Loading Matching Properties From Thousands of Properties Listed...',
           progressText: 'Loading...',
           width:300,
           wait:true,
           waitConfig: {interval:200},
           icon:'ext-mb-download', //custom class in msg-box.html
           animEl: 'mb7'
       });



}

function loadDynamicData() {
  	var myNewRecord = new TopicRecord({
		    Image_tag: 'Do my job please',
		    Title: 'noobie',
		    DateAdded: new Date(),
		    Popularity: 'Animal'
		});
 		store.add(myNewRecord);
}


function initialize_gmap2() {
	//GSearch.setOnLoadCallback(gmapload);
}



   	
   	//All Globals
 		
 		// Parameter Handling
 		var qsParm = new Array();
 		
 	  // Map Loading	
		var g_lat= 20.593684;
		var g_lng = 78.96288;
		var g_zoom = 5;
		var g_city = "India";
		var g_city_list = new Array(1);
		g_city_list[0] = "India";
		var g_pos_list = new Array(1);
		g_pos_list[0] = "20.593684 , 78.96288";

    //Load City
    First_time = true;

   	
	 		// Parameter Handling
			function qs() {
					var query = window.location.search.substring(1);
					var parms = query.split('&');
					for (var i=0; i<parms.length; i++) {
						var pos = parms[i].indexOf('=');
						if (pos > 0) {
							var key = parms[i].substring(0,pos);
							var val = parms[i].substring(pos+1);
							qsParm[key] = val;
						}
					}
		   } 
		
	 	   // Map Loading	
			 function mt_appendOptionLast(city, pos)
			 {
			  var elOptNew = document.createElement('option');
			  elOptNew.text = city;
			  elOptNew.value = pos+" , 10"+" , "+city;
			  var elSel = document.getElementById('mt_SelectCity');
			  g_city_list.push(city);
			  g_pos_list.push(pos);
			  
			  try {
			    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
			  }
			  catch(ex) {
			    elSel.add(elOptNew); // IE only
			  }
			 }
		
		   function mt_go(txt) {
		   
		   
		      //Change map height based on browser
					if (browser != "Microsoft Internet Explorer")
					{
							Ext.getDom("map").style.height="100%";
					}
		      

          // Activate Map Tab
          Ext.getCmp('main_central_tab').setActiveTab(0);
		   
		   	  var value_arr = new Array();
		   	  value_arr = txt.split(" , ");
		   		g_lat = parseFloat(value_arr[0]);
					g_lng = parseFloat(value_arr[1]);
					g_zoom = parseInt (value_arr[2]);
					g_zoom=12; //override
					g_city = value_arr[3];
	
          // find total Count
         GDownloadUrl("/irmv2/include/lib_gen_js_gmap3.php?function=getCount_XmlMarkersInCity&whichcity="+g_city, function(data, responseCode) {

		          var xmlDoc = GXml.parse(data);
              var count = xmlDoc.documentElement.firstChild.textContent;
              //alert(count);
          
          });


					zoom_to_city(g_city,g_lat,g_lng,g_zoom,0,100);
					
					ListingGrid.getView().scrollToTop();
					
					Ext.getCmp('south_panel').collapse(true);
          Ext.getDom("info_panel_content").style.display="none";
          
          Ext.getDom("info_panel_filler").style.display="block";

					// Add button to post new listings
					document.getElementById("Add_div").innerHTML='<input type="button" id = "add" value="Add Listing \n (Zoom in first)" 	onclick = "addNewMarker();" title="Marker added by clicking on map."></input>	<input type="button" id="clearmap" value=" Clear All Markers" title="Remove All Markers On The Map."	onclick = "clearAllMarkers();"></input>';	

		   }

    	
		  function showAddress(address) {
  	   	  geocoder = new GClientGeocoder();
  	   	  geocoder.setBaseCountryCode("IN");
		      if (geocoder) {
		        geocoder.getLatLng(
		          address,
		          function(point) {
		            if (!point) {
		              alert(address + " not found");
		            } else {
		              //map.setCenter(point, 9);
		              //var marker = new GMarker(point);
									//mgr.addMarker(marker,9);
		              //marker.openInfoWindowHtml(address);
		              
		              // load nearby items
		              var g_lat = point.lat();
		              var g_lng = point.lng();
				          zoom_to_loc(address,g_lat,g_lng,9);
		            }
		          }
		        );
		      }
		  }














		// ExtJS
		var store;
		var TopicRecord;
	  var ListingGrid;	
		function doJSON(stringData) {
			try {
				var jsonData = Ext.util.JSON.decode(stringData);
				//Ext.MessageBox.alert('Success', 'Decode of stringData OK<br />jsonData.date = ' + jsonData.date);
			}
			catch (err) {
				//Ext.MessageBox.alert('ERROR', 'Could not decode ' + stringData);
			}
		}

		function open_details_tab(id)	 {
						var thtml ="<iframe style=\"height:100%;width:100%\" frameBorder=0 id=\"iframe_add_marker\" src=\"/index2.php?action=listingview&listingID="+id+"\"></iframe>";
		        var newComponent = eval('('+'{ closable:true, id:\''+id+'\',title:\'ID:'+id+' \', html:\''+ thtml+'\'}'+')');
		        Ext.getCmp('main_central_tab').add(newComponent);
		        Ext.getCmp('main_central_tab').setActiveTab(id);
		}

		function open_url_tab(fetch_url)	 {
						var thtml ="<iframe style=\"height:100%;width:100%\" frameBorder=0 id=\"iframe_add_marker\" src=\""+fetch_url+"\"></iframe>";
		        var newComponent = eval('('+'{ closable:true, id:\''+fetch_url+'\', title:\'Add New Entry\', html:\''+ thtml+'\'}'+')');
		        Ext.getCmp('main_central_tab').add(newComponent);
		        Ext.getCmp('main_central_tab').setActiveTab(fetch_url);
		}


//EXT -------------------------------------------------

















    Ext.onReady(function(){

        // NOTE: This is an example showing simple state management. During development,
        // it is generally best to disable state management as dynamically-generated ids
        // can change across page loads, leading to unpredictable results.  The developer
        // should ensure that stable state ids are set for stateful components in real apps.
        //Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
        
        
        
    // Filter Tree    - Begin
    var Tree = Ext.tree;
    
    var tree = new Tree.TreePanel({
        renderTo:'tree-div',
        useArrows:true,
        autoScroll:true,
        //animate:true,
        //enableDD:true,
        containerScroll: true,
        iconCls:"",


        // auto create TreeLoader
//        dataUrl: 'get-nodes.php',

        loader:  new Tree.TreeLoader({
	    preloadChildren: true,
            dataUrl:'get-nodes.php'
        }),




        root: {
            nodeType: 'async',
            text: 'Refine',
            draggable:false,
            id:'Root'
        }
    });

    // render the tree
    //tree.render();
    //tree.getRootNode().expand();
    tree.expandAll();        
    // Filter Tree    - End
        
        
        
        
        

    var myData = [
        //['image','Titel 1','9/1 12:00am','High'],
    ];

		TopicRecord = Ext.data.Record.create([

		    {name: 'gmindex', mapping: 'gmindex'},

			  {name: 'id'}, 					  
			  {name: 'title'},					
			  {name: 'creation_date', type: 'date', dateFormat: 'n/j h:ia'},  
			  {name: 'hit_count'}, 			
			  {name: 'last_modified', type: 'date', dateFormat: 'n/j h:ia'}, 	
			  {name: 'featured'}, 			
			  {name: 'class_id'}, 			

			  {name: 'additional_features'},
			  {name: 'additional_rooms'},
			  {name: 'address_line_1'},
			  {name: 'address_line_2'},
			  {name: 'age'},
			  {name: 'annual_due'},
			  {name: 'apartment_features'},
			  {name: 'apartment_size'},
			  {name: 'bath_rooms'},
			  {name: 'beds'},
			  {name: 'builtup_area'},
			  {name: 'car_parking'},
			  {name: 'car_parking_type'},
			  {name: 'city'},
			  {name: 'contact_info'},
			  {name: 'district'},
			  {name: 'flooring_type'},
			  {name: 'full_desc'},
			  {name: 'home_features'},
			  {name: 'hospital_near_by'},
			  {name: 'lmark'},
			  {name: 'latitude'},
			  {name: 'locality'},
			  {name: 'longitude'},
			  {name: 'mlsexport'},
			  {name: 'neighborhood'},
			  {name: 'number_of_floors'},
			  {name: 'number_of_lifts'},
			  {name: 'or_owner'},
			  {name: 'other_city'},
			  {name: 'pincode'},
			  {name: 'plot_area'},
			  {name: 'price'},
			  {name: 'property_avialbility'},
			  {name: 'property_class'},
			  {name: 'property_for'},
			  {name: 'property_ownership'},
			  {name: 'property_type_apartment'},
			  {name: 'property_type_building_materials'},
			  {name: 'property_type_commercial_space'},
			  {name: 'property_type_house'},
			  {name: 'property_type_human_resources'},
			  {name: 'property_type_industrial_space'},
			  {name: 'property_type_l'},
			  {name: 'property_type_office_space'},
			  {name: 'proximity_airport'},
			  {name: 'proximity_central_bus_st'},
			  {name: 'proximity_details_div'},
			  {name: 'proximity_railway_station'},
			  {name: 'rental_income'},
			  {name: 'room_details'},
			  {name: 'shool_near_by'},
			  {name: 'state'},
			  {name: 'status'},
			  {name: 'use_of_property'},
			  {name: 'which_floor'},
			  {name: 'limage'},
			  
        {name: 'Image_tag'}
		    
	    
		]);
				    
    // example of custom renderer function
    function change(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '</span>';
        }
        return val;
    }

    // example of custom renderer function
    function pctChange(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '%</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '%</span>';
        }
        return val;
    }

    // create the data store
//    store = new Ext.data.SimpleStore({
    store = new Ext.data.SimpleStore({
    		//autoLoad: {params:{start: 0, limit: 25}},
    		proxy: new Ext.data.DataProxy({load : function(params) {}}),
        fields: [

    		    {name: 'gmindex'},

					  {name: 'id'}, 					  
					  {name: 'title'},					
					  {name: 'creation_date', type: 'date', dateFormat: 'n/j h:ia'},  
					  {name: 'hit_count'}, 			
					  {name: 'last_modified', type: 'date', dateFormat: 'n/j h:ia'}, 	
					  {name: 'featured'}, 			
					  {name: 'class_id'}, 			

					  {name: 'additional_features'},
					  {name: 'additional_rooms'},
					  {name: 'address_line_1'},
					  {name: 'address_line_2'},
					  {name: 'age'},
					  {name: 'annual_due'},
					  {name: 'apartment_features'},
					  {name: 'apartment_size'},
					  {name: 'bath_rooms'},
					  {name: 'beds'},
					  {name: 'builtup_area'},
					  {name: 'car_parking'},
					  {name: 'car_parking_type'},
					  {name: 'city'},
					  {name: 'contact_info'},
					  {name: 'district'},
					  {name: 'flooring_type'},
					  {name: 'full_desc'},
					  {name: 'home_features'},
					  {name: 'hospital_near_by'},
					  {name: 'lmark'},
					  {name: 'latitude'},
					  {name: 'locality'},
					  {name: 'longitude'},
					  {name: 'mlsexport'},
					  {name: 'neighborhood'},
					  {name: 'number_of_floors'},
					  {name: 'number_of_lifts'},
					  {name: 'or_owner'},
					  {name: 'other_city'},
					  {name: 'pincode'},
					  {name: 'plot_area'},
					  {name: 'price'},
					  {name: 'property_avialbility'},
					  {name: 'property_class'},
					  {name: 'property_for'},
					  {name: 'property_ownership'},
					  {name: 'property_type_apartment'},
					  {name: 'property_type_building_materials'},
					  {name: 'property_type_commercial_space'},
					  {name: 'property_type_house'},
					  {name: 'property_type_human_resources'},
					  {name: 'property_type_industrial_space'},
					  {name: 'property_type_l'},
					  {name: 'property_type_office_space'},
					  {name: 'proximity_airport'},
					  {name: 'proximity_central_bus_st'},
					  {name: 'proximity_details_div'},
					  {name: 'proximity_railway_station'},
					  {name: 'rental_income'},
					  {name: 'room_details'},
					  {name: 'shool_near_by'},
					  {name: 'state'},
					  {name: 'status'},
					  {name: 'use_of_property'},
					  {name: 'which_floor'	},
					  {name: 'limage'},
					  
	          {name: 'Image_tag'}
        ]
       // ,sortInfo : {field: "limage", direction: "DESC"}
    });
    //store.loadData(myData);



    // create the Grid
    
    pagingBar = new Ext.PagingToolbar({
        pageSize: 25,
        store: store,
        displayInfo: true,
        displayMsg: 'Displaying topics {0} - {1} of {2}',
        emptyMsg: "No topics to display",
        
        items:[
            '-', {
            pressed: true,
            enableToggle:true,
            text: 'Show Preview',
            cls: 'x-btn-text-icon details',
            toggleHandler: function(btn, pressed){
                var view = ListingGrid.getView();
                view.showPreview = pressed;
                view.refresh();
            }
        }]
    });


    
        ListingGrid = new Ext.grid.GridPanel({
        store: store,
        stripes: true,
        loadMask: true,


        columns: [
            {id:'Image_tag',header: "Image", width: 125, sortable: false, dataIndex: 'Image_tag'},

					  {header: "id", width: 35, sortable: true, hidden: true, dataIndex: 'id'}, 
					  {header: "title", width: 250, sortable: true, hidden: false, dataIndex: 'title'}, 
					  {header: "creation_date", width: 35, hidden: true,sortable: true, dataIndex: 'creation_date'}, 
					  {header: "hit_count", width: 35, hidden: true,sortable: true, hidden: false, dataIndex: 'hit_count'}, 
					  {header: "last_modified", width: 35, sortable: true, hidden: true, dataIndex: 'last_modified'}, 
					  {header: "featured", width: 35, sortable: true, hidden: true, dataIndex: 'featured'}, 
					  {header: "class_id", width: 35, sortable: true, hidden: true, dataIndex: 'class_id'}, 

					  {header: "additional_features", width: 35, sortable: true, hidden: true, dataIndex: 'additional_features'}, 
					  {header: "additional_rooms", width: 35, sortable: true, hidden: true, dataIndex: 'additional_rooms'}, 
					  {header: "address_line_1", width: 35, sortable: true, hidden: true, dataIndex: 'address_line_1'}, 
					  {header: "address_line_2", width: 35, sortable: true, hidden: true, dataIndex: 'address_line_2'}, 
					  {header: "age", width: 35, sortable: true, hidden: true, dataIndex: 'age'}, 
					  {header: "annual_due", width: 35, sortable: true, hidden: true, dataIndex: 'annual_due'}, 
					  {header: "apartment_features", width: 35, sortable: true, hidden: true, dataIndex: 'apartment_features'}, 
					  {header: "apartment_size", width: 35, sortable: true, hidden: true, dataIndex: 'apartment_size'}, 
					  {header: "bath_rooms", width: 35, sortable: true, hidden: true, dataIndex: 'bath_rooms'}, 
					  {header: "beds", width: 35, sortable: true, hidden: true, dataIndex: 'beds'}, 
					  {header: "builtup_area", width: 35, sortable: true, hidden: true, dataIndex: 'builtup_area'}, 
					  {header: "car_parking", width: 35, sortable: true, hidden: true, dataIndex: 'car_parking'}, 
					  {header: "car_parking_type", width: 35, sortable: true, hidden: true, dataIndex: 'car_parking_type'}, 
					  {header: "city", width: 35, sortable: true, hidden: true, dataIndex: 'city'}, 
					  {header: "contact_info", width: 35, sortable: true, hidden: true, dataIndex: 'contact_info'}, 
					  {header: "district", width: 35, sortable: true, hidden: true, dataIndex: 'district'}, 
					  {header: "flooring_type", width: 35, sortable: true, hidden: true, dataIndex: 'flooring_type'}, 
					  {header: "full_desc", width: 35, sortable: true, hidden: true, dataIndex: 'full_desc'}, 
					  {header: "home_features", width: 35, sortable: true, hidden: true, dataIndex: 'home_features'}, 
					  {header: "hospital_near_by", width: 35, sortable: true, hidden: true, dataIndex: 'hospital_near_by'}, 
					  {header: "lmark", width: 35, sortable: true, hidden: true, dataIndex: 'lmark'}, 
					  {header: "latitude", width: 35, sortable: true, hidden: true, dataIndex: 'latitude'}, 
					  {header: "locality", width: 35, sortable: true, hidden: true, dataIndex: 'locality'}, 
					  {header: "longitude", width: 35, sortable: true, hidden: true, dataIndex: 'longitude'}, 
					  {header: "mlsexport", width: 35, sortable: true, hidden: true, dataIndex: 'mlsexport'}, 
					  {header: "neighborhood", width: 35, sortable: true, hidden: true, dataIndex: 'neighborhood'}, 
					  {header: "number_of_floors", width: 35, sortable: true, hidden: true, dataIndex: 'number_of_floors'}, 
					  {header: "number_of_lifts", width: 35, sortable: true, hidden: true, dataIndex: 'number_of_lifts'}, 
					  {header: "or_owner", width: 35, sortable: true, hidden: true, dataIndex: 'or_owner'}, 
					  {header: "other_city", width: 35, sortable: true, hidden: true, dataIndex: 'other_city'}, 
					  {header: "pincode", width: 35, sortable: true, hidden: true, dataIndex: 'pincode'}, 
					  {header: "plot_area", width: 35, sortable: true, hidden: true, dataIndex: 'plot_area'}, 
					  {header: "price", width: 35, sortable: true, hidden: true, dataIndex: 'price'}, 
					  {header: "property_avialbility", width: 35, sortable: true, hidden: true, dataIndex: 'property_avialbility'}, 
					  {header: "property_class", width: 35, sortable: true, hidden: true, dataIndex: 'property_class'}, 
					  {header: "property_for", width: 35, sortable: true, hidden: true, dataIndex: 'property_for'}, 
					  {header: "property_ownership", width: 35, sortable: true, hidden: true, dataIndex: 'property_ownership'}, 
					  {header: "property_type_apartment", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_apartment'}, 
					  {header: "property_type_building_materials", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_building_materials'}, 
					  {header: "property_type_commercial_space", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_commercial_space'}, 
					  {header: "property_type_house", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_house'}, 
					  {header: "property_type_human_resources", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_human_resources'}, 
					  {header: "property_type_industrial_space", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_industrial_space'}, 
					  {header: "property_type_l", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_l'}, 
					  {header: "property_type_office_space", width: 35, sortable: true, hidden: true, dataIndex: 'property_type_office_space'}, 
					  {header: "proximity_airport", width: 35, sortable: true, hidden: true, dataIndex: 'proximity_airport'}, 
					  {header: "proximity_central_bus_st", width: 35, sortable: true, hidden: true, dataIndex: 'proximity_central_bus_st'}, 
					  {header: "proximity_details_div", width: 35, sortable: true, hidden: true, dataIndex: 'proximity_details_div'}, 
					  {header: "proximity_railway_station", width: 35, sortable: true, hidden: true, dataIndex: 'proximity_railway_station'}, 
					  {header: "rental_income", width: 35, sortable: true, hidden: true, dataIndex: 'rental_income'}, 
					  {header: "room_details", width: 35, sortable: true, hidden: true, dataIndex: 'room_details'}, 
					  {header: "shool_near_by", width: 35, sortable: true, hidden: true, dataIndex: 'shool_near_by'}, 
					  {header: "state", width: 35, sortable: true, hidden: true, dataIndex: 'state'}, 
					  {header: "status", width: 35, sortable: true, hidden: true, dataIndex: 'status'}, 
					  {header: "use_of_property", width: 35, sortable: true, hidden: true, dataIndex: 'use_of_property'}, 
					  {header: "which_floor"	, width: 35, sortable: true, hidden: true, dataIndex: 'which_floor'},
					
					  {header: "limage'"	, width: 35, sortable: true, hidden: true, dataIndex: 'limage'}

        ],
        stripeRows: true,
        //autoExpandColumn: 'Image_tag',
        height:350,
        width:600,
        title:'Live Listing',
        // customize view config
        viewConfig: {
            forceFit:true,
            enableRowBody:true,
            showPreview:true,
            getRowClass : function(record, rowIndex, p, store){
                if(this.showPreview){
                    //p.body = '<p>'+record.data.excerpt+'</p>';
                    return 'x-grid3-row-expanded';
                }
                return 'x-grid3-row-collapsed';
            }
        }

        // paging bar on the bottom
        //bbar: pagingBar
        
    });


//pagingBar.resize();

    // render it
    //ListingGrid.render();

    // trigger the data store load
    //store.load({params:{start:0, limit:25}});





     //grid.getSelectionModel().selectFirstRow();

	    var onRowMouseOver = function(){ 
	    	}
	    var onAdd = function(){ 
	    	Ext.MessageBox.hide();
	    	}
//25347773	    	
	    var onRowMouseClick = function(){ }
	    
	    var onRowClick = function(){ 
	    
	          if( !ListingGrid.getSelectionModel().getSelections()[0] ) {
	          	return;
	          }
            
            // activate map tab
            Ext.getCmp('main_central_tab').setActiveTab(0);
            
            // show Details panel
            Ext.getCmp('south_panel').expand(true);
            
            // Open infoWindow
            var info_win_html="<div style='width:280px; height:120px'><table class=\"info_table\">";
            info_win_html += "<tr>";	
            info_win_html += "<th>"+ListingGrid.getSelectionModel().getSelections()[0].data['Image_tag']+"</th>";
            info_win_html += "<td><div style='width:150px; height:120px; overflow:auto'><span id='mw_contact_info'>Contact Info</span><br/>"+ListingGrid.getSelectionModel().getSelections()[0].data['contact_info']+"</div></td>";
          	info_win_html += "</tr>";	
          	info_win_html += "</table></div>";	


            myclick((ListingGrid.getSelectionModel().getSelections()[0].data['gmindex']),info_win_html);

            // hide filler panel
            Ext.getDom("info_panel_filler").style.display="none";
             
          	Ext.getDom("info_panel_content").style.display="block";

            Ext.getDom("info_title").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['title'];
            Ext.getDom("info_id").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['id'];
            Ext.getDom("info_creation_date").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['creation_date'];
            Ext.getDom("info_hit_count").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['hit_count'];
            Ext.getDom("info_last_modified").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['last_modified'];
            Ext.getDom("info_featured").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['featured'];
            Ext.getDom("info_class_id").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['class_id'];
            Ext.getDom("info_status").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['status'];



						Ext.getCmp('south_panel').setTitle("ID:"+ListingGrid.getSelectionModel().getSelections()[0].data['id']+"&nbsp;"+ListingGrid.getSelectionModel().getSelections()[0].data['title']+"&nbsp; &nbsp; <img src=/irmv2/images/site/moreinfo.gif onclick=\"open_details_tab('"+ListingGrid.getSelectionModel().getSelections()[0].data['id']+"')\">");
            var image_file = "nophoto.gif";
            if(ListingGrid.getSelectionModel().getSelections()[0].data['limage'] != ""){
            	image_file="thumb_"+ListingGrid.getSelectionModel().getSelections()[0].data['limage'].split(".")[0]+".jpg";
            }
            var image_url = "/irmv2/images/listing_photos/"+image_file;

            Ext.getDom("info_limage").innerHTML="<img src="+image_url+">";
            Ext.getDom("info_price").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['price'];
            Ext.getDom("info_plot_area").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['plot_area'];


            Ext.getDom("info_address_line_1").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['address_line_1'];
            Ext.getDom("info_address_line_2").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['address_line_2'];
            Ext.getDom("info_city").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['city'];
            Ext.getDom("info_pincode").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['pincode'];
            Ext.getDom("info_state").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['state'];


            if(ListingGrid.getSelectionModel().getSelections()[0].data['class_id'] == "1" || ListingGrid.getSelectionModel().getSelections()[0].data['class_id'] == "2") {
								Ext.getDom("filter_Apartment_House").style.display="block";
								
								Ext.getDom("info_unit").style.display="block";
								
								Ext.getDom("info_full_desc_div").style.width="25%";
								Ext.getDom("info_full_desc").style.display="block";

		            Ext.getDom("info_beds").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['beds'];
		            Ext.getDom("info_bath_rooms").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['bath_rooms'];
		            Ext.getDom("info_additional_rooms").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['additional_rooms'];
		            Ext.getDom("info_builtup_area").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['builtup_area'];
		
		            Ext.getDom("info_full_desc").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['full_desc'];


            } else {

								Ext.getDom("filter_Apartment_House").style.display="none";
								
								Ext.getDom("info_unit").style.display="none";
								
								Ext.getDom("info_full_desc_div").style.width="50%";
								Ext.getDom("info_full_desc").style.display="block";
								
		            Ext.getDom("info_full_desc").innerHTML=ListingGrid.getSelectionModel().getSelections()[0].data['full_desc'];
            }

	    	}
	    	
	    var rowdblclick = function(){ 
            //alert(i);
            //myclick((ListingGrid.getSelectionModel().getSelections()[0].data['gmindex']),(ListingGrid.getSelectionModel().getSelections()[0].data['Image_tag'])+(ListingGrid.getSelectionModel().getSelections()[0].data['title']));
	    	}
	    	
	    var onRowMouseOut = function(){ }

	    var onrowsinserted = function(){
	    	Ext.MessageBox.hide();
	    	//ListingGrid.getView().scrollToTop();

	     }

 			ListingGrid.getView().on( {
 			 	  'rowsinserted'   : {
			        fn: onrowsinserted ,
			        scope: this
			 	  }
	    });
	    
	    //this.ListingGrid.addListener(onRowMouseOver);
			 ListingGrid.on({
			 	  'beforeadd'   : {
			        fn: onAdd,
			        scope: this
			 	  },
			    'click' : {
			        //fn: onRowMouseClick,
			        fn: onRowClick,
			        scope: this
			        //delay: 100
			    },
			    'mouseover' : {
			        fn: onRowMouseOver,
			        scope: this
			    },
			    'mouseout' : {
			        fn: onRowMouseOut,
			        scope: this
			    }
			 });   
			     
			 ListingGrid.getSelectionModel().on({
			    'rowselect' : {
			        //fn: onRowMouseClick,
			        fn: onRowClick,
			        scope: this
			        //delay: 100
			    }
			 });   
			     
			     
			 var FirstTimeLoadingGmap = true;     
		   function handleActivate(tab){
			    	if(FirstTimeLoadingGmap === true){
			    		gmapload();
			    		FirstTimeLoadingGmap=false;
			      }
		   }

        
       var viewport = new Ext.Viewport({
            layout:'border',
            hidden:false,
//            style: '{background: url(/irmv2/images/site/themes/orangee/bg.png) repeat;}',
            style: '{background: #7979D2;}',
            items:[
                new Ext.BoxComponent({ // raw
                    region:'north',
                    el: 'north',
                    height:75,
                    margins:'0 10 10 0'
                    
//                    style: '{background: url(/irmv2/images/site/themes/orangee/gloss1.png) repeat;}'
                }),{
                    region:'south',
                    id:'south_panel',
                    contentEl: 'south',
//                    header:false,
//                    style: '{background: url(/irmv2/images/site/themes/orangee/gloss1.png) repeat;}',
                    autoScroll:true,
//                    iconCls:'background: url(/irmv2/images/site/themes/orangee/gloss.png) repeat;', 
                    split:true,
                    height: 185,
                    minSize: 100,
                    maxSize: 200,
                    collapsible: true,
                    collapsed: true,
                    title:'Details',
                    margins:'0 5 5 5'
//                    style: 'background: #FF0000; '
                }, {
                    region:'east',
                    id:'east_panel',
//                    header:false,
                    title: 'Listings',
                    collapsible: true,
                    collapsed: true,
                    split:true,
                    width: 300,
                    minSize: 185,
                   // maxSize: 400,
                    layout:'fit',
                    margins:'0 5 5 5',
                    items:
                        new Ext.TabPanel({
                            border:false,
//                    				header:false,
                            activeTab:0,
                            tabPosition:'bottom',
                            items:[
                            ListingGrid
                            ]
                        })
                 },{
                    region:'west',
                    id:'west_panel',
                    title:'Control Panel',
//                    header:false,
                    split:true,
                    width: 200,
                    minSize: 200,
                    maxSize: 200,
                    collapsible: true,
                    margins:'0 5 5 5',
                    layout:'accordion',
                    layoutConfig:{
                        animate:true
                    },
                    items: [{
                        contentEl: 'west',
                        title:'Filters',
                        border:false,
                        iconCls:'nav',
                        autoScroll:true
                    }]
                },
                new Ext.TabPanel({
                    id:'main_central_tab',
                    margins:'0 0 5 0',
                    header:false,
                    region:'center',
                    deferredRender:false,
                    autoScroll:true,
                    activeTab:1,
                    items:[{
                        contentEl:'MapView',
                        title: 'Map View',
                        closable:false,
                        listeners: {activate: handleActivate},
                        //listeners: {render: handleRender},
                        autoScroll:true
                    },{
                        contentEl:'Welcome',
                        title: 'Welcome!',
                        closable:false,
                        autoScroll:true
                    }]
                })
                
                
                
             ]
        });
        Ext.get("hideit").on('click', function() {
           var w = Ext.getCmp('west_panel');
           w.collapsed ? w.expand() : w.collapse(); 
        });
        Ext.get("hide_map").on('click', function() {
           var w = Ext.getCmp('main_central_tab');
           w.collapsed ? w.expand() : w.collapse(); 
        });
        

        // Load

 
   		//var t=setTimeout("gmapload()",1000);
      // Streamline the order of JS execution
      postExtJsProcessing();

        
    });

  
		function loadPhp(phpfile){
		    alert("loading"+phpfile);
				Ext.Ajax.request({
				    url: phpfile,
				    params: {
				        //startDate = Ext.getCmp('start-date').getValue(),
				        //endDate = Ext.getCmp('end-date').getValue()
				    },
				    success: function(xhr) {
				        eval(xhr.responseText);
				        grepCityLatLong_js();
				    },
				    failure: function() {
				    	Ext.Msg.alert("Grid create failed", "Server communication failure");
				    }
				});
		}


    
var FirstTimeLoadingGmapInit = true;     

function postExtJsProcessing() {
	    	if(FirstTimeLoadingGmapInit === true){
	      	grepCityLatLong_js();
	    		FirstTimeLoadingGmapInit = false;	
	    	}
	     	document.getElementById("initial").style.display="none";
}


