﻿/*
author:char
date:2009.12.1
*/
function playerPara(){
    this.pics=new Array();
    this.last=0;
    this.next=1;
    this.btncolor1="blue";
    this.btncolor2="green";
    this.fontcolor1="white";
    this.fontcolor2="red";
    this.width="0";
    this.height="0";
}
var para=new playerPara();
var f_timer=null;
function init(){
    document.getElementById("flash_d_content").style.width=para.width;
    document.getElementById("flash_d_content").style.height=para.height;
	for(var ii=0;ii<para.pics.length;ii++){
		var btn=document.getElementById("b_flash_"+(ii+1));
		btn.className="flash_btn";
		btn.innerHTML=ii+1;
		btn.style.backgroundColor=para.btncolor1;
		btn.style.color=para.fontcolor1;
		btn.onmouseover=function(){
			this.style.color=para.fontcolor2;
		}
		btn.onmouseout=function(){
			this.style.color=para.fontcolor1;
		}
		btn.onclick=function(){
			var count=this.id.substring(this.id.length-1,this.id.length);
			if(para.last==count)return;
			para.next=count;
			play();
		}
	}
	var img=document.getElementById("flash_img");
	img.src=para.pics[0][0];
	img.alt=para.pics[0][1];
	img.parentNode.title=para.pics[0][1];
	img.parentNode.href=para.pics[0][2];
	play();
}
function play(){
	clearTimeout(f_timer);
	if(para.last>0)document.getElementById("b_flash_"+para.last).style.backgroundColor=para.btncolor1;
	document.getElementById("b_flash_"+para.next).style.backgroundColor=para.btncolor2;
	var img=document.getElementById("flash_img");
	if(getOs()=="Firefox"||para.last==0){
		img.src=para.pics[para.next-1][0];
		img.alt=para.pics[para.next-1][1];
		img.parentNode.title=para.pics[para.next-1][1];
		img.parentNode.href=para.pics[para.next-1][2];
	}else{
		img.filters.revealTrans.Transition=Math.floor(Math.random()*23);
		img.filters.revealTrans.apply();
		img.src=para.pics[para.next-1][0];
		img.alt=para.pics[para.next-1][1];
		img.parentNode.title=para.pics[para.next-1][1];
		img.parentNode.href=para.pics[para.next-1][2];
		img.filters.revealTrans.play();
	}

	para.last=para.next;
	para.next++;
	if(para.next>para.pics.length)para.next=1;
	f_timer=setTimeout(play,3500);
}
function getOs()
{
    if(navigator.userAgent.indexOf("MSIE")>0) { 
         return "MSIE"; 
    }
    if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
         return "Firefox"; 
    }
    if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
         return "Safari"; 
    }
    if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
         return "Camino"; 
    }
    if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ 
         return "Gecko"; 
    } 
}
