//幻灯
//UI&UE Dept. mengjia
//090316

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}}
};

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 : "PicTitle",
	picMemoId : "PicMemo",
	picListId : "picList",
	BigPicId : "BigPic",
	picArrLeftId : "picArrLeft",
	picArrRightId : "picArrRight",
	playButtonId : "playButton",
	statusId : "status",
	mainBoxId : "Main",
	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);
		};
	},
	initialize : function(){
		//全屏
	//	epidiascope.fullScreen.initialize();

		var tempWidth = 0;
		if(this.filmstrips.length * 110 < sina.$("picList").offsetWidth){
			tempWidth = Math.round(sina.$("picList").offsetWidth / 2 - this.filmstrips.length * 110/2);
		};

		var tempHTML = '<div class="PL_cont" style="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><a href="javascript:epidiascope.select(' + i + ');" onclick="this.blur();"><img src="' + this.filmstrips[i].lowsrc + '" alt="' + this.filmstrips[i].title + '"  onload="DrawImage(this);" oncontextmenu="event.returnValue=false;return false;" /></a></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();};

		//sina.$("commentLink").onclick = function(){epidiascope.clickComment()}; //评论
		//
		this.BigImgBox = sina.$(this.BigPicId);

		this.ImgObj1 = document.createElement("img");
		this.ImgObj2 = document.createElement("img");
		this.Link1 = document.createElement("a");
		this.Link2 = document.createElement("a");
		this.SpanObj1 = document.createElement("Span");
		this.SpanObj2 = document.createElement("Span");

		//
		this.ImgObj1.oncontextmenu = this.ImgObj2.oncontextmenu = function(e){
			e = e?e:event;
			e.returnValue=false;
			return false;
		};
		this.ImgObj1.onmousedown = this.ImgObj2.onmousedown = function(){return false};

		this.ImgObj1.galleryImg = false;
		this.ImgObj2.galleryImg = false;

		this.ImgObj1.src = this.filmstrips[0].src;//默认图片

		this.ImgObj1.onload = this.ImgObj2.onload = function(){
			if(epidiascope.maxWidth == 0 ){return};
			var temp = new Image();
			temp.src = this.src;

			if(temp.width > epidiascope.maxWidth){
				this.width = epidiascope.maxWidth;
				this.height = Math.round(epidiascope.maxWidth * temp.height / temp.width);
			}else{
				this.width = temp.width;
				this.height = temp.height;
			};
		};

		this.BigImgBox.appendChild(this.SpanObj1);
		this.BigImgBox.appendChild(this.SpanObj2);
		this.SpanObj1.appendChild(this.Link1);
		this.SpanObj2.appendChild(this.Link2);
		//this.SpanObj1.appendChild(this.ImgObj1);
		//this.SpanObj2.appendChild(this.ImgObj2);
		this.Link1.appendChild(this.ImgObj1);
		this.Link2.appendChild(this.ImgObj2);

		this.Link1.target = "_blank";
		this.Link2.target = "_blank";

		this.select(0);

//		this.foreAndAft();

		if(!sina.isIE){
			this.BigImgBox.style.position = 'relative';
			this.BigImgBox.style.overflow = "hidden";
			this.SpanObj2.style.position = "absolute";
			this.SpanObj2.style.width = "100%";
			this.SpanObj2.style.top = "0px";
			this.SpanObj1.style.textAlign = this.SpanObj2.style.textAlign = "center";
			this.SpanObj1.style.display = this.SpanObj2.style.display = "block";
			this.SpanObj1.style.zIndex = 1;
			this.SpanObj2.style.zIndex = 2;
		}else{
			this.SpanObj2.style.display = 'none';
		};
		
		
		if(this.autoPlay){this.play()}else{this.stop()};

		if(this.onstart){this.onstart()};
	},
	select : function(num,type){
		
		if(this.endSelect.status == 1){
			this.endSelect.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 = this.filmstrips[num].text;
		
		if(this.filmstrips[num].link=="" || this.filmstrips[num].link == "javascript:void(0)"){
			this.Link1.target = "_self";
			this.Link2.target = "_self";
			this.Link1.href = "javascript:void(0)";
			this.Link2.href = "javascript:void(0)";
		}else{
			this.Link1.target = "_brank";
			this.Link2.target = "_brank";
			this.Link1.href = this.filmstrips[num].link;
			this.Link2.href = this.filmstrips[num].link;
		};

		if(sina.isIE){
			this.ImgObj1.filters[0].Apply();
			this.ImgObj1.lowsrc = this.filmstrips[num].lowsrc;
			this.ImgObj1.src = this.filmstrips[num].src;

			this.ImgObj1.filters[0].Play();
			
		}else{
			this.ImgObj2.src = this.filmstrips[num].src;
			this.ImgObj2.lowsrc = this.filmstrips[num].lowsrc;
			this.ImgObj1.style.opacity = 1;
			this.ImgObj2.style.opacity = 0;
			
			if(this._timeOut){
				for(i=0;i<this._timeOut.length;i++){
					clearTimeout(this._timeOut[i]);
				};
			};
			this._timeOut = [];
			window.tempThis = this;
			for(i = 0;i <= 5;i ++){
				this._timeOut[i] = setTimeout(Function("tempThis.ImgObj2.style.opacity = " + i + " * 0.2"),i * 60);
			};
			this._timeOut[i] = setTimeout(Function("tempThis.ImgObj1.width=tempThis.ImgObj2.width;tempThis.ImgObj1.src = tempThis.ImgObj2.src;"),5 * 60);
		};
		if(sina.$("slide_" + this.selectedIndex)){sina.$("slide_" + this.selectedIndex).className = "pic"};
		sina.$("slide_" + num).className = "picOn";
		this.selectedIndex = num;

		this.picList.foucsTo(num + 1); //滚动

		sina.$("total").innerHTML = (num + 1) + "/" + 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;
		};
		
	},
	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{
				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 = "pause";
		this.autoPlay = true;
	},
	stop : function(){
		clearInterval(this.autoPlayTimeObj);
		sina.$(this.playButtonId).onclick = function(){epidiascope.play()};
		sina.$(this.statusId).className = "play";
		sina.$(this.statusId).title = "play";
		this.autoPlay = false;
	},
