﻿var interval = 3; // 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++] = '<p align="center" style="font-size:34pt; font-weight:bold; text-decoration:none;"><a align="center" style="font-size:42pt; font-weight:bold; text-decoration:none;" href="http://www.print328.com/" target="_blank"><img border="0" src="../images/otherbusiness/print328logo.JPG" style="vertical-align:middle; position:relative;" /></a>';
innerHTML_list[innerHTML_index++] = '<p align="center" style="font-size:34pt; font-weight:bold; text-decoration:none;"><img border="0" src="../images/otherbusiness/stationerylogo.JPG" style="vertical-align:middle; position:relative;" />';

var style_index = 0;
style_bgColor_list = new Array();
style_bgColor_list[style_index++] = '#FFFFFF';
style_bgColor_list[style_index++] = '#FFFFFF';

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;
 }
 
 finalhtml = '<table border="0" width="100%" style="background-color:'+style_bgColor_list[innerHTML_index]+';">';
 finalhtml += '<tr height="100px"><td>';
 finalhtml += innerHTML_list[innerHTML_index];
 finalhtml += '</td></tr><tr height="20px">';
 finalhtml += '<td align="right" style="color:#000000; font-size:15px">&#26412;&#20844;&#21496;&#30456;&#38364;&#26989;&#21209;</td></tr></table>';
 document.getElementById(place).innerHTML = finalhtml;


 //document.getElementById(place).innerHTML = '<table border="0" width="100%" style="background-color:'+style_bgColor_list[innerHTML_index]+';"><tr height="100px"><td><div style="position:relative">' + innerHTML_list[innerHTML_index]+'</tr><tr height="20px"><td align="right" style="color:#000000;font-size:15px">本公司相關業務</td></tr></table>';
 //document.getElementById(place).style.backgroundColor = style_bgColor_list[innerHTML_index];
 var recur_call = "rotateImage('"+place+"')";
 setTimeout(recur_call, interval);
}