//Radar images version

var satpics = new Array();
var radpics = new Array();
getPics();

function getPics() {
	currtime=new Date().getTime()
	if (document.images) {
 	radpic0 = new Image();
  	radpic0.src = 'http://www.weather.gov.hk/content_elements/radar1.png?'+currtime;
  	radpic1 = new Image();
  	radpic1.src = 'http://www.weather.gov.hk/content_elements/radar2.png?'+currtime;
  	radpic2 = new Image();
  	radpic2.src = 'http://www.weather.gov.hk/content_elements/radar3.png?'+currtime;
  	radpic3 = new Image();
  	radpic3.src = 'http://www.weather.gov.hk/content_elements/radar4.png?'+currtime;
  	radpic4 = new Image();
  	radpic4.src = 'http://www.weather.gov.hk/content_elements/radar5.png?'+currtime;
  	radpic5 = new Image();
  	radpic5.src = 'http://www.weather.gov.hk/content_elements/radar6.png?'+currtime;
	}
radpics[0] = radpic0.src;
radpics[1] = radpic1.src;
radpics[2] = radpic2.src;
radpics[3] = radpic3.src;
radpics[4] = radpic4.src;
radpics[5] = radpic5.src;
}

var AnimatedID
var Order=-1
var inputType

function startAnimation(type) {
	getPics();
	inputType = type;
	clearInterval(AnimatedID);
	AnimatedID=setInterval('showPic(inputType)',1000);
}

function showPic(type) {
	Order++;
	if (Order > 4){
		//Order=0;
		//Order=5;
		clearInterval(AnimatedID);
		stopAnimation('rad',5);
	} else {
		if (type == 'sat') {
			document.satrad.src = satpics[Order];
		} else if (type == 'rad') {
			document.satrad.src = radpics[Order];
		}
	}
}

function stopAnimation(type,picNum) {
	clearInterval(AnimatedID);
	if (type == 'sat') {
		document.satrad.src = satpics[picNum];
	} else if (type == 'rad') {
		document.satrad.src = radpics[picNum];
	}
	if (picNum < 5) {
		Order=picNum;
	} else {
		Order=-1;
	}
}