var limit = "0:20";

if (document.images) {
	var parselimit = limit.split(":");
	parselimit = parselimit[0] * 60 + parselimit[1] * 1;
}

function beginRefresh() {
	if (!document.images)
		return;
	if (parselimit == 1)
		window.location.reload();
	else { 
		parselimit -= 1;
		curmin = Math.floor(parselimit / 60);
		cursec = parselimit % 60;
		if (curmin != 0)
			curtime = curmin+" minutes and "+cursec+" seconds left until page refresh!";
		else
			curtime = cursec+" seconds left until page refresh!";

		//window.status = curtime;
		setTimeout("beginRefresh()", 1000)
	}
}

function openWindow(page, winName, features) {
	popup = window.open(page, winName, features);
	popup.focus();
}

function openShopXpress() {
  openWindow('http://www.shop-xpress.com/index.asp?sis={72C9AA94-605C-419C-8A5C-4391AE75AB5C}&amp;l=nl', 'shopXpress', 'width=600, height=616');
}

function openSchrijfbloks() {
  openWindow('http://www.promotionalpaperproducts.nl/', 'schrijfbloks', 'width=900, height=616, resizable=yes');
}

function randomImage() {
	duration = 5;
	
	images = [
		[
			'images/showroom/001.jpg', 
			'images/showroom/002.jpg', 
			'images/showroom/003.jpg',
			'images/showroom/005.jpg', 
			'images/showroom/006.jpg', 
			'images/showroom/007.jpg',
			'images/showroom/008.jpg',
			'images/showroom/009.jpg', 
			'images/showroom/010.jpg', 
			'images/showroom/011.jpg', 
			'images/showroom/012.jpg', 
			'images/showroom/013.jpg', 
			'images/showroom/014.jpg', 
			'images/showroom/017.jpg', 
			'images/showroom/018.jpg', 
			'images/showroom/019.jpg', 
			'images/showroom/020.jpg', 
			'images/showroom/022.jpg'
		],
		[
			'images/showroom/023.jpg', 
			'images/showroom/026.jpg', 
			'images/showroom/027.jpg',
			'images/showroom/028.jpg',
			'images/showroom/029.jpg',
			'images/showroom/030.jpg',
			'images/showroom/031.jpg',
			'images/showroom/032.jpg',
			'images/showroom/033.jpg',
			'images/showroom/034.jpg', 
			'images/showroom/036.jpg', 
			'images/showroom/037.jpg', 
			'images/showroom/038.jpg', 
			'images/showroom/039.jpg',
			'images/showroom/040.jpg',
			'images/showroom/041.jpg',
			'images/showroom/042.jpg',
			'images/showroom/043.jpg'
		],
		[
			'images/showroom/044.jpg',
			'images/showroom/046.jpg',
			'images/showroom/047.jpg',
			'images/showroom/048.jpg',
			'images/showroom/049.jpg',
			'images/showroom/050.jpg',
			'images/showroom/051.jpg',
			'images/showroom/057.jpg',
			'images/showroom/060.jpg',
			'images/showroom/062.jpg',
			'images/showroom/063.jpg',
			'images/showroom/064.jpg',
			'images/showroom/066.jpg',
			'images/showroom/067.jpg',
			'images/showroom/068.jpg',
			'images/showroom/069.jpg',
			'images/showroom/070.jpg',
			'images/showroom/072.jpg',
			'images/showroom/078.jpg'
		],
		[
			'images/showroom/004.jpg', 
			'images/showroom/021.jpg', 
			'images/showroom/024.jpg', 
			'images/showroom/053.jpg',
			'images/showroom/055.jpg',
			'images/showroom/061.jpg',
			'images/showroom/065.jpg',
			'images/showroom/071.jpg',
			'images/showroom/073.jpg',
			'images/showroom/074.jpg',
			'images/showroom/075.jpg',
			'images/showroom/076.jpg',
			'images/showroom/077.jpg'
		]
	];
	
//	for (i = 1; i <= images.length; i++) {
	for (i = 1; i <= 4; i++) {
		rv = randomValue(0, (images[i - 1].length) - 1);
		//alert(rv);
		document.getElementById('ai' + i).src = images[i - 1][rv];
	}

	setTimeout('randomImage()', duration * 1000);
	
}

function randomValue(low, high) { 
	return Math.floor(Math.random() * (1 + high - low) + low); 
}
	