//	foreAndAft : function(){ //设置 前一个 后一个 图集
//		var foreBoxId = "PL_Left";
//		var aftBoxId = "PL_Right";
//		var nextPicsButId = "nextPicsBut";
//		var i;
//		var links = sina.$(foreBoxId).getElementsByTagName("a");
//		for(i=0;i<links.length;i++){
//			links[i].href = this.previousPicList.link;
//		};
//		sina.$(foreBoxId).getElementsByTagName("img")[0].src = this.previousPicList.lowsrc;
//
//		links = sina.$(aftBoxId).getElementsByTagName("a");
//		for(i=0;i<links.length;i++){
//			links[i].href = this.nextPicList.link;
//		};
//		sina.$(aftBoxId).getElementsByTagName("img")[0].src = this.nextPicList.lowsrc;
//
//		sina.$(nextPicsButId).href = this.nextPicList.link;
//	},
	rePlay : function(){ //重新播放
		if(this.endSelect.status == 1){this.endSelect.close()};
		this.autoPlay = true;
		this.select(0);
	},
	clickComment : function(){ //评论
		var thisFilmstrip = this.filmstrips[this.selectedIndex];
		if(thisFilmstrip.comment){window.open(thisFilmstrip.comment)};
	},
	downloadPic : function(){ //下载图片
		var thisFilmstrip = this.filmstrips[this.selectedIndex];

	},
	sendToMobile : function(){ //发送到手机
		var thisFilmstrip = this.filmstrips[this.selectedIndex];

	}
};

epidiascope.speedBar = { //速度条

	slideId : "slide",
	slideButtonId : "slideButton",
	grades : 10, //等级数
	grade : 1, //等级
	_slideWidth : 0,
	_slideButtonWidth : 0,
	_marginLeft : 0,
	_mouseDisparity : 0,
	initialize : function(){
		this._slideWidth = sina.$(this.slideId).offsetWidth;
		this._slideButtonWidth = sina.$(this.slideButtonId).offsetWidth;
		this._marginLeft = Math.round(this._slideWidth/this.grades * (this.grade - 1));

		sina.$(this.slideButtonId).style.marginLeft = this._marginLeft + "px";
		sina.$("speedCall").innerHTML = this.grade + "s";

		sina.$(this.slideId).onselectstart = function(){return false};
		sina.$(this.slideButtonId).onmousedown = function(e){epidiascope.speedBar.mouseDown(e);return false};
	},
	mouseDown : function(e){
		e = window.event?window.event:e;
		this._mouseDisparity = (e.pageX?e.pageX:e.clientX) - this._marginLeft;
		document.onmousemove = function(e){epidiascope.speedBar.mouseOver(e)};
		document.onmouseup = function(){epidiascope.speedBar.mouseEnd()};
	},
	mouseOver : function(e){
		e = window.event?window.event:e;
		this._marginLeft = (e.pageX?e.pageX:e.clientX) - this._mouseDisparity;
		if(this._marginLeft > (this._slideWidth - this._slideButtonWidth)){this._marginLeft = this._slideWidth - this._slideButtonWidth};
		if(this._marginLeft < 0){this._marginLeft = 0;};
		sina.$(this.slideButtonId).style.marginLeft = this._marginLeft + "px";

		this.grade = Math.round(this._marginLeft/(this._slideWidth/this.grades) + 1);

		if(this.onmover){this.onmover()};
	},
	mouseEnd : function(){
		if(this.onend){this.onend()};

		sina.writeCookie("eSp",this.grade,720);
		document.onmousemove = null;
		document.onmouseup = null;
	},
	onmover : function(){
		sina.$("speedCall").innerHTML = this.grade + "s";
	},
	onend : function(){
		epidiascope.timeSpeed = this.grade;
		if(epidiascope.autoPlay){epidiascope.play()};
	}
};

