// GENERATE A RANDOM BANNER IMAGE

if (eval(unescape(window.location).match(/bling/i))) {
	// test if URL contains "bling"
	var n = 1; // default image
	var r = 9; // # of images in set
	n = (Math.round(Math.random()*(r - 1)) + 1); // generate random number
	i = "http://www.undp.org/bling/bling_go" + n + ".gif";
	credit = "";
} else {
	// no match, choose from one of the default sets
	var n = 1; // default image
	
	// pick a number between 1 and 10
	var chance = Math.round(Math.random()*5) + 1;

	// use each set 40/60% of the time
	if (chance > 9) {
		// UNCDF
		var r = 8; // # of images in set
		n = (Math.round(Math.random()*(r - 1)) + 1); // generate random number
		i = "http://www.undp.org/bling/bling_go" + n + ".gif";
		credit = "Banner photo by<br><a href=\"http://www.nospodemos.org.br/\" target=\"_blank\">UNDP Brazil </a>.";
	} else {
		// Aerial Images
		var r = 9; // # of images in set
		n = (Math.round(Math.random()*(r - 1)) + 1); // generate random number
		i = "http://www.undp.org/bling/bling_go" + n + ".gif";
		credit = "";
	}

}

// write image CSS
document.write('<style type="text/css">.banner {background-image: url(' + i + ');}</style>');


