/* JPEG Animation */

var index = 0;
var tid;
var images_url = "http://www.figureskatingguide.com/images/";

var obj_images = new Array();
var images = new Array();
images["axel"] = [
"P3211845.jpg",
"P3211846.jpg",
"P3211847.jpg",
"P3211848.jpg",
"P3211849.jpg",
"P3211850.jpg",
"P3211851.jpg",
"P3211852.jpg",
"P3211853.jpg",
"P3211854.jpg",
"P3211855.jpg",
"P3211856.jpg",
"P3211857.jpg",
"P3211858.jpg",
"P3211859.jpg",
"P3211860.jpg",
"P3211861.jpg",
"P3211862.jpg",
"P3211863.jpg",
"P3211864.jpg",
"P3211865.jpg",
"P3211866.jpg",
"P3211867.jpg",
"P3211868.jpg",
"P3211869.jpg",
"P3211870.jpg",
"P3211871.jpg",
"P3211872.jpg",
"P3211873.jpg",
"P3211874.jpg",
"P3211875.jpg",
"P3211876.jpg",
"P3211877.jpg",
"P3211878.jpg",
"P3211879.jpg"
];
images["lutz"] = [
"P3234631.jpg",
"P3234632.jpg",
"P3234633.jpg",
"P3234634.jpg",
"P3234635.jpg",
"P3234636.jpg",
"P3234637.jpg",
"P3234638.jpg",
"P3234639.jpg",
"P3234640.jpg",
"P3234641.jpg",
"P3234642.jpg",
"P3234643.jpg",
"P3234644.jpg",
"P3234645.jpg",
"P3234646.jpg",
"P3234647.jpg",
"P3234648.jpg",
"P3234649.jpg",
"P3234650.jpg",
"P3234651.jpg",
"P3234652.jpg",
"P3234653.jpg",
"P3234654.jpg",
"P3234655.jpg",
"P3234656.jpg",
"P3234657.jpg",
"P3234658.jpg",
"P3234659.jpg",
"P3234660.jpg",
"P3234661.jpg",
"P3234662.jpg",
"P3234663.jpg",
"P3234664.jpg",
"P3234665.jpg",
"P3234666.jpg",
"P3234667.jpg",
"P3234668.jpg",
"P3234669.jpg"
];
images["flip"] = [
"PB300094.jpg",
"PB300095.jpg",
"PB300096.jpg",
"PB300097.jpg",
"PB300098.jpg",
"PB300099.jpg",
"PB300100.jpg",
"PB300101.jpg",
"PB300102.jpg",
"PB300103.jpg",
"PB300104.jpg",
"PB300105.jpg",
"PB300106.jpg",
"PB300107.jpg",
"PB300108.jpg",
"PB300109.jpg",
"PB300110.jpg",
"PB300111.jpg",
"PB300112.jpg",
"PB300113.jpg",
"PB300114.jpg",
"PB300115.jpg",
"PB300116.jpg",
"PB300117.jpg",
"PB300118.jpg",
"PB300119.jpg",
"PB300120.jpg",
"PB300121.jpg",
"PB300122.jpg",
"PB300123.jpg",
"PB300124.jpg",
"PB300125.jpg",
"PB300126.jpg",
"PB300127.jpg",
"PB300128.jpg",
"PB300129.jpg",
"PB300130.jpg",
"PB300131.jpg",
"PB300132.jpg",
"PB300133.jpg",
"PB300134.jpg",
"PB300135.jpg",
"PB300136.jpg",
"PB300137.jpg",
"PB300138.jpg"
];
images["loop"] = [
"P3212103.jpg",
"P3212104.jpg",
"P3212105.jpg",
"P3212106.jpg",
"P3212107.jpg",
"P3212108.jpg",
"P3212109.jpg",
"P3212110.jpg",
"P3212111.jpg",
"P3212112.jpg",
"P3212113.jpg",
"P3212114.jpg",
"P3212115.jpg",
"P3212116.jpg",
"P3212117.jpg",
"P3212118.jpg",
"P3212119.jpg",
"P3212120.jpg",
"P3212121.jpg",
"P3212122.jpg",
"P3212123.jpg",
"P3212124.jpg",
"P3212125.jpg",
"P3212126.jpg",
"P3212127.jpg",
"P3212128.jpg",
"P3212129.jpg",
"P3212130.jpg",
"P3212131.jpg",
"P3212132.jpg",
"P3212133.jpg",
"P3212134.jpg",
"P3212135.jpg",
"P3212136.jpg",
"P3212137.jpg",
"P3212138.jpg",
"P3212139.jpg",
"P3212140.jpg",
"P3212141.jpg",
"P3212142.jpg",
"P3212143.jpg"
];
images["salchow"] = [
"P3211222.jpg",
"P3211223.jpg",
"P3211224.jpg",
"P3211225.jpg",
"P3211226.jpg",
"P3211227.jpg",
"P3211228.jpg",
"P3211229.jpg",
"P3211230.jpg",
"P3211231.jpg",
"P3211232.jpg",
"P3211233.jpg",
"P3211234.jpg",
"P3211235.jpg",
"P3211236.jpg",
"P3211237.jpg",
"P3211238.jpg",
"P3211239.jpg",
"P3211240.jpg",
"P3211241.jpg",
"P3211242.jpg",
"P3211243.jpg",
"P3211244.jpg",
"P3211245.jpg",
"P3211246.jpg",
"P3211247.jpg",
"P3211248.jpg",
"P3211249.jpg",
"P3211250.jpg",
"P3211251.jpg",
"P3211252.jpg",
"P3211253.jpg",
"P3211254.jpg",
"P3211255.jpg",
"P3211256.jpg",
"P3211257.jpg",
"P3211258.jpg",
"P3211259.jpg"
];
images["toeloop"] = [
"P3212273.jpg",
"P3212274.jpg",
"P3212275.jpg",
"P3212276.jpg",
"P3212277.jpg",
"P3212278.jpg",
"P3212279.jpg",
"P3212280.jpg",
"P3212281.jpg",
"P3212282.jpg",
"P3212283.jpg",
"P3212284.jpg",
"P3212285.jpg",
"P3212286.jpg",
"P3212287.jpg",
"P3212288.jpg",
"P3212289.jpg",
"P3212290.jpg",
"P3212291.jpg",
"P3212292.jpg",
"P3212293.jpg",
"P3212294.jpg",
"P3212295.jpg",
"P3212296.jpg",
"P3212297.jpg",
"P3212298.jpg",
"P3212299.jpg",
"P3212300.jpg",
"P3212301.jpg",
"P3212302.jpg",
"P3212303.jpg"
];

