/************************************************************************************************************
Author: Marvin Mempin
Dependencies:
jQuery 1.3

************************************************************************************************************/
/* Required: Please dont remove/modify from here ...********************************************************/
	google.load("maps", "2");

/* ... to here     ****************************************************************************************/
/* Plugin Required Variables ***************************************************************************** */
	var map = null;
	var centerMarker=null;
	var searchMarker=null;
	var mapConfig=null;
	var dataBuffer=null;
	var eInfoWPath='/common/components_jsp/googlemap/js/extinfowindow.js'; //might be needed to move inside Jasmine
	var geodesicJSPath='/common/components_jsp/googlemap/js/geodesics.js';

/* Mode 9 HTML  **************************************************************************** */	
	var MODE9_PRE='<h1>Location Finder</h1><form action="#" onsubmit="showAddress(this.address.value); return false">'+
				  '<p><input type="text" size="60" name="address" value="Singapore" style="float:none !important" />'+
				  '<input type="submit" value="Go!" style="float:none !important" />'+
				  '</p></form><div id="log">Instructions: Please type a country name, city name or address above. <br />'+
				  'See more info below the map</div><br />';
	var MODE9_SUF='<div style="width:500px"><p>More Info :</p><ol><li>Please type a country name, city name or address on '+
				  'the input field provided. Coordinates returned is based on Google\'s data associated with the location you '+
				  'typed in.</li><li>Drag the map or click the cross on upper left to change map centering</li><li>Drag the '+
				  'vertical slider on the left to change zoom or use mouse wheel </li><li>Double left mouse click to zoom in, '+
				  'double right mouse click to zoom out </li></ol></div>';
/* Mode 1 HTML  **************************************************************************** */	
	var MODE1_FORM= '<div id="wmap_filter_container">'+
					'<form action="javascript:;" id="wmap_filters">'+
					'<div id="wmap_brand_ct" class="filter_ddls"><select name="wmap_brand" id="wmap_brand"><option value="">- All Brands -</option></select></div>'+
					'<div id="wmap_country_ct" class="filter_ddls"><select name="wmap_country" id="wmap_country"><option value="">- All Countries -</option></select></div>'+
					'<div id="wmap_city_ct" class="filter_ddls"><select name="wmap_city" id="wmap_city"><option value="">- All Cities -</option></select></div>'+
					'<div id="wmap_go_ct"><input name="wmap_go" type="button" id="wmap_go" value="Go"/></div>'+
					'<div id="wmap_reset_ct"><input name="wmap_reset" type="button" id="wmap_reset" value="Reset"/></div>'+
					'</form>'+
					'</div>';
	
	var countryDDLBuff=new Array();
	var cityDDLBuff=new Array();
