//展开收起<![CDATA[
function showHide(obj, idname)
{
	var divid = document.getElementById(idname);
	if (obj.className.indexOf("open")<0)
	{
		obj.className += " open";
		divid.style.display = "none";
		obj.innerHTML="展开";

	}
	else
	{
		obj.className = obj.className.replace("open","");
		divid.style.display = "block";
		obj.innerHTML="收起";
		
	}
}
//]]>
//摄影图集
//UI&UE Dept. mengjia
//090708
function resize_tiny_image(e)
{
	var max_w = 60;
	var max_h = 60;
	if(e.width <= max_w && e.height <= max_h)
	{
		return;
	}
	if((e.width / e.height) >= (max_w / max_h))
	{
		e.height = Math.floor(e.height * (max_w / e.width));
		e.width = max_w;
	}
	else
	{
		e.width = Math.floor(e.width * (max_h / e.height));
		e.height = max_h;
	}
}

var sina = {
	$ : function(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}},
	isIE : navigator.appVersion.indexOf("MSIE")!=-1?true:false,

	//Event
	addEvent : function(obj,eventType,func){if(obj.attachEvent){obj.attachEvent("on" + eventType,func);}else{obj.addEventListener(eventType,func,false)}},
	delEvent : function(obj,eventType,func){
		if(obj.detachEvent){obj.detachEvent("on" + eventType,func)}else{obj.removeEventListener(eventType,func,false)}
	},
	//Cookie
	readCookie : function(l){var i="",I=l+"=";if(document.cookie.length>0){var offset=document.cookie.indexOf(I);if(offset!=-1){offset+=I.length;var end=document.cookie.indexOf(";",offset);if(end==-1)end=document.cookie.length;i=document.cookie.substring(offset,end)}};return i},

	writeCookie : function(O,o,l,I){var i="",c="";if(l!=null){i=new Date((new Date).getTime()+l*3600000);i="; expires="+i.toGMTString()};if(I!=null){c=";domain="+I};document.cookie=O+"="+escape(o)+i+c},
	//Style
	readStyle:function(i,I){if(i.style[I]){return i.style[I]}else if(i.currentStyle){return i.currentStyle[I]}else if(document.defaultView&&document.defaultView.getComputedStyle){var l=document.defaultView.getComputedStyle(i,null);return l.getPropertyValue(I)}else{return null}},
	absPosition : function(obj,parentObj){ //位置
		var left = obj.offsetLeft;
		var top = obj.offsetTop;
		var tempObj = obj.offsetParent;
		var sss = "";
		try{
			while(tempObj.id!=document.body && tempObj.id!=document.documentElement && tempObj != parentObj && tempObj!= null){
				sss += tempObj.tagName + " , ";
				tempObj = tempObj.offsetParent;
				left += tempObj.offsetLeft;
				top += tempObj.offsetTop;
			};
		}catch(e){};
		return {left:left,top:top};
	}
};
sina.Step = function(){
	this.stepIndex = 0; //当前步数
	this.classBase = 'step_'; //class规则
	this.limit = 3; //步总数
	this.stepTime = 20; //步时长
	this.element = null; //html对象
	this._timeObj = null; //setInterval对象
	this._type = '+'; //步方向
};
sina.Step.prototype.action = function(type){
	if(!this.element){return};
	var tempThis = this;
	if(type=='+'){
		this._type = '+';
	}else{
		this._type = '-';
	};
	clearInterval(this._timeObj);
	this._timeObj = setInterval(function(){tempThis.nextStep()},this.stepTime);
};
sina.Step.prototype.nextStep = function(){
	if(this._type == '+'){
		this.stepIndex ++;
	}else{
		this.stepIndex --;
	};
	
	if(this.stepIndex <= 0){
		clearInterval(this._timeObj);
		this.stepIndex = 0;
		if(this._type == '-'){
			if(this.onfirst){this.onfirst()};
		};
	};
	if(this.stepIndex >= this.limit){
		clearInterval(this._timeObj);
		this.stepIndex = this.limit;
		if(this._type == '+'){
			if(this.onlast){this.onlast()};
		};
	};
	this.element.className = this.classBase + this.stepIndex;
	
	if(this.onstep){this.onstep()};
};

var coverLayer = {
	divObj : null,
	_coverTime : null,
	_coverRe : function(){//刷新遮盖层
		if(document.body.offsetHeight < document.documentElement.clientHeight){
			this.divObj.style.width = document.body.clientWidth + "px";
			this.divObj.style.height = document.documentElement.clientHeight + "px";
		}else{
			this.divObj.style.width = document.body.clientWidth + "px";
			this.divObj.style.height = document.body.clientHeight + "px";
		}
	},
	isIE : navigator.appVersion.indexOf("MSIE")!=-1?true:false,
	on : function(noSave){ //打开遮盖层
		if(this.divObj == null){
			this.divObj = document.createElement("div");
			this.divObj.style.zIndex = 10000;
			this.divObj.style.left = '0px';;
			this.divObj.style.top = '0px';;
			this.divObj.style.position = "absolute";
			this.divObj.style.backgroundColor = "#333";
			if(this.isIE){
				var tempFrame = document.createElement("iframe");
				tempFrame.style.filter = "Alpha(Opacity=0)";
				tempFrame.frameBorder=0;
				tempFrame.scrolling="no";
				tempFrame.style.width = "100%";
				tempFrame.style.height = "100%";
				this.divObj.appendChild(tempFrame);
				this.divObj.style.filter = "Alpha(Opacity=80)";
			}else{
				this.divObj.style.opacity = 0.8
			};
			document.body.appendChild(this.divObj);
		};
		if(document.body.offsetHeight < document.documentElement.clientHeight){
			this.divObj.style.width = document.body.clientWidth + "px";
			this.divObj.style.height = document.documentElement.clientHeight + "px";
		}else{
			this.divObj.style.width = document.body.clientWidth + "px";
			this.divObj.style.height = document.body.clientHeight + "px";
		};
		this.divObj.style.display = "block";
		clearInterval(this._coverTime);
		this._coverTime = setInterval("coverLayer._coverRe()",50);
	},
	off : function(noSave){ //关闭遮盖层
		if(this.divObj){this.divObj.style.display = "none"};
		clearInterval(this._coverTime);
	}
}

