
var aDiv = document.getElementsByTagName("div");
aDiv[0].onclick = function(){
starMove(this,"width",300);
}
aDiv[1].onclick = function(){
starMove(this,"height",300);
}
aDiv[2].onclick = function(){
starMove(this,"marginLeft",300);
}
aDiv[3].onclick = function(){
starMove(this,"fontSize",100);
}
aDiv[4].onclick = function(){
starMove(this,"opacity",100);
}
function starMove(node,attr,iTarget){
clearInterval(node.timer);
node.timer = setInterval(function(){
if(attr=="opacity"){
iCur = parseInt(parseFloat(getStyle(node,"opacity"))*100);
}else{
iCur = parseInt(getStyle(node,attr));
}
var speed = (iTarget - iCur) / 8;
speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
if(iCur == iTarget){
clearInterval(node.timer);
}else{
if(attr=="opacity"){
iCur += speed;
node.style.opacity = iCur / 100;
node.style.filter = "alpha(opacity=" + iCur +")"
}else{
node.style[attr] = iCur + speed + "px";
}
}
},30);
}
function getStyle(node,cssStr){
return node.currentStyle ? node.currentStyle[cssStr]:getComputedStyle(node)[cssStr];
}