/* Plugin Utility Functions  **************************************************************************** */	
	function linkJSOnDemand(jsURL)
    {
	  $('head').append("<script src=\""+jsURL+"\" type=\"text/javascript\"></script>");
    }//end linkJSOnDemand


	function toggleGroup(type) {
      for (var i = 0; i < mapConfig.markerGroups[type].length; i++) {
        var marker = mapConfig.markerGroups[type][i];
        if (marker.isHidden()) {
          marker.show();
        } else {
          marker.hide();
        }
      } 
    }
	
	
	function hideGroup(groupObj,type) {
	
      if(type==null || type =="")
	  for (property in groupObj)
		  for (var i = 0; i <  groupObj[property].length; i++) {
			var marker = groupObj[property][i];
			if (!marker.isHidden()) marker.hide();
		  } //for
	  else
		  for (var i = 0; i <  groupObj[type].length; i++) {
			var marker = groupObj[type][i];
			if (!marker.isHidden()) marker.hide();
		  } //for
    }//hideGroup
	
	function showGroup(groupObj,type) {
			$.jaslog(type);
	  if(type==null || type =="")
	  for (property in groupObj)
		  for (var i = 0; i <  groupObj[property].length; i++) {
			var marker = groupObj[property][i];
			if (marker.isHidden()) marker.show();
		  } //for
	  else
		  for (var i = 0; i <  groupObj[type].length; i++) {
			var marker = groupObj[type][i];
			if (marker.isHidden()) marker.show();
		  } //for
    }//showGroup
	
	
	function initializeAttractions(){
		var attraction_content="<ul class=\"main_location\">";
		
		for (property in mapConfig.markerGroups) {
			var markerCatLabel="No Marker Cat Label";
		
			if(property==mapConfig.hotelID)
				markerCatLabel=mapConfig.hotelCatLabel;
			else if(property==mapConfig.otherHotelsID)
				markerCatLabel=mapConfig.otherCatLabel;
			else markerCatLabel=property;
			
			if(property!=mapConfig.hotelID || mapConfig.includeHotel){
				attraction_content+="<li class=\"location_header "+property.replace(/ /, "_")+"\"><input type=\"checkbox\" value=\"Hide/Show Bars\" onclick=\"closeCustomInfo();toggleGroup('"+property+"')\" checked=\"checked\" class=\"location_checkbox\"/><h2>"+markerCatLabel+"</h2>";
					attraction_content+="<ul class=\"sub_location\">";
					for (var i = 0; i < mapConfig.markerGroups[property].length; i++) {
						attraction_content+="<li class=\"location_info\" onclick=\"closeCustomInfo();showAttraction('"+property+"',"+i+");\">"+mapConfig.markerGroups[property][i].getTitle()+"</li>";
	
					} //end for
					attraction_content+="</ul>";
				attraction_content+="</li>";
			}//end if
		}//end for
		
		attraction_content+="</ul>";
		
		$(mapConfig.markerCatContainer).html(attraction_content);
	}//end initializeAttractions
	
	
	function showAttraction(markerCat,markerID){
				var attMarker =mapConfig.markerGroups[markerCat][markerID];		
				customInfoWindow(attMarker,attMarker.getTitle(), balloonContent(attMarker));
				if(mapConfig.centerOnMarker)
				map.setCenter(attMarker.getLatLng(), mapConfig.centerOnMarkerZoom);
	}//end showAttraction
	
	
	function customInfoWindow(markerObj, infoTitle, infoBody){
		try {
			markerObj.openExtInfoWindow(map,"custom_info_window_red", "<div class='title'>"+infoTitle+"</div>"+"<p>"+infoBody+"</p>",{beakOffset: 2,paddingY:30});	
		}
		catch(e) {	
		} 
	}//end customInfoWindow
	
	
	function balloonContent(markerObj){
		var balloonHTML="";
		
		if(markerObj.address1!="") balloonHTML+="<span class=\"markerAddress\">"+markerObj.address1+"</span><br class=\"break\"/>";
		
		if(markerObj.thumb!="") balloonHTML+="<img class=\"balloonImageThumb\" src=\""+markerObj.thumb+"\" border=\"0\" />";
		
			var target=markerObj.brand;
			if(mapConfig.balloonLinkMode==1)target = "_blank";
			
			if(markerObj.category==mapConfig.hotelID || markerObj.category==mapConfig.otherHotelsID) {
				balloonHTML+="<span class=\"spanhotelSummary\">"+hotelSummary[markerObj.id]+"</span>";
				if(markerObj.uri!=""){
					balloonHTML+="<br class=\"break\"/><a href=\""+markerObj.uri+"\" onclick=\"javascript:trackGALink(this.href,this.target); return false;\" class=\"balloonPropLink\" target=\""+target+"\">";
				if(mapConfig.useBalloonImg)
					balloonHTML+="<img src=\""+mapConfig.balloonImgProp+"\" alt=\"\" /></a>";
				else
					balloonHTML+="<span>"+mapConfig.propLink+"</span></a>";}
			}
			else
			{
				balloonHTML+=markerSummary[markerObj.id];
				if(markerObj.uri!=""){
				balloonHTML+="<br class=\"break\"/><a href=\""+markerObj.uri+"\" onclick=\"javascript:trackGALink(this.href,this.target); return false;\" class=\"balloonPropLink\" target=\""+target+"\">";
				if(mapConfig.useBalloonImg)
					balloonHTML+="<img src=\""+mapConfig.balloonImg+"\" alt=\"\" /></a>";
				else
					balloonHTML+="<span>"+mapConfig.defaultLink+"</span></a>";}
			}	

		return balloonHTML;
	}//end balloonContent
	
	function trackGALink(href, target){
		window.open(pageTracker._getLinkerUrl(href),target);		
	}
	
	function closeCustomInfo(){
		map.closeExtInfoWindow();
	}//end closeCustomInfo
	
	function setMarkerIcon(markerIconImage,markerShadowImage) {
        var icon = new GIcon();
        icon.image = markerIconImage;
        icon.iconAnchor = new GPoint(mapConfig.anchorSizeX, mapConfig.anchorSizeY);
        icon.infoWindowAnchor = new GPoint(mapConfig.infoWanchorSizeX, mapConfig.infoWanchorSizeY);
        icon.iconSize = new GSize(mapConfig.markerSizeX, mapConfig.markerSizeY);
        icon.shadow = markerShadowImage;
        icon.shadowSize = new GSize(mapConfig.shadowX, mapConfig.shadowY);
		return icon;
    }//end setMarkerIcon
	
	function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
			  GEvent.addListener(marker, "click", function() {    marker.openInfoWindowHtml(address);  });
            }
          }
        );
      }
    }
	
