/**
 * Function: preloadCountrySelectorImages(imagePaths, containerId)
 * @description Preload country selector elements
 * @example preloadCountrySelectorImages(imagePaths, containerId);
 * @param images A string array containing all image paths
 * @param containerId A node Id of an element which will contain the preloded images
 * @return returns false if preloading failed; otherwise it will return true
 */
function preloadCountrySelectorImages(images, containerId) {
	/* validate function parameters */
	if (!images) {
		/* missing parameter: no image paths defined */
		return false;
	}
	
	if (! containerId) {
		/* missing parameter: no container id */
		return false;
	}
	
	/* preload images */
	try {
		var preloadContainer = document.getElementById(containerId);
		var imagecontainer = document.createElement("div");
		imagecontainer.style.display = "none";
		for (var i=0; i<images.length; i++) {
			var image = document.createElement("img");
			image.src = images[i];
			imagecontainer.appendChild(image);
		}
		preloadContainer.appendChild(imagecontainer);
	} catch (e) {
		/* preloading failed */
		return false;
	}
	
	return true;
}

var basepath = "portaldata/scripts/countryselector/";
var images = [
	basepath + "images/base/active_arrow.gif",
	basepath + "images/base/hover_arrow.gif",
	basepath + "images/black/corners.gif",
	basepath + "images/black/center.gif",
	basepath + "images/white/corners.gif",
	basepath + "images/white/center.gif"
];
	
preloadCountrySelectorImages(images, "country_selector");