/*
 *　世界時計の配布先
 *　http://www.proglogic.com/code/javascript/time/worldclock.php
 *　この版はクラシック・ラジオで利用するため一部省略・改変しています。
 */


function worldClock(zone, region){
var dst = 0
var time = new Date()
var gmtMS = time.getTime() + (time.getTimezoneOffset() * 60000)
var gmtTime = new Date(gmtMS)
var day = gmtTime.getDate()
var month = gmtTime.getMonth()
var year = gmtTime.getYear()
if(year < 1000){
year += 1900
}
var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
var monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
if (year%4 == 0){
monthDays = new Array("31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}
if(year%100 == 0 && year%400 != 0){
monthDays = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31")
}

var hr = gmtTime.getHours() + zone
var min = gmtTime.getMinutes()
var sec = gmtTime.getSeconds()

if (hr >= 24){
hr = hr-24
day -= -1
}
if (hr < 0){
hr -= -24
day -= 1
}
if (hr < 10){
hr = " " + hr
}
if (min < 10){
min = "0" + min
}
if (sec < 10){
sec = "0" + sec
}
if (day <= 0){
if (month == 0){
	month = 11
	year -= 1
	}
	else{
	month = month -1
	}
day = monthDays[month]
}
if(day > monthDays[month]){
	day = 1
	if(month == 11){
	month = 0
	year -= -1
	}
	else{
	month -= -1
	}
}
if (region == "NAmerica"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(3)
	startDST.setHours(2)
	startDST.setDate(1)
	var dayDST = startDST.getDay()
	if (dayDST != 0){
		startDST.setDate(8-dayDST)
		}
		else{
		startDST.setDate(1)
		}
	endDST.setMonth(9)
	endDST.setHours(1)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "Europe"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(2)
	startDST.setHours(1)
	startDST.setDate(31)
	var dayDST = startDST.getDay()
	startDST.setDate(31-dayDST)
	endDST.setMonth(9)
	endDST.setHours(0)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST && currentTime < endDST){
		dst = 1
		}
}
if (region == "SAmerica"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(9)
	startDST.setHours(0)
	startDST.setDate(1)
	var dayDST = startDST.getDay()
	if (dayDST != 0){
		startDST.setDate(22-dayDST)
		}
		else{
		startDST.setDate(15)
		}
	endDST.setMonth(1)
	endDST.setHours(11)
	endDST.setDate(1)
	dayDST = endDST.getDay()
	if (dayDST != 0){
		endDST.setDate(21-dayDST)
		}
		else{
		endDST.setDate(14)
		}
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST || currentTime < endDST){
		dst = 1
		}
}
if (region == "Australia"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(9)
	startDST.setHours(2)
	startDST.setDate(31)
	var dayDST = startDST.getDay()
	startDST.setDate(31-dayDST)
	endDST.setMonth(2)
	endDST.setHours(2)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST || currentTime < endDST){
		dst = 1
		}
}
if (region == "NewZealand"){
	var startDST = new Date()
	var endDST = new Date()
	startDST.setMonth(9)
	startDST.setHours(2)
	startDST.setDate(31)
	var dayDST = startDST.getDay()
	startDST.setDate(31-dayDST)
	endDST.setMonth(3)
	endDST.setHours(2)
	endDST.setDate(31)
	dayDST = endDST.getDay()
	endDST.setDate(31-dayDST)
	var currentTime = new Date()
	currentTime.setMonth(month)
	currentTime.setYear(year)
	currentTime.setDate(day)
	currentTime.setHours(hr)
	if(currentTime >= startDST || currentTime < endDST){
		dst = 1
		}
}


if (dst == 1){
	hr -= -1
	if (hr >= 24){
	hr = hr-24
	day -= -1
	}
	if (hr < 10){
	hr = " " + hr
	}
	if(day > monthDays[month]){
	day = 1
	if(month == 11){
	month = 0
	year -= -1
	}
	else{
	month -= -1
	}
	}
return "夏時間 " +  day + "日 " + hr + ":" + min + ":" + sec + "<br />"
}
else{
return "標準時 " +  day + "日 " + hr + ":" + min + ":" + sec + "<br />"
}
}

function worldClockZone(){
document.getElementById("kdfc").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("kusc").innerHTML = worldClock(-8, "NAmerica")
document.getElementById("kuat").innerHTML = worldClock(-7, "Arizona")
document.getElementById("mpr").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("wfmt").innerHTML = worldClock(-6, "NAmerica")
document.getElementById("wgbh").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("vpr").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("wqxr").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("wcpe").innerHTML = worldClock(-5, "NAmerica")
document.getElementById("bbc").innerHTML = worldClock(0, "Europe")
document.getElementById("ig_classicfm").innerHTML = worldClock(0, "Europe")
document.getElementById("radio_swiss").innerHTML = worldClock(1, "Europe")
document.getElementById("stephansdam").innerHTML = worldClock(1, "Europe")
document.getElementById("bayern").innerHTML = worldClock(1, "Europe")
document.getElementById("mdr").innerHTML = worldClock(1, "Europe")
document.getElementById("klassikradio").innerHTML = worldClock(1, "Europe")
document.getElementById("francemusique").innerHTML = worldClock(1, "Europe")
document.getElementById("radioclassique").innerHTML = worldClock(1, "Europe")
document.getElementById("radiocrazy").innerHTML = worldClock(1, "Europe")
document.getElementById("radio4").innerHTML = worldClock(1, "Europe")
document.getElementById("concertzender").innerHTML = worldClock(1, "Europe")
document.getElementById("or_classicfm").innerHTML = worldClock(1, "Europe")
document.getElementById("dr").innerHTML = worldClock(1, "Europe")
document.getElementById("nrk").innerHTML = worldClock(1, "Europe")
document.getElementById("d-dur").innerHTML = worldClock(1, "Europe")
document.getElementById("slovensky").innerHTML = worldClock(1, "Europe")
document.getElementById("bartok").innerHTML = worldClock(1, "Europe")
document.getElementById("sveriges").innerHTML = worldClock(1, "Europe")
document.getElementById("yle").innerHTML = worldClock(2, "Europe")
document.getElementById("orfeus").innerHTML = worldClock(3, "Europe")
document.getElementById("ottava").innerHTML = worldClock(9, "Nippon")
document.getElementById("nhk").innerHTML = worldClock(9, "Nippon")
document.getElementById("abc").innerHTML = worldClock(10, "Australia")
document.getElementById("two_mbs").innerHTML = worldClock(10, "Australia")
document.getElementById("three_mbs").innerHTML = worldClock(10, "Australia")
document.getElementById("concertfm").innerHTML = worldClock(12, "NewZealand")


setTimeout("worldClockZone()", 1000)
}
window.onload=worldClockZone;

