var ajax_www_ver='0.1';  //ajax响应程序版本号
var dir=null;
var path='/';
var page=1;
var UNam='';
var showarea_width=0;
var you_2_innerHTML='';
var imgpaths=null;
var linkdid=0;
var linkbut_Interval=null;

function file_show_url(uri)
{
	return "http://img1.668wd.cn"+url;
}

function page_url_script(url)
{
        var pos  = url.indexOf('?');
        if(pos!=-1)
                url= url.substring(0,pos);
        pos=url.lastIndexOf('/');
        if(pos>-1)
                return url.substring(pos+1);
        else
                return '/';
        
}

function left_hl_check()
{
        var scriptfile=page_url_script(location.href);
        if(leftarr[scriptfile] != undefined)
                scriptfile=leftarr[scriptfile];
        else{
                var pos  = scriptfile.indexOf('.');
                if(pos!=-1)
                        scriptfile = scriptfile.substring(0,pos);
        }
        //background-image:url(http://img.668wd.cn/images/template_44.gif);
        $('left_'+scriptfile).setStyles({'background-image':'url(http://img.668wd.cn/images/template_44.gif)'});
}

function copyToClipboard(txt)
{
	if(window.clipboardData) {	
		window.clipboardData.clearData();	
		window.clipboardData.setData("Text", txt);	
	} else if(navigator.userAgent.indexOf("Opera") != -1) {	
		window.location = txt;	
	} else if (window.netscape) {	
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");	
		} catch (e) {
			alert("代码复制被浏览器拒绝！\n您需要手工从代码框里复制完整代码");	
	  	}
	  	var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);	
	  	if (!clip)	
			return false;	
	  	var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);	
	  	if (!trans)	
			return false;	
	  	trans.addDataFlavor('text/unicode');	
	  	var str = new Object();	
	  	var len = new Object();	
	  	var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);	
	  	var copytext = txt;	
	  	str.data = copytext;	
	  	trans.setTransferData("text/unicode",str,copytext.length*2);	
	  	var clipid = Components.interfaces.nsIClipboard;	
	  	if (!clip)	
			return false;	
		clip.setData(trans,null,clipid.kGlobalClipboard);	
	}
	return true;
}

function copyaddr(src)
{
	copyToClipboard(src);
	alert('地址 '+src+" 已经成功复制到您的系统剪贴板");
}

function copycode(src)
{
	src='<img src="'+src+'" />';
	copyToClipboard(src);
	alert('代码 '+src+" 已经成功复制到您的系统剪贴板");
}

function MoveTo(mpath)
{
	if(mpath==''){
		alert('请设定您要转移到的目录');
	}
	noteindex='0,0';
	$$('.fcheck').each(function(item){
		if(item.checked)
			noteindex+=','+item.value;
	});
	var now = new Date();
	var req = new Request({
		url: 'move.php?n='+noteindex+'&path='+encodeURIComponent(mpath)+'&t='+now.getTime(),
		method: 'get',
		onSuccess: function(responseText)
		{
			//对于后台程序的回应
			if(responseText=='ok'){
				alert('转移成功');
				Dir(mpath,page);
			}
			else if(responseText=='file not exists')
				alert('您指定的文件不存在');
			else if(responseText=='db error')
				alert('删除过程中发生了数据库错误，删除失败');
			else if(responseText=='not empty')
				alert("您欲删除的目录不为空，无法删除，\n请将该目录下的所有文件和子目录删除后执行此操作");
			else if(responseText=='not login')
				alert('请登录后执行此操作');
			else
				alert(responseText);
		},
  		onFailure: function() {  
			alert("通讯出错");  
  		}
	}).send();
}

function Editor_UsePics()
{
	var tmp_html='';
	if(imgpaths != null){
		$$('.fcheck').each(function(item){
			if(item.checked){
				tmp_html=tmp_html+'<img src="'+imgpaths[item.value]+'" /><br />';
			}
		});
	}
	if(tmp_html != '')
		Editor_InsertHTML(tmp_html);
}

function DelSel()
{
	noteindex='0,0';
	$$('.fcheck').each(function(item){
		if(item.checked)
			noteindex+=','+item.value;
	});
	var now = new Date();
	var req = new Request({
		url: '/xiangce/del.php?n='+noteindex+'&t='+now.getTime(),
		method: 'get',
		onSuccess: function(responseText)
		{
			//Dir(path,page);
			//对于后台程序的回应
			if(responseText=='ok'){
				alert('文件删除成功');
				location.href="http://www.668wd.cn/xiangce/list.php?path="+encodeURIComponent(path)+"&page="+page;
			}
			else if(responseText=='file not exists')
				alert('您指定的文件不存在');
			else if(responseText=='db error')
				alert('删除过程中发生了数据库错误，删除失败');
			else if(responseText=='not empty')
				alert("您欲删除的目录不为空，无法删除，\n请将该目录下的所有文件和子目录删除后执行此操作");
			else if(responseText=='not login')
				alert('请登录后执行此操作');
		},
  		onFailure: function() {  
			alert("通讯出错");  
  		}
	}).send();
}

