/***********************************************
* DHTML Billboard script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//List of transitional effects to be randomly applied to billboard:
var billboardeffects=["GradientWipe(GradientSize=1.0 Duration=0.7)", "Inset", "Iris", "Pixelate(MaxSquare=5 enabled=false)", "RadialWipe", "RandomBars", "Slide(slideStyle='push')", "Spiral", "Stretch", "Strips", "Wheel", "ZigZag"]

var billboardeffects=["ZigZag"] //Uncomment this line and input one of the effects above (ie: "Iris") for single effect.

var tickspeed=5000 //ticker speed in miliseconds (2000=2 seconds)
var effectduration=800 //Transitional effect duration in miliseconds
var hidecontent_from_legacy=1 //Should content be hidden in legacy browsers- IE4/NS4 (0=no, 1=yes).

var filterid=Math.floor(Math.random()*billboardeffects.length)

document.write('<style type="text/css">\n')
if (document.getElementById)
document.write('.billcontent{display:none;\n'+'filter:progid:DXImageTransform.Microsoft.'+billboardeffects[filterid]+'}\n')
else if (hidecontent_from_legacy)
document.write('#contentwrapper{display:none;}')
document.write('</style>\n')

var selectedDiv=0
var totalDivs=0

function contractboard(){
var inc=0
while (document.getElementById("billboard"+inc)){
document.getElementById("billboard"+inc).style.display="none"
inc++
}
}

function expandboard(){
var selectedDivObj=document.getElementById("billboard"+selectedDiv)
contractboard()
if (selectedDivObj.filters){
if (billboardeffects.length>1){
filterid=Math.floor(Math.random()*billboardeffects.length)
selectedDivObj.style.filter="progid:DXImageTransform.Microsoft."+billboardeffects[filterid]
}
selectedDivObj.filters[0].duration=effectduration/1000
selectedDivObj.filters[0].Apply()
}
selectedDivObj.style.display="block"
if (selectedDivObj.filters)
selectedDivObj.filters[0].Play()
selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
setTimeout("expandboard()",tickspeed)
}

function startbill(){
while (document.getElementById("billboard"+totalDivs)!=null)
totalDivs++
if (document.getElementById("billboard0").filters)
tickspeed+=effectduration
expandboard()
}

if (window.addEventListener)
window.addEventListener("load", startbill, false)
else if (window.attachEvent)
window.attachEvent("onload", startbill)
else if (document.getElementById)
window.onload=startbill


var timerID ;
function tzone(tz, os, ds, cl)
{
	this.ct = new Date(0) ;		// datetime
	this.tz = tz ;		// code
	this.os = os ;		// GMT offset
	this.ds = ds ;		// has daylight savings
	this.cl = cl ;		// font color
}

function UpdateClocks()
{
	// www.timeanddate.com/worldclock
	var ct = new Array(
		new tzone(' New York', -5, 0, '#FF0000'),
		new tzone(' Tokyo', +9, 0, '#FF0000'),
		new tzone(' Colombo', +5.5, 0, '#FF0000'),
		new tzone(' Sydney', +11, 1, '#FF0000'),
		new tzone(' London', 0, 0, '#FF0000'),
		new tzone(' Singapore',  +8, 1, '#FF0000')
	) ;

	var dt = new Date() ;	// [GMT] time according to machine clock

	var startDST = new Date(dt.getFullYear(), 3, 1) ;
	while (startDST.getDay() != 0)
		startDST.setDate(startDST.getDate() + 1) ;

	var endDST = new Date(dt.getFullYear(), 9, 31) ;
	while (endDST.getDay() != 0)
		endDST.setDate(endDST.getDate() - 1) ;

	var ds_active ;		// DS currently active
	if (startDST < dt && dt < endDST)
		ds_active = 1 ;
	else
		ds_active = 0 ;

	// Adjust each clock offset if that clock has DS and in DS.
	for(n=0 ; n<ct.length ; n++)
		if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;

	// compensate time zones
	gmdt = new Date() ;
	for (n=0 ; n<ct.length ; n++)
		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;

	document.getElementById("billboard0").innerHTML =
		ClockString(ct[0].ct) + ct[0].tz ;

	document.getElementById("billboard1").innerHTML =
		ClockString(ct[1].ct) + ct[1].tz ;

	document.getElementById("billboard2").innerHTML =
		ClockString(ct[2].ct) + ct[2].tz ;

	document.getElementById("billboard3").innerHTML =
		ClockString(ct[3].ct) + ct[3].tz ;

	document.getElementById("billboard4").innerHTML =
		ClockString(ct[4].ct) + ct[4].tz ;

	document.getElementById("billboard5").innerHTML =
		ClockString(ct[5].ct) + ct[5].tz ;

	
	
	timerID = window.setTimeout("UpdateClocks()", 1001) ;
}

function ClockString(dt)
{
	var stemp, ampm ;
	
	var month=new Array(12);
	month[0]="Jan";
	month[1]="Feb";
	month[2]="Mar";
	month[3]="Apr";
	month[4]="May";
	month[5]="Jun";
	month[6]="Jul";
	month[7]="Aug";
	month[8]="Sep";
	month[9]="Oct";
	month[10]="Nov";
	month[11]="Dec";

	var weekday=new Array(7);
	weekday[0]="Sunday";
	weekday[1]="Monday";
	weekday[2]="Tuesday";
	weekday[3]="Wednesday";
	weekday[4]="Thursday";
	weekday[5]="Friday";
	weekday[6]="Saturday";

	var dt_year = dt.getUTCFullYear() ;
	//var dt_month = dt.getUTCMonth() + 1 ;
	var dt_date = weekday[dt.getUTCDay()];
	var dt_month = month[dt.getUTCMonth()];
	var dt_day = dt.getUTCDate() ;
	var dt_hour = dt.getUTCHours() ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;
	
	dt_year = dt_year.toString() ;
	if (0 <= dt_hour && dt_hour < 12)
	{
		ampm = 'AM' ;
		if (dt_hour == 0) dt_hour = 12 ;		
	} else {
		ampm = 'PM' ;
		dt_hour = dt_hour - 12 ;
		if (dt_hour == 0) dt_hour = 12 ;		
	}
	
	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;
	
	if (dt_second < 10)
		dt_second = '0' + dt_second ;

	stemp = '<font color="#666666">' + dt_date+', '+dt_month + ' ' + dt_day + ', ' + dt_year + '</font><div style="padding:4px 0 0 0;"></div>' ;
	stemp = '<font color="#FF0000">' + stemp + ' ' + dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm + '</font>';
	return stemp ;
}

