var LANGARR = new Array();

switch (USER_LANG)
{
	case "en":
		LANGARR["PAGE"] = "Page:";
		LANGARR["VISITOR"] = "Visitor:";
		break;
	case "cn":
		LANGARR["PAGE"] = "页面:";
		LANGARR["VISITOR"] = "查看:";
		break;
	case "hk":
		LANGARR["PAGE"] = "頁面:";
		LANGARR["VISITOR"] = "人氣:";
		break;
	case "ja":
		LANGARR["PAGE"] = "次へ:";
		LANGARR["VISITOR"] = "表示:";
		LANGARR["REVIEW"] = "コメント:";
		break;
}
var isIE = (document.all) ? true : false;
var calcTimer = null;
var loadokFlag = false;
var effectDone = false;
var screenTimer = null;
var runningScreenSaver = false;
var copyArray = new Array();
var isCopyVisible = false;
var $ = function (id) {
	return "string" == typeof id ? document.getElementById(id) : id;
};
if(!isIE){
	HTMLElement.prototype.__defineGetter__("currentStyle", function () {
		return this.ownerDocument.defaultView.getComputedStyle(this, null);
	});
}
var Class = {
  create: function() {
	return function() {
	  this.initialize.apply(this, arguments);
	}
  }
}
Object.extend = function(destination, source) {
	for (var property in source) {
		destination[property] = source[property];
	}
	return destination;
}
var FadeStruct = function(options){
	this.run = false;//是否渐变
	this.start = 0;//开始值
	this.end = 0;//结束值
	this.target = 0;//目标值
	Object.extend(this, options || {});
}
var Fade = Class.create();
Fade.prototype = {
  initialize: function(obj, options) {
	
	var obj = $(obj);
	obj.style.overflow = "hidden";
	this._obj = obj;
	
	this._timer = null;//定时器
	this._finish = true;//是否执行完成
	this._fun = function(){};//渐变程序
	this._x = this._y = 0;//变换点位置
	
	//设置获取透明度程序
	this._setOpacity = isIE ? function(opacity){ obj.style.filter = "alpha(opacity:" + opacity + ")"; } : function(opacity){ obj.style.opacity = opacity / 100; };
	this._getOpacity = isIE ? function(){ return parseInt(obj.filters["alpha"].opacity); } : function(opacity){ return 100 * parseFloat(obj.currentStyle.opacity); };
	
	//获取边框宽度程序
	this._xBorder = function(){ return (parseInt(obj.currentStyle.borderLeftWidth) + parseInt(obj.currentStyle.borderRightWidth)); }
	this._yBorder = function(){ return (parseInt(obj.currentStyle.borderTopWidth) + parseInt(obj.currentStyle.borderBottomWidth)); }
	
	this.SetOptions(options);
	
	this.Mode = this.options.Mode;
	this.Time = Math.abs(this.options.Time);
	this.onFinish = this.options.onFinish;
	
	//先设置特殊默认值
	this.Opacity = new FadeStruct({ end: 100 });
	this.Top = new FadeStruct({ start: this._obj.offsetTop, end: this._obj.offsetTop });
	this.Left = new FadeStruct({ start: this._obj.offsetLeft, end: this._obj.offsetLeft });
	this.Height = new FadeStruct({ end: this._obj.offsetHeight - this._yBorder() });
	this.Width = new FadeStruct({ end: this._obj.offsetWidth - this._xBorder() });
	
	//再设置用户默认值
	Object.extend(this.Opacity, this.options.Opacity);
	Object.extend(this.Top, this.options.Top);
	Object.extend(this.Left, this.options.Left);
	Object.extend(this.Height, this.options.Height);
	Object.extend(this.Width, this.options.Width);
	
	//变换位置参数
	this.Height.pos = Number(this.options.Height.pos);
	this.Width.pos = Number(this.options.Width.pos);
	
	//设置成默认状态
	this.Show = !this.options.Show;
	this.Step = 1;
	this.Start();
	//重新设置Step
	this.Step = Math.abs(this.options.Step);
  },
  //设置默认属性
  SetOptions: function(options) {
	this.options = {//默认值
		Opacity:	{},//透明渐变参数
		Height:		{},//高度渐变参数
		Width:		{},//宽度渐变参数
		Top:		{},//Top渐变参数
		Left:		{},//Left渐变参数
		Step:		10,//变化率
		Time:		10,//变化间隔
		Mode:		"both",//渐变顺序
		Show:		false,//是否默认打开状态
		onFinish:	function(){}//完成时执行
	};
	Object.extend(this.options, options || {});
  },		
  //触发
  Start: function() {
	clearTimeout(this._timer);
	//取反表示要设置的状态
	this.Show = !this.Show;
	//为避免透明度为null值，需要先设置一次透明度
	if(this.Opacity.run){ this._setOpacity(this.Show ? this.Opacity.start : this.Opacity.end); }
	//根据状态设置目标值
	if(this.Show){
		this.Opacity.target = this.Opacity.end;
		this.Top.target = this.Top.end;
		this.Left.target = this.Left.end;
		this.Height.target = this.Height.end;
		this.Width.target = this.Width.end;
	} else{
		this.Opacity.target = this.Opacity.start;
		this.Top.target = this.Top.start;
		this.Left.target = this.Left.start;
		this.Height.target = this.Height.start;
		this.Width.target = this.Width.start;
	}
	//设置渐变程序
	switch (this.Mode.toLowerCase()) {
		case "width" :
			this._fun = function(){
				this.SetWidth() && this.SetHeight();
				//由于分了两步，下面的步长变成两倍
				this.Step = 2*this.Step;
				this.SetOpacity(); this.SetTop(); this.SetLeft();
				this.Step = this.Step/2;
			}
			break;
		case "height" :
			this._fun = function(){
				this.SetHeight() && this.SetWidth();
				//由于分了两步，下面的步长变成两倍
				this.Step = 2*this.Step;
				this.SetOpacity(); this.SetTop(); this.SetLeft();
				this.Step = this.Step/2;
			}
			break;
		case "both" :
		default :
			this._fun = function(){ this.SetHeight(); this.SetWidth(); this.SetOpacity(); this.SetTop(); this.SetLeft();}
	}
	//获取变换点位置
	//由于设置变换点后与top和left变换有冲突只能执行其一
	if(this.Height.pos){ this._y = this._obj.offsetTop + this._obj.offsetHeight * this.Height.pos; this.Top.run = false; }
	if(this.Width.pos){ this._x = this._obj.offsetLeft + this._obj.offsetWidth * this.Width.pos; this.Left.run = false; }
	
	this.Run();
  },
  //执行
  Run: function() {
	clearTimeout(this._timer);
	this._finish = true;
	//执行渐变
	this._fun();
	//未完成继续执行
	if (this._finish) { this.onFinish(); }
	else { var oThis = this; this._timer = setTimeout(function(){ oThis.Run(); }, this.Time); }
  },
  //设置高度渐变
  SetHeight: function() {
	var iGet = this.Get(this.Height, this._obj.offsetHeight - this._yBorder());
	if(isNaN(iGet)) return true;
	
	this._obj.style.height = iGet + "px";
	//如果有变换点设置
	if(this.Height.pos){ this._obj.style.top = this._y - this._obj.offsetHeight * this.Height.pos + "px"; }
	return false;
  },
  //设置宽度渐变
  SetWidth: function() {
	var iGet = this.Get(this.Width, this._obj.offsetWidth - this._xBorder());
	if(isNaN(iGet)) return true;
	
	this._obj.style.width = iGet + "px";
	if(this.Width.pos){ this._obj.style.left = this._x - this._obj.offsetWidth * this.Width.pos + "px"; }
	return false;
  },
  //设置top渐变
  SetTop: function() {
	var iGet = this.Get(this.Top, this._obj.offsetTop);
	if(isNaN(iGet)) return true;
	
	this._obj.style.top = iGet + "px";
	return false;
  },
  //设置left渐变
  SetLeft: function() {
	var iGet = this.Get(this.Left, this._obj.offsetLeft);
	if(isNaN(iGet)) return true;
	
	this._obj.style.left = iGet + "px";
	return false;
  },
  //设置透明渐变
  SetOpacity: function() {
	var iGet = this.Get(this.Opacity, this._getOpacity());
	if(isNaN(iGet)) return true;
	
	this._setOpacity(iGet);
	return false;
  },
  //获取设置值
  Get: function(o, now){
	if(o.run){
		var iStep = (o.target - now) / this.Step;
		if(iStep){		
			this._finish = false;
			if(Math.abs(iStep) < 1){ iStep = iStep > 0 ? 1 : -1; }
			return now + iStep;
		}
	}
  }
};