/* Plugins  **************************************************************************** */	
	

jQuery.jaslog = function(message,ieEnabled,hID) {
	var pre="Jasmine Log: ";
	if(window.console) console.log(pre+message);
	else if (ieEnabled) alert(pre+message);
	if(hID) $("#"+hID).html(message);
}

// jQuery.uniqueStrArray
// jQuery utility function, removes the duplicates in a string/num array and returns new array
// the array parameter remains untouched
jQuery.uniqueStrArray = function(vals,sortArray){
    var uniques = [];
    for(var i=vals.length;i--;){
        var val = vals[i];  
        if(jQuery.inArray( val, uniques )===-1){
            uniques.unshift(val);
        }
    }
	$.jaslog(uniques);
	if(sortArray) uniques.sort();
	$.jaslog(uniques);
    return uniques;
} 
// Sample Usage:
// var unsortedDuplicatedArray=new Array("hh", "bb", "hh", "aa", "zz","cc");
// jQuery.jaslog(jQuery.uniqueStrArray(unsortedDuplicatedArray,true));
// jQuery.jaslog(unsortedDuplicatedArray);

jQuery.fn.jasmineGMAP = function(opts) {
	return this.eq(0).each(function(){ //ensures Gmap is placed on first match of the id provided and returns the matched element
	mapConfig = jQuery.extend({},
   	 jQuery.fn.jasmineGMAP.defaults, opts);
	mapConfig.markerGroups[mapConfig.hotelID]=new Array();
	mapConfig.markerGroups[mapConfig.otherHotelsID]=new Array();
	mapConfig.markerGroups[mapConfig.defaultType]=new Array();
	for (property in mapConfig.markerGroupsExt)
		mapConfig.markerGroups[property]=mapConfig.markerGroupsExt[property];
	 
	if (GBrowserIsCompatible() && (mapConfig.mapMode==1 || mapConfig.mapMode==2)) {
		mapContainerNode=document.getElementById(jQuery(this).attr('id'));
		
        map = new GMap2(mapContainerNode);
        map.addControl(new GLargeMapControl());
		if(mapConfig.enableMapType) map.addControl(new GMapTypeControl());
		if(mapConfig.extInfoWindowEnabled) linkJSOnDemand(eInfoWPath);
		if(mapConfig.geodesicsEnabled) linkJSOnDemand(geodesicJSPath);
		
		var firstMarkerToShow=null;
		mapConfig.gmapData+="&mapMode="+mapConfig.mapMode;
		
		if(mapConfig.mapMode==1) jQuery(mapContainerNode).before(MODE1_FORM);	//should only be done with mode 1
		$.getJSON(mapConfig.gmapData, 
		function(data){
					databuffer=data; // data buffer is what it says ... a buffer object for the map data
					$.each(databuffer.points, function(i, item){
					
					var tempmarker = new GMarker(new GLatLng(item.lat, item.lng),{ icon: setMarkerIcon(item.icon,mapConfig.defaultShadow), title:item.title});
					tempmarker.id=item.id;
					tempmarker.uri=item.uri;
					tempmarker.openingdate=item.opendate;
					tempmarker.category=item.type;
					tempmarker.prplink=item.proplink;
					tempmarker.thumb=item.thumb;
					tempmarker.brand=item.brand;
					tempmarker.country=item.country;
					tempmarker.countryName=item.countryName;
					tempmarker.city=item.city;
					tempmarker.address1=item.address1;
					tempmarker.zoom=item.zoom;
						
						//if(item.type==mapConfig.hotelID || item.type==mapConfig.otherHotelsID)
						GEvent.addListener(tempmarker, "click", function() {   
							customInfoWindow(tempmarker,tempmarker.getTitle(), balloonContent(tempmarker));
						});
						
						if(item.type==mapConfig.hotelID && mapConfig.mapMode==2){
							firstMarkerToShow=tempmarker;
							centerMarker=tempmarker;
						}
						
					try{	
						mapConfig.markerGroups[item.type].push(tempmarker);
					}catch(e){
						mapConfig.markerGroups[mapConfig.defaultType].push(tempmarker);
					}
					try{	
						if(mapConfig.mapMode==1){//should only be done with mode 1
							//brands
							if(!mapConfig.wmap_brands[item.brand] && item.type=='Hotel'){
								mapConfig.wmap_brands[item.brand]=new Array();
								jQuery("#wmap_brand").append(jQuery('<option></option>').val(item.brand).html(item.brand));
								}//end if brands
							if(mapConfig.wmap_brands[item.brand]) mapConfig.wmap_brands[item.brand].push(tempmarker);
							//country markers
							if(!mapConfig.wmap_countries[item.countryName] && item.type=='Country_Marker'){
								mapConfig.wmap_countries[item.countryName]=new Array();
								//jQuery.jaslog("Country "+item.countryName);
								}//end if country markers
							//city markers
							if(!mapConfig.wmap_cities[item.city] && item.type=='City_Marker'){
								mapConfig.wmap_cities[item.city]=new Array();
								if(!mapConfig.wmap_cityMarkers[item.countryName])
									mapConfig.wmap_cityMarkers[item.countryName]=new Array();
								mapConfig.wmap_cityMarkers[item.countryName].push(tempmarker);
								//jQuery.jaslog("City "+item.city);
								}//end if city markers
						}//end mode 1 if
					}catch(e){
						jQuery.jaslog("Worldmap brand pre-population error : "+e);
					}
					try{
						map.addOverlay(tempmarker);
					}
					catch(e){
						jQuery.jaslog("Worldmap map addoverlay error : "+e);
					}
					if(mapConfig.mapMode==1) 
						try{
							tempmarker.hide();
						}catch(e){
							jQuery.jaslog("Worldmap tempmarker.hide() error : "+e);
						}
					});//each
					
			//START PLUGINS

			try{
				//marker categories
				if(mapConfig.markerCatEnabled && jQuery(mapConfig.markerCatContainer) && mapConfig.mapMode!=1) initializeAttractions();
				
				if(mapConfig.mapMode==2){//should only be done with mode 2
				//initial marker to pop
				map.setCenter(centerMarker.getLatLng(), mapConfig.mapZoom);
				customInfoWindow(firstMarkerToShow,firstMarkerToShow.getTitle(), balloonContent(firstMarkerToShow));
				}
			}catch(e){ jQuery.jaslog("Basic initialization error : "+e);}	
			
			try{
				if(mapConfig.mapMode==1){//should only be done with mode 1
					map.setCenter(new GLatLng(mapConfig.wmap_initial_Lat, mapConfig.wmap_initial_Lng), mapConfig.wmap_initial_zoom);
					initializeWorldMap();
				}
			}catch(e){jQuery.jaslog("Worldmap initialization error : "+e);}	
			
			try{
			
				//run custom call back functions
				for(var i=0;i<mapConfig.setupCallBacks.length;i++)
					eval(mapConfig.setupCallBacks[i]);

			}catch(e){jQuery.jaslog("Callback functions error : "+e);}	
			
			
		});
		
		
      } // end mode 2
	  
	  if (GBrowserIsCompatible() && mapConfig.mapMode==9) {
		$('body').empty().append(MODE9_PRE).append('<div id="map"></div>').append(MODE9_SUF);
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.enableScrollWheelZoom() ;
        map.setCenter(new GLatLng(mapConfig.mode9Lat, mapConfig.mode9Lng), mapConfig.mapZoom);
        geocoder = new GClientGeocoder();
		var marker = new GMarker(new GLatLng(mapConfig.mode9Lat, mapConfig.mode9Lng));
        map.addOverlay(marker);
		GEvent.addListener(marker, "click", function() {    marker.openInfoWindowHtml("Singapore");  });
		marker.openInfoWindowHtml("Singapore");
		GEvent.addListener(map, "drag", function() {$.jaslog("<b>Map Center Coordinates(Lat,Lng):</b> "+map.getCenter()+" <br /><b>Zoom:</b> "+map.getZoom(),false,'log');});
		GEvent.addListener(map, "zoom", function() {$.jaslog("<b>Map Center Coordinates(Lat,Lng):</b> "+map.getCenter()+" <br /><b>Zoom:</b> "+map.getZoom(),false,'log');});
		GEvent.addListener(map, "move", function() {$.jaslog("<b>Map Center Coordinates(Lat,Lng):</b> "+map.getCenter()+" <br /><b>Zoom:</b> "+map.getZoom(),false,'log');});
		  
	  } // end mode 9
	  
	});//end this.eq(0)
}

