﻿
 


var map1;
 
 var markers ;
  var markersPS ;

 var markersHL ;

 var markersST ;
  var markersSU ;


 var zoomlevel=0;
 var lsIsAmmTick=false;
 
 
    var arr1;
     var arr2;
  function loadcenter(center)
{ 
try
{
if(map1!==null)
{
if(arr1!=null && arr2!=null)
{
if(arr1!="" && arr2!="")
{
var flag;
flag=0;

var point=new GLatLng(arr1[center],arr2[center]);
var j;
for(j=0;j<markers.length;j++)
{
var g=markers[j].getPoint();
if(g.x==arr2[center]&& g.y==arr1[center]&& center==j)
{
if(flag==0)
{
var m=markers[j];
m.Image = "/hm/img/big_property_img.png"; 

m.setImage(m.Image);
//alert(m.Image == "/hm/img/big_property_img.png");
//m.getIcon().image = "/hm/img/big_property_img.png";  

//m.setImage("/hm/img/bullet_check_box2.png");

flag=1;
}
}
else
{
var m=markers[j];
m.setImage("/hm/img/property_img.png");

}
}



map1.panTo(point);


}
}
}
}
catch(exception)
            {
            }
}
//functions added by chetan
//end added function
var CentreLatLong;
function GetProperty(center)
{

var propTool= document.getElementById("ctl00_cph_hfProptool").value;
    var locPrimTool= document.getElementById("ctl00_cph_hfPrimtool").value;
    var locStatTool= document.getElementById("ctl00_cph_hfStattool").value;
    var locSupTool= document.getElementById("ctl00_cph_hfSuptool").value;
    var locHospTool= document.getElementById("ctl00_cph_hfHosptool").value;
   
     var val1= document.getElementById("ctl00_cph_hLat").value;
     var val2= document.getElementById("ctl00_cph_hLon").value;
     var valPrimLat= document.getElementById("ctl00_cph_hPrimLat").value;
     var valPrimLon= document.getElementById("ctl00_cph_hPrimLon").value;
      var valStatLat= document.getElementById("ctl00_cph_hStationsLat").value;
     var valStatLon= document.getElementById("ctl00_cph_hStationsLon").value;
     var valSecLat= document.getElementById("ctl00_cph_hSecLat").value;
     var valSecLon= document.getElementById("ctl00_cph_hSecLon").value;
     var valHospLat= document.getElementById("ctl00_cph_hHospLat").value;
     var valHospLon= document.getElementById("ctl00_cph_hHospLon").value;
var lsUrlBig="";
 markers= new Array();

ispropDetails=false;
//map_tr = set div to show map in tht div.
   if(document.getElementById("map_tr"))
          map1 = new GMap2(document.getElementById("map_tr"));
   else if(document.getElementById("map_lr"))       
          map1 = new GMap2(document.getElementById("map_lr"));
   else if (document.getElementById("map_bd"))       
          map1 = new GMap2(document.getElementById("map_bd"));
   else if(document.getElementById("map"))
   {
          map1 = new GMap2(document.getElementById("map"));
          ispropDetails=true;
    }
   else 
          map1 = new GMap2(document.getElementById("map_tr"));       
          
          
          
                 
            map1.addControl(new GSmallMapControl());

           
     var lsUrl = "/hm/img/property_img.png";
       //map1.clearMarkers(); 
           var arrProptool=propTool.split('#|xxx|#');
       //arra and arr2 is array of lat and long .
       if(val1!="" && val2!="")
       {
             arr1 = val1.split(',');
             arr2=val2.split(',');
          if(arr1.length!=0 && arr2.length!=0)
          {
                
                 map1.setCenter(new GLatLng(arr1[center],arr2[center]), 13);
                //13 is zooming factor
           
           
                var icon1 = new GIcon();
                icon1.image = lsUrl;
            
//              var point = new GLatLng(arr1[0],arr2[0]);
//              icon.iconAnchor = new GPoint(10,15);
//              map1.addOverlay(new GMarker(point,icon));
         
                var i;
             
                //to get all info for property marker
                for(i=0;i<arr1.length;i++)
                {
                    if(arr1[i] != 0 && arr2[i] !=0)
                    {
                        var point1 = new GLatLng(arr1[i],arr2[i]);
                        icon1.iconAnchor = new GPoint(10, 15);
                        if((i==center) )
                        {
                            var iconbig = new GIcon();
                            lsUrlBig+="/hm/img/big_property_img.png";
                            iconbig.image = lsUrlBig;
                            iconbig.iconAnchor = new GPoint(10, 15);
                            markerOptions = { icon:iconbig, title:arrProptool[i]};
                        }
                        else
                        {
                            markerOptions = { icon:icon1, title:arrProptool[i]};
                        }
                        //to create marker 
                        var marker = new GMarker(point1, markerOptions);
                        //to add marker to map   
                        map1.addOverlay(marker);
                        markers.push(marker)   
                    }
                }
           
            }   
        }
}
function load_x(center)
{ 



var pointCenter;
if(map1!=null)
{
 
 pointCenter = map1.getCenter();
   map1.clearOverlays(); 
   zoomlevel=map1.getZoom();

}
if(center != null)
{
    CentreLatLong= center;
}
//center=to set property at centre
   try
   {
  
    var propTool= document.getElementById("ctl00_cph_hfProptool").value;
    var locPrimTool= document.getElementById("ctl00_cph_hfPrimtool").value;
    var locStatTool= document.getElementById("ctl00_cph_hfStattool").value;
    var locSupTool= document.getElementById("ctl00_cph_hfSuptool").value;
    var locHospTool= document.getElementById("ctl00_cph_hfHosptool").value;
   
     var val1= document.getElementById("ctl00_cph_hLat").value;
     var val2= document.getElementById("ctl00_cph_hLon").value;
     var valPrimLat= document.getElementById("ctl00_cph_hPrimLat").value;
     var valPrimLon= document.getElementById("ctl00_cph_hPrimLon").value;
      var valStatLat= document.getElementById("ctl00_cph_hStationsLat").value;
     var valStatLon= document.getElementById("ctl00_cph_hStationsLon").value;
     var valSecLat= document.getElementById("ctl00_cph_hSecLat").value;
     var valSecLon= document.getElementById("ctl00_cph_hSecLon").value;
     var valHospLat= document.getElementById("ctl00_cph_hHospLat").value;
     var valHospLon= document.getElementById("ctl00_cph_hHospLon").value;
var lsUrlBig="";
if(map1==null)
{ 


GetProperty(center)
                          } 
                          
                          else
                          {
                          
                        
                          GetProperty(CentreLatLong)
                          
                          
                          
                          
//                          var cnt;
//                          cnt=0;
//                            if(markersPS!=null)
//                            {
//                          for(cnt=0;cnt<markersPS.length;cnt++)
//                          {
//                          var m=markersPS[cnt];
//                          map1.removeOverlay(m);
//                          
//                          }
//                          markersPS=null;
//                          }
//                            if(markersST!=null)
//                            {
//                          for(cnt=0;cnt<markersST.length;cnt++)
//                          {
//                          var m=markersST[cnt];
//                          map1.removeOverlay(m);
//                          }
//                          markersST=null;
//                          }
//                            if(markersHL!=null)
//                            {
//                          for(cnt=0;cnt<markersHL.length;cnt++)
//                          {var m=markersHL[cnt];
//                          map1.removeOverlay(m);
//                          }
//                          markersHL=null;
//                          }
//                            if(markersSU!=null)
//                            {
//                          for(cnt=0;cnt<markersSU.length;cnt++)
//                          {
//                          var m=markersSU[cnt];
//                          map1.removeOverlay(m);
//                          }
//                          markersSU=null;
//                          }
//                          
//                          
//                          
                       }          
 
 
// alert(document.getElementById("ChkSC").checked);
// alert(document.getElementById("ChkSt").checked);
// alert(document.getElementById("ChkSM").checked);
// alert(document.getElementById("ChkSC").checked);

 
 
 
 if(document.getElementById("ChkSC").checked)
 {
 //lsIsAmmTick=true;
 var arrloctool=locPrimTool.split('#|yyy|#');
          if(valPrimLat!="" && valPrimLon!="")
          {  markersPS=new Array();

          var arrPrimLat=valPrimLat.split(',');
          var arrPrimLon=valPrimLon.split(',');
          var j;
           
           var   lsUrlPrim = "/hm/img/bullet_check_box2.png";
                
              var iconPrim = new GIcon();
             iconPrim.image = lsUrlPrim;
          for(j=0;j<arrPrimLon.length;j++)
          {
          
             var pointPrim = new GLatLng(arrPrimLat[j],arrPrimLon[j]);
              iconPrim.iconAnchor = new GPoint(10, 15);
             markerOptions = { icon:iconPrim, title:arrloctool[j]};
              var MarkPS=new GMarker(pointPrim,markerOptions);
              map1.addOverlay(MarkPS);
              markersPS.push(MarkPS);
          }
          }
          
 }
 
 if(document.getElementById("ChkSt").checked )
 {     
 //lsIsAmmTick=true;   
              arrloctool=locStatTool.split('#|yyy|#');
          if(valStatLat!="" && valStatLon!="")
          {  markersST=new Array();

          var ArrStatLat=valStatLat.split(',');
          var ArrStatLon=valStatLon.split(',');
          var j;
           
           var lsUrlStat = "/hm/img/bullet_check_box.png";
                
              var iconStat = new GIcon();
             iconStat.image = lsUrlStat;
          for(j=0;j<ArrStatLat.length;j++)
          {
          
             var pointStat = new GLatLng(ArrStatLat[j],ArrStatLon[j]);
              iconStat.iconAnchor = new GPoint(10, 15);
               markerOptions = { icon:iconStat, title:arrloctool[j]};
                  var MarkST=new GMarker(pointStat,markerOptions);
              map1.addOverlay(MarkST);
               markersST.push(MarkST);
          }
          }
  }
  if(document.getElementById("ChkSM").checked )
  {
        
     //   lsIsAmmTick=true;  
             arrloctool=locSupTool.split('#|yyy|#');
          if(valSecLat!="" && valSecLon!="")
          {  markersSU=new Array();

          var ArrSecLat=valSecLat.split(',');
          var ArrSecLon=valSecLon.split(',');
          var j;
           
         var    lsUrlSec = "/hm/img/bullet_check_box3.png";
                
              var iconSec = new GIcon();
             iconSec.image = lsUrlSec;
          for(j=0;j<ArrSecLat.length;j++)
          {
          
             var pointSec = new GLatLng(ArrSecLat[j],ArrSecLon[j]);
              iconSec.iconAnchor = new GPoint(10, 15);
              markerOptions = { icon:iconSec, title:arrloctool[j]};
              map1.addOverlay(new GMarker(pointSec,markerOptions));
              
                var MarkSU=new GMarker(pointSec,markerOptions);
              map1.addOverlay(MarkSU);
        
               markersSU.push(MarkSU);
          }
          }
  }
  if(document.getElementById("ChkHL").checked )
  {
  //lsIsAmmTick=true;
             arrloctool=locHospTool.split('#|yyy|#');
           if(valHospLat !="" && valHospLon !="")
          {  markersHL=new Array();

          var ArrHospLat=valHospLat.split(',');
          var ArrHospLon=valHospLon.split(',');
          var j;
           
        var   lsUrlHosp = "/hm/img/bullet_check_box4.png";
                
              var iconHosp = new GIcon();
             iconHosp.image = lsUrlHosp;
          for(j=0;j<ArrHospLat.length;j++)
          {
             var pointHosp = new GLatLng(ArrHospLat[j],ArrHospLon[j]);
              iconHosp.iconAnchor = new GPoint(10, 15);
              markerOptions = { icon:iconHosp, title:arrloctool[j]};
              
               var MarkHL=new GMarker(pointHosp,markerOptions);
              map1.addOverlay(MarkHL);
        
               markersHL.push(MarkHL);
         
          }
          }
   }  
        //added by Firdose 14 july
    
         var bounds = new GLatLngBounds;
         var x;
  for (x=0; x<markers.length; x++)
   {
    bounds.extend(markers[x].getPoint());
  }
if(lsIsAmmTick != true)
{
    map1.setZoom(map1.getBoundsZoomLevel(bounds)-1);   
    lsIsAmmTick=true; 
   // alert("in if");
    if(ispropDetails == true)
      map1.setZoom(eval(map1.getZoom() - 2)); 
 }
 else
 {
   if(zoomlevel != 0)
    map1.setZoom(zoomlevel);     
   // alert("in fun");
   //   alert("in else");
 }
// if(lsIsAmmTick != true)
// {
//  alert("in fun");
//    
// }
// alert("cc___"+ map1.getZoom())
// alert(zoomlevel)
 

 map1.setCenter(bounds.getCenter());
 if(pointCenter!=null)
 {
 map1.setCenter(pointCenter);
 }
 
 

       //ended
       
       
        }
           catch(exception)
            {
            }
}


// function EndRequestHandler(sender, args)

//                 {
//                 try
//                 {
//                 var c;
//                 for(c=0;c<sender._panelsToRefreshIDs.length;c++)
//                 {
//                  if(sender._panelsToRefreshIDs[c]=='ctl00$cph$up3')
//                  {
//                   load(0);
//                  }
//				
//                 }
//                 }
//                  catch(exception)
//            {
//            }
//                 }




           