var epidiascope = {
	picTitleId : "d_picTit",
	picMemoId : "d_picIntro",
	picListId : "efpPicListCont",
	BigPicId : "d_BigPic",
	picArrLeftId : "efpLeftArea",
	picArrRightId : "efpRightArea",
	playButtonId : "ecbPlay",
	statusId : "ecpPlayStatus",
	mainBoxId : "efpBigPic",
	PVUrl_a : null,
	PVUrl_m : null,
	repetition : false, //循环播放
	prefetch : false, //预读图片
	autoPlay : true, //自动播放
	autoPlayTimeObj : null,
	timeSpeed : 5,
	maxWidth : 948,
	filmstrips : [],
	prefetchImg : [],
	selectedIndex : -1,
	previousPicList : {},
	nextPicList : {},
	add : function(s){
		this.filmstrips.push(s);
		if(this.prefetch){ //预载图片
			var tempImg = new Image();
			tempImg.src = s.src;
			this.prefetchImg.push(tempImg);
		};
	},
	init : function(){
		var tempWidth = 0;
		var tempThis = this;
		if(this.filmstrips.length * 110 < sina.$(this.picListId).offsetWidth){
			tempWidth = Math.round(sina.$(this.picListId).offsetWidth / 2 - this.filmstrips.length * 110/2);
		};

		var tempHTML = '<div style="width:32760px;padding-left:' + tempWidth + 'px">',i;
		for(i=0;i<this.filmstrips.length;i++){
			tempHTML += '<div class="pic" id="slide_' + i + '"><table cellspacing="0"><tr><td class="picCont"><table cellspacing="0"><tr><td class="pb_01"></td><td class="pb_02"></td><td class="pb_03"></td></tr><tr><td class="pb_04"></td><td><a href="javascript:epidiascope.select(' + i + ');" onclick="this.blur();"><img src="' + this.filmstrips[i].lowsrc + '" alt="' + this.filmstrips[i].title + '"  onload="resize_tiny_image(this);" oncontextmenu="event.returnValue=false;return false;" /></a></td><td class="pb_05"></td></tr><tr><td class="pb_06"></td><td class="pb_07"></td><td class="pb_08"></td></tr></table></td></tr></table></div>'
		};

		sina.$(this.picListId).innerHTML = tempHTML + "</div>";

		//
		sina.$(this.picArrLeftId).onclick = function(){epidiascope.previous();epidiascope.stop();};
		sina.$(this.picArrRightId).onclick = function(){epidiascope.next();epidiascope.stop();};
		
		
		//按钮
		this.buttonNext = new epidiascope.Button('ecbNext'); //下一页
		this.buttonPre = new epidiascope.Button('ecbPre'); //上一页
		this.buttonPlay = new epidiascope.Button('ecbPlay'); //播放暂停
		this.buttonFullScreen = new epidiascope.Button('ecbFullScreen'); //全屏
		this.buttonSpeed = new epidiascope.Button('ecbSpeed'); //速度
		
		this.buttonPre.element.onclick = function(){epidiascope.previous();epidiascope.stop();};
		this.buttonNext.element.onclick = function(){epidiascope.next();epidiascope.stop();};
		
		//
		this.BigImgBox = sina.$(this.BigPicId);


		//禁止右键
		this.BigImgBox.oncontextmenu = function(e){
			e = e?e:event;
			e.returnValue=false;
			return false;
		};
		this._imgLoad = function(){
			if(epidiascope.maxWidth == 0 ){return};
			if(this.width > epidiascope.maxWidth){
				this.width = epidiascope.maxWidth;
				//tempImg.style.height = Math.round(epidiascope.maxWidth * temp.height / temp.width) + 'px';
			};
			if(this.width < 948){
				sina.$('d_BigPic').style.padding = "10px 0 0";
			}else{
				sina.$('d_BigPic').style.padding = "0px";
			};
		};
		
		this.createImg(this.filmstrips[0].src);
		
		if(!sina.isIE){
			this.BigImgBox.style.position = 'relative';
			this.BigImgBox.style.overflow = "hidden";
			
		}else{
			
			clearInterval(this._ieButHeiTimeObj);
			this._ieButHeiTimeObj = setInterval(function(){tempThis.setPicButtonHeight()},300);
		};
		
		//设置下一图集
		var nextPics = sina.$('efpNextGroup').getElementsByTagName('a');
		
		sina.$('nextPicsBut').href = nextPics[0].href;
		sina.$('startnextPicsBut').href = nextPics[0].href;
		
		if(this.autoPlay){this.play()}else{this.stop()};

		if(this.onstart){this.onstart()};
		
		this.select(0);
	},
	createImg : function(src){
		if(this.ImgObj1){
			this.BigImgBox.removeChild(this.ImgObj1);
		};
		this.ImgObj1 = document.createElement("img");
		this.ImgObj1.onmousedown = function(){return false};
		this.ImgObj1.galleryImg = false;
		this.ImgObj1.onload = this._imgLoad;
		if(src){
			this.ImgObj1.src = src;
		};
		this.BigImgBox.appendChild(this.ImgObj1);
	},
	select : function(num,type){
		var tempThis = this;
		if(this.endSelect.status == 1){
			this.endSelect.close();
		};
		if(this.startSelect.status == 1){
			this.startSelect.close();
		};
		//if(num == this.selectedIndex){return};
		var i;
		if(num >= this.filmstrips.length || num < 0){return};
		
		sina.$(this.picTitleId).innerHTML = this.filmstrips[num].title;
		sina.$(this.picMemoId).innerHTML = '查看更多我的摄影作品请登录：<a href="'+this.filmstrips[num].exif+'">'+this.filmstrips[num].exif+'</a>';
		
		
		//隐藏loading图片1秒钟
		sina.$('d_BigPic').className = '';
		clearTimeout(this._hideBgTimeObj);
		this._hideBgTimeObj = setTimeout("sina.$('d_BigPic').className='loading'",500);
	
		this.createImg();
		
		this.ImgObj1.style.opacity = 0;
		
		if(this._timeOut){
			for(i=0;i<this._timeOut.length;i++){
				clearTimeout(this._timeOut[i]);
			};
		};
		this._timeOut = [];
		
		if(sina.isIE){
			this.ImgObj1.src = 'http://i0.sinaimg.cn/dy/deco/2008/0331/yocc080331img/news_mj_005.gif';
			this.ImgObj1.filters[0].Apply();
			
			this.ImgObj1.src = this.filmstrips[num].src;
			this.ImgObj1.filters[0].Play();
		}else{
			this.ImgObj1.src = this.filmstrips[num].src;
			for(i = 0;i <= 3;i ++){
				this._timeOut[i] = setTimeout("epidiascope.ImgObj1.style.opacity = " + i * 0.3,i * 100);
			};
			this._timeOut[i] = setTimeout("epidiascope.ImgObj1.style.opacity = 1;",4 * 100);
		};
		if(sina.$('showBigPic')){sina.$('showBigPic').href='/imageshow.asp?imgid='+this.filmstrips[num].orisrc+'&name='+this.filmstrips[num].title+'&user='+this.filmstrips[num].username}; //这里增加一行
		
		if(sina.$("slide_" + this.selectedIndex)){sina.$("slide_" + this.selectedIndex).className = "pic"};
		sina.$("slide_" + num).className = "picOn";
		this.selectedIndex = num;
		
		this.exif.setInfo('<a href="'+this.filmstrips[num].exif+'">'+this.filmstrips[num].exif+'</a>');

		this.picList.foucsTo(num + 1); //滚动

		sina.$("total").innerHTML = '(<span class="cC00">'+(num + 1) + "</span>/" + this.filmstrips.length + ')';
		if(this.autoPlay){this.play()};
		this.PVCount(type); //PV统计
		
		//预载下一张
		if(!this.prefetch && num < this.filmstrips.length - 1){ //未预载全部图片
			this.reLoad = new Image();
			this.reLoad.src = this.filmstrips[num + 1].src;
		};
		
	},
	setPicButtonHeight : function(){
		sina.$(this.picArrLeftId).style.height = sina.$(this.picArrRightId).style.height = sina.$(this.picArrLeftId).parentNode.offsetHeight + 'px';
	},
	PVCount : function(type){
		if(type=="auto"){
			if(this.PVUrl_a == null){return;};
		}else{
			if(this.PVUrl_m == null){return;};
		};
		if(!this.firstPage){ //第一次不请求PV
			this.firstPage = true;
			return;
		};
		//移除iframe
		if(this.PVFrame){
			this.PVFrame.parentNode.removeChild(this.PVFrame);
		};
		//create new iframe
		this.PVFrame = document.createElement("iframe");
		//style="height:0px;width:1px;overflow:hidden;"
		this.PVFrame.style.height = "0px";
		this.PVFrame.style.width = "1px";
		this.PVFrame.style.overflow = "hidden";
		this.PVFrame.frameBorder = 0;
		sina.$(this.mainBoxId).appendChild(this.PVFrame);
		this.PVFrame.src = (type=="auto"?this.PVUrl_a:this.PVUrl_m) + "?r=" + Math.random();
		//set page
		if(type!="auto"){this.setPageInfo(this.selectedIndex)};
	},
	setPageInfo : function(num){
		var href = window.location.href;
		url = href.match(/^(.*?)#.*?/);
		if(url){
			url = url[1];
		}else{
			url = href;
		};
		url += '#p='+Math.round(num+1);
		window.location.href = url;
	},
	next : function(type){
		var tempNum = this.selectedIndex + 1;
		if(tempNum >= this.filmstrips.length){
			if(this.repetition){ //循环播放
				tempNum = 0;
			}else{
				this.endSelect.open(); //选择
				return;
			};
		};
		
		//自动播放，判断下张图片是否载入
		if(type=="auto"){
			var testImg = new Image();
			testImg.src = this.filmstrips[tempNum].src;
			if(!testImg.complete){
				return;
			};
		};
		
		this.select(tempNum,type);
	},
	previous : function(){
		var tempNum = this.selectedIndex - 1;
		
		if(tempNum < 0){ //循环播放
			if(this.repetition){
				tempNum = this.filmstrips.length - 1
			}else{
				this.startSelect.open(); //选择
				return;
			};
		};
		this.select(tempNum);
	},
	play : function(){
		clearInterval(this.autoPlayTimeObj);
		this.autoPlayTimeObj = setInterval("epidiascope.next('auto')",this.timeSpeed*1000);
		sina.$(this.playButtonId).onclick = function(){epidiascope.stop()};
		sina.$(this.statusId).className = "stop";
		sina.$(this.statusId).title = "暂停";
		this.autoPlay = true;
	},
	stop : function(){
		clearInterval(this.autoPlayTimeObj);
		sina.$(this.playButtonId).onclick = function(){epidiascope.play();epidiascope.next('auto');};
		sina.$(this.statusId).className = "play";
		sina.$(this.statusId).title = "播放";
		this.autoPlay = false;
	},
	clickComment : function(){ //评论
		var thisFilmstrip = this.filmstrips[this.selectedIndex];
		if(thisFilmstrip.comment){window.open(thisFilmstrip.comment)};
	},
	rePlay : function(){ //重新播放
		if(this.endSelect.status == 1){this.endSelect.close()};
		if(this.startSelect.status == 1){this.startSelect.close()};
		this.autoPlay = true;
		this.select(0);
	}
};

epidiascope.speedBar = { //速度条
	boxId : "SpeedBox", //容器id
	contId : "SpeedCont", //内容id
	slideId : "SpeedSlide", //滑区id
	slideButtonId : "SpeedNonius", //滑块id
	infoId : "ecbSpeedInfo", //信息id
	grades : 10, //等级数
	grade : 5, //等级
	_slideHeight : 112, //滑区高度
	_slideButtonHeight : 9, //滑块高度
	_baseTop : 4, //top基数
	_marginTop : 0,
	_mouseDisparity : 0,
	_showStep : 0,
	_showType : 'close',
	_showTimeObj : null,
	init : function(){
		var tempThis = this;
		this._marginTop = Math.round(this._slideHeight/this.grades * (this.grade - 1));
		
		sina.$(this.slideButtonId).style.top = this._marginTop + this._baseTop + "px";
		sina.$(this.infoId).innerHTML = this.grade + "秒";
		
		//动画效果
		this.step = new sina.Step();
		this.step.element = sina.$(this.contId);
		this.step.limit = 6;
		this.step.stepTime = 20;
		this.step.classBase = 'speedStep_';
		this.step.onfirst = function(){
			epidiascope.buttonSpeed.setStatus('ok');
			sina.$(epidiascope.speedBar.boxId).style.display = 'none';
		};
		
		sina.$(this.slideId).onselectstart = function(){return false};
		sina.$(this.slideButtonId).onmousedown = function(e){tempThis.mouseDown(e);return false};
		sina.$(this.slideId).onmousedown = function(e){tempThis.slideClick(e);return false};
		
		epidiascope.buttonSpeed.element.onmousedown = function(){tempThis.show();return false;};
		epidiascope.buttonSpeed.element.onselectstart = function(){return false};
	},
	show : function(){
		if(this._showType == 'close'){
			this.open();
		}else{
			this.close();
		};
	},
	open : function(){
		var tempThis = this;
		this._showType = 'open';
		var tempMouseDown = document.onmousedown;
		var mousedown = function(e){
			e = window.event?event:e;
			if(e.stopPropagation){ //阻止冒泡
				e.stopPropagation();
			}else{
				window.event.cancelBubble = true;
			};
			var eventObj = e.target?e.target:e.srcElement;
			
			while(eventObj != sina.$(tempThis.boxId) && eventObj != epidiascope.buttonSpeed.element){
				if(eventObj.parentNode){
					eventObj = eventObj.parentNode;
				}else{
					break;
				};
			};
			if(eventObj == sina.$(tempThis.boxId) || eventObj == epidiascope.buttonSpeed.element){
				return;
			}else{
				tempThis.close();
			};
			sina.delEvent(document,'mousedown',mousedown);
		};
		sina.addEvent(document,'mousedown',mousedown);
		
		epidiascope.buttonSpeed.setStatus('down');
		sina.$(this.boxId).style.display = 'block';
		
		this.step.action('+');
	},
	close : function(){
		var tempThis = this;
		this._showType = 'close';
		epidiascope.buttonSpeed.setStatus('ok');
		this.step.action('-');
	},
	slideClick : function(e){
		e = window.event?event:e;
		var Y = e.layerY?e.layerY:e.offsetY;
		if(!Y){return};
		
		this._marginTop = Y - Math.round(this._slideButtonHeight/2);
		if(this._marginTop<0){this._marginTop=0};
		this.grade = Math.round(this._marginTop/(this._slideHeight/this.grades) + 1);
		sina.$(this.slideButtonId).style.top = this._marginTop + this._baseTop + "px";
		sina.$(this.infoId).innerHTML = this.grade + "秒";
		
		if(this.onend){this.onend()};
	},
	setGrade : function(num){
		this.grade = num;
		this._marginTop = Math.round(this._slideHeight/this.grades * (this.grade - 1));
		
		sina.$(this.slideButtonId).style.top = this._marginTop + this._baseTop + "px";
		sina.$(this.infoId).innerHTML = this.grade + "秒";
		sina.writeCookie("eSp",this.grade,720);
	},
	mouseDown : function(e){
		var tempThis = this;
		e = window.event?window.event:e;
		this._mouseDisparity = (e.pageY?e.pageY:e.clientY) - this._marginTop;
		document.onmousemove = function(e){tempThis.mouseOver(e)};
		document.onmouseup = function(){tempThis.mouseEnd()};
	},
	mouseOver : function(e){
		e = window.event?window.event:e;
		this._marginTop = (e.pageY?e.pageY:e.clientY) - this._mouseDisparity;
		if(this._marginTop > (this._slideHeight - this._slideButtonHeight)){this._marginTop = this._slideHeight - this._slideButtonHeight};
		if(this._marginTop < 0){this._marginTop = 0;};
		sina.$(this.slideButtonId).style.top = this._marginTop + this._baseTop + "px";

		this.grade = Math.round(this._marginTop/(this._slideHeight/this.grades) + 1);

		if(this.onmover){this.onmover()};
	},
	mouseEnd : function(){
		if(this.onend){this.onend()};
		
		document.onmousemove = null;
		document.onmouseup = null;
	},
	onmover : function(){
		sina.$(this.infoId).innerHTML = this.grade + "秒";
	},
	onend : function(){
		sina.writeCookie("eSp",this.grade,720);
		epidiascope.timeSpeed = this.grade;
		if(epidiascope.autoPlay){epidiascope.play()};
	}
};

epidiascope.exif = {
	closeId : 'peClose',
	contId : 'peInfo',
	boxId : 'picExif',
	status : 'loading',
	init : function(){
		var tempThis = this;
		
		//动画效果
		this.step = new sina.Step();
		this.step.element = sina.$(this.boxId);
		this.step.limit = 3;
		this.step.stepTime = 20;
		this.step.classBase = 'exifStep_';
		
		sina.$(this.closeId).onclick = function(){tempThis.chkClick()};
		
		if(sina.readCookie('ePe') == '0'){
			this.status = 'close';
			this.close();
		}else{
			this.status = 'ok';
			this.open();
		}
	},
	chkClick : function(){
		if(this.status == 'close'){
			this.open();
			this.status = 'ok';
			sina.writeCookie('ePe','1',-1);
		}else{
			this.close();
			this.status = 'close';
			sina.writeCookie('ePe','0',24*7);
		};
	},
	setInfo : function(str){
		sina.$(this.contId).innerHTML = '<a href="'+str+'" target=_blank title="查看更多我的摄影作品请登录'+str+'">'+str+'</a>';
		if(this.status != 'ok'){return;}//已经手动改变过状态
		if(str == ''){
			this.close();
		}else{
			this.open();
		};
	},
	close : function(){
		this.step.action('+');
	},
	open : function(){
		this.step.action('-');
	}
};

epidiascope.picList = { //列表滚动
	leftArrId : "efpListLeftArr",
	rightArrId : "efpListRightArr",
	picListId : "efpPicListCont",
	timeoutObj : null,
	pageWidth : 110,
	totalWidth : 0,
	offsetWidth : 0,
	lock : false,
	init : function(){
		sina.$(this.rightArrId).onmousedown = function(){epidiascope.picList.leftMouseDown()};
		sina.$(this.rightArrId).onmouseout = function(){epidiascope.picList.leftEnd("out");this.className='';};
		sina.$(this.rightArrId).onmouseup = function(){epidiascope.picList.leftEnd("up")};
		sina.$(this.leftArrId).onmousedown = function(){epidiascope.picList.rightMouseDown()};
		sina.$(this.leftArrId).onmouseout = function(){epidiascope.picList.rightEnd("out");this.className='';};
		sina.$(this.leftArrId).onmouseup = function(){epidiascope.picList.rightEnd("up")};
		this.totalWidth = epidiascope.filmstrips.length * this.pageWidth;
		this.offsetWidth = sina.$(this.picListId).offsetWidth;

	},
	leftMouseDown : function(){
		if(this.lock){return};
		this.lock = true;
		this.timeoutObj = setInterval("epidiascope.picList.moveLeft()",10);
	},
	rightMouseDown : function(){
		if(this.lock){return};
		this.lock = true;
		this.timeoutObj = setInterval("epidiascope.picList.moveRight()",10);
	},
	moveLeft : function(){
		if(sina.$(this.picListId).scrollLeft + 10 > this.totalWidth - this.offsetWidth){
			sina.$(this.picListId).scrollLeft = this.totalWidth - this.offsetWidth;
			this.leftEnd();
		}else{
			sina.$(this.picListId).scrollLeft += 10;
		};
	},
	moveRight : function(){
		sina.$(this.picListId).scrollLeft -= 10;
		if(sina.$(this.picListId).scrollLeft == 0){this.rightEnd()};
	},
	leftEnd : function(type){
		if(type=="out"){if(!this.lock){return}};
		clearInterval(this.timeoutObj);
		this.lock = false;
		this.move(200);
	},
	rightEnd : function(type){
		if(type=="out"){if(!this.lock){return}};
		clearInterval(this.timeoutObj);
		this.lock = false;
		this.move(-200);
	},
	foucsTo : function(num){
		if(this.lock){return};
		this.lock = true;

		var _moveWidth = Math.round(num * this.pageWidth - this.offsetWidth / 2) - 33;
		
		_moveWidth -= sina.$(this.picListId).scrollLeft;

		if(sina.$(this.picListId).scrollLeft + _moveWidth < 0){
			_moveWidth = - sina.$(this.picListId).scrollLeft;
		};
		if(sina.$(this.picListId).scrollLeft + _moveWidth >= this.totalWidth - this.offsetWidth){
			_moveWidth = this.totalWidth - this.offsetWidth - sina.$(this.picListId).scrollLeft;
		};
		
		this.move(_moveWidth);
	},
	move : function(num){
		var thisMove = num/4;
		if(Math.abs(thisMove)<1 && thisMove!=0){
			thisMove = (thisMove>=0?1:-1)*1;
		}else{
			thisMove = Math.round(thisMove);
		};

		var temp = sina.$(this.picListId).scrollLeft + thisMove;
		if(temp <= 0){sina.$(this.picListId).scrollLeft = 0;this.lock = false;return;}
		if(temp >= this.totalWidth - this.offsetWidth){sina.$(this.picListId).scrollLeft = this.totalWidth - this.offsetWidth;this.lock = false;return;}
		sina.$(this.picListId).scrollLeft += thisMove;
		num -= thisMove;
		if(Math.abs(num) <= 1){this.lock = false;return;}else{
			setTimeout("epidiascope.picList.move(" + num + ")",10)
		}
	}
};
//键盘控制
epidiascope.keyboard = {
	init : function(){
		var tempThis = this;
		sina.addEvent(document,'keydown',function(e){tempThis.keyDown(e)});
		
		this.step = new sina.Step();
		this.step.element = sina.$('efpClew');
		this.step.limit = 5;
		this.step.stepTime = 30;
		this.step.classBase = 'efpClewStep_';
		
		if(!this.closeObj){
			this.closeObj = document.createElement('span');
			this.closeObj.style.display = 'block';
			this.closeObj.id = 'efpClewClose';
			sina.$('efpClew').appendChild(this.closeObj);
			
			this.closeObj.onclick = function(){tempThis.clewClose()};
		};
		
		//提示次数
		this.clewNum = parseInt(sina.readCookie('eCn'));
		if(isNaN(this.clewNum)){this.clewNum = 0};
		if(this.clewNum<5){
			//this.clewNum ++;
			//sina.writeCookie('eCn',this.clewNum,24*7);
			this.clewOpen();
		};
	},
	clewClose : function(){
		this.step.action('-');
		sina.writeCookie('eCn',6,24*7);
	},
	clewOpen : function(){
		this.step.action('+');
	},
	keyDown : function(e){
		e = window.event?event:e;
		var obj = e.target?e.target:e.srcElement;
		if(obj.tagName == 'INPUT' || obj.tagName == 'SELECT' || obj.tagName == 'TEXTAREA'){
			if(e.stopPropagation){ //阻止冒泡
				e.stopPropagation();
			}else{
				window.event.cancelBubble = true;
			};
			return;
		};
		if(e.keyCode == 39){
			epidiascope.next();
		};
		if(e.keyCode == 37){
			epidiascope.previous();
		};
	}
};

//结束选择
epidiascope.endSelect = {
	endSelectId : "endSelect",
	closeId : "endSelClose",
	rePlayButId : "rePlayBut",
	status : 0, //1:open  0:close
	open : function(){
		this.status = 1;
		sina.$(this.endSelectId).style.display = "block";

		sina.$(this.endSelectId).style.left = Math.round((sina.$(epidiascope.mainBoxId).offsetWidth - sina.$(this.endSelectId).offsetWidth)/2) + "px";
		sina.$(this.endSelectId).style.top = Math.round((sina.$(epidiascope.mainBoxId).offsetHeight - sina.$(this.endSelectId).offsetHeight)/2) + "px";
		epidiascope.stop();
		sina.$(epidiascope.playButtonId).onclick = function(){epidiascope.rePlay()};
		sina.$(this.closeId).onclick = function(){epidiascope.endSelect.close()};
		sina.$(this.rePlayButId).onclick = function(){epidiascope.rePlay()};
	},
	close : function(){
		this.status = 0;
		sina.$(this.endSelectId).style.display = "none";
	}
};

//到第一页
epidiascope.startSelect = {
	startSelectId : "startSelect",
	closeId : "startSelClose",
	rePlayButId : "startrePlayBut",
	status : 0, //1:open  0:close
	open : function(){
		this.status = 1;
		sina.$(this.startSelectId).style.display = "block";

		sina.$(this.startSelectId).style.left = Math.round((sina.$(epidiascope.mainBoxId).offsetWidth - sina.$(this.startSelectId).offsetWidth)/2) + "px";
		sina.$(this.startSelectId).style.top = Math.round((sina.$(epidiascope.mainBoxId).offsetHeight - sina.$(this.startSelectId).offsetHeight)/2) + "px";
		epidiascope.stop();
		sina.$(epidiascope.playButtonId).onclick = function(){epidiascope.rePlay()};
		sina.$(this.closeId).onclick = function(){epidiascope.startSelect.close()};
		sina.$(this.rePlayButId).onclick = function(){epidiascope.rePlay()};
	},
	close : function(){
		this.status = 0;
		sina.$(this.startSelectId).style.display = "none";
	}
};


epidiascope.onstart = function(){
	try{document.execCommand('BackgroundImageCache', false, true);}catch(e){};

	//速度条
	epidiascope.speedBar.grade = parseInt(sina.readCookie("eSp"));
	if(isNaN(epidiascope.speedBar.grade)){epidiascope.speedBar.grade = 5};
	epidiascope.speedBar.init();
	epidiascope.speedBar.onend();
		
	//图片列表滚动
	epidiascope.picList.init();
	
	//按键控制
	epidiascope.keyboard.init();
	
	//图片信息
	epidiascope.exif.init();
};
//按钮构造函数
epidiascope.Button = function(id){
	this.status = 'ok';
	this.id = id;
	this.init();
};
epidiascope.Button.prototype.init = function(){
	if(!sina.$(this.id)){return};
	var tempThis = this;
	this.element = sina.$(this.id);
	this.classNameNum = '';
	if(this.element.offsetWidth == 43){
		this.classNameNum = '1';
	};
	this.mouseStatus = 'out';
	
	this.bgDiv = document.createElement('div');
	this.bgDiv.className = 'buttonBg' + this.classNameNum;
	this.element.parentNode.style.position = 'relative';
	this.element.style.position = 'relative';
	this.element.style.zIndex = '5';
	this.element.parentNode.appendChild(this.bgDiv);
	this.bgDiv.style.top = this.element.offsetTop - 6 + 'px';
	this.bgDiv.style.left = this.element.offsetLeft - 6 + 'px';
	
	//动画效果
	this.step = new sina.Step();
	this.step.element = this.bgDiv;
	this.step.limit = 3;
	this.step.stepTime = 30;
	this.step.classBase = 'buttonBg' + this.classNameNum + ' bBg' + this.classNameNum + 'S_';
	
	sina.addEvent(this.element,'mouseover',function(){tempThis.mouseover()});
	sina.addEvent(this.element,'mouseout',function(){tempThis.mouseout()});
	sina.addEvent(this.element,'mousedown',function(){tempThis.mousedown()});
	sina.addEvent(this.element,'mouseup',function(){tempThis.mouseup()});
};
epidiascope.Button.prototype.mouseover = function(){
	this.mouseStatus = 'in';
	if(this.status != 'down'){
		this.element.className = "hover";
		this.step.action('+');
	};
};
epidiascope.Button.prototype.mouseout = function(){
	this.mouseStatus = 'out';
	if(this.status != 'down'){
		this.element.className = "";
		this.step.action('-');
	};
};
epidiascope.Button.prototype.mouseup = function(){
	if(this.status == 'down'){return;}
	this.element.className = "hover";
};
epidiascope.Button.prototype.mousedown = function(){
	if(this.status == 'down'){return;}
	this.element.className = "active";
};
epidiascope.Button.prototype.setStatus = function(status){
	switch(status){
		case 'ok':
			this.status = 'ok';
			this.element.className = "";
			if(this.mouseStatus == 'in'){
				this.step.action('+');
			}else{
				this.step.action('-');
			};
			break;
		case 'down':
			this.status = 'down';
			this.step.action('-');
			this.element.className = "active";
			break;
	};
};
// -------------------------------------------------------------------------------------

function DrawImage(ImgD,iwidth,iheight){
	var image=new Image();
	if(!iwidth)iwidth = 60;
	if(!iheight)iheight = 60; //定义允许高度，当宽度大于这个值时等比例缩小
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		var flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){ 
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}else{
			if(image.height>iheight){ 
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height; 
			}else{
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
		}
	}
};

