//ajax提示框开始
var Obj=''
document.onmouseup=MUp
document.onmousemove=MMove

function MDown(Object){
Obj=Object.id
document.all(Obj).setCapture()
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
}

function MMove(){
if(Obj!=''){
  document.all(Obj).style.left=event.x-pX;
  document.all(Obj).style.top=event.y-pY;
  }
}

function MUp(){
if(Obj!=''){
  document.all(Obj).releaseCapture();
  Obj='';
  }
}

function openWithIframe(tit,url,w,h){
    //屏幕变暗
	var sWidth,sHeight;
	sWidth=document.body.clientWidth;
	sHeight=document.body.scrollHeight;
	if(sHeight<window.screen.height){sHeight=window.screen.height;}
	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#000000";
	bgObj.style.filter="Alpha(Opacity=30);";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
    document.body.appendChild(bgObj);
    //显示层
    massage_box.style.left = (document.body.clientWidth - w) / 2;
    massage_box.style.top = (screen.height - h) / 2-80;
    massage_box.style.screenx = (document.body.clientWidth - w) / 2;//仅适用于Netscape
    massage_box.style.screeny = (screen.height - h) / 2-80;//仅适用于Netscape
    massage_box.style.width = w+"px";
    massage_box.style.height = h+"px";
    massage_box.className = "massage_box";
	var popiframe;
	popiframe = '<div style="border-width:1 1 3 1; width:100%; height:100%; background:#fff; color:#666666; font-size:12px;zIndex:1000">'
	popiframe += '<div onmousedown=MDown(massage_box) style="background:#666666; height:20px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;color:#fff;cursor:move;padding:0 0 4px 0">'
	popiframe += '<div style="display:inline; width:200px; position:absolute;padding:3px 0 0 5px;color:#ffffff" id=pop_title>'+tit+'</div>'
	popiframe += '<span onClick="closeWithIframe()" style="float:right; display:inline; cursor:pointer;padding:3px 5px 0 0;font-size:12px;color:#ffffff;">关闭</span>'
	popiframe += '</div>'
	popiframe += '<div style="padding:5px" ><iframe src="'+url+'" width="'+(w-11)+'px"  height="'+(h-36)+'px" frameborder=0 scrolling=no></iframe></div>'
	popiframe += '</div>'
    massage_box.innerHTML=popiframe;
    massage_box.style.display = "";
}
function closeWithIframe(){
    massage_box.style.display="none";
    document.body.removeChild(document.getElementById("bgDiv"));
}

document.write('<div id="massage_box" style="display:none">loading...</div>');
//ajax提示框功能结束

// 日期显示脚本
    function date_js()
    {
    tmpDate = new Date();
    date = tmpDate.getDate();
    month= tmpDate.getMonth() + 1;
    year= tmpDate.getYear();
    document.write(year);
    document.write("年");
    document.write(month);
    document.write("月");
    document.write(date);
    document.write("日 ");
    myArray=new Array(6);
    myArray[0]="星期日"
    myArray[1]="星期一"
    myArray[2]="星期二"
    myArray[3]="星期三"
    myArray[4]="星期四"
    myArray[5]="星期五"
    myArray[6]="星期六"
    weekday=tmpDate.getDay();
    if (weekday==0 | weekday==6)
    {
    document.write(myArray[weekday])
    }
    else
    {
    document.write(myArray[weekday])
    }
    };

//图片最大长宽限定
function DrawImage(ImgD,width_s,height_s){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0){ 
        flag=true; 
        if(image.width/image.height>=width_s/height_s){ 
        if(image.width>width_s){ 
            ImgD.width=width_s; 
            ImgD.height=(image.height*width_s)/image.width; 
            }else{ 
            ImgD.width=image.width; 
            ImgD.height=image.height; 
            } 
        } 
    else{ 
      if(image.height>height_s){ 
        ImgD.height=height_s; 
        ImgD.width=(image.width*height_s)/image.height; 
        }else{ 
        ImgD.width=image.width; 
        ImgD.height=image.height; 
        } 
     } 
    } 
}