function wmap_reset(dontResetBrandDDL){
	closeCustomInfo(); 
	map.setCenter(new GLatLng(mapConfig.wmap_initial_Lat, mapConfig.wmap_initial_Lng), mapConfig.wmap_initial_zoom);
	hideGroup(mapConfig.markerGroups,"City_Marker");
	hideGroup(mapConfig.markerGroups,"Country_Marker");
	hideGroup(mapConfig.markerGroups,"Hotel");
	wmap_updateCountryCityDLL(mapConfig.wmap_brands,mapConfig.wmap_countries,mapConfig.wmap_cities,null,null);
	if(!dontResetBrandDDL) jQuery("#wmap_brand option").eq(0).attr('selected', true);
}// end wmap_reset

function initializeWorldMap(){
	wmap_updateCountryCityDLL(mapConfig.wmap_brands,mapConfig.wmap_countries,mapConfig.wmap_cities,null,null,null);
	hideGroup(mapConfig.markerGroups,"Country_Marker");
	
	
	//set handler for brand DDL
	jQuery("#wmap_brand").change(function(){
		var dontResetBrandDDL=true;
		
		var brandValue=this.value;
		var countryValue=null;
		var cityValue=null;
						
		wmap_updateCountryCityDLL(mapConfig.wmap_brands,mapConfig.wmap_countries,mapConfig.wmap_cities,brandValue,null,null);
		if(mapConfig.wmap_onChangeEnabled) {wmap_reset(dontResetBrandDDL); wmap_zoomAndShowMarkers(); }
	}); // end jQuery("#wmap_brand") change handler
	
	//set handler for country DDL
	jQuery("#wmap_country").change(function(){
		var brandValue=jQuery("#wmap_brand option:selected").attr('value');
		var countryValue=this.value;
		var cityValue=null;
		wmap_updateCountryCityDLL(mapConfig.wmap_brands,mapConfig.wmap_countries,mapConfig.wmap_cities,brandValue,countryValue,null);
		//jQuery.jaslog(brandValue+" : "+countryValue+" : ");
		if(mapConfig.wmap_onChangeEnabled) wmap_zoomAndShowMarkers();
		}); // end jQuery("#wmap_country") change handler
	
	
	//set handler for city DDL
	jQuery("#wmap_city").change(function(){
		var brandValue=jQuery("#wmap_brand option:selected").attr('value');
		var countryValue=this.value.split("|")[1];
		var cityValue=this.value.split("|")[0];
		var DDLval=this.value;
		//jQuery.jaslog(brandValue+" : "+countryValue+" : "+cityValue);
		wmap_updateCountryCityDLL(mapConfig.wmap_brands,mapConfig.wmap_countries,mapConfig.wmap_cities,brandValue,countryValue,cityValue);
		jQuery("#wmap_country option[value="+countryValue+"]").attr('selected', true);
		jQuery("#wmap_city option[value="+DDLval+"]").attr('selected', true);
		if(mapConfig.wmap_onChangeEnabled) wmap_zoomAndShowMarkers();
		}); // end jQuery("#wmap_city") change handler
	//set handler for Go DDL
	if(!mapConfig.wmap_onChangeEnabled){
		jQuery("#wmap_go").click(function(){
			wmap_zoomAndShowMarkers();
		});
		
		jQuery("#wmap_reset").click(function(){
		wmap_reset();
		});
	}
	else{
		jQuery("#wmap_go_ct").hide();
		jQuery("#wmap_reset_ct").hide();
	}
	
}// end initializeWorldMap