function Del(noteindex)
{
	//if(noteindex<1)
	//	alert('参数错误');
	noteindex='0,'+noteindex+',0';
	var now = new Date();
	var req = new Request({
		url: '/xiangce/del.php?n='+noteindex+'&t='+now.getTime(),
		method: 'get',
		onSuccess: function(responseText)
		{
			//对于后台程序的回应
			if(responseText=='ok')
				alert('文件删除成功');
			else if(responseText=='file not exists')
				alert('您指定的文件不存在');
			else if(responseText=='db error')
				alert('删除过程中发生了数据库错误，删除失败');
			else if(responseText=='not empty')
				alert("您欲删除的目录不为空，无法删除，\n请将该目录下的所有文件和子目录删除后执行此操作");
			else if(responseText=='not login')
				alert('请登录后执行此操作');
			//Dir(path,page);
			location.href="http://www.668wd.cn/xiangce/list.php?path="+encodeURIComponent(path)+"&page="+page;
		},
  		onFailure: function() {  
			alert("通讯出错");  
  		}
	}).send();
}

function BuildList_Dir(dir,i,showarea)
{
	tip_html= "<a href=\"#\" onclick=\"Del("+dir[i].fid+")\">删除</a>&nbsp;<br />";
	tip_html=tip_html + '<span><b>文件夹名：</b>'+dir[i].filename+'</span><br />';
	tip_html=tip_html + '<span><b>创建时间：</b>'+dir[i].inserttime+"</span><br />";
	tip_html=tip_html + '<span><b>创建IP：</b>'+dir[i].insertip+"</span><br />";
	tip_html=tip_html + '<span><b>备注：</b>'+dir[i].summ+"</span>";

	var el2=new Element('div',{'class':'pic_area'});
	var el3=new Element('div',{'class':'picarea-t'});
	var el4=new Element('div',{'class':'picarea-b'});

	tmp=new Element('div',{'html':dir[i].filename,'style':'overflow:hidden;width:102px;height:16px;'});
	tmp.inject(el4);
	var tmp=new Element('input',{'class':'fcheck','name':'files[]','type':'checkbox','value':dir[i].fid});
	tmp.inject(el4);

	var tmp=new Element('a',{'href':'#','html':'删除','class':'option_a'});
    tmp.addEvent('click',function(event){
			Del(dir[i].fid);
    });
	tmp.setStyles({'text-decoration':'underline'});
	tmp.inject(el4);

	dir[i].width=102;
	dir[i].height=102;

	var t_width=102;
	var t_rate=dir[i].height / dir[i].width;
	var t_height=Math.round(t_rate * t_width);
	if(t_height > 87){
		var t_height=87;
		var t_rate=dir[i].width / dir[i].height;
		var t_width=Math.round(t_rate * t_height);
		var img_top='0px';
	}
	else{
		var img_top=87-t_height;
		img_top=Math.round(img_top / 2)-8;
		if(img_top<0)
			img_top=0;
		img_top=img_top+'px';
	}

	var imgdiv=new Element('div',{'class':'imgdiv'});

	var tmp=new Element('div',{});
	tmp.setStyle('height',img_top);
	tmp.inject(imgdiv);

	var t_path=path+'/'+dir[i].filename;
	t_path=t_path.replace('//','/');

	dir_a=new Element('a',{'href':"#"});
    dir_a.addEvent('click',function(event){
			Dir(t_path,1);
    });

	tmp=new Element('img',
		{
			'src': 'http://img.668wd.cn/dir.png',
			'width': t_width,
			'height': t_height
		});
//	tip_nomove(tmp,tip_html);
	tmp.inject(dir_a);
	dir_a.inject(imgdiv);

	imgdiv.inject(el3);
	el4.inject(el3);
	el3.inject(el2);
	//el2.inject(el1);

	el2.inject(showarea);
}