//鼠标指向图片后显示大图
function ShowPic(sUrl){ 
 var x,y; 
 x = event.clientX; 
 y = event.clientY; 
 document.getElementById("Layer1").style.left = x; 
 document.getElementById("Layer1").style.top = y; 
 document.getElementById("Layer1").innerHTML = "<img src=\"" + sUrl + "\">"; 
 document.getElementById("Layer1").style.display = "block"; 
} 
function hiddenPic(){ 
 document.getElementById("Layer1").innerHTML = ""; 
 document.getElementById("Layer1").style.display = "none"; 
}

/*显示验证码*/
function Get_code() {
	var Dv_CodeFile = "/inc/chkcode.asp";
	if(document.getElementById("imgid"))
	document.getElementById("imgid").innerHTML = '<img src="'+Dv_CodeFile+'?'+Math.random()+'" alt="点击刷新验证码" style="cursor:pointer;border:0;" onclick="this.src=\''+Dv_CodeFile+'?\'+Math.random()" />'
}

//分页跳转
function mychange(v){
if (v==""){}
else{
window.open (v,target="_self")
}
}

//选取所有
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')e.checked = form.chkall.checked; 
	}
}

//站内链接选项
function showadv()
{
	var tab;//表格ID
	if(document.form.Link_Type.checked == true) {
	link.style.display = "";
	info_input1.style.display = "none";
	info_input2.style.display = "none";
	info_input3.style.display = "none";
	} else {
	link.style.display = "none";
	info_input1.style.display = "";
	info_input2.style.display = "";
	info_input3.style.display = "";
	}
}

//选取分页代码
function copyc(){
    document.all.SDFY.select();
    document.execCommand("copy");
}

//图片管理
function AddUrl(cname,objname){
	var obj=$(objname);
	var thisurl=cname+(obj.length+1)+'|http://'; 
	var url=prompt('请输入'+cname+'和链接地址，中间用“|”隔开：',thisurl);
	if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);}
}

function ModifyUrl(cname,objname){
	var obj=$(objname);
	if(obj.length==0) return false;
	var thisurl=obj.value; 
	if (thisurl=='') {alert('请先选择一个'+cname+'，再点修改按钮！');return false;}
	var url=prompt('请输入'+cname+'和链接地址，中间用“|”隔开：',thisurl);
	if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);}
}

function DelUrl(cname,objname){
	var obj=$(objname);
	if(obj.length==0) return false;
	var thisurl=obj.value; 
	if (thisurl=='') {alert('请先选择一个'+cname+'，再点删除按钮！');return false;}
	if(obj.selectedIndex==0){alert('不能删除第一个'+cname+'！');return false;}
	obj.options[obj.selectedIndex]=null;
}

function UpUrl(cname,objname) {
	var obj=$(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==0)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的"+cname+"！");
		return;
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex-1].value;
	//var sHTML=obj.options[nIndex].innerHTML;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex-1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex-1;
}

function DownUrl(cname,objname) {
	var obj=$(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==nLen-1)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的"+cname+"！");
		return;
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex+1].value;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex+1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex+1;
}

function $(){return document.getElementById(arguments[0]);}

//显示图片缩略图
function doPreview(objname){
	var obj=$(objname);
	if(obj.length==0) return false;
	var url=obj.value; 

	if (url){
		url = url.replace(/.*[|]/,"");
		//url = url.replace("/",Wpath);
		//url = url.replace("/UpFile/",Upath);
		var sExt=url.substr(url.lastIndexOf(".")+1);
		sExt=sExt.toUpperCase();
		var sHTML;
		switch(sExt){
		case "GIF":
		case "JPG":
		case "BMP":
		case "PNG":
			tdPreview.innerHTML = "<img border='0' src='" + url + "' width='200' height='150'>";
			break;
		//case "SWF":
		//	sHTML = "<img border=0 src='" + url + "' width='170' height='140'>";
		//	break;
		default:
			tdPreview.innerHTML = "";
			break;
		}
		//tdPreview.innerHTML = sHTML;
	}else{
		tdPreview.innerHTML = "";
	}
}

// 显示无模式对话框
function ShowDialog(url, width, height) {
	var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
}

function preview() /* Preview for the "Compilation" */
	{
		if(document.form.HtmlCode.value.length>0)
			{
				pr=window.open("","Preview","scrollbars=1,width=800,height=500");
				pr.document.write(document.form.HtmlCode.value);
			}
		else alert('无任何内容可供预览!')
}