function countryCityZoom(arrObj, strCC, isCountry, isCity){
	var zoom=null;
	
	for(var i=0; i<arrObj.length; i++){
		if(isCountry && arrObj[i].countryName==strCC) zoom=arrObj[i];
		if(isCity && arrObj[i].city==strCC) zoom=arrObj[i];
	}
	return zoom;
}// end countryCityZoom

function wmap_zoomAndShowMarkers(){

	var brandDDLval=jQuery("#wmap_brand").val();
	var countryDDLval=jQuery("#wmap_country").val();
	var cityDDLval=jQuery("#wmap_city").val().split('|')[0];
	var mapcenter=null;
	var markerArry=mapConfig.markerGroups["Hotel"];
	
	if(brandDDLval) markerArry=mapConfig.wmap_brands[brandDDLval];
	closeCustomInfo(); 
	hideGroup(mapConfig.markerGroups,"Hotel");
	
	for(var i=0; i<markerArry.length; i++){
			var exam=true;
			if(brandDDLval && markerArry[i].brand!=brandDDLval) exam=false;
			if(countryDDLval && markerArry[i].countryName!=countryDDLval) exam=false;
			if(cityDDLval && markerArry[i].city !=cityDDLval) exam=false;
			if(!brandDDLval && !countryDDLval && !cityDDLval) exam=false;
			if(exam)markerArry[i].show();
	}// for

	if(countryDDLval){
		var zoomTarget=null;
		if(cityDDLval) 	//country city
			zoomTarget=countryCityZoom(mapConfig.markerGroups["City_Marker"],cityDDLval,false, true);
		else			// country only
			zoomTarget=countryCityZoom(mapConfig.markerGroups["Country_Marker"],countryDDLval, true);
		map.setCenter(zoomTarget.getLatLng(),parseInt(zoomTarget.zoom));
		

	}
	else{map.setCenter(new GLatLng(mapConfig.wmap_initial_Lat, mapConfig.wmap_initial_Lng), mapConfig.wmap_initial_zoom);}

} //end wmap_zoomAndShowMarkers

