function addEventListener(instance, eventName, listener) {
     var listenerFn = listener;
     if (instance.addEventListener) {
         instance.addEventListener(eventName, listenerFn, false);
     } else if (instance.attachEvent) {
         listenerFn = function() {
             listener(window.event);
         }
         instance.attachEvent("on" + eventName, listenerFn);
     } else {
     }
     return {
         instance: instance,
         name: eventName,
         listener: listenerFn
     };
}

var _time = 0;
var _timeout = null;
var _timeout2 = null;
var _timeout4 = null;
var _timeout5 = null;
var _preId = -1;
var _picid = 0;
var o = document.getElementById("full-image");
var picArray = document.getElementsByName("pic_a");
var picSmallArray = new Array();


//判断浏览器是否属于Mozilla,Sofari
var isIE = checkBrowse();

function checkBrowse(){
	if(window.XMLHttpRequest){
		return true;
	}else{
		return false;
	}
}
	
function genPiceSmallArray(){
	for (var i = 0; i < picArray.length; i++) {
		picSmallArray[i] = document.getElementById("pic_small_a_" + i);
		with({i:i}){
			addEventListener(picArray[i], "mouseout", picaction);
			addEventListener(picArray[i], "mouseover", clearMTimes);
			addEventListener(picSmallArray[i], "mouseout", picaction);
			addEventListener(picSmallArray[i], "mouseover", function (){ picaction2(i); });		
		}
	}
}

function picaction()
{
	try{		
		_time = _time + 0.1;
		
		o.style.opacity=_time;
		o.style.filter = 'alpha(opacity=' + _time*100 + ')';
		
		_timeout = window.setTimeout("picaction()",200);
		
		if(_time > 4){
			window.clearTimeout(_timeout2);
			window.clearTimeout(_timeout4);
			window.clearTimeout(_timeout5);
			_time = 0;
			_picid = (_picid+1)%picArray.length;		
			for(var i=0; i<picArray.length; i++){
				picArray[i].className="display_n";
				picSmallArray[i].className = "";
			}
			o.style.opacity=0;
			o.style.filter = 'alpha(opacity=0)';
			picArray[_picid].className="";
			picSmallArray[_picid].className = "selected";
		}
	}catch(e){}
}


function picaction2( id )
{
	try{		
		clearT();
		_timeout2 = window.setTimeout("picaction()",100);
		
		_time = 0;
		_picid = id;
		
		for(var i=0; i<picArray.length; i++){
			picArray[i].className="display_n";		
			picSmallArray[i].className = "";
		}
			o.style.opacity=0;
			o.style.filter = 'alpha(opacity=0)';
			picArray[_picid].className="";
			picSmallArray[_picid].className = "selected";
			
		window.clearTimeout(_timeout2);
	}catch(e){}
}

function picaction3()
{
	try{
		_time = _time + 0.1;
		o.style.opacity=_time;
		o.style.filter = 'alpha(opacity=' + _time*100 + ')';
		
		_timeout4 = window.setTimeout("picaction3()",100);
		
		if(_time > 1){
			window.clearTimeout(_timeout4);
		}
	}catch(e){}
}

function picaction4()
{
	try{	
		_time = _time + 0.1;
		o.style.opacity=_time;
		o.style.filter = 'alpha(opacity=' + _time*100 + ')';
		
		_timeout5 = window.setTimeout("picaction4()",100);
		
		if(_time > 1){
			window.clearTimeout(_timeout5);
		}
	}catch(e){}
}


function clearT(){
	try{
		clearAllTime();		
		_time = 0;
		o.style.opacity=0;
		o.style.filter = 'alpha(opacity=0)';
		picaction3();
	}catch(e){}
}

function clearAllTime(){
	try{
		window.clearTimeout(_timeout);
		window.clearTimeout(_timeout2);
		window.clearTimeout(_timeout4);
		window.clearTimeout(_timeout5);
	}catch(e){}
}