//模拟Select mengjia 2008.12.30
function DivSelect(O,l,I){var C=this;C.id=O;C.divId=l;C.divClassName=I;C.selectObj=sina.$(C.id);if(!C.selectObj){return};var o=C;C.status="close";C.parentObj=C.selectObj.parentNode;while(sina.readStyle(C.parentObj,"display")!="block"){if(C.parentObj.parentNode){C.parentObj=C.parentObj.parentNode}else{break}};C.parentObj.style.position="relative";C.selectObjWidth=C.selectObj.offsetWidth;C.selectObjHeight=C.selectObj.offsetHeight;C.selectPosition=sina.absPosition(C.selectObj,C.parentObj);C.selectObj.style.visibility="hidden";C.divObj=document.createElement("div");C.divObj.id=C.divId;if(C.divClassName){C.divObj.className=C.divClassName};C.parentObj.appendChild(C.divObj);C.divObj.style.width=C.selectObjWidth+"px";C.divObj.style.position="absolute";C.divObj.style.left=C.selectPosition.left+"px";C.divObj.style.top=C.selectPosition.top+"px";C.divObj.onclick=function(){o.click()};C.divObj_count=document.createElement("div");C.divObj.appendChild(C.divObj_count);C.divObj_count.className="ds_cont";C.divObj_title=document.createElement("div");C.divObj_count.appendChild(C.divObj_title);C.divObj_title.className="ds_title";C.divObj_button=document.createElement("div");C.divObj_count.appendChild(C.divObj_button);C.divObj_button.className="ds_button";C.divObj_list=document.createElement("div");C.divObj.appendChild(C.divObj_list);C.divObj_list.className="ds_list";C.divObj_list.style.display="none";C.divObj_listCont=document.createElement("div");C.divObj_list.appendChild(C.divObj_listCont);C.divObj_listCont.className="dsl_cont";C.list=[];var i;for(var c=0;c<C.selectObj.options.length;c++){i=document.createElement("p");C.list.push(i);C.divObj_listCont.appendChild(i);i.innerHTML=C.selectObj.options[c].innerHTML;if(C.selectObj.selectedIndex==c){C.divObj_title.innerHTML=i.innerHTML};i.onmouseover=function(){this.className="selected"};i.onmouseout=function(){this.className=""};i.onclick=function(){o.select(this.innerHTML)}};C.select=function(i){var l=this;for(var I=0;I<l.selectObj.options.length;I++){if(l.selectObj.options[I].innerHTML==i){l.selectObj.selectedIndex=I;if(l.selectObj.onchange){l.selectObj.onchange()};l.divObj_title.innerHTML=i;break}}};C.clickClose=function(I){var i=I.target?I.target:event.srcElement;do{if(i==o.divObj){return};if(i.tagName=="BODY"){break};i=i.parentNode}while(i.parentNode);o.close()};C.open=function(){var i=this;i.divObj_list.style.display="block";i.status="open";sina.addEvent(document,"click",i.clickClose)};C.close=function(){var i=this;i.divObj_list.style.display="none";i.status="close";sina.delEvent(document,"click",i.clickClose)};C.click=function(){var i=this;if(i.status=="open"){i.close()}else{i.open()}}};

