	function view_status()
	{
		this.viewmode = "thumb"; 
		//this.viewmode = "detail";
		this.changeTimes = 0;
		this.autoplay = "no";
		this.autoplayStatus = "idle";
		this.showinfo = "yes";
	}
	
	var vs = new view_status();
	
/*yLib ===============================	 */
	function ylib_Browser()
	{
		d=document;
		this.agt=navigator.userAgent.toLowerCase();
		this.major = parseInt(navigator.appVersion);
		this.dom=(d.getElementById)?1:0;
		this.ns=(d.layers);
		this.ns4up=(this.ns && this.major >=4);
		this.ns6=(this.dom&&navigator.appName=="Netscape");
		this.op=(window.opera? 1:0);
		this.ie=(d.all);
		this.ie4=(d.all&&!this.dom)?1:0;
		this.ie4up=(this.ie && this.major >= 4);
		this.ie5=(d.all&&this.dom);
		this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
		this.mac=(this.agt.indexOf("mac")!=-1);
		this.safari=(this.agt.indexOf("webkit")!=-1);
	}

	var oBw = new ylib_Browser();
	
	function ylib_getH(o) { return (oBw.ns)?((o.height)?o.height:o.clip.height):((oBw.op&&typeof o.style.pixelHeight!='undefined')?o.style.pixelHeight:o.offsetHeight); };
	function ylib_setH(o,h) { if(o.clip) o.clip.height=h; else if(oBw.op && typeof o.style.pixelHeight != 'undefined') o.style.pixelHeight=h; else o.style.height=h; };
	function ylib_getW(o) { return (oBw.ns)?((o.width)?o.width:o.clip.width):((oBw.op&&typeof o.style.pixelWidth!='undefined')?w=o.style.pixelWidth:o.offsetWidth); };
	function ylib_setW(o,w) { if(o.clip) o.clip.width=w; else if(oBw.op && typeof o.style.pixelWidth != 'undefined') o.style.pixelWidth=w; else o.style.width=w; };
	function ylib_getX(o) { return (oBw.ns)?o.left:((o.style.pixelLeft)?o.style.pixelLeft:o.offsetLeft); };
	function ylib_setX(o,x) { if(oBw.ns) o.left=x; else if(typeof o.style.pixelLeft != 'undefined') o.style.pixelLeft=x; else o.style.left=x; };
	function ylib_getY(o) { return (oBw.ns)?o.top:((o.style.pixelTop)?o.style.pixelTop:o.offsetTop); };
	function ylib_setY(o,y) { if(oBw.ns) o.top=y; else if(typeof o.style.pixelTop != 'undefined') o.style.pixelTop=y; else o.style.top=y; };
	function ylib_getPageX(o) { var x=0; if(oBw.ns) x=o.pageX; else { while(eval(o)) { x+=o.offsetLeft; o=o.offsetParent; } } return x; };
	function ylib_getPageY(o) { var y=0; if(oBw.ns) y=o.pageY; else { while(eval(o)) { y+=o.offsetTop; o=o.offsetParent; } } return y; };
	function ylib_getZ(o) { return (oBw.ns)?o.zIndex:o.style.zIndex; };
	function ylib_moveTo(o,x,y) { ylib_setX(o,x);ylib_setY(o,y); };
	function ylib_moveBy(o,x,y) { ylib_setX(o,ylib_getPageX(o)+x);ylib_setY(o,ylib_getPageY(o)+y); };
/* ===============================	 */


// changeOpacity for FireFox
	function decreasingOpacity_ff()
	{
		if ( Number(document.getElementById("thumbnail_window").style.opacity) > 0.1 ) {
			document.getElementById("thumbnail_window").style.opacity = Number(document.getElementById("thumbnail_window").style.opacity) - 0.1;
		}
		else {
			clearTimeout(de_thumbnail);
			return;
		}
		var de_thumbnail = setTimeout("decreasingOpacity_ff()",5);
	}
	
	function increasingOpacity_ff()
	{
		if ( Number(document.getElementById("thumbnail_window").style.opacity) < 1 && vs.viewmode == "thumb" && vs.changeTimes < 15 ) {
			document.getElementById("thumbnail_window").style.opacity = Number(document.getElementById("thumbnail_window").style.opacity) + 0.1;
			vs.changeTimes++;
		}
		else {
			vs.changeTimes = 0;
			clearTimeout(in_thumbnail);
			return;
		}
		var in_thumbnail = setTimeout("increasingOpacity_ff()",5);
	}
	