function btnshow(start_val)
{
	var k =0;
	var nextpage = true;
	for (i=0;i<10;i++)
	{
		img_obj = document.getElementById('img'+i);
		name_obj = document.getElementById('iname'+i);
		img_obj.src = "cdn/x.gif";
		img_obj.style.display = "none";
		name_obj.innerHTML = "";
		$('ichk'+i).style.visibility = "hidden";
	}
	for (i=start_val;i<start_val+10;i++)
	{
		img_obj = document.getElementById('img'+(i-start_val));
		name_obj = document.getElementById('iname'+(i-start_val));
		if (i >= pic_num)
		{
			nextpage = false;
			break;
		}
		$('ichk'+(i-start_val)).checked = copyArray[i];
		$('ichk'+(i-start_val)).style.visibility = isCopyVisible ? "" : "hidden";
		img_obj.src = (imglist[i][2] ? "thumbs/"+imglist[i][2]+".jpg" : imglist[i][0]);
		img_obj.style.display = "";
		name_obj.innerHTML = imglist[i][1];
	}
	if (start_val+10 >= pic_num)
	{
		document.getElementById('nextbtn').innerHTML = '';
	}else
	{
		document.getElementById('nextbtn').innerHTML = '>';
	}
	if (page == 1)
	{
		document.getElementById('beforebtn').innerHTML = '';
	}else{
		document.getElementById('beforebtn').innerHTML = '&lt;';
	}
}
function setOpacity(obj,opacity){
	if (isIE)
	{
		obj.style.filter = "alpha(opacity:" + opacity + ")";
	}else{
		obj.style.opacity = opacity / 100;
	}
}
function getOpacity(obj){
	if (isIE)
	{
		return typeof obj.filters["alpha"] == "undefined" ? 100 : parseInt(obj.filters["alpha"].opacity);
	}else{
		return 100 * parseFloat(obj.currentStyle.opacity);
	}
}
String.prototype._indexOf = String.prototype.indexOf;
String.prototype.indexOf = function()
{
        if(typeof(arguments[arguments.length - 1]) != 'boolean')
                return this._indexOf.apply(this,arguments);
        else
        {
                var bi = arguments[arguments.length - 1];
                var thisObj = this;
                var idx = 0;
                if(typeof(arguments[arguments.length - 2]) == 'number')
                {
                        idx = arguments[arguments.length - 2];
                        thisObj = this.substr(idx);
                }
                
                var re = new RegExp(arguments[0],bi?'i':'');
                var r = thisObj.match(re);
                return r==null?-1:r.index + idx;
        }
}
function chbefore()
{
	page--;
	if (page < 1) page = 1;
	var start_val = (page-1)*10;
	btnshow(start_val);
	clickimg(0);
}
function chnext()
{
	if (page*10 >= pic_num) return;
	page++;
	var start_val = (page-1)*10;
	btnshow(start_val);
	clickimg(0);
}