//表情显示和插入操作
var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

var postSubmited = false;
var smdiv = new Array();
var codecount = '-1';
var codehtml = new Array();

var jsmenu = new Array();
var ctrlobjclassName;
jsmenu['active'] = new Array();
jsmenu['timer'] = new Array();
jsmenu['iframe'] = new Array();

var attachimg = '';
//*******************
//等同Discuz中 $()函数
//*******************
function myphoto_$(id) {
	return document.getElementById(id);
}

//*******************
//
//*******************
function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}
//*******************
//聚焦
//*******************
function checkFocus() {
	var obj = myphoto_$('ajax_post_form').message ;
	if(!obj.hasfocus) {
		obj.focus();
	}
}


function ebygum(eventobj) {
	if(!eventobj || is_ie) {
		window.event.cancelBubble = true;
		return window.event;
	} else {
		if(eventobj.target.type == 'submit') {
			eventobj.target.form.submit();
		}
		eventobj.stopPropagation();
		return eventobj;
	}
}

function initCtrl(ctrlobj, click, duration, timeout, layer) {
	if(ctrlobj && !ctrlobj.initialized) {
		ctrlobj.initialized = true;
		ctrlobj.unselectable = true;

		ctrlobj.outfunc = typeof ctrlobj.onmouseout == 'function' ? ctrlobj.onmouseout : null;
		ctrlobj.onmouseout = function() {
			if(this.outfunc) this.outfunc();
			if(duration < 3) jsmenu['timer'][ctrlobj.id] = setTimeout('hideMenu(' + layer + ')', timeout);
		}

		if(click && duration) {
			ctrlobj.clickfunc = typeof ctrlobj.onclick == 'function' ? ctrlobj.onclick : null;
			ctrlobj.onclick = function (e) {
				doane(e);
				if(jsmenu['active'][layer] == null || jsmenu['active'][layer].ctrlkey != this.id) {
					if(this.clickfunc) this.clickfunc();
					else showMenu(this.id, true);
				} else {
					hideMenu(layer);
				}
			}
		}

		ctrlobj.overfunc = typeof ctrlobj.onmouseover == 'function' ? ctrlobj.onmouseover : null;
		ctrlobj.onmouseover = function(e) {
			doane(e);
			if(this.overfunc) this.overfunc();
			if(click) {
				clearTimeout(jsmenu['timer'][this.id]);
			} else {
				for(var id in jsmenu['timer']) {
					if(jsmenu['timer'][id]) clearTimeout(jsmenu['timer'][id]);
				}
			}
		}
	}
}

