﻿function InvokePop()
{
      
        window.open("location_finder.html","Location_finder","height=800,width=910,resizable=yes,modal=yes");
     
}

function load() 
{
    pcSetLocation.Show();
    if (GBrowserIsCompatible()) 
    {
        var map = new GMap2(document.getElementById("map"));
        map.addControl (new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        var latitude= txtLatitude.GetText();
        var longitude= txtLongitude.GetText();
        var center = '';
        if((latitude != '') && (longitude != ''))
        {
            center = new GLatLng(latitude,longitude);
        }
        else
        {
            center = new GLatLng(25.2859898968053,51.5068244934082);
        }
        map.setCenter(center, 11);
        //map.setMapType(G_SATELLITE_MAP);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {draggable: true}); 
        map.addOverlay(marker);
        txtPopupLatitude.SetText(center.lat());
        txtPopupLongitude.SetText(center.lng ());
        geocoder = new GClientGeocoder();
        GEvent.addListener
        (
            marker, "dragend", function() 
            {
                var point =marker.getPoint();
                map.panTo(point);
                txtPopupLatitude.SetText(point.lat());
                txtPopupLongitude.SetText(point.lng());
            }
        );

        GEvent.addListener
        (
            map, "moveend", function() 
            {
                map.clearOverlays();
                var center = map.getCenter();
                var marker = new GMarker(center, {draggable: true});
                map.addOverlay(marker);
                txtPopupLatitude.SetText(center.lat());
                txtPopupLongitude.SetText(center.lng());
                GEvent.addListener
                (
                    marker, "dragend", function() 
                    {
                        var point =marker.getPoint();
                        map.panTo(point);
                        txtPopupLatitude.SetText(point.lat());
                        txtPopupLongitude.SetText(point.lng());
                    }
                );
            }
        );
    }
}


function showAddress(address) 
{
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    if (geocoder) 
    {
            geocoder.getLatLng 
            (
                address, function(point) 
                {
                    if (!point) 
                    {
                        alert(address + " city not found !");
                    }
                    else 
                    {
                        txtPopupLatitude.SetText(point.lat());
                        txtPopupLongitude.SetText(point.lng());
                        map.clearOverlays()
                        map.setCenter(point, 14);
                        var marker = new GMarker(point, {draggable: true}); 
                        map.addOverlay(marker);
                        GEvent.addListener
                        (
                            marker, "dragend", function() 
                            {
                                var pt =marker.getPoint();
                                map.panTo(pt);
                                txtPopupLatitude.SetText(pt.lat());
                                txtPopupLongitude.SetText(pt.lng());
                            }
                        );

                        GEvent.addListener(map, "moveend", function() 
                        {
                            map.clearOverlays();
                            var center = map.getCenter();
                            var marker = new GMarker(center, {draggable: true});
                            map.addOverlay(marker);
                            txtPopupLatitude.SetText(center.lat());
                            txtPopupLongitude.SetText(center.lng());

                            GEvent.addListener
                            (
                                marker, "dragend", function() 
                                {
                                    var pt =marker.getPoint();
                                    map.panTo(pt);
                                    txtPopupLatitude.SetText(pt.lat());
                                    txtPopupLongitude.SetText(pt.lng());
                                }
                            );
                        }
                    );
                }
            }
        );
    }
}

function GetSelected(latitude)
{
    txtLatitude.SetText(txtPopupLatitude.GetText());
    txtLongitude.SetText(txtPopupLongitude.GetText());
    pcSetLocation.Hide();
}


function myLogin() 
{
    var username = document.getElementById("ctl00$loginControl$txtusername").value;
    var password= document.getElementById("ctl00$loginControl$txtpassword").value;
    
    if (username=='')
    {
        alert('Enter Username');
        //document.getElementById("ctl00$loginControl$txtUserName").focus();
        return false;
    }
    if (password=='')
    {
        alert('Enter Password');
        //document.getElementById("ctl00$loginControl$txtPassword").focus();
        return false;
    }
    //PageMethods.LoginControl.GetLogin(username,password,myLogin_callback);
    //myLogin_callback('Succeed')
}

function confirmation() 
{
    var cnf = confirm('Are you sure ?');
    if(!cnf)
    {
        return false;
    }
}
function ChangeContent()
{
var tabcontrol=document.getElementById ('result_box');
   if(tabcontrol.innerHTML=="English")
      {
      document.getElementById ('arabiccontent').style .display ='none';
      document.getElementById ('englishcontent').style .display ='block';
      tabcontrol.innerHTML="العربية";
      }
      else
      {
      document.getElementById ('arabiccontent').style .display ='block';
      document.getElementById ('englishcontent').style .display ='none';
      tabcontrol.innerHTML="English"
      }
      void(0);
}
function SetPoint()
{
   if (GBrowserIsCompatible()) 
    {
        var map = new GMap2(document.getElementById("map"));
        map.addControl (new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        var latitude= txtPopupLatitude.GetText();
        var longitude= txtPopupLongitude.GetText();
        var center = '';
        if(isNaN(latitude) || isNaN(longitude))
        {
        alert("Only numbers are allowed");
        center = new GLatLng(25.2859898968053,51.5068244934082);
        txtPopupLatitude.SetText('25.2859898968053');
        txtPopupLongitude.SetText('51.5068244934082');
        }
        else if((latitude != '') && (longitude != ''))
        {
          center = new GLatLng(latitude,longitude);
        }
        else
        {
            center = new GLatLng(25.2859898968053,51.5068244934082);
        }
        map.setCenter(center, 11);
        geocoder = new GClientGeocoder();
        var marker = new GMarker(center, {draggable: true}); 
        map.addOverlay(marker);
        geocoder = new GClientGeocoder();
        GEvent.addListener(marker, "dragend", function(){var point =marker.getPoint(); map.panTo(point); txtPopupLatitude.SetText(point.lat());txtPopupLongitude.SetText(point.lng());});
        GEvent.addListener(map, "moveend", function(){map.clearOverlays();var center = map.getCenter();var marker = new GMarker(center, {draggable: true});
        map.addOverlay(marker);
        txtPopupLatitude.SetText(center.lat());
        txtPopupLongitude.SetText(center.lng());
        GEvent.addListener(marker, "dragend", function(){var point =marker.getPoint();map.panTo(point);txtPopupLatitude.SetText(point.lat());txtPopupLongitude.SetText(point.lng());});});
    }
 }

 