function loadImages()
{
    var d=document; if(d.images)
               {
                     if(!d.MM_p) d.MM_p=new Array();
                     var i,j=d.MM_p.length,a=loadImages.arguments; 
                     for(i=0; i<a.length; i++)
                     {
                            if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
                     }   
               }
}
function preload2_comp()
{
	loadokFlag = true;
	if (effectDone){
		if ($('preload2').src!="cdn/null.png")
		{
			runLoadTimeout();
			runOKTimeout();
		}
	}
}
function runLoadTimeout()
{
	//if (loadokFlag) return;
	clearInterval(calcTimer);
	curOpac = getOpacity($('big_img'));
	if (curOpac > 10)
	{
		setOpacity($('big_img'),curOpac-10);
		calcTimer = setTimeout(function(){ runLoadTimeout(); }, 50);
	}else
	{
		effectDone = true;
		if (loadokFlag)
		{
			var cusimg = new Image();
			cusimg.src = $('preload2').src;
			//$('big_img').height = "";
			$('big_img').src = $('preload2').src;
			scroll(0,310);
			//if ($('big_img').height > getWindowHeight())
			{
				//$('big_img').height = screen.height-228;
				$('big_img').height = getWindowHeight()-10;
			}
			if ($('big_img').height > cusimg.height)
			{
				$('big_img').height = cusimg.height;
			}
			runOKTimeout();
		}
	}
}
function runOKTimeout()
{
	clearInterval(calcTimer);
	curOpac = getOpacity($('big_img'));
	if (curOpac < 100)
	{
		setOpacity($('big_img'),curOpac+10);
		calcTimer = setTimeout(function(){ runOKTimeout(); }, 50);
	}
}
function getWindowHeight()
{
	if (window.innerHeight) {
		return window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	}
	else if (document.body) {
		return document.body.clientHeight;
	}
}
function getWindowWidth()
{
	if (window.innerWidth) {
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	}
	else if (document.body) {
		return document.body.clientWidth;
	}
}
function clickimg(img_id)
{
	sid = (page-1)*10+img_id;
	if (sid >= pic_num) return;
	lastimg = img_id;
	image_obj = document.getElementById('big_img');
	name_obj = document.getElementById('big_img_name');
	name_obj.innerHTML = imglist[sid][1]+"<br /><a href=pictures/"+imglist[sid][3]+">原始尺寸</a>";
	

	
	
	loadokFlag = false;
	effectDone = false;
	if (image_obj.src != "cdn/x.gif") runLoadTimeout();
	//setOpacity(image_obj,10);

	//image_obj.src = imglist[sid][0];
	$('preload2').src = imglist[sid][0];
	
	if (sid+2 > pic_num)
	{
		document.getElementById('inextbtn').style.display = 'none';
	}else
	{
		document.getElementById('inextbtn').style.display = '';
	}
	if (sid == 0)
	{
		document.getElementById('ibeforebtn').style.display = 'none';
	}else
	{
		document.getElementById('ibeforebtn').style.display = '';
	}
}
function beforeimg()
{
	if (lastimg == 0 && page != 1)
	{
		chbefore();
		clickimg(9);
	}else
	{
		clickimg(lastimg-1);
	}
}
function nextimg()
{
	if (lastimg == 9)
	{
		chnext();
		clickimg(0);
	}else
	{
		clickimg(lastimg+1);
	}
}
function screensaver(clientReq)
{
	clearInterval(screenTimer);
	if (clientReq)
	{
		runningScreenSaver = !runningScreenSaver;
		if (!runningScreenSaver)
		{
			return;
		}
	}
	nextimg();
	screenTimer = setTimeout(function() { screensaver(false); },5000);
}
function Event(e){
	var oEvent = isIE ? window.event : e;
	if (isIE) {
		oEvent.pageX = oEvent.clientX + document.documentElement.scrollLeft;
		oEvent.pageY = oEvent.clientY + document.documentElement.scrollTop;
		oEvent.stopPropagation = function(){ this.cancelBubble = true; }; 
	}
	return oEvent;
}
var curpage = 1;
var perline = Math.floor(getWindowWidth()/270) > 4 ? Math.floor(getWindowWidth()/270) : 4;
var perpage = Math.floor((getWindowHeight()-130)/280)*perline;
if (perpage < perline*2) perpage = perline*2;
var search_filter = "";
/*if (screen.height>=1200)
{
	perpage = 12;
}else
{
	perpage = 12;
}*/
var pagenum;
function rawurlencode (str) {
    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };
 
    var ret = '',
            unreserved = /[\w.~-]/; // A-Za-z0-9_.~-
    str = (str+'').toString();
 
    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            // Reserved assumed to be in UTF-8, as in PHP
            if (code < 128) { // 1 byte
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) { // 2 bytes
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) { // 3 bytes
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;
}