function show_pic_attr(fileattr)
{
	var tip_html='<div style="text-align:left;">';
	tip_html=tip_html + '<span><b>文件名：</b>'+fileattr.filename+'</span><br />';
	tip_html=tip_html + '<span><b>图片尺寸：</b>'+fileattr.width+' x '+fileattr.height+' px</span><br />';
	tip_html=tip_html + '<span><b>文件大小：</b>'+fileattr.filesize+"</span><br />";
	tip_html=tip_html + '<span><b>上传时间：</b>'+fileattr.inserttime+"</span><br />";
	tip_html=tip_html + '<span><b>上传IP：</b>'+fileattr.insertip+"</span><br />";
	tip_html=tip_html + '<span><b>水印：</b><a href="http://www.668wd.cn/xiangce/allwm.php?id='+fileattr.fid+'&wm=text" target="_blank">文字&nbsp;<a href="http://www.668wd.cn/xiangce/allwm.php?id='+fileattr.fid+'&wm=images" target="_blank">图片</a></span><br />';
	tip_html=tip_html + '<span><b>备注：</b>'+fileattr.summ+"</span><br />";
	tip_html=tip_html + '<span><b>地址：</b><input type="text" value="http://img1.668wd.cn'+fileattr.path+"\" /></span><br /></div>";
	return tip_html;
}

function BuildList_File(dir,i,showarea)
{
	if(dir[i].filesize>1024 * 1024){
		dir[i].filesize=dir[i].filesize / (1024 * 1024);
		dir[i].filesize=Math.round(dir[i].filesize*10)/10.00;
		dir[i].filesize=dir[i].filesize+'MB';
	}
	else if(dir[i].filesize>1024){
		dir[i].filesize=dir[i].filesize / 1024;
		dir[i].filesize=Math.round(dir[i].filesize*10)/10.00;
		dir[i].filesize=dir[i].filesize+'KB';
	}
	else
		dir[i].filesize=dir[i].filesize+'B';


	tip_html="<a href=\"#\" onclick=\"copyaddr('http://img1.668wd.cn"+dir[i].path+"')\">获取地址</a>&nbsp;";
	//tip_html=tip_html + "<a href=\"javascript:copycode('http://img1.668wd.cn"+dir[i].path+"')\">获取代码</a>&nbsp;";
	tip_html=tip_html + "<a href=\"#\" onclick=\"Del("+dir[i].fid+")\">删除</a>&nbsp;<br />";
	//tip_html=tip_html +'<img src="http://img1.668wd.cn'+dir[i].path+'" width="220" /><br />';
	tip_html=tip_html + '<span><b>文件名：</b>'+dir[i].filename+'</span><br />';
	tip_html=tip_html + '<span><b>图片尺寸：</b>'+dir[i].width+' x '+dir[i].height+' px</span><br />';
	tip_html=tip_html + '<span><b>文件大小：</b>'+dir[i].filesize+"</span><br />";
	tip_html=tip_html + '<span><b>上传时间：</b>'+dir[i].inserttime+"</span><br />";
	tip_html=tip_html + '<span><b>上传IP：</b>'+dir[i].insertip+"</span><br />";
	tip_html=tip_html + '<span><b>备注：</b>'+dir[i].summ+"</span><br />";
	tip_html=tip_html + '<span><b>地址：</b><input type="text" value="http://img1.668wd.cn'+dir[i].path+"\" /></span><br />";
	//tip_html=tip_html + '<span><b>代码：</b><input type="text" value="&lt;img src=http://img1.668wd.cn'+dir[i].path+" /&gt;\" /></span><br />";

//	var el1=new Element('div',{'class':'biankuang'});
	var el2=new Element('div',{'class':'pic_area'});
	var el3=new Element('div',{'class':'picarea-t'});
	var el4=new Element('div',{'class':'picarea-b'});

	tmp=new Element('div',{'html':dir[i].filename,'style':'overflow:hidden;width:102px;height:16px;'});
	tmp.inject(el4);
	var tmp=new Element('input',{'class':'fcheck','name':'files[]','type':'checkbox','value':dir[i].fid});
	tmp.inject(el4);

	var tmp=new Element('a',{'href':"#",'html':'地址'});
	tmp.setStyles({'text-decoration':'underline'});
    tmp.addEvent('click',function(event){
	copyaddr('http://img1.668wd.cn'+dir[i].path);
    });
	tmp.inject(el4);
	//el4.innerHTML=el4.innerHTML+'&nbsp;';
	//var tmp=new Element('a',{'href':'edit.php?n='+dir[i].fid,'html':'编辑','class':'option_a'});
	//tmp.inject(el4);
	var tmp=new Element('a',{'href':'#','html':'删除','class':'option_a'});
	tmp.setStyles({'text-decoration':'underline'});
    tmp.addEvent('click',function(event){
	Del(dir[i].fid);
    });
	tmp.inject(el4);
	//el4.innerHTML=el4.innerHTML+'&nbsp;';

	var tmp=new Element('a',{'href':'#','html':'详情','class':'option_a'});
	tmp.setStyles({'text-decoration':'underline'});
	tip_nomove(tmp,tip_html);
	tmp.inject(el4);

	var t_width=102;
	var t_rate=dir[i].height / dir[i].width;
	var t_height=Math.round(t_rate * t_width);
	if(t_height > 87){
		var t_height=87;
		var t_rate=dir[i].width / dir[i].height;
		var t_width=Math.round(t_rate * t_height);
		var img_top='0px';
	}
	else{
		var img_top=87-t_height;
		img_top=Math.round(img_top / 2)-8;
		if(img_top<0)
			img_top=0;
		img_top=img_top+'px';
	}

	var imgdiv=new Element('div',{'class':'picarea-t'});

	var tmp=new Element('div',{});
	tmp.setStyle('height',img_top);
	tmp.inject(imgdiv);

	var imglink=new Element('a',
	{
		'href':'http://img.668wd.cn'+dir[i].path,
		'target':'_blank'
	});
	imglink.inject(imgdiv);

	tmp=new Element('img',
	{
		'src': 'http://img.668wd.cn'+dir[i].small,
		'width': t_width,
		'height': t_height
	});
	if(showarea_width>0){
		imgpaths[dir[i].fid]='http://img1.668wd.cn'+dir[i].path;
		tmp.addEvent('mouseup',function(event){
			var editor_source='http://img1.668wd.cn'+dir[i].path;
			Editor_Ok(editor_source);
		});
	}
//	else
//		tip_nomove(tmp,tip_html);
	tmp.inject(imglink);

	imgdiv.inject(el3);
	el4.inject(el3);
	el3.inject(el2);
//	el2.inject(el1);

	el2.inject(showarea);
}

