var AwardCount = 0;
var awards_array = new Array();
var images_array = new Array();

function loadImage(file) {
	images_array[AwardCount] = new Image();
	images_array[AwardCount].src = "/images/awards/" + file;
	var w = images_array[AwardCount].width;
	var h = images_array[AwardCount].height;
	if(w > 112 || h > 94) {
		var w_ratio = 112 / w;
		var h_ratio = 94 / h;
		if(w_ratio < h_ratio) {
			w = Math.round(w_ratio * w);
			h = Math.round(w_ratio * h);
		} else {
			w = Math.round(h_ratio * w);
			h = Math.round(h_ratio * h);
		}
	}
	var p = 0;
	if((94-h) > 1) {
		p = Math.round((94-h) / 2 -1);
	}
	
	var image_tag = "<a href='/awards_reviews/index.html'><img src='/images/awards/" + file + "' width='" + w +"' height='" + h + "' border='0' style='margin-top:"+p+"px' /></a>";
	var x = document.getElementById("awards_display");
	x.innerHTML = image_tag;
	
}

function preloadImages() {
	for(var i=0; i<awards_array.length; i++) {
		images_array[i] = new Image();
		images_array[i].src = "/images/awards/" + awards_array[i];
	}
}

function loadAward() {
	loadImage(awards_array[AwardCount]);
	AwardCount++;
	if(AwardCount>=awards_array.length) AwardCount=0;
	setTimeout ( "loadAward()", 2000 );
}

function displayAwards(awards) {
	awards = awards.replace(/ /g,"");
	awards_array = awards.split(",");
	preloadImages();
	loadAward();
}