function _movie(elem){
// 画像ファイル事前キャッシュ
for(i=0; i<images[elem].length; i++){
obj_images[i] = new Image();
obj_images[i].src = images_url + elem + "/" + images[elem][i];
}
document.write("【アニメーション】<br />");
document.write("<img id='movie' width='320' height='240' src='" + obj_images[0].src + "' /><br />");
document.write("<input id='button_normal' type='button' value='等倍速' onclick='_play(66, this)' /> ");
document.write("<input id='button_slow' type='button' value='スロー' onclick='_play(200, this)' /> ");
document.write("<input id='button_top' type='button' value='先頭' onclick='_top()' /> ");
document.write("<input id='button_previous' type='button' value='戻る' onclick='_previous()' /> ");
document.write("<input id='button_next' type='button' value='進む' onclick='_next()' /> ");
document.write("<input id='button_bottom' type='button' value='最後' onclick='_bottom()' />");
document.write("<br /><br />");
}
function _play(interval, obj){
if(obj.value == "停止"){
clearInterval(tid);
if(obj.id == "button_normal"){
obj.value = "等倍速";
}else{
obj.value = "スロー";
}
_enable_buttons();
}else{
if(index == obj_images.length) index = 0;
_disable_buttons();
document.getElementById(obj.id).disabled = false;
obj.value = "停止";
tid = setInterval("_move('" + obj.id + "')", interval);
}
}
function _move(play_mode){
document.getElementById("movie").src = obj_images[index].src;
index++;
if(index == obj_images.length){
clearInterval(tid);
if(play_mode == "button_normal"){
document.getElementById(play_mode).value = "等倍速";
}else{
document.getElementById(play_mode).value = "スロー";
}
_enable_buttons();
}
}
function _top(){
document.getElementById("movie").src = obj_images[0].src;
index = 1;
}
function _previous(){
if(index > 1){
index--;
document.getElementById("movie").src = obj_images[index-1].src;
}
}
function _next(){
if(index < obj_images.length){
document.getElementById("movie").src = obj_images[index].src;
index++;
}
}
function _bottom(){
index = obj_images.length;
document.getElementById("movie").src = obj_images[index-1].src;
}
function _disable_buttons(){
document.getElementById("button_normal").disabled = true;
document.getElementById("button_slow").disabled = true;
document.getElementById("button_top").disabled = true;
document.getElementById("button_previous").disabled = true;
document.getElementById("button_next").disabled = true;
document.getElementById("button_bottom").disabled = true;
}
function _enable_buttons(){
document.getElementById("button_normal").disabled = false;
document.getElementById("button_slow").disabled = false;
document.getElementById("button_top").disabled = false;
document.getElementById("button_previous").disabled = false;
document.getElementById("button_next").disabled = false;
document.getElementById("button_bottom").disabled = false;
}

/* Preload icons */

function initRollOvers() {
if (!document.getElementById){
return;
}

var preLoads = new Array();
var allImages = document.getElementsByTagName('img');

for (var i = 0; i < allImages.length; i++) {        
if (allImages[i].className == 'rollover') {
var src = allImages[i].getAttribute('src');
var ftype = src.substring(src.lastIndexOf('.'), src.length);
var oSrc = src.replace(ftype, '_f'+ftype);

//-- スワップ元、スワップ先画像の登録
allImages[i].setAttribute('pSrc', src);
allImages[i].setAttribute('oSrc', oSrc);

//-- イメージのプリロード
preLoads[i] = new Image();
preLoads[i].src = oSrc;

//-- イベントの設定
allImages[i].onmouseover = function() {
    this.setAttribute('src', this.getAttribute('oSrc'));
}
allImages[i].onmouseout = function() {
    this.setAttribute('src', this.getAttribute('pSrc'));
}
}
}
}
 
function addOnload(func){
if ( typeof window.addEventListener != "undefined" ){
window.addEventListener( "load", func, false );
}else if ( typeof window.attachEvent != "undefined" ) {
window.attachEvent( "onload", func );
}else{
if ( window.onload != null ){
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
window[func]();
};
}else
window.onload = func;
}
}