function PDir(t_page)
{
	Dir(path,t_page);
}

function Dir(t_path,t_page)
{
	if(t_page<1)
		t_page=1;
	if(t_path != '')
		path=t_path;
	$('checkall').checked=false;
	page=t_page;
	var path_list="<a href=\"#\" onclick=\"Dir('/',1);\">根目录</a>&gt;";
	var tmp_path='/';
	var parr=path.split('/');
	var t_len=parr.length;
	for(i=1;i<t_len;i++){
		if(parr[i] != ''){
			tmp_path+='/'+parr[i];
			tmp_path=tmp_path.replace('//','/');
			path_list+="<a href=\"#\" onclick=\"Dir('"+tmp_path+"',1)\">"+parr[i]+'</a>&gt;';
		}
	}

	var now = new Date();
	var req = new Request({
		url: 'dir.php?s='+encodeURIComponent(search)+'&path='+encodeURIComponent(path)+'&page='+page+'&t='+now.getTime(),
		method: 'get' ,
		onSuccess: function(responseText)
		{
			if(responseText.length>1){
				var showarea=$("showarea");
				showarea.erase('html');
				if(responseText == 'no login'){
					showarea.innerHTML='您尚未登录，请登录后再试';
				}
				else{
					eval('dir = '+responseText+';');
					if(showarea_width>0){
						$('you_2').innerHTML=you_2_innerHTML+'您当前所在位置: '+path_list+' <br />文件数量'+dir['pagearr'].RecordCount;
					}
					else
						$('you_2').innerHTML='您当前所在位置: '+path_list+' <br />文件数量'+dir['pagearr'].RecordCount;
					var pstr='';
					pstr+='<a href="#" onclick="PDir(1)">第一页</a>&nbsp;';
					pstr+='<a href="#" onclick="PDir('+dir['pagearr'].PrePage+')">上一页</a>&nbsp;';
					var l=dir['pagearr'].PageArr.length;
					for(i=0;i<l;i++){
						if(dir['pagearr'].PageArr[i] != dir['pagearr'].Page)
							pstr+='<a href="#" onclick="PDir('+dir['pagearr'].PageArr[i]+')">'+dir['pagearr'].PageArr[i]+'</a>&nbsp;';
						else
							pstr+=dir['pagearr'].PageArr[i]+'&nbsp;';
					}
					pstr+='<a href="#" onclick="PDir('+dir['pagearr'].NextPage+')">下一页</a>&nbsp;';
					pstr+='<a href="#" onclick="PDir('+dir['pagearr'].PageCount+')">尾页</a>&nbsp;';
					showarea.innerHTML=pstr;

					var obj=$('mpath');
					l=obj.options.length-1;
					for(i=l ; i>= 0 ; i--)
						 obj.options[i] = null;
					obj.options.add(new Option('转移到',''));
					l=dir['dirlist'].length;
					for(i=0;i<l;i++)
						obj.options.add(new Option(dir['dirlist'][i],dir['dirlist'][i]));

					l=dir['list'].length;
					var tip_html='';
					var cleardiv=null;
					if(showarea_width>0)
						line_count=3;
					else
						line_count=5;

					imgpaths = new Array();
					for(i=0;i<l;i++){
						if(dir['list'][i].filesize>0)
							BuildList_File(dir['list'],i,showarea);
						else
							BuildList_Dir(dir['list'],i,showarea);
						if((i+1) % line_count == 0){
							cleardiv=new Element('div',{});
							cleardiv.setStyle('clear','both');
							cleardiv.inject(showarea);
						}
					}
				}
			}
			if(showarea_width>0){
				showarea.setStyles({
					'width':showarea_width+'px',
					'height':showarea_height+'px',
					'overflow-y':'scroll'
				});
			}
  		},  
  		onFailure: function() {  
			alert("通讯出错");  
  		}
	}).send(null); 
}

