

ycn=window.ycnui||{
	
};
ycn.Common=new function (){
	this.lTrim=function (i){
		return i.replace(/^\s/,"");
		
	};
	this.rTrim=function (i){
		return i.replace(/\s*$/,"");
		
	};
	this.trim=function (i){
		return this.rTrim(this.lTrim(i));
		
	};
	this.getEl=function(i){
		if(!document.getElementById)return false;
		if(typeof i==="string"){
			return document.getElementById(i);
		}else{
			return i;
		}
	};
	this.getElByClassName=function (t,n,s,el){
		var el=(el)?el:document;
		var itm=el.getElementsByTagName(t);
		var num=1;
		for(i=0;i<itm.length;i++){
			if(itm[i].className===n&&s===num){
				return itm[i];
				
			}else if(itm[i].className===n){
				num++;
				
			}
		}
		return false;
		
	};	
	this.isIE6=function (){
		return navigator.userAgent.search('MSIE')>0&&navigator.userAgent.search('6')>0;
		
	}
	this.isIE=function (){
		return navigator.userAgent.search('MSIE')>0;
		
	}
	this.isOpera=function (){
		return navigator.userAgent.indexOf('Opera')>-1;
		
	}
	this.isMoz=function (){
		return navigator.userAgent.indexOf('Mozilla/5.')>-1;
		
	}
	this.setCookie=function (cn,cv,d,dm){
		var now=new Date();
		var expire=new Date();
		if(d==null||d==0)d=1;
		expire.setTime(now.getTime()+3600000*24*d);
		document.cookie=cn+"="+escape(cv)
		+";expires="+expire.toGMTString()
		+";domain="+dm;
		
	}
	this.deleteCookie=function (cn,dm){
		if(getCookie(name))
		{
			document.cookie=cn+"="+
			((domain)?"; domain="+dm:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
			
		}
	}
	this.getCookie=function (cn)
	{
		var dc=document.cookie;
		var prefix=cn+"=";
		var begin=dc.indexOf("; "+prefix);
		if(begin==-1)
		{
			begin=dc.indexOf(prefix);
			if(begin!=0)return null;
			
		}
		else 
		{
			begin+=2;
			
		}
		var end=document.cookie.indexOf(";",begin);
		if(end==-1)
		{
			end=dc.length;
			
		}
		return unescape(dc.substring(begin+prefix.length,end));
		
	}
};


ycn=window.ycn||{
	
};
ycn.Event={
	addEvent:function (obj,evType,fn){
		if(obj.addEventListener)
		{
			obj.addEventListener(evType,fn,false);
			return true;
			
		}
		else if(obj.attachEvent)
		{
			var r=obj.attachEvent("on"+evType,fn);
			ycn.EventCache.add(obj,evType,fn);
			return r;
			
		}
		else 
		{
			return false;
			
		}
	},
	removeEvent:function (obj,evType,fn){
		if(obj.removeEventListener){
			obj.removeEventListener(evType,fn,false);
			return true;
			
		}else if(obj.detachEvent){
			var r=obj.detachEvent("on"+evType,fn);
			return r;
			
		}else {
			return false;
			
		}
	},
	getEvent:function (e)
	{
		e=window.event||e;
		e.leftButton=false;
		if(e.srcElement==null&&e.target!=null)
		{
			e.srcElement=e.target;
			e.leftButton=(e.button==1);
			
		}
		else if(e.target==null&&e.srcElement!=null)
		{
			e.target=e.srcElement;
			e.leftButton=(e.button==0);
			
		}
		else if(e.srcElement!=null&&e.target!=null)
		{
			
		}
		else {
			return null
		}
		if(document.body&&document.documentElement)
		{
			e.mouseX=e.pageX||(e.clientX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));
			e.mouseY=e.pageY||(e.clientY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));
			
		}
		else 
		{
			e.mouseX=-1;
			e.mouseY=-1;
			
		}
		return e;
		
	},
	stopEvent:function (e)
	{
		if(e&&e.cancelBubble!=null)
		{
			e.cancelBubble=true;
			e.returnValue=false;
			
		}
		if(e&&e.stopPropagation&&e.preventDefault)
		{
			e.stopPropagation();
			e.preventDefault();
			
		}
		return false;
		
	}
};
ycn.EventCache=function ()
{
	var listEvents=[];
	return {
		listEvents:listEvents,add:function (node,sEventName,fHandler,bCapture){
			listEvents[listEvents.length]=arguments;
			
		},
		flush:function (){
			var i,item;
			for(i=listEvents.length-1;i>=0;i=i-1)
			{
				item=listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1],item[2],item[3]);
					
				};
				if(item[1].substring(0,2)!="on"){
					item[1]="on"+item[1];
					
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1],item[2]);
					
				};
				item[0][item[1]]=null;
				
			};
			
		}
	};
	
}();
ycn.Event.addEvent(window,"unload",ycn.EventCache.flush);
function error_handler(a,b,c)
{
	window.status=(c+"\n"+b+"\n\n"+a+"\n\n"+error_handler.caller);
	return true;
	
}









