google.load("maps", "2.x"); google.setOnLoadCallback(function() { Array.prototype.inArray = function (value) { // Returns true if the passed value is found in the // array. Returns false if it is not. var i; for (i=0; i < this.length; i++) { if (this[i] == value) { return true; } } return false; }; if(google.loader.ClientLocation) { var permittedCountries = []; //defines a new array which contains the countries which are permitted //to view this site var permittedCountries = ["CA", "US", "UM"]; //The ISO code of the countries permitted see http://www.iso.org/iso/iso-3166-1_decoding_table //for ISO definitions var cl = google.loader.ClientLocation; geo_location = [cl.address.country_code]; //alert(geo_location); //document.getElementById('loc').innerHTML = geo_location; //} if(!permittedCountries.inArray(geo_location)) { document.getElementById('location_message').style.display = 'block'; } } ); function hideLocationMessage() { document.getElementById('location_message').style.display = 'none'; }