function initMenu(ctrlid, menuobj, duration, timeout, layer) {
	if(menuobj && !menuobj.initialized) {
		menuobj.initialized = true;
		menuobj.ctrlkey = ctrlid;
		menuobj.onclick = ebygum;
		menuobj.style.position = 'absolute';
		if(duration < 3) {
			if(duration > 1) {
				menuobj.onmouseover = function() {
					clearTimeout(jsmenu['timer'][ctrlid]);
				}
			}
			if(duration != 1) {
				menuobj.onmouseout = function() {
					jsmenu['timer'][ctrlid] = setTimeout('hideMenu(' + layer + ')', timeout);
				}
			}
		}
		menuobj.style.zIndex = 50;
		if(is_ie) {
			menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#CCCCCC,strength=2)";
		}
	}
}
//*******************
//隐藏浮动菜单
//*******************
function hideMenu(layer) {
	if(isUndefined(layer)) layer = 0;
	if(jsmenu['active'][layer]) {
		try {
			myphoto_$(jsmenu['active'][layer].ctrlkey).className = ctrlobjclassName;
		} catch(e) {}
		clearTimeout(jsmenu['timer'][jsmenu['active'][layer].ctrlkey]);
		jsmenu['active'][layer].style.display = 'none';
		if(is_ie && is_ie < 7 && jsmenu['iframe'][layer]) {
			jsmenu['iframe'][layer].style.display = 'none';
		}
		jsmenu['active'][layer] = null;
	}
}
//*******************
//位置
//*******************
function fetchOffset(obj) {
	var left_offset = obj.offsetLeft;
	var top_offset = obj.offsetTop;
	while((obj = obj.offsetParent) != null) {
		left_offset += obj.offsetLeft;
		top_offset += obj.offsetTop;
	}
	return { 'left' : left_offset, 'top' : top_offset };
}
//*******************
//显示浮动菜单
//*******************
function showMenu(ctrlid, click, offset, duration, timeout, layer, showid, maxh) {
	e = window.event ? window.event : showMenu.caller.arguments[0];
	var ctrlobj = myphoto_$(ctrlid);
	if(!ctrlobj) return;
	if(isUndefined(click)) click = false;
	if(isUndefined(offset)) offset = 0;
	if(isUndefined(duration)) duration = 2;
	if(isUndefined(timeout)) timeout = 500;
	if(isUndefined(layer)) layer = 0;
	if(isUndefined(showid)) showid = ctrlid;
	var showobj = myphoto_$(showid);
	var menuobj = myphoto_$(showid + '_menu');
	if(!showobj|| !menuobj) return;
	if(isUndefined(maxh)) maxh = 400;


	hideMenu(layer);

	for(var id in jsmenu['timer']) {
		if(jsmenu['timer'][id]) clearTimeout(jsmenu['timer'][id]);
	}

	initCtrl(ctrlobj, click, duration, timeout, layer);
	ctrlobjclassName = ctrlobj.className;
	ctrlobj.className += ' hover';
	initMenu(ctrlid, menuobj, duration, timeout, layer);
	menuobj.style.display = '';
	if(!is_opera) {
		menuobj.style.clip = 'rect(auto, auto, auto, auto)';
	}

	setMenuPosition(showid, offset);

	if(is_ie && is_ie < 7) {
		if(!jsmenu['iframe'][layer]) {
			var iframe = document.createElement('iframe');
			iframe.style.display = 'none';
			iframe.style.position = 'absolute';
			iframe.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			myphoto_$('append_parent') ? myphoto_$('append_parent').appendChild(iframe) : menuobj.parentNode.appendChild(iframe);
			jsmenu['iframe'][layer] = iframe;
		}
		jsmenu['iframe'][layer].style.top = menuobj.style.top;
		jsmenu['iframe'][layer].style.left = menuobj.style.left;
		jsmenu['iframe'][layer].style.width = menuobj.w;
		jsmenu['iframe'][layer].style.height = menuobj.h;
		jsmenu['iframe'][layer].style.display = 'block';
	}
	
	if(maxh && menuobj.scrollHeight > maxh) {
		menuobj.style.height = maxh + 'px';
		if(is_opera) {
			menuobj.style.overflow = 'auto';
		} else {
			menuobj.style.overflowY = 'auto';
		}
	}
	if(is_moz && ctrlid=='forumlist'&& menuobj.scrollWidth < 115){

			menuobj.style.width = '115px';
	}
	if(!duration) {
		setTimeout('hideMenu(' + layer + ')', timeout);
	}

	jsmenu['active'][layer] = menuobj;
}

