// global variables for my functions
var map;
var x;
var y;
var zoom;

var baseIcon = new GIcon();
    baseIcon.iconSize=new GSize(26,26);
    baseIcon.shadowSize=new GSize(46,26);
    baseIcon.iconAnchor=new GPoint(16,26);
    baseIcon.infoWindowAnchor=new GPoint(16,0);
      
var smallIcon = new GIcon();
// property search (building icon)
    smallIcon.iconSize=new GSize(58,36);
    smallIcon.shadowSize=new GSize(56,36);
     smallIcon.iconAnchor=new GPoint(15,30);  
    smallIcon.infoWindowAnchor=new GPoint(30,5);      

      
var ZPNIcon = new GIcon();
// KK 
    ZPNIcon.iconSize=new GSize(39,34);
    ZPNIcon.shadowSize=new GSize(39,29);
    ZPNIcon.iconAnchor=new GPoint(10,29);    
    ZPNIcon.infoWindowAnchor=new GPoint(20,0);      

var ZPNIcon2 = new GIcon();
    ZPNIcon2.iconSize=new GSize(47,36);
    ZPNIcon2.shadowSize=new GSize(46,36);
    ZPNIcon2.iconAnchor=new GPoint(23,31);    
    ZPNIcon2.infoWindowAnchor=new GPoint(30,5);      

var ZPNIcon3 = new GIcon();
    ZPNIcon3.iconSize=new GSize(53,36);
    ZPNIcon3.shadowSize=new GSize(53,36);
    ZPNIcon3.iconAnchor=new GPoint(18,34);    
    ZPNIcon3.infoWindowAnchor=new GPoint(30,5);      


var icons=[];
      icons["nonclient"] = new GIcon(G_DEFAULT_ICON, "/images/mappins/colour086.png", null);
      icons["community"] = new GIcon(ZPNIcon2, "/images/mappins/community.png", null, "/images/mappins/community_shadow.png");    // Z marker for communities
      icons["community1"] = new GIcon(ZPNIcon3, "/images/mappins/community1.png", null, "/images/mappins/shadow.png");    // red marker for communities
      icons["community2"] = new GIcon(ZPNIcon3, "/images/mappins/community2.png", null, "/images/mappins/shadow.png");    // orange marker for communities            
      icons["community3"] = new GIcon(ZPNIcon3, "/images/mappins/community3.png", null, "/images/mappins/shadow.png");    // yellow marker for communities            
      icons["community4"] = new GIcon(ZPNIcon3, "/images/mappins/community4.png", null, "/images/mappins/shadow.png");    // yellow marker for communities     
      icons["community5"] = new GIcon(ZPNIcon3, "/images/mappins/community5.png", null, "/images/mappins/shadow.png");    // yellow marker for communities     
      icons["community6"] = new GIcon(ZPNIcon3, "/images/mappins/community6.png", null, "/images/mappins/shadow.png");    // yellow marker for communities     
      icons["community7"] = new GIcon(ZPNIcon3, "/images/mappins/community7.png", null, "/images/mappins/shadow.png");    // yellow marker for communities     
      icons["property"] =  new GIcon(smallIcon, "/images/mappins/property.png", null, "/images/mappins/property_shadow.png");     // building marker for properties

      
// Common values for the ReadyState of the XMLHttpRequest object /*/
var READYSTATE_UNINITIALIZED = 0;
var READYSTATE_LOADING = 1;
var READYSTATE_LOADED = 2;
var READYSTATE_INTERACTIVE = 3;
var READYSTATE_COMPLETE = 4;
var HTTPSTATUS_OK = 200;

/////////// GENERIC FUNCTIONs to create a marker and center map. Send the point and some text
function createMarker(point, text, strname, type) 
{ 
    var marker = new GMarker(point,icons[type]);  

    GEvent.addListener(marker, "click", function() 
    {    
     marker.openInfoWindowHtml("<b>" + text + "</b>");
    });  

    // Change marker on mouseover. marker image names are same as type so I can change marker to correct image for proerties and communities.

    GEvent.addListener(marker, "mouseover", function() 
    {    
     marker.openInfoWindowHtml("<b>" + strname + "</b>");
     marker.setImage("/images/mappins/" + type + "on.png");
    });

    GEvent.addListener(marker, "mouseout", function() 
    {
     marker.setImage("/images/mappins/" + type + ".png"); 
    });
      
    return marker;
}


function definecenter(y,x,zoom)
{
// Set x,y center and default zoom level.
map.setCenter(new GLatLng(y, x),zoom);
}



/////////////////////////////////// create a basic httprequest object to obtain a valid XMLHttpRequest object.
function XmlHttpObject()
{
    var xmlObj;
    if (window.ActiveXObject)
    {
        try
        {
           xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e)
        {
           xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    else
        xmlObj = new XMLHttpRequest();        
    return xmlObj;
}



//////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////