function CheckUserName()
{
	var un=$('username');
	var input=un.value;
	if( input != ''){
		var reg=/^[a-z0-9\-_\.\u4E00-\u9FA5]+$/ig
		if (reg.test(input)){

var req = new Request({  
  url: 'http://www.668wd.cn/ajax/www/'+ajax_www_ver+'/checkun.php?u='+encodeURIComponent(input),  
  method: 'get' ,
  onSuccess: function(responseText)
  {
	if(responseText=='exist'){
		//存在的用户名
		errtip($('username'),'用户名已经存在，请重新输入');
		$('username').value='';
	}
	else{
		$('pwd1').focus();
	}
  },  
  onFailure: function() {  
    alert("通讯出错");  
  }  
}).send(); 
		}
		else{
			errtip($('username'),'用户名不合法');
			$('username').value='';
			$('username').focus();
		}
	}
	
}

function CheckEmail()
{
	var Email=$('email');
 	var reg = /^[0-9a-zA-Z_\-\.]+@[0-9a-zA-Z_\-]+(\.[0-9a-zA-Z_\-]+)*$/; 
	if(!reg.test(Email.value)){
		errtip($('email'),'Email地址格式错误');
		Email.value='';
	}
	else{
		$('pwd1').focus();
	}
}

function CheckPwd()
{
	var pwd1=$('pwd1');
	if(pwd1.value.length<4){
		errtip($('pwd'),'密码长度不得少于4个字母');
		pwd1.value='';
	}
	else{
		$('pwd2').focus();
	}
}

function CheckPwd2()
{
	var pwd2=$('pwd2');
	if(pwd2.value != $('pwd1').value){
		errtip($('pwd2'),'两次密码输入不一致');
		pwd2.value='';
	}
}

function treg()
{
	$('reg-button').setStyle('visibility','hidden');
	setTimeout("$('reg-button').setStyle('visibility','visible')",100);
	$('reg-button').enable=false;
	$('form1').submit();
	return;
	var req = new Request({  
		url: 'reg.php',  
		method: 'post' ,
		onSuccess: function(responseText)
		{
 			var reg = /^\d+$/; 
			if(!reg.test(responseText)){
				//返回值为非数字，出错，显示错误信息
				//alert(responseText);
				if(responseText=='username format'){
					alert('用户名格式有误');
					$('reg-button').enable=true;
				}
			}
			else
				location.href="userhome.html";
  		},  
  		onFailure: function() {  
			alert("通讯出错");  
			$('reg-button').enable=true;
  		}
	}).send($('form1').toQueryString());
}

function errtip(els,html)
{
	//出错消息提示框
	var now = new Date();
	if(html=='' || html==null)
		html='';
	var el1=new Element('div',{'id':'el1_'+now.getTime(),'class':'big'});
	el1.setStyle('opacity',0);

	var info1=new Element('div',{'class':'big2_a','html':html});

	var tmp=new Element('div',{'class':'big1'});
	var tmp_img=new Element('img',{'src':'http://img.668wd.cn/images/tsk2.gif','width':180,'height':110});
	tmp_img.inject(tmp);
	tmp.inject(el1);
	info1.inject(el1);

	el1.inject($$('body')[0]);

	mx=els.offsetLeft+els.offsetWidth-5;//获取浏览器x坐标并且偏移20px
	my=els.offsetTop-40;//同理
	el1.setStyles({
		'left':mx,
		'top':my
	});
	el1.tween('opacity',1);//变换透明度到1
	//变换透明度到0
	setTimeout("$('el1_"+now.getTime()+"').tween('opacity',0)",6000);
}

function hidden_nomove_tip(id)
{
	if(nomove_tip_inshow){
		$(id).tween('opacity',0);
		nomove_tip_inshow=false;
	}
}

var nomove_tip_inshow=false;