//Add sText  mod by duhu
slidePlayer.prototype.iNum;
slidePlayer.prototype.sWidth;
slidePlayer.prototype.sHeight;
slidePlayer.prototype.sSpeed;
slidePlayer.prototype.sStyle;
slidePlayer.prototype.sContainer;
slidePlayer.prototype.dPanel;
slidePlayer.prototype.nPanel;
slidePlayer.prototype.dImg;
slidePlayer.prototype.LinkTarget="_blank";
slidePlayer.prototype.iArr;
slidePlayer.prototype.lArr;
slidePlayer.prototype.sImg;
slidePlayer.prototype.sLink;
slidePlayer.prototype.bWidth;
slidePlayer.prototype.sTime;
slidePlayer.prototype.isStart;
slidePlayer.prototype.cNum;
slidePlayer.prototype.sText;

slidePlayer.prototype.initDisplayPanel=function (){
	var that=this;
	var sC=this.sContainer;
	var nP=this.nPanel;
	var ul,li,n,i,tmp;
	var cnText = new Array( "票","订","住","评","奖","荐" );		//注意，数组内元素不有任何重复，否则切换将会出错

	sC.style.display="block";
	sC.style.width=(this.sWidth+this.bWidth*2)+"px";
	sC.style.height=this.sHeight+"px";
	this.iArr=this.dImg.getElementsByTagName("img");
	this.lArr=this.dImg.getElementsByTagName("a");
	this.iNum=this.iArr.length;
	this.dPanel=document.createElement("div");

	var dP=this.dPanel;
	dP.className="slideDisplayPannel";
	this.sLink=document.createElement("a");
	this.sLink.setAttribute("href",this.lArr[0].href);
	this.sLink.setAttribute("target",this.LinkTarget);
	this.sImg=document.createElement("img");
	this.sImg.style.display="block";
	this.sImg.setAttribute("src",this.iArr[0].src);
	this.sImg.setAttribute("alt",this.iArr[0].alt);
	this.sImg.setAttribute("width",this.sWidth);
	this.sImg.setAttribute("height",this.sHeight);
	this.sLink.appendChild(this.sImg);

	//this.sText = document.createElement("span");
	//this.sText.setAttribute("id","sideTextBar");
	//this.sLink.appendChild(this.sText);
	//this.sText.innerHTML = this.iArr[0].alt;

	dP.style.width=this.sWidth+"px";
	dP.style.Height=this.sHeight+"px";
	nP.style.width=dP.style.width;
	dP.appendChild(this.sLink);
	//dP.appendChild(this.sText);
	var over=function (){
		that.isStart=false;
		
	};
	var out=function (){
		that.isStart=true;
		
	};
	var changeNum=function (e){
		var nb=(e)?e:window.event;
		if(nb.target){
			var ne=(nb.target.nodeType===3)?nb.target.parentNode:nb.target;
			
		}else {
			var ne=nb.srcElement;
			
		}
		//that.cNum=parseInt(ne.innerHTML)-1;
		that.cNum=cnText.join("").indexOf(ne.innerHTML);
		clearTimeout(that.sTime);
		that.changeSlideAction(that.cNum,that);
		that.cNum++;
		that.sTime=setTimeout(slidePlay,that.sSpeed);
		
	};
	ycn.Event.addEvent(dP,"mouseover",over);
	ycn.Event.addEvent(dP,"mouseout",out);
	ul=document.createElement("ul");
	ul.className="slideNumber";

	for(i=0;i<this.iNum;i++){
		li=document.createElement("li");
		if(i===0){
			li.className="curSlideNumber";			
		}
		n= document.createTextNode(cnText[i]);
		li.appendChild(n);
		ul.appendChild(li);

		ycn.Event.addEvent(li,"click",changeNum);
	}
	sC.insertBefore(dP,this.nPanel);
	nP.appendChild(ul);
	this.isStart=true;
	var slidePlay=function (){
		if(that.sTime)clearTimeout(that.sTime);
		var iN=that.iNum;
		var nT=that.nPanel.getElementsByTagName("li");
		var sI=that.sImg;
		var sL=that.sLink;
		if(that.isStart){
			if(that.cNum<iN){
				that.cNum++;
				
			}else {
				that.cNum=1;
				
			}
			that.changeSlideAction(that.cNum-1,that);
			that.sTime=setTimeout(slidePlay,that.sSpeed);
			
		}else {
			that.sTime=setTimeout(slidePlay,that.sSpeed);
			
		}
	};
	this.sTime=setTimeout(slidePlay,this.sSpeed);
	
}
slidePlayer.prototype.changeSlideAction=function (cn,o){
	var dP=o.dPanel;
	var iN=o.iNum;
	var nT=o.nPanel.getElementsByTagName("li");
	var transdivid="slideNextImgId"+Math.floor(Math.random()*1000);
	var nimgdiv=document.createElement("div");
	nimgdiv.id=transdivid
	nimgdiv.style.position="absolute";
	nimgdiv.style.top=0;
	nimgdiv.style.left=0;
	nimgdiv.style.zIndex=1;
	nimgdiv.style.filter="alpha(opacity=0)";
	nimgdiv.style.opacity=0;
	nimgdiv.style.MozOpacity=0;
	nimgdiv.style.width=o.sWidth+"px";
	nimgdiv.style.height=o.sHeight+"px";
	var nimg=document.createElement("img");
	nimg.setAttribute("src",o.iArr[cn].src);
	nimg.setAttribute("width",o.sWidth);
	nimg.setAttribute("height",o.sHeight);
	nimgdiv.appendChild(nimg);
	dP.appendChild(nimgdiv);
	var transdiv=document.getElementById(transdivid);
	if(o.isIE5()){
		o.sImg.setAttribute("src",o.iArr[cn].src);
		o.sImg.setAttribute("alt",o.iArr[cn].alt);
		//o.sLink.setAttribute("href",o.lArr[cn].href);
		//o.sText.innerHTML = o.iArr[cn].alt;
		dP.removeChild(transdiv);
		
	}else {
		var trans=0;
		var act=function (){
			if(t)clearTimeout(t);
			trans+=10;
			if(trans<=100){
				transdiv.style.filter="alpha(opacity="+trans+")";
				transdiv.style.opacity=trans/100;
				transdiv.style.MozOpacity=trans/100;
				var t=setTimeout(act,50);
				
			}else {
				o.sImg.setAttribute("src",o.iArr[cn].src);
				o.sImg.setAttribute("alt",o.iArr[cn].alt);
				o.sLink.setAttribute("href",o.lArr[cn].href);
				//o.sText.innerHTML = o.iArr[cn].alt;
				dP.removeChild(transdiv);
				
			}
		};
		var t=setTimeout(act,50);
		
	}
	for(i=0;i<iN;i++){
		if(i===(cn)){
			nT[i].className="curSlideNumber";
			
		}else {
			nT[i].className="";
			
		}
	}
	if(typeof(slidCallBack)!='undefined')slidCallBack.endChangeSlidePic(cn,o);
	
}
slidePlayer.prototype.isIE5=function (){
	return navigator.userAgent.toLowerCase().indexOf('msie 5.0')>0;
	
};
function slidePlayer(sc,dp,np,sw,sh,sp,bw,st){
	this.sContainer=ycn.Common.getEl(sc);
	this.dImg=ycn.Common.getEl(dp);
	this.nPanel=ycn.Common.getEl(np);
	this.sWidth=sw;
	this.sHeight=sh;
	this.sSpeed=sp*1000;
	this.bWidth=bw;
	this.cNum=1;
	this.initDisplayPanel();
	
}