function wmap_showMarkers(brand, country, city){
	hideGroup(mapConfig.markerGroups,"Country_Marker");	
	for(var i=0;i<countryDDLBuff.length;i++) 
		for(var j=0; j<mapConfig.markerGroups["Country_Marker"].length;j++)
			if(countryDDLBuff[i]==mapConfig.markerGroups["Country_Marker"][j].countryName)
				mapConfig.markerGroups["Country_Marker"][j].show();
	
}//end wmap_showMarkers

function wmap_updateCountryCityDDL_byBrand(brandArray,countryBuff,cityBuff,brand,country,city){
	for(var i=0;i <brandArray.length;i++){
		if(countryBuff[brandArray[i].countryName]&&cityBuff[brandArray[i].city]){
			countryDDLBuff.push(brandArray[i].countryName);
			countryBuff[brandArray[i].countryName].push(brandArray[i]);
			if(country){
				if(brandArray[i].countryName==country){
					cityDDLBuff.push(brandArray[i].city+"|"+brandArray[i].countryName);
					cityBuff[brandArray[i].city].push(brandArray[i]);
					}
			}
			else{
				cityDDLBuff.push(brandArray[i].city+"|"+brandArray[i].countryName);
				cityBuff[brandArray[i].city].push(brandArray[i]);
			}
		}//end if
	}//end for
}// end wmap_updateCountryCityDDL_byBrand