//*******************
//表情预览位置
//*******************
function setMenuPosition(showid, offset) {
	var showobj = myphoto_$(showid);
	var menuobj = myphoto_$(showid + '_menu');
	if(isUndefined(offset)) offset = 0;
	if(showobj) {
		showobj.pos = fetchOffset(showobj);
		showobj.X = showobj.pos['left'];
		showobj.Y = showobj.pos['top'];
		showobj.w = showobj.offsetWidth;
		showobj.h = showobj.offsetHeight;
		menuobj.w = menuobj.offsetWidth;
		menuobj.h = menuobj.offsetHeight;
		menuobj.style.left = (showobj.X + menuobj.w > document.body.clientWidth) && (showobj.X + showobj.w - menuobj.w >= 0) ? showobj.X + showobj.w - menuobj.w + 'px' : showobj.X + 'px';
		menuobj.style.top = offset == 1 ? showobj.Y + 'px' : (offset == 2 || ((showobj.Y + showobj.h + menuobj.h > document.documentElement.scrollTop + document.documentElement.clientHeight) && (showobj.Y - menuobj.h >= 0)) ? (showobj.Y - menuobj.h) + 'px' : showobj.Y + showobj.h + 'px');
		if(menuobj.style.clip && !is_opera) {
			menuobj.style.clip = 'rect(auto, auto, auto, auto)';
		}
	}
}