epidiascope.background = {
	status : 1,
	initialize : function(){
		sina.$("color_01").onclick = function(){epidiascope.background.select(1)};
		sina.$("color_02").onclick = function(){epidiascope.background.select(2)};
		//sina.$("color_03").onclick = function(){epidiascope.background.select(3)};
		this.select(this.status);
	},
	select : function(num){
		var className = "";
		num = parseInt(num);
		if(isNaN(num)){return;};
		switch(num){
			case 2:
				className = "bS_02";
				this.labelClass(2);
				break;
			case 3:
				className = "bS_03";
				this.labelClass(3);
				break;
			default :
				num = 1;
				className = "";
				this.labelClass(1);
		};
		document.body.className = className;
		sina.writeCookie("eBg",num,720);
		
	},
	labelClass : function(num){
		sina.$("color_01").className = "";
		sina.$("color_02").className = "";
		//sina.$("color_03").className = "";
		sina.$("color_0" + num).className = "selected";
	}
};

epidiascope.picList = { //列表滚动
	leftArrId : "leftArr",
	rightArrId : "rightArr",
	picListId : "picList",
	timeoutObj : null,
	pageWidth : 110,
	totalWidth : 0,
	offsetWidth : 0,
	lock : false,
	initialize : 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(30);
	},
	rightEnd : function(type){
		if(type=="out"){if(!this.lock){return}};
		clearInterval(this.timeoutObj);
		this.lock = false;
		this.move(-30);
	},
	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.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.$(epidiascope.statusId).title = "Replay";
		sina.$(this.closeId).onclick = function(){epidiascope.endSelect.close()};
		sina.$(this.rePlayButId).onclick = function(){epidiascope.rePlay()};
	},
	close : function(){
		this.status = 0;
		//sina.$(epidiascope.playButtonId).onclick = function(){epidiascope.play()};
		sina.$(this.endSelectId).style.display = "none";
	}
};

//全屏
epidiascope.fullScreen = {
	fullScreenButId : "fullScreen",
	status : 0,//1:full 0:close
	fullWin : null,
	timeObj : null,
	initialize : function(){
		try{
			if(window.opener){
				if(window.opener.epidiascope.fullScreen.status == 1){
					this.setFull();
				}
			}else{
				sina.$(this.fullScreenButId).onclick = function(){epidiascope.fullScreen.full()};
			}
		}catch(e){sina.$(this.fullScreenButId).onclick = function(){epidiascope.fullScreen.full()}};
	},
	unset : function(){
		sina.$(this.fullScreenButId).onclick = null;
	},
	full : function(){
		this.fullWin = window.open(window.location.href,"fullWin","scrollbars")
		this.fullWin.moveTo(0,0)
		this.fullWin.resizeTo(screen.width,screen.height);
		this.status = 1;
		epidiascope.stop();

		sina.$("fullClew").style.display = "block";
		coverLayer.on();
		this.timeObj = setInterval("epidiascope.fullScreen.scoutFullWin()",100);
		sina.$("fullClose").onclick = function(){epidiascope.fullScreen.fullWin.close()};
		sina.$("fullCloseBut").onclick = function(){epidiascope.fullScreen.fullWin.close()};
	},
	scoutFullWin : function(){
		if(this.fullWin.closed){
			coverLayer.off();
			sina.$("fullClew").style.display = "none";
			clearInterval(this.timeObj);
			epidiascope.onstart();
			epidiascope.play();
		}else{
			sina.$("fullClew").style.left = Math.round((document.body.offsetWidth - 230)/2) + "px";
			sina.$("fullClew").style.top = Math.round((document.documentElement.scrollTop==0?document.body.scrollTop:document.documentElement.scrollTop) + document.documentElement.clientHeight * 0.3) + "px";
		};
	},
	close : function(){
		window.close();
	},
	setFull : function(){
		sina.$(this.fullScreenButId).onclick = function(){epidiascope.fullScreen.close()};
		sina.$("wrap").style.width = "auto";
		sina.$("wrap").style.padding = "5px";
		sina.$(this.fullScreenButId).innerHTML = "Back";
		sina.$(this.fullScreenButId).className = "close";
		sina.$(epidiascope.picList.picListId).style.width = sina.$("wrap").offsetWidth - 290 + "px";
	}
}

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.initialize();
	epidiascope.speedBar.onend();

	//背景
//	epidiascope.background.status = parseInt(sina.readCookie("eBg"));
//	if(isNaN(epidiascope.background.status)){epidiascope.background.status = 1};
//	epidiascope.background.initialize();

	//图片列表滚动
	epidiascope.picList.initialize();
};

// -------------------------------------------------------------------------------------

function DrawImage(ImgD,iwidth,iheight){
	var image=new Image();
	if(!iwidth)iwidth = 90;
	if(!iheight)iheight = 90; //定义允许高度，当宽度大于这个值时等比例缩小
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		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;
			}
		}
	}
} 