function wmap_updateCountryCityDLL(brandObj,countryBuff,cityBuff,brand,country,city){
	var Country_DDLID="wmap_country";
	var City_DDLID="wmap_city";
	
	//clear the buffers
	countryDDLBuff=[];cityDDLBuff=[];
	for (property in countryBuff) countryBuff[property]=[];
	for (property in cityBuff) cityBuff[property]=[];
	
	
	if(brand != null && brand !=""){ // if brand ddl is selected
		wmap_updateCountryCityDDL_byBrand(brandObj[brand],countryBuff,cityBuff,brand,country,city);
	}
	else{
		for (property in brandObj) wmap_updateCountryCityDDL_byBrand(brandObj[property],countryBuff,cityBuff,property,country,city);
	}//mapConfig.wmap_brands
	
	countryDDLBuff=jQuery.uniqueStrArray(countryDDLBuff,true);
	cityDDLBuff=jQuery.uniqueStrArray(cityDDLBuff,true);
	
	//render the DDLs
	if(!country){
	jQuery("#"+Country_DDLID).empty();
	jQuery("#"+Country_DDLID).append(jQuery('<option></option>').val("").html("- All Countries -"));
	for(var i=0;i<countryDDLBuff.length;i++) 
		jQuery("#"+Country_DDLID).append(jQuery('<option></option>').val(countryDDLBuff[i]).html(countryDDLBuff[i]));
	}
		
	jQuery("#"+City_DDLID).empty();
	jQuery("#"+City_DDLID).append(jQuery('<option></option>').val("").html("- All Cities -"));
	for(var i=0;i<cityDDLBuff.length;i++) 
		jQuery("#"+City_DDLID).append(jQuery('<option></option>').val(cityDDLBuff[i]).html(cityDDLBuff[i].split("|")[0]));
}// end wmap_updateCountryCityDLL


jQuery.fn.jasmineGMAP.defaults = {
	
	//GENERAL
	gmapData:"", 
	autoInit:false,
	mapMode:2, // 0 demo mode, 1 world map mode, 2 property mode, 9 finder mode
	
	hotelCatLabel:"Hotel",
	hotelID:"Hotel",
	otherCatLabel:"Other Hotels",
	otherHotelsID:"Other Hotels",
	defaultType:"Others",
	
	markerGroups:{},
	markerGroupsExt:{},
	setupCallBacks:[], 
	
	//controls
	enableMapType:false,
	
	// marker settings
	defaultShadow:"/common/components_jsp/googlemap/images/shadow.png", 
	anchorSizeX:16,
	anchorSizeY:16,
	markerSizeX:32,
	markerSizeY:32,
	infoWanchorSizeX:16,
	infoWanchorSizeY:0,
	shadowX:59,
	shadowY:32,
	
	//plugin configs
	geodesicsEnabled:false,
	extInfoWindowEnabled:true,
	
	includeHotel: true,
	markerCatContainer:null,
	markerCatEnabled:true,
	
	//extInfoWindow configs
	balloonLinkMode: 0, // 1 = links pop-ups new window, 0 = respective window;
	useBalloonImg:true,
	
	propLink:"Go to Property",
	balloonImgProp:'/application/images/googlemap/gotoProperty.gif',
	
	defaultLink:"Website",
	balloonImg:'/application/images/googlemap/gotoWebsite.gif',
	
	//zoom configs
	mapZoom:14,
	centerOnMarker: true,
	centerOnMarkerZoom: 14,
	
	mode9Lat:1.2846712,
	mode9Lng:103.8444227,
	
	//world map controls
	wmap_initial_zoom:2,
	wmap_initial_Lat:33.7243396617476,
	wmap_initial_Lng:71.015625,
	wmap_initial_zoom_city:10,
	wmap_brands:[],
	wmap_countries:[],wmap_cities:[],
	wmap_cityMarkers:[],
	wmap_ddlContainer:null,
	wmap_chkContainer:null,
	wmap_brandFilterMode:1, //0-check box, 1-DDL
	wmap_onChangeEnabled:false
	
}//end jQuery.fn.jasmineGMAP.defaults