function tip_nomove(els,html)
{
	if(html=='' || html==null)
		html='<img src="http://img.668wd.cn/images/1_05.gif" width="50px" />';
	//var el1=new Element('div',{'class':'bubble'});
	var el1=new Element('div',{'class':'show_tips'});
	el1.setStyle('opacity',0);
	var el2=new Element('div',{'class':'bubbleLeft'});
	var el3=new Element('div',{'class':'bubbleRight'});
	var el4=new Element('div',{'class':'show_tips_data','html':html});
	el4.inject(el3);
	el3.inject(el2);
	el2.inject(el1);
	el1.inject($$('body')[0]);

	els.addEvent('mouseenter',function(event){
		mx=event.page.x-20;//获取浏览器x坐标并且偏移20px
		my=event.page.y-40;//同理
		if(mx+305>window.screen.availWidth)
			mx=window.screen.availWidth-305;
		el1.setStyles({
			'left':mx,
			'top':my
		});
		nomove_tip_inshow=true;
		el1.tween('opacity',1);//变换透明度到1
	});
	els.addEvent('mouseleave',function(event){
		el1.tween('opacity',0);
	});

	el1.addEvent('mouseenter',function(event){
		el1.tween('opacity',1);//变换透明度到1
	});
	el1.addEvent('mouseleave',function(event){
		el1.tween('opacity',0);
		//setTimeout("hidden_nomove_tip('"+id+"')",3000);
	});
}

function tip(els,html)
{
	if(html=='' || html==null)
		html='<img src="http://img.668wd.cn/images/1_05.gif" width="50px" />';
	var el1=new Element('div',{'class':'bubble'});
	el1.setStyle('opacity',0);
	var el2=new Element('div',{'class':'bubbleLeft'});
	var el3=new Element('div',{'class':'bubbleRight'});
	var el4=new Element('div',{'html':html});
	el4.inject(el3);
	el3.inject(el2);
	el2.inject(el1);
	el1.inject($$('body')[0]);
	//以上步骤生成气泡所需html代码
	els.addEvent('mouseenter',function(event){//鼠标进入时触发
		mx=event.page.x+20;//获取浏览器x坐标并且偏移20px
		my=event.page.y-40;//同理
		el1.setStyles({
			'left':mx,
			'top':my
		});
		el1.tween('opacity',1);//变换透明度到1
	});
	els.addEvent('mousemove',function(event){//鼠标移动时触发
		mx=event.page.x+20;
		my=event.page.y-40;
		el1.setStyles({
			'left':mx,
			'top':my
		});
	});
	els.addEvent('mouseleave',function(event){//鼠标离开时触发
		el1.tween('opacity',0);//变换透明度到0
	});
}

function tips(els){
	var el1=new Element('div',{'class':'bubble'});
	el1.setStyle('opacity',0);
	var el2=new Element('div',{'class':'bubbleLeft'});
	var el3=new Element('div',{'class':'bubbleRight'});
	var el4=new Element('div',{'id':'bubbleFont'});
	el4.inject(el3);
	el3.inject(el2);
	el2.inject(el1);
	el1.inject($$('body')[0]);
	//以上步骤生成气泡所需html代码
	$$(els).each(function(e){//为所有class属性包含els的元素初始化
		e.addEvent('mouseenter',function(event){//鼠标进入时触发
			mx=event.page.x+20;//获取浏览器x坐标并且偏移20px
			my=event.page.y-40;//同理
			note=this.get('title');//提示的信息由元素的title属性提供
			$('bubbleFont').set('text',note);
			el1.setStyles({
				'left':mx,
				'top':my
			});
			el1.tween('opacity',1);//变换透明度到1
			$('bubbleFont').innerHTML=event.page.x;
			//设定其内html内容
		});
		e.addEvent('mousemove',function(event){//鼠标移动时触发
			//$('bubbleFont').innerHTML=event.page.x;
			mx=event.page.x+20;
			my=event.page.y-40;
			el1.setStyles({
				'left':mx,
				'top':my
			});
		});
		e.addEvent('mouseleave',function(event){//鼠标离开时触发
			el1.tween('opacity',0);//变换透明度到0
		});
	});
}

