function checkAnimationEnable() {
	var startStr = 'AnimationStart';
	var endStr = 'AnimationEnd';
	var iterationStr = 'AnimationIteration';
	
	var check = document.createElement('div');
	var prefixList = ['Webkit', 'Moz', 'O', 'ms', ''];
	
	var tmpObj = new Object();
	tmpObj.animation = false;
	
	for( var i = 0; i < prefixList.length; i++ ) {
		if(check.style[prefixList[i] + 'AnimationName' ] !== undefined ) {
			var pre = prefixList[i];
			tmpObj.domPrefix = pre;
			tmpObj.stylePrefix = '-' + pre.toLowerCase() + '-';
			
			//events
			switch(tmpObj.domPrefix) {
				case 'Webkit':
					var eventPrefix = pre.toLowerCase();
					tmpObj.startEvent = eventPrefix + startStr;
					tmpObj.endEvent = eventPrefix + endStr;
					tmpObj.iterationEvent = eventPrefix + iterationStr;
					break;
				case 'Moz':
				case '':
				default:
					tmpObj.startEvent = startStr.toLowerCase();
					tmpObj.endEvent = endStr.toLowerCase();
					tmpObj.iterationEvent = iterationStr.toLowerCase();
					break;
			}
			
			//style
			tmpObj.nameStyle = pre + 'AnimationName';
			tmpObj.durationStyle = pre + 'AnimationDuration';
			tmpObj.timingFunctionStyle = pre + 'AnimationTimingFunction';
			tmpObj.iterationStyle = pre + 'AnimationIterationCount';
			tmpObj.directionStyle = pre + 'AnimationDirection';
			tmpObj.playStateStyle = pre + 'AnimationPlayState';
			tmpObj.delayStyle = pre + 'AnimationDelay';
			tmpObj.fillModeStyle = pre + 'AnimationFillMode';
			tmpObj.animation = true;
			break;
		}
	}
	return tmpObj;
}

var aProp = new Object();
function setup() {
	aProp = checkAnimationEnable();
	
	var b = document.getElementById('btn');
	if(aProp.animation) {
		b.addEventListener('click', click, false);
	} else {
		b.disabled = true;
	}
}

function click(e) {
	var t = document.getElementById('plane');
	t.addEventListener(aProp.startEvent, animStart, false);
	t.addEventListener(aProp.endEvent, animEnd, false);
	
	var state = aProp.playStateStyle;
	if(t.style[state] == 'running') {
		t.style[state] = 'paused';
	} else {
		t.style[state] = 'running';
	}
	t.style[aProp.nameStyle] = 'fly';
}

function animStart(e) {
	var status = document.getElementById('status');
	status.innerHTML = 'アニメーション開始！';
}

function animEnd(e) {
	var status = document.getElementById('status');
	status.innerHTML = 'アニメーション終了！';
	var b = document.getElementById('btn');
	b.disabled = false;
	
	var t = document.getElementById('plane');
	t.style[aProp.playStateStyle] = 'paused';
	t.style[aProp.nameStyle] = '';
	t.removeEventListener(aProp.startEvent, animStart, false);
	t.removeEventListener(aProp.endEvent, animEnd, false);
}