function rawurldecode(str){
  var ret="";
  for(var i=0;i<str.length;i++){
   var chr = str.charAt(i);
    if(chr == "+"){
      ret+=" ";
    }else if(chr=="%"){
     var asc = str.substring(i+1,i+3);
     break;
     if(parseInt("0x"+asc)>0x7f){
      ret+=String.fromCharCode(parseInt("0x"+asc+str.substring(i+4,i+6)));
      i+=5;
     }else{
      ret+=String.fromCharCode(parseInt("0x"+asc));
      i+=2;
     }
    }else{
      ret+= chr;
    }
  }
  return ret;
}

function showfolderlist(page)
{
	$('idFolder').className="Fade";
	if (typeof page == "undefined")
		page = 1;
	
	var objTable = document.createElement("table");
	objTable.width="100%";
	objTable.cellpadding=0;
	objTable.cellspacing=0;
	var objTBody = document.createElement("tbody");
	objTable.appendChild(objTBody);
	
	$('idFolder').innerHTML = "";
	$('idFolder').appendChild(objTable);
	/*var objUL = document.createElement("ul");
	//$('idFolder').appendChild(objUL);
	*/
	
	outId = 0;
	objTR = null;
	for (i=0;i<folderlist.length;i++)
	{
		if (!search_filter)
		{
			if (i < (page-1)*perpage) continue;
			if (i >= page*perpage) break;
		}else
		{
			if (typeof folderlist[i] != 'object')
			{
				//alert(typeof folderlist[i]);
				//exit;
			}
		}
		if (typeof folderlist[i] == "undefined" || typeof folderlist[i][1] == "undefined" || folderlist[i][1].indexOf(search_filter) == -1) continue;
		switch (folderlist[i][2])
		{
			case 1:
				cover = "cdn/lock.jpg";
				break;
			case 2:
				cover = "cdn/nocover.jpg";
				break;
			default:
				cover = "cover/"+folderlist[i][4]+".jpg";
		}
		if (outId%perline == 0)
		{
			objTR = document.createElement("tr");
			if (objTR != null) objTBody.appendChild(objTR);
		}
		outId++;
		objTD = document.createElement("td");
		objTD.width=Math.floor(100/perline)+"%";
		objTD.align="center";
		objTD.className="Fade";
		objTD.id = "objTD_"+i;
		//folderlist[i][0]
		
		objTD.innerHTML = "<a href='album.php?u="+folderlist[i][0]+"'"+(folderlist[i][2] == 1 ? " onclick=\"return showpwform(event,'"+folderlist[i][0]+"');\"" : "")+"><img src=\"cdn/x.gif\" height=\"225\" width=\"150\" border=\"0\" id=\"objTmp_"+i+"\"><img src=\""+cover+"\" border=\"0\" align=\"absmiddle\" style=\"display:none\" width=\"150\" tabIndex=\""+(i-page*perpage)+"\" onload=\"$('objTD_"+i+"').className=''; this.style.display='';$('objTmp_"+i+"').style.display='none'; \" /><br />"+folderlist[i][1]+"</a><br /><span class='dir_extrainfo'>"+LANGARR["VISITOR"]+folderlist[i][3]+"</span>";
		objTR.appendChild(objTD);
		/*
		var objItem = document.createElement("li");
		objItem.id = "objItem_"+i;
		objItem.className="Fade";
		objItem.innerHTML = "<a href='?"+folderlist[i][0]+"'"+(folderlist[i][2] == 1 ? " onclick=\"return showpwform(event,'"+folderlist[i][0]+"');\"" : "")+"><img src=\"cdn/x.gif\" height=\"225\" width=\"150\" border=\"0\" id=\"objTmp_"+i+"\"><img src=\""+cover+"\" border=\"0\" style=\"display:none\" width=\"150\" tabIndex=\""+(i-page*perpage)+"\" onload=\"$('objItem_"+i+"').className=''; this.style.display='';$('objTmp_"+i+"').style.display='none'; \" /><br />"+folderlist[i][1]+"</a><br /><span class='dir_extrainfo'>"+LANGARR["VISITOR"]+folderlist[i][3]+"</span>";
		objUL.appendChild(objItem);*/
	}
	if (!search_filter)
	{
		$('idFolder').innerHTML += "<b style='color:lime'>"+LANGARR["PAGE"]+" </b>";
		pagenum = Math.ceil(folderlist.length/perpage);
		for (i=0;i<pagenum;i++)
		{
			if (i+1 == page)
			{
				$('idFolder').innerHTML += "<b>"+(i+1)+"</b> ";
			}else
			{
				$('idFolder').innerHTML += "<a href='javascript:showfolderlist("+(i+1)+")'>"+(i+1)+"</a> ";
			}
		}
	}
	$('idFolder').className="";
	curpage = page;
}
function searchIn(obj)
{
	obj.className = "search_input";
	$("search_button").className = "search_input";
	$("SearchContainer").className = "search_input";
	if (obj.value == "Search") obj.value = "";
}
function searchOut(obj)
{
	obj.className = "search";
	$("search_button").className = "search";
	$("SearchContainer").className = "search";
	if (obj.value == "")
		obj.value = "Search";
}
function searchKey(search_data)
{
	search_filter = search_data;
	if (typeof folderlist == "undefined") return;
	showfolderlist(1);
}
function searchEvent(event)
{
	if (event.keyCode == 13) // Return
	{
		searchKey($("SearchInput").value);
	}else if (event.keyCode == 27)	// Escape
	{
		$("SearchInput").value = "";
		document.body.focus();
		searchKey('');
	}
}
var timerArray = new Array();
function showEffForm(formname)
{
	if (typeof timerArray[formname] != "undefined")
	{
		clearInterval(timerArray[formname]);
	}
	curOpac = getOpacity($(formname));
	if (curOpac < 100)
	{
		setOpacity($(formname),curOpac+10);
		if (curOpac+10 < 100)
		{
			timerArray[formname] = setTimeout(function(){ showEffForm(formname); }, 50);
		}else
		{
			document.onclick = function (){ hideEffForm(formname); }
		}
	}else
	{
		setOpacity($(formname),0);
		showEffForm(formname);
	}
	$(formname).style.display = '';
}
function hideEffForm(formname)
{
	if (typeof timerArray[formname] != "undefined")
	{
		clearInterval(timerArray[formname]);
	}
	document.onclick = function() {};
	curOpac = getOpacity($(formname));
	if (curOpac > 0)
	{
		setOpacity($(formname),curOpac-10);
		timerArray[formname] = setTimeout(function(){ hideEffForm(formname); }, 50);
	}else
	{
		$(formname).style.display = 'none';
	}
}
function showpwform(sevent,targetPath)
{
	showEffForm('idPass');
	$('idPass').action = "album.php?u="+targetPath;
	$('idPass').style.left = Event(sevent).pageX+"px";
	$('idPass').style.top = Event(sevent).pageY+"px";
	$('idMainPass').focus();
	return false;
}
function setCookie(name,value) {
	var Days = 365;
	var exp = new Date(); //new Date("December 31, 9998");
	exp.setTime(exp.getTime() + Days*24*60*60*1000);
	document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString();
}
function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null)
		return unescape(arr[2]);
	return null;
}
function delCookie(name) {
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null)
		document.cookie=name +"="+cval+";expires="+exp.toGMTString();
}
function setLang(langid)
{
	if (USER_LANG == langid) return;
	setCookie('lang',langid);
	setCookie('lang_change',1);
	window.location.reload();
}
function showCopyArea()
{
	isCopyVisible = true;
	for (i=0;i<10;i++)
	{
		$("ichk"+i).style.visibility = "";
	}
	chbefore();
	return false;
}
function addCopy(img_id)
{
	sid = (page-1)*10+img_id;
	if (sid >= pic_num) return;
	
	copyArray[sid]=$('ichk'+img_id).checked;
	
	k=0;
	$('copyarea').innerHTML = "";
	for (i=0;i<pic_num;i++)
	{
		if (copyArray[i])
		{
			k++;
			$('copyarea').innerHTML+=k+". "+imglist[i][1]+"<br />\n[img]http://"+window.location.host+"/"+imglist[i][0]+"[/img]<br />\n";
		}
	}
}