function show_mkdir()
{
	var el1=new Element('div',{'class':'show_mkdir'});
	var el3=new Element('div',{'class':'show_bg'});

	var el4=new Element('form',{'id':'mkdir_form','name':'mkdir_form'});

	var el2=new Element('label',{'html':'父目录： '+path+' <br />目录名:'});
	var tmp=new Element('input',{'name':'vdir','type':'hidden','value': path});
	tmp.inject(el4);

	var tmp=new Element('input',{'name':'dir','type':'text'});
	tmp.inject(el2);
	el2.inject(el4);
	var tmp=new Element('br',{});
	tmp.inject(el4);

	var el2=new Element('label',{'html':'备注:'});
	var tmp=new Element('input',{'name':'summ','type':'text'});
	tmp.inject(el2);
	el2.inject(el4);
	var tmp=new Element('br',{});
	tmp.inject(el4);

	var el2=new Element('input',{'type':'button','value':'创建'});
	el2.addEvent('click',function(event){
		var req = new Request({
			url: '/xiangce/mkdir.php',
			method: 'post' ,
			onSuccess: function(responseText){
				if(responseText=='ok')
					location.href="http://www.668wd.cn/xiangce/list.php?page="+page+"&path="+encodeURIComponent(path);
		//			Dir(path,page);
				el3.destroy();
				el1.destroy();
				if(responseText!='ok')
					alert(responseText);
  			},  
	  		onFailure: function() {  
				alert('error');
				el3.destroy();
				el1.destroy();	
  			}
		}).send($('mkdir_form').toQueryString());
	});

	el2.inject(el4);
	var el2=new Element('input',{'type':'button','value':'取消'});
	el2.inject(el4);
	el2.addEvent('click',function(event){
		el3.destroy();
		el1.destroy();
	});

	//window.screen.availWidth
	t_left=Math.round(window.screen.availWidth / 2) - 90;
	t_top=Math.round(window.screen.availHeight / 2) - 90 + window.getScrollTop();
	el1.setStyles(
		{
			'top':t_top+'px',
			'left':t_left+'px'
		}
	);
	t_width=window.getScrollWidth();
	t_height=window.getScrollHeight();
	el3.setStyles(
		{
			'width':t_width+'px',
			'height':t_height+'px'
		}
	);
	el4.inject(el1);
	el3.inject($$('body')[0]);
	el1.inject($$('body')[0]);
}


function PayUrl()
{
	var now = new Date();
	var req = new Request({
		url: 'http://www.668wd.cn/tenpay/topay.php?q='+$('q').value+'&type=0&t='+now.getTime(),
		method: 'get' ,
		onSuccess: function(responseText){
			if(responseText != 'faild')
				location.href=responseText;
			else
				alert('faild');
  		},  
  		onFailure: function() {  
				alert('faild');
  		}
	}).send(null);
}

function InitAllDir()
{
	var req = new Request({
		url: 'dir.php?do=2',
		method: 'get' ,
		onSuccess: function(responseText){
			if(responseText != 'no login'){
				eval('dir = '+responseText+';');
				var l=dir['list'].length;
				for(i=1;i<l;i++){
					$('path').options.add(new Option(dir['list'][i],dir['list'][i]));
					if(i==1)
						$('path').options.selected=true;
				}
			}
  		},  
  		onFailure: function() {  
  		}
	}).send(null);
}

function login(username,pwd)
{
	var req = new Request({
		url: 'login.php',
		method: 'post',
		onSuccess: function(responseText){
			if(responseText != ''){
				eval('ret = '+responseText+';');
				if(ret['stat']=='ok'){
					CheckLogin();
				}
				else{
					alert(ret['data']);
				}
			}
  		},  
  		onFailure: function() {  
  		}
	}).send($('login_form').toQueryString());
}

function GetSettings()
{
	var req = new Request({
		url: 'wm.php',
		method: 'get',
		onSuccess: function(responseText){
			if(responseText != 'no login' && responseText != null){
				eval('ret = '+responseText+';');
				$('wttile').value=ret['wttile'];
				$('wtcolor').value=ret['wtcolor'];
				$('wtsize').value=ret['wtsize'];
				$('wialpha').value=ret['wialpha'];
				if(ret['wpos']<1 || ret['wpos']>9)
					ret['wpos']=9;
				$$('.wpos').each(function(item){
					if(item.value==ret['wpos'])
						item.checked=true;
				});
				var wtfont=$('wtfont');
				var olen=wtfont.options.length;
				for(i=0;i<olen;i++){
					if(wtfont.options[i].value==ret['wtfont'])
						wtfont.options[i].selected=true;
				}
			}
  		},  
  		onFailure: function() {  
  		}
	}).send(null);
}

function CheckLogin()
{
	//检查是否登录
	$cs=Cookie.read('jw');
	if($cs != null && $cs != ''){
		$ca=$cs.split("\t");
		if($ca[0] != ''){
			UNam=$ca[0].trim();
			$('logging').erase('html');
	var req = new Request({
		url: '/sys/userstat.php',
		method: 'get',
		onSuccess: function(responseText){
			switch(responseText){
				case '':
					
					break;
				case 'no login':

					break;
				default:
eval('var userstat = '+responseText+';');
$('logging').innerHTML='<div class="username-wenzi"> <strong>'+UNam+' <a href="/loginout.php">[退出]</a></strong>&nbsp;</div><div class="username-wenzi">帐户余额：<span class="red-font">'+userstat.money+'</span>;   空间大小：<span class="red-font">'+userstat.spacesize+'</span>;   剩余空间：<span class="red-font">'+userstat.spacefree+'</span>;   '+userstat.timeoutp+'</div></div>';
					break;
			}
  		},  
  		onFailure: function() {  
  		}
	}).send(null);
			return true;
		}
	}
	return false;
}