//*******************
//表情文字
//*******************
function AddText(txt) {
	obj = myphoto_$('ajax_post_form').message;
	selection = document.selection;
	checkFocus();
	if(!isUndefined(obj.selectionStart)) {
		var opn = obj.selectionStart + 0;
		obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
	} else if(selection && selection.createRange) {
		var sel = selection.createRange();
		sel.text = txt;
		//sel.moveStart('character', -strlen(txt));
	} else {
		obj.value += txt;
	}
}
//*******************
//插入表情
//*******************
function insertSmiley(smilieid) {
	checkFocus();
	var src = myphoto_$('smilie_' + smilieid).src;
	var code = myphoto_$('smilie_' + smilieid).code;
	code += ' ';
	AddText(code);
	
}

//*******************
//预览表情
//*******************
function smileyMenu(ctrl) {
	var smiley = ctrl.firstChild;
	ctrl.style.cursor = 'pointer';
	if(smiley.alt) {
		smiley.code = smiley.alt;
		smiley.alt = '';
	}
	if(smiley.title) {
		smiley.lw = smiley.title;
		smiley.title = '';
	}
	smdiv[ctrl.id] = document.createElement('div');
	smdiv[ctrl.id].id = smiley.id + '_menu';
	smdiv[ctrl.id].style.display = 'none';
	smdiv[ctrl.id].style.width = '60px';
	smdiv[ctrl.id].style.height = '60px';
	smdiv[ctrl.id].className = 'popupmenu_popup';
	document.getElementById("smilieslist").appendChild(smdiv[ctrl.id]);
	smdiv[ctrl.id].innerHTML = '<table width="100%" height="100%"><tr><td align="center" valign="middle"><img src="' + smiley.src + '" border="0" width="' + smiley.lw + '" /></td></tr></table>';
	showMenu(ctrl.id, 0, 0, 1, 0, 0, smiley.id);
}	