function clearMTimes(){	
	try{
		clearAllTime();
		picaction4();
	}catch(e){}
}



//首页底部特权信息滚动动画
var left_flag=0;
var right_flag=0;

var pic_array={
	$:function(objName){
		if(document.getElementById){
			return eval('document.getElementById("'+objName+'")')
		}else{
			return eval('document.all.'+objName)
		}
	},isIE:navigator.appVersion.indexOf("MSIE")!=-1?true:false,addEvent:function(l,i,I){
		if(l.attachEvent){
			l.attachEvent("on"+i,I)
		}else{
			l.addEventListener(i,I,false)
		}
	}
};


function ScrollPic(scrollContId,arrLeftId,arrRightId,dotListId)
{
	this.scrollContId=scrollContId;
	this.arrLeftId=arrLeftId;
	this.arrRightId=arrRightId;
	this.pageWidth=0;
	this.frameWidth=0;
	this.speed=10;
	this.space=10;
	this.end_Left = false;
	this.end_Right = false;
	var _scrollTimeObj = null;
	this.stripDiv=document.createElement("div");
	this.listDiv01=document.createElement("div");	
	if(!ScrollPic.childs){
		ScrollPic.childs=[]
	};
	this.ID=ScrollPic.childs.length;
	ScrollPic.childs.push(this);
	this.initialize=function(){
		if(!this.scrollContId){			
			return
		};
		this.scrollContDiv=pic_array.$(this.scrollContId);
		if(!this.scrollContDiv){			
			return
		};
		this.scrollContDiv.style.width=this.frameWidth+"px";
		this.scrollContDiv.style.overflow="hidden";
		this.listDiv01.innerHTML=this.scrollContDiv.innerHTML;
		this.scrollContDiv.innerHTML="";
		this.scrollContDiv.appendChild(this.stripDiv);
		this.stripDiv.appendChild(this.listDiv01);		
		this.stripDiv.style.overflow="hidden";
		this.stripDiv.style.zoom="1";
		this.stripDiv.style.width="1776px";
		this.listDiv01.style.cssFloat="left";				
		if(this.arrLeftId){
			this.arrLeftObj=pic_array.$(this.arrLeftId);
			if(this.arrLeftObj){
				pic_array.addEvent(this.arrLeftObj,"click",Function("ScrollPic.childs["+this.ID+"].rightMouseDown()"));		
				}
			};
			if(this.arrRightId){
				this.arrRightObj=pic_array.$(this.arrRightId);
				if(this.arrRightObj){
					pic_array.addEvent(this.arrRightObj,"click",Function("ScrollPic.childs["+this.ID+"].leftMouseDown()"));
				}
			};			
	};
	this.leftMouseDown=function(){
		if(left_flag==0){
			_scrollTimeObj=setInterval("ScrollPic.childs["+this.ID+"].moveLeft()",this.speed);
		}
	};
	this.rightMouseDown=function(){
		if(right_flag==0){
			_scrollTimeObj=setInterval("ScrollPic.childs["+this.ID+"].moveRight()",this.speed);	
		}
	};
	this.moveLeft=function(){
		left_flag = 1;
		this.scrollContDiv.scrollLeft+=this.space;
		if(this.scrollContDiv.scrollLeft>=this.frameWidth){
			$(this.arrRightId).style.display="none";
			$(this.arrLeftId).className="prev";
			$(this.arrLeftId).style.display="";						
			this.scrollContDiv.scrollLeft=888;
			left_flag = 0;
			clearInterval(_scrollTimeObj);
		}
	};
	this.moveRight=function(){
		right_flag = 1;
		this.scrollContDiv.scrollLeft-=this.space;
		if(this.scrollContDiv.scrollLeft<=0){
			$(this.arrLeftId).style.display="none";
			$(this.arrRightId).className="next";
			$(this.arrRightId).style.display="";
			this.scrollContDiv.scrollLeft=0;
			right_flag = 0;
			clearInterval(_scrollTimeObj);
		}		
	};	
};