document.onkeydown = function (e) {
		if (typeof folderlist == "undefined")
		{
			if (isIE)
			{
				if (event.keyCode==37) beforeimg();
				if (event.keyCode==39) nextimg();
				if (event.keyCode==33) chbefore();
				if (event.keyCode==34) chnext();
			}else
			{
				if (e.keyCode==37) beforeimg();
				if (e.keyCode==39) nextimg();
				if (e.keyCode==33) chbefore();
				if (e.keyCode==34) chnext();
			}
		}else
		{
			if (isIE)
			{
				if ((event.keyCode==37 || event.keyCode == 38) && curpage > 1) showfolderlist(curpage-1);
				if ((event.keyCode==39 || event.keyCode == 40) && curpage < pagenum) showfolderlist(curpage+1);
			}else
			{
				if ((e.keyCode==37 || e.keyCode == 38) && curpage > 1) showfolderlist(curpage-1);
				if ((e.keyCode==39 || e.keyCode == 40) && curpage < pagenum) showfolderlist(curpage+1);
			}
		}
	}
window.onload = function()
{
	if (typeof imglist == "undefined") return;
	for (i=0;i<imglist.length;i++)
	{
		if (imglist[i][2]) loadImages("thumbs/"+imglist[i][2]+".jpg");
	}
	for (i=0;i<imglist.length;i++)
	{
		loadImages(imglist[i][0]);
	}
}
loadImages("cdn/null.png");