function CheckedAll(classname,flag)
{
	$$(classname).each(function(item){
		item.checked=flag;
	});
}

editdiv_Interval=null;
function temp_edit_s(did)
{
	if(divshow)
		return;
	//divshow=true;
	$("editdid").value=did;
	t_left=Math.round(window.screen.availWidth / 2) - 260;
	t_top=Math.round(window.screen.availHeight / 2) - 180 + window.getScrollTop();
	$("editdiv").setStyles(
		{
			'top':t_top+'px',
			'left':t_left+'px'
		}
	);
	$("editdiv").setStyles({'display': 'block'});
	editdiv_Interval=setInterval("moveditediv()",100);
}

linkdiv_Interval=null;
function showlinkval(did)
{
	$('ldid').value=did;
	t_left=Math.round(window.screen.availWidth / 2) - 260;
	t_top=Math.round(window.screen.availHeight / 2) - 280 + window.getScrollTop();
	$("linkdiv").setStyles({'display': 'inline'});
	$("linkdiv").setStyles(
		{
			'top':t_top+'px',
			'left':t_left+'px'
		}
	);
	linkdiv_Interval=setInterval("movelinkdiv()",100);
}

function getEventY(e) //同时兼容ie和ff的写法 
{  
	if(document.all)  return e.y;
	return e.pageY; 
} 
function getEventX(e) //同时兼容ie和ff的写法 
{  
	if(document.all)  return e.x;
	return e.pageX; 
} 

function getEvent() //同时兼容ie和ff的写法 
{  
	if(document.all){
		var e = event ? event : window.event;
		return e;
	}
	func=getEvent.caller;        
	while(func!=null){  
		var arg0=func.arguments[0]; 
		if(arg0){ 
			if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
				return arg0; 
		} 
		func=func.caller; 
	} 
	return null; 
} 

function temp_edit_l(did)
{
//	if(divshow)
//		return;
	linkdid=did;
	var e=getEvent();

	$('editlinkbutton').setStyles({
			'top':getEventY(e)+'px',
			'left':getEventX(e)+'px',
			'width':'80px',
			'display':'block'
			});
	if(linkbut_Interval!=null)
		clearInterval(linkbut_Interval);
	linkbut_Interval=setInterval("$('editlinkbutton').setStyles({'display':'none'});clearInterval(linkbut_Interval);",8000);
}

function showarrval(did)
{
	$('adid').value=did;
	t_left=Math.round(window.screen.availWidth / 2) - 260;
	t_top=Math.round(window.screen.availHeight / 2) - 280 + window.getScrollTop();
	$("arrdiv").setStyles({'display': 'inline'});
	$("arrdiv").setStyles(
		{
			'top':t_top+'px',
			'left':t_left+'px'
		}
	);
	linkdiv_Interval=setInterval("movearrdiv()",100);
}

function temp_edit_a(did)
{
	var now=new Date();
	var req = new Request({
		url: 'arrval.php?t='+now.getTime()+'&fid='+fid+'&pid='+pid+'&did='+did,
		method: 'get',
		onSuccess: function(responseText){
			if(responseText != ''){
				$("arrdiv").innerHTML=arrdiv_html+responseText;
				showarrval(did);
			}
  		},  
  		onFailure: function() {  
  		}
	}).send();
}


function shownoticeval(did)
{
	//$('ndid').value=did;
	t_left=Math.round(window.screen.availWidth / 2) - 290;
	t_top=Math.round(window.screen.availHeight / 2) - 280 + window.getScrollTop();
	$("noticediv").setStyles({'display': 'inline'});
	$("noticediv").setStyles(
		{
			'top':t_top+'px',
			'left':t_left+'px'
		}
	);
	linkdiv_Interval=setInterval("movenoticediv()",100);
}
function temp_edit_notice(did)
{
	var now=new Date();
	var req = new Request({
		url: 'noticeval.php?t='+now.getTime()+'&fid='+fid+'&pid='+pid+'&did='+did,
		method: 'get',
		onSuccess: function(responseText){
			if(responseText != ''){
				shownoticeval(did);
				$("noticediv").innerHTML=responseText;
			}
  		},  
  		onFailure: function() {  
  		}
	}).send();
}
