// Copyright 11 November 2008, Cavalry Outpost Publications

// This program:
//      1.0 reads and assigns the host url (site) to a variable

//      2.0 self inhibits operation when the hostg URL (site) employs
//      other GoogleMap API features that may cause conflicts in operation.

//      3.0 enables a property of the GoogleMap AJAX API Loader,
//      "grt-location IP" to obtain the Internet Provider address (city and
//      region) of the viewer.

// *********************************************************************
// **********     Program Name = LocateIP.js Rev 08.11.11     **********
// *********************************************************************

// 1.0 READ & ASSIGN HOST URL
var HREFpage = window.location.href;    // return URL of the host site
// document.write(HREFpage);            // remove comment lines to print document.referrer

// 2.0 INHIBIT IP Location if using URL employs conflicting API features
if (HREFpage) {
        if ((HREFpage != "[unknown origin]") &&
           (HREFpage.substring(0, 29) != "http://first-team.us/spurride") &&
           (HREFpage.substring(0, 33) != "http://www.first-team.us/spurride") &&
           (HREFpage.substring(0, 40) != "http://first-team.us/spurride/index.html") &&
           (HREFpage.substring(0, 44) != "http://www.first-team.us/spurride/index.html")) {

// 3.0 WRITE IP LOCATION (if not one of the designated subStrings above)
                document.write('<B>Your IP is in ');
                if (typeof(google.loader.ClientLocation.address.city) != null) {
                        document.write(google.loader.ClientLocation.address.city
                      + ', '
                      + google.loader.ClientLocation.address.region +'</B>');
                } else  {
                        document.write('an "Unknown" location.</B>');
                } 
        } else  {
                document.write('<B>Your IP is in an "Unknown" location.</B>');
        }
}

