﻿var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var innerHTML_index = 0;
innerHTML_list = new Array();
innerHTML_list[innerHTML_index++] = '<a align="center" style="font-size:34pt; font-weight:bold; text-decoration:none;" href="12%202010%20Calendar.asp"><img border="0" src="img_yd/adv_calendar.bmp"style="vertical-align:middle; position:relative;" /></a>';
innerHTML_list[innerHTML_index++] = '<a align="center" style="font-size:42pt; font-weight:bold; text-decoration:none;" href="http://www.greenbag.com.hk/" target="_blank"><img border="0" src="img_yd/greenbagmanufactory.jpg" style="vertical-align:middle; position:relative;" /></a>';
innerHTML_list[innerHTML_index++] = '<a align="center" style="font-size:42pt; font-weight:bold; text-decoration:none;"><img border="0" src="img_yd/stationerylogo.bmp" style="vertical-align:middle; position:relative;" /></a>';

var style_index = 0;
style_bgColor_list = new Array();
style_bgColor_list[style_index++] = '#CC0000';
style_bgColor_list[style_index++] = '#68AB67';
style_bgColor_list[style_index++] = '#A9DDFF';

var number_of_image = innerHTML_list.length;

function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}

function rotateImage(place) {
 if (random_display) {
  innerHTML_index = generate(0, number_of_image-1);
 } else {
  innerHTML_index = (innerHTML_index+1) % number_of_image;
 }
 document.getElementById(place).innerHTML = '<table border="0" width="100%"  style="background-color:'+style_bgColor_list[innerHTML_index]+';"><tr height="150px"><td align="center">' + innerHTML_list[innerHTML_index]+'</td></tr><tr height="20px"><td align="right" style="color:#ffffff;font-size:20px">本公司相關業務</td></tr></table>';
 document.getElementById(place).style.backgroundColor = style_bgColor_list[innerHTML_index];
 var recur_call = "rotateImage('"+place+"')";
 setTimeout(recur_call, interval);
}