// changeOpacity for IE
	function decreasingOpacity_ie()
	{
		var filter = String(document.getElementById("thumbnail_window").style.filter);
		alpha = Number( filter.substring( filter.indexOf("=")+1 , filter.length - 1) );
		if ( alpha > 10 ) {
			alpha = alpha - 10;
			document.getElementById("thumbnail_window").style.filter = 'alpha(opacity=' + String(alpha) + ')';
		}
		else {
			clearTimeout(de_thumbnail);
			return;
		}
		var de_thumbnail = setTimeout("decreasingOpacity_ie()",5);
	}
	
	function increasingOpacity_ie()
	{
		var filter = String(document.getElementById("thumbnail_window").style.filter);
		alpha = Number( filter.substring( filter.indexOf("=")+1 , filter.length - 1) );
		if ( alpha < 100 && vs.viewmode == "thumb" && vs.changeTimes < 15 ) {
			alpha = alpha + 10;
			document.getElementById("thumbnail_window").style.filter = 'alpha(opacity=' + String(alpha) + ')';
			vs.changeTimes++;
		}
		else {
			vs.changeTimes = 0;
			clearTimeout(in_thumbnail);
			return;
		}
		var in_thumbnail = setTimeout("increasingOpacity_ie()",5);
	} 
	
// changeOpacity for Mac
	function decreasingOpacity_mac()
	{
		if ( Number(document.getElementById("thumbnail_window").style.opacity) > 0.1 ) {
			document.getElementById("thumbnail_window").style.opacity = Number(document.getElementById("thumbnail_window").style.opacity) - 0.4;
		}
		else {
			clearTimeout(de_thumbnail);
			return;
		}
		var de_thumbnail = setTimeout("decreasingOpacity_mac()",5);
	}
	
	function increasingOpacity_mac()
	{
		if ( Number(document.getElementById("thumbnail_window").style.opacity) < 1 && vs.viewmode == "thumb" && vs.changeTimes < 15 ) {
			document.getElementById("thumbnail_window").style.opacity = Number(document.getElementById("thumbnail_window").style.opacity) + 0.3;
			vs.changeTimes++;
		}
		else {
			vs.changeTimes = 0;
			clearTimeout(in_thumbnail);
			return;
		}
		var in_thumbnail = setTimeout("increasingOpacity_mac()",0);
	}
	

	function commentImg(n)
	{
		vs.viewmode = "detail";
		document.getElementById("menu_right").style.display = "inline";
		document.getElementById("menu_option").style.display = "inline";
		document.getElementById("menu_left").style.display = "none";
		document.getElementById("menu_function").style.display = "none";
		if ( oBw.ie )
		{
			document.getElementById("thumbnail_window").style.filter = "alpha(opacity=100)";
			decreasingOpacity_ie();
		}
		else if ( oBw.mac ) 
		{
			document.getElementById("thumbnail_window").style.opacity = 1;
			decreasingOpacity_mac();
		}
		else 
		{
		document.getElementById("thumbnail_window").style.opacity = 1;
		decreasingOpacity_ff();
		}
		document.getElementById("detail_img").src = "images/space.gif";
		var array_img = pic[n];
		array_img = array_img.replace("size_0","size_2");
		document.getElementById("detail_img").src = array_img;
		document.getElementById("description").innerHTML = desc[n];
		document.getElementById("description").style.display = "inline";
		current_id = n;
		document.getElementById("detail_window").style.display = "inline";
	}
	
	function disableLink()
	{
		document.getElementById("next_link").style.color = "";
		document.getElementById("prev_link").style.color = "";
	}
	
	function close_detail_window() 
	{
		document.getElementById("menu_right").style.display = "none";
		document.getElementById("menu_option").style.display = "none";
		document.getElementById("menu_left").style.display = "inline";
		document.getElementById("menu_function").style.display = "inline";
		if (vs.viewmode == "detail") vs.viewmode = "thumb";
		if( oBw.ie )
		{
			document.getElementById("thumbnail_window").style.opacity = 0.09;
			increasingOpacity_ie();
		}
		else if ( oBw.mac)
		{
			document.getElementById("thumbnail_window").style.opacity = 0.09;
			increasingOpacity_mac();
		}
		else
		{
			document.getElementById("thumbnail_window").style.filter = "alpha(opacity=9)";
			increasingOpacity_ff();
		}
		document.getElementById("detail_window").style.display = "none";
		document.getElementById("description").style.display = "none";
		disableLink();
	}
	
	function next() 
	{
		if (current_id < total_number) 
		{
			document.getElementById("description").style.display = "none";
			var array_img = pic[current_id+1];
			array_img = array_img.replace("size_0","size_2");
			document.getElementById("detail_img").src = array_img;
			document.getElementById("description").innerHTML = desc[current_id+1];
			document.getElementById("description").style.display = "inline";
			current_id++;
		}
	}
	
	function prev() 
	{
		if ( current_id > 0) 
		{
			document.getElementById("description").style.display = "none";
			var array_img = pic[current_id-1];
			array_img = array_img.replace("size_0","size_2");
			document.getElementById("detail_img").src = array_img;
			document.getElementById("description").innerHTML = desc[current_id-1];
			document.getElementById("description").style.display = "inline";
			current_id --;
		}
	}

	function changePage(evt)
	{
		var detail_img = document.getElementById('detail_img');
		var div_desc = document.getElementById('div_desc');
		var prev_link = document.getElementById("prev_link");
		var next_link = document.getElementById("next_link");
		
		var mX = evt.clientX; //获取当前鼠标位置的X坐标 
		var mY = evt.clientY; //获取当前鼠标位置的Y坐标 
		var oX = ylib_getPageX(detail_img);
		var oY = ylib_getPageY(detail_img);
		var rangeX = oX + detail_img.width;
		var rangeY = oY + detail_img.height;
		
		if ( mX > oX && mX < (rangeX-oX)/2+oX )
		{
			detail_img.onclick = prev;
			detail_img.alt = "上一张";
			detail_img.title = "上一张";
			prev_link.style.color = "#FFF";
			next_link.style.color = "";
		}
		else if ( mX > (rangeX-oX)/2+oX && mX < rangeX)
		{
			detail_img.onclick = next;
			detail_img.alt = "下一张";
			detail_img.title = "下一张";
			prev_link.style.color = "";
			next_link.style.color = "#FFF";
		}
		else 
		{
			detail_img.onclick = close_detail_window;
			detail_img.alt = "";
			detail_img.style.cursor = "pointer";
		}

	}

	function autoplay()
	{
		next();
		vs.autoplayStatus = setTimeout("autoplay()",8000);
	}

	function enable_autoplay()
	{
		if ( vs.autoplay == "no")
		{
			vs.autoplay = "yes";
			autoplay();
			document.getElementById("autoplay_link").onmouseover = "";
			document.getElementById("autoplay_link").onmouseout = "";
			document.getElementById("autoplay_link").style.color = "#FFF";
		}
	}
	
	function disable_autoplay()
	{
		clearTimeout(vs.autoplayStatus);
		vs.autoplay = "no";
		document.getElementById("autoplay_link").style.color = "#777";
		document.getElementById("autoplay_link").onmouseover = new function () { document.getElementById("autoplay_link").style.color = "#FFF";};
		document.getElementById("autoplay_link").onmouseout = new function () { document.getElementById("autoplay_link").style.color = "#777";};
	}
	
	function autoplay_onclick()
	{
		if(vs.autoplay == 'yes') { disable_autoplay();}
		else { enable_autoplay();}
	}
	
	function info_onclick()
	{
		if(vs.showinfo == "no") 
		{
			document.getElementById("info_link").style.color = "#FFF";
			document.getElementById("info_link").onmouseover = "";
			document.getElementById("info_link").onmouseout = "";
			document.getElementById("desc_td").style.visibility = "visible";
			vs.showinfo = "yes"
		}
		else 
		{
			document.getElementById("info_link").style.color = "#777";
			document.getElementById("info_link").onmouseover = new function () { document.getElementById("info_link").style.color = "#FFF";};
			document.getElementById("info_link").onmouseout = new function () { document.getElementById("info_link").style.color = "#777";};
			document.getElementById("desc_td").style.visibility = "hidden";
			vs.showinfo = "no";
		}
	}