/* Ancestral Atlas search widget class To be used on third-party websites */ aaSearchWidget = function(v_affid, o_options){ ////////////////////////////////////////////// // Private properties ////////////////////////////////////////////// var v_hostname = "http://www.ancestralatlas.com/"; var affid = 0; var that = this; // Error in ECMA spec means that "this" is incorrectly set for private methods var element = null; // DOM element that contains the search form widget var wrapper = null; // DOM element that contains the above element - used to grab the innerHTML var v_uniqueid = Math.random().toString().substr(2); ////////////////////////////////////////////// // Public properties ////////////////////////////////////////////// this.affid = (v_affid || 0); this.options = { css: v_hostname + "_cinclude/searchwidget.css.php", default_country: "", default_location: "", new_window: true, logo_format: "jpg", include_link: true } ////////////////////////////////////////////// // Private methods ////////////////////////////////////////////// /* Class constructor */ var constructor = function(o_options){ // Configure options if (o_options){ if (o_options.css){that.options.css = o_options.css;} if (o_options.default_country){that.options.default_country = o_options.default_country;} if (o_options.default_location){that.options.default_location = o_options.default_location;} if (!(o_options.new_window == undefined)){that.options.new_window = o_options.new_window;} if (!(o_options.include_link == undefined)){that.options.include_link = o_options.include_link;} if (o_options.logo_format){ switch (o_options.logo_format){ case "jpg": case "png": case "gif": that.options.logo_format = o_options.logo_format; } } } // Load CSS file loadResourceFile(that.options.css, "css"); // Build form element that.wrapper = document.createElement("div"); that.element = document.createElement("div"); that.wrapper.appendChild(that.element); that.element.id = "aa-sw-" + v_uniqueid; that.element.className = "aa-sw-container"; var v_countryoptions = countryOptions(that.options.default_country); var v_newwindow = (that.options.new_window) ? ' target="_blank"': ""; var v_buffer = '' + '
\n' + '
\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n'; if (that.options.include_link){ v_buffer += '' + ' \n' + ' \n' + ' \n' } v_buffer += '' + ' \n' + '
\n' + ' Ancestral Atlas Family History Search\n' + '
Enter the location where you want to start your own Ancestral Atlas:
\n' + '
\n' + ' \n' + '
\n' + ' ' + '\n' + '
\n' + ' www.ancestralatlas.com\n' + '
\n' + '
\n' + '
\n'; that.element.innerHTML = v_buffer; } // constructor() /* Return a countries array */ var countryArray = function(){ return [ { "iso": "", "country": "-- Please Choose --" }, { "iso": "GB", "country": "United Kingdom" }, { "iso": "US", "country": "United States of America" }, { "iso": "AF", "country": "Afghanistan" }, { "iso": "AX", "country": "Aland Islands" }, { "iso": "AL", "country": "Albania" }, { "iso": "DZ", "country": "Algeria" }, { "iso": "AS", "country": "American Samoa" }, { "iso": "AD", "country": "Andorra" }, { "iso": "AO", "country": "Angola" }, { "iso": "AI", "country": "Anguilla" }, { "iso": "AQ", "country": "Antarctica" }, { "iso": "AG", "country": "Antigua and Barbuda" }, { "iso": "AR", "country": "Argentina" }, { "iso": "AM", "country": "Armenia" }, { "iso": "AW", "country": "Aruba" }, { "iso": "AU", "country": "Australia" }, { "iso": "AT", "country": "Austria" }, { "iso": "AZ", "country": "Azerbaijan" }, { "iso": "BS", "country": "Bahamas" }, { "iso": "BH", "country": "Bahrain" }, { "iso": "BD", "country": "Bangladesh" }, { "iso": "BB", "country": "Barbados" }, { "iso": "BY", "country": "Belarus" }, { "iso": "BE", "country": "Belgium" }, { "iso": "BZ", "country": "Belize" }, { "iso": "BJ", "country": "Benin" }, { "iso": "BM", "country": "Bermuda" }, { "iso": "BT", "country": "Bhutan" }, { "iso": "BO", "country": "Bolivia" }, { "iso": "BA", "country": "Bosnia and Herzegovina" }, { "iso": "BW", "country": "Botswana" }, { "iso": "BV", "country": "Bouvet Island" }, { "iso": "BR", "country": "Brazil" }, { "iso": "IO", "country": "British Indian Ocean Territory" }, { "iso": "VG", "country": "British Virgin Islands" }, { "iso": "BN", "country": "Brunei" }, { "iso": "BG", "country": "Bulgaria" }, { "iso": "BF", "country": "Burkina Faso" }, { "iso": "BI", "country": "Burundi" }, { "iso": "KH", "country": "Cambodia" }, { "iso": "CM", "country": "Cameroon" }, { "iso": "CA", "country": "Canada" }, { "iso": "CV", "country": "Cape Verde" }, { "iso": "KY", "country": "Cayman Islands" }, { "iso": "CF", "country": "Central African Republic" }, { "iso": "TD", "country": "Chad" }, { "iso": "CL", "country": "Chile" }, { "iso": "CN", "country": "China" }, { "iso": "CX", "country": "Christmas Island" }, { "iso": "CC", "country": "Cocos Islands" }, { "iso": "CO", "country": "Colombia" }, { "iso": "KM", "country": "Comoros" }, { "iso": "CK", "country": "Cook Islands" }, { "iso": "CR", "country": "Costa Rica" }, { "iso": "HR", "country": "Croatia" }, { "iso": "CU", "country": "Cuba" }, { "iso": "CY", "country": "Cyprus" }, { "iso": "CZ", "country": "Czech Republic" }, { "iso": "CD", "country": "Democratic Republic of the Congo" }, { "iso": "DK", "country": "Denmark" }, { "iso": "DJ", "country": "Djibouti" }, { "iso": "DM", "country": "Dominica" }, { "iso": "DO", "country": "Dominican Republic" }, { "iso": "TL", "country": "East Timor" }, { "iso": "EC", "country": "Ecuador" }, { "iso": "EG", "country": "Egypt" }, { "iso": "SV", "country": "El Salvador" }, { "iso": "GQ", "country": "Equatorial Guinea" }, { "iso": "ER", "country": "Eritrea" }, { "iso": "EE", "country": "Estonia" }, { "iso": "ET", "country": "Ethiopia" }, { "iso": "FK", "country": "Falkland Islands" }, { "iso": "FO", "country": "Faroe Islands" }, { "iso": "FJ", "country": "Fiji" }, { "iso": "FI", "country": "Finland" }, { "iso": "FR", "country": "France" }, { "iso": "GF", "country": "French Guiana" }, { "iso": "PF", "country": "French Polynesia" }, { "iso": "TF", "country": "French Southern Territories" }, { "iso": "GA", "country": "Gabon" }, { "iso": "GM", "country": "Gambia" }, { "iso": "GE", "country": "Georgia" }, { "iso": "DE", "country": "Germany" }, { "iso": "GH", "country": "Ghana" }, { "iso": "GI", "country": "Gibraltar" }, { "iso": "GR", "country": "Greece" }, { "iso": "GL", "country": "Greenland" }, { "iso": "GD", "country": "Grenada" }, { "iso": "GP", "country": "Guadeloupe" }, { "iso": "GU", "country": "Guam" }, { "iso": "GT", "country": "Guatemala" }, { "iso": "GG", "country": "Guernsey" }, { "iso": "GN", "country": "Guinea" }, { "iso": "GW", "country": "Guinea-Bissau" }, { "iso": "GY", "country": "Guyana" }, { "iso": "HT", "country": "Haiti" }, { "iso": "HM", "country": "Heard Island and McDonald Islands" }, { "iso": "HN", "country": "Honduras" }, { "iso": "HK", "country": "Hong Kong" }, { "iso": "HU", "country": "Hungary" }, { "iso": "IS", "country": "Iceland" }, { "iso": "IN", "country": "India" }, { "iso": "ID", "country": "Indonesia" }, { "iso": "IR", "country": "Iran" }, { "iso": "IQ", "country": "Iraq" }, { "iso": "IE", "country": "Ireland" }, { "iso": "IM", "country": "Isle of Man" }, { "iso": "IL", "country": "Israel" }, { "iso": "IT", "country": "Italy" }, { "iso": "CI", "country": "Ivory Coast" }, { "iso": "JM", "country": "Jamaica" }, { "iso": "JP", "country": "Japan" }, { "iso": "JE", "country": "Jersey" }, { "iso": "JO", "country": "Jordan" }, { "iso": "KZ", "country": "Kazakhstan" }, { "iso": "KE", "country": "Kenya" }, { "iso": "KI", "country": "Kiribati" }, { "iso": "KW", "country": "Kuwait" }, { "iso": "KG", "country": "Kyrgyzstan" }, { "iso": "LA", "country": "Laos" }, { "iso": "LV", "country": "Latvia" }, { "iso": "LB", "country": "Lebanon" }, { "iso": "LS", "country": "Lesotho" }, { "iso": "LR", "country": "Liberia" }, { "iso": "LY", "country": "Libya" }, { "iso": "LI", "country": "Liechtenstein" }, { "iso": "LT", "country": "Lithuania" }, { "iso": "LU", "country": "Luxembourg" }, { "iso": "MO", "country": "Macao" }, { "iso": "MK", "country": "Macedonia" }, { "iso": "MG", "country": "Madagascar" }, { "iso": "MW", "country": "Malawi" }, { "iso": "MY", "country": "Malaysia" }, { "iso": "MV", "country": "Maldives" }, { "iso": "ML", "country": "Mali" }, { "iso": "MT", "country": "Malta" }, { "iso": "MH", "country": "Marshall Islands" }, { "iso": "MQ", "country": "Martinique" }, { "iso": "MR", "country": "Mauritania" }, { "iso": "MU", "country": "Mauritius" }, { "iso": "YT", "country": "Mayotte" }, { "iso": "MX", "country": "Mexico" }, { "iso": "FM", "country": "Micronesia" }, { "iso": "MD", "country": "Moldova" }, { "iso": "MC", "country": "Monaco" }, { "iso": "MN", "country": "Mongolia" }, { "iso": "ME", "country": "Montenegro" }, { "iso": "MS", "country": "Montserrat" }, { "iso": "MA", "country": "Morocco" }, { "iso": "MZ", "country": "Mozambique" }, { "iso": "MM", "country": "Myanmar" }, { "iso": "NA", "country": "Namibia" }, { "iso": "NR", "country": "Nauru" }, { "iso": "NP", "country": "Nepal" }, { "iso": "NL", "country": "Netherlands" }, { "iso": "AN", "country": "Netherlands Antilles" }, { "iso": "NC", "country": "New Caledonia" }, { "iso": "NZ", "country": "New Zealand" }, { "iso": "NI", "country": "Nicaragua" }, { "iso": "NE", "country": "Niger" }, { "iso": "NG", "country": "Nigeria" }, { "iso": "NU", "country": "Niue" }, { "iso": "NF", "country": "Norfolk Island" }, { "iso": "KP", "country": "North Korea" }, { "iso": "MP", "country": "Northern Mariana Islands" }, { "iso": "NO", "country": "Norway" }, { "iso": "OM", "country": "Oman" }, { "iso": "PK", "country": "Pakistan" }, { "iso": "PW", "country": "Palau" }, { "iso": "PS", "country": "Palestinian Territory" }, { "iso": "PA", "country": "Panama" }, { "iso": "PG", "country": "Papua New Guinea" }, { "iso": "PY", "country": "Paraguay" }, { "iso": "PE", "country": "Peru" }, { "iso": "PH", "country": "Philippines" }, { "iso": "PN", "country": "Pitcairn" }, { "iso": "PL", "country": "Poland" }, { "iso": "PT", "country": "Portugal" }, { "iso": "PR", "country": "Puerto Rico" }, { "iso": "QA", "country": "Qatar" }, { "iso": "CG", "country": "Republic of the Congo" }, { "iso": "RE", "country": "Reunion" }, { "iso": "RO", "country": "Romania" }, { "iso": "RU", "country": "Russia" }, { "iso": "RW", "country": "Rwanda" }, { "iso": "BL", "country": "Saint Barthélemy" }, { "iso": "SH", "country": "Saint Helena" }, { "iso": "KN", "country": "Saint Kitts and Nevis" }, { "iso": "LC", "country": "Saint Lucia" }, { "iso": "MF", "country": "Saint Martin" }, { "iso": "PM", "country": "Saint Pierre and Miquelon" }, { "iso": "VC", "country": "Saint Vincent and the Grenadines" }, { "iso": "WS", "country": "Samoa" }, { "iso": "SM", "country": "San Marino" }, { "iso": "ST", "country": "Sao Tome and Principe" }, { "iso": "SA", "country": "Saudi Arabia" }, { "iso": "SN", "country": "Senegal" }, { "iso": "RS", "country": "Serbia" }, { "iso": "CS", "country": "Serbia and Montenegro" }, { "iso": "SC", "country": "Seychelles" }, { "iso": "SL", "country": "Sierra Leone" }, { "iso": "SG", "country": "Singapore" }, { "iso": "SK", "country": "Slovakia" }, { "iso": "SI", "country": "Slovenia" }, { "iso": "SB", "country": "Solomon Islands" }, { "iso": "SO", "country": "Somalia" }, { "iso": "ZA", "country": "South Africa" }, { "iso": "GS", "country": "South Georgia and the South Sandwich Islands" }, { "iso": "KR", "country": "South Korea" }, { "iso": "ES", "country": "Spain" }, { "iso": "LK", "country": "Sri Lanka" }, { "iso": "SD", "country": "Sudan" }, { "iso": "SR", "country": "Suriname" }, { "iso": "SJ", "country": "Svalbard and Jan Mayen" }, { "iso": "SZ", "country": "Swaziland" }, { "iso": "SE", "country": "Sweden" }, { "iso": "CH", "country": "Switzerland" }, { "iso": "SY", "country": "Syria" }, { "iso": "TW", "country": "Taiwan" }, { "iso": "TJ", "country": "Tajikistan" }, { "iso": "TZ", "country": "Tanzania" }, { "iso": "TH", "country": "Thailand" }, { "iso": "TG", "country": "Togo" }, { "iso": "TK", "country": "Tokelau" }, { "iso": "TO", "country": "Tonga" }, { "iso": "TT", "country": "Trinidad and Tobago" }, { "iso": "TN", "country": "Tunisia" }, { "iso": "TR", "country": "Turkey" }, { "iso": "TM", "country": "Turkmenistan" }, { "iso": "TC", "country": "Turks and Caicos Islands" }, { "iso": "TV", "country": "Tuvalu" }, { "iso": "VI", "country": "U.S. Virgin Islands" }, { "iso": "UG", "country": "Uganda" }, { "iso": "UA", "country": "Ukraine" }, { "iso": "AE", "country": "United Arab Emirates" }, { "iso": "UM", "country": "United States Minor Outlying Islands" }, { "iso": "UY", "country": "Uruguay" }, { "iso": "UZ", "country": "Uzbekistan" }, { "iso": "VU", "country": "Vanuatu" }, { "iso": "VA", "country": "Vatican" }, { "iso": "VE", "country": "Venezuela" }, { "iso": "VN", "country": "Vietnam" }, { "iso": "WF", "country": "Wallis and Futuna" }, { "iso": "EH", "country": "Western Sahara" }, { "iso": "YE", "country": "Yemen" }, { "iso": "ZM", "country": "Zambia" }, { "iso": "ZW", "country": "Zimbabwe" } ]; } // countryArray() /* Return a string list of for countries */ var countryOptions = function(v_selected){ var a_countries = countryArray(); var v_buffer = ""; for (var i = 0; i < a_countries.length; i++){ var o_country = a_countries[i]; if (o_country){ var v_sel = (v_selected == o_country.iso) ? ' selected="selected"': ''; v_buffer += ''; } } return v_buffer; } // countryOptions() /* Load an external resource file */ var loadResourceFile = function(v_filename, v_filetype){ switch (v_filetype){ case "js": var o_fileref = document.createElement('script'); o_fileref.setAttribute("type","text/javascript"); o_fileref.setAttribute("src", v_filename); break; case "css": var o_fileref = document.createElement("link"); o_fileref.setAttribute("rel", "stylesheet"); o_fileref.setAttribute("type", "text/css"); o_fileref.setAttribute("href", v_filename); break; default: throw("Invalid resource file type."); return false; } document.getElementsByTagName("head")[0].appendChild(o_fileref); return true; } // loadResourceFile() ////////////////////////////////////////////// // Public methods ////////////////////////////////////////////// /* Display the markup for the search widget */ this.display = function(){ if (this.element){ // Write out the widget document.write (this.wrapper.innerHTML); // Turn the non-xhtml compliant autocomplete attribute off var o_form = document.getElementById("aa-sw-form-" + v_uniqueid); if (o_form){o_form.setAttribute("autocomplete", "off");} } return this; } // this.display() // Execute constructor constructor(o_options); return this; } // aaSearchWidget()