﻿/*
 * Script to randomise the left hand image and set the alt/title images
 * dependant upon the browsers current URL.
 * By:- Ben Griffiths
 * Last Modified:- 05/09/2006
 */

							// define the array of images to be used.
							// if a new image is added each of the alt/title
							// definitions will need to be updated
							
var meerkat_array = [
	"http://resources.discoveryeurope.com/ap/meerkat/js/images/flower.gif",
	"http://resources.discoveryeurope.com/ap/meerkat/js/images/mozart.gif",
	"http://resources.discoveryeurope.com/ap/meerkat/js/images/zaphod.gif"
];

							// this is the default alt/title array - using English
							
var alt_array = [
	"Flower",
	"Mozart",
	"Zaphod"
];

							// add extra countries here, firstly add the URL then the alternative
							// title tags.
							
var countriesAlt = [
["animalplanet.co.uk", "Flower", "Mozart", "Zaphod"],
["animalplanetbrasil.com", "Flower", "Mozart", "Zaphod"],
["animalplanetlatino.com", "Flor", "Mozart", "Zaphod" ],
["animalplanet.pl", "Róża", "Sonia", "Hieronim" ],
["animalplanet.de", "Blümchen", "Mozart", "Zaphod" ],
["animalplanet.de", "花花", "莫札特", "察佛德" ]
]

for (i=0; i<countriesAlt.length; i++) {					// iterate through countries
	currentCountry = countriesAlt[i];
	if (location.href.match(currentCountry[0])) {		// if URL matches current country in array
		for (k=0; k<currentCountry.length; k++) {
			alt_array[k] = currentCountry[k+1];			// populate alt_array with new values
		}
	}
}

function drawRandomMeerkat() {

  if (document.images) {   	// ensure that the browser understands the DOM otherwise
                           	// revert to standard image
  
    var rand = Math.floor(Math.random()*meerkat_array.length);
    document.getElementById("meerkat_nav_image").src = meerkat_array[rand];
	
	try {
		document.getElementById("meerkat_nav_image").alt = alt_array[rand];
		document.getElementById("meerkat_nav_image").title = alt_array[rand];
	}
	catch (e) {}
  }
}