function close_window(){
window.opener=null;
window.close();
}

function browsePopWindow(url,title,width,height,xpos,ypos) {
	var windowProperty="height="+height+", width="+width+",top="+ypos+",left="+xpos+", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	window.open (url,"弹出新闻",windowProperty);
}

function reset_data(){
document.getElementById("datafrm").reset();
}

function submit_data(){
document.getElementById("datafrm").submit();
}

function go_url(url){
window.location.href=url;
}

function openWindow_url(url){
window.open(url);
}

function return_list(){
document.getElementById("datafrm").action="list.asp";
submit_data();
}

function deal_editSubmitAfter(url){
document.getElementById("datafrm").action=url;
submit_data();
}

function deal_addSubmitAfter(url,isAddOk){
	if(isAddOk==1){
		//document.getElementById("id").value=0;
		//document.getElementById("page").value=1;
		document.getElementById("keyword").value="";
	}
	document.getElementById("datafrm").action=url;
	submit_data();
}





function del_batchPuts(){
var str="该操作将永久删除批量记录，确认继续吗？";
	if(confirm(str)){
	document.getElementById("datafrm").action="batch_del.asp";
	submit_data();
	}
}

//-------------------------复合查询------------------------------

function compose_complexTj(){
var string;
	if(s_tj==""){
		if(s_px==""){
			string="";
		}else{
			string="2=2 "+s_px;
		}
	}else{
		if(s_px==""){
			string=s_tj;
		}else{
			string=s_tj+" "+s_px;
		}
	}
	return string;
}

//复合查询依据的处理
function deal_complexTj(ctrlType,objId,fieldName,matchType){
	var s_partTj=deal_perSeekTj(ctrlType,objId,fieldName,matchType);
	if(s_tj==""){
		if(s_partTj!=""){
		s_tj=deal_perSeekTj(ctrlType,objId,fieldName,matchType);
		}
	}else{
		if(s_partTj!=""){
		s_tj=s_tj+" and "+deal_perSeekTj(ctrlType,objId,fieldName,matchType);
		}
	}
}

//依据参数选择处理单个查询依据的方式
function deal_perSeekTj(ctrlType,objId,fieldName,matchType){
var string;
	switch(ctrlType){
		case "input":
		string=deal_perSeek_inputTj(objId,fieldName,matchType);
		break;
		case "list":
		string=deal_perSeek_listTj(objId,fieldName,matchType);
		break;
		case "dt":
		string=deal_perSeek_dtTj(objId,fieldName);
		break;
	}
return string;	
}

//处理日期查询依据（日期类）
function deal_perSeek_dtTj(objId,fieldName){
var string,strDt1,strDt2,obj,s_match;
var arrDt=objId.split(",");
obj=eval("document.getElementById(\""+arrDt[0]+"\")");
s_match=obj.value;
	if(s_match==""||s_match==undefined){
	strDt1="";
	}else{
	strDt1="DateDiff(day,"+fieldName+",cast('"+s_match+"' as smalldatetime))<=0";
	}
obj=eval("document.getElementById(\""+arrDt[1]+"\")");
s_match=obj.value;
	if(s_match==""||s_match==undefined){
	strDt2="";
	}else{
	strDt2="DateDiff(day,cast('"+s_match+"' as smalldatetime),"+fieldName+")<=0";
	}	
	if(strDt1==""){
		if(strDt2==""){
			string="";
		}else{
			string=strDt2;
		}
	}else{
		if(strDt2==""){
			string=strDt1;
		}else{
			string=strDt1+" and "+strDt2;
		}
	}
	return string;
}

//处理单个查询依据（输入框类）
function deal_perSeek_inputTj(objId,fieldName,matchType){
var string;
var obj=eval("document.getElementById(\""+objId+"\")");
var s_match=obj.value;
	if(s_match==""||s_match==undefined){
	string="";
	}else{
		switch(matchType){
		case "i":
		string=fieldName+"="+s_match;
		break;
		case "s_exact":
		string=fieldName+"='"+s_match+"'";
		break;
		case "s_blur":
		string=fieldName+" like '%"+s_match+"%'";
		break;
		}
		string=" "+string;
	}
return string;
}

//处理单个查询依据（列表框类）
function deal_perSeek_listTj(objId,fieldName,matchType){
var string;
var obj=eval("document.getElementById(\""+objId+"\")");
var s_match=obj.options[obj.selectedIndex].value;
	if(s_match==""){
	string="";
	}else{
		if(s_match==""){
		string="";
		}else{
			switch(matchType){
			case "i":
			string=fieldName+"="+s_match;
			break;
			case "s":
			string=fieldName+"='"+s_match+"'";
			break;
			}
			string=" "+string;
		}
	}
return string;
}


//处理单个查询排序依据
function deal_sortTj(objId,fieldName){
var string;
var obj=eval("document.getElementById(\""+objId+"\")");
var s_match=obj.options[obj.selectedIndex].value;
string="order by "+fieldName+" "+s_match;
string=" "+string;
return string;
}

//查询依据加密
function encode_complexTj(string){
string=string.trim();
string=string.replace(/ /g,"&nbsp;");
string=string.replace(/\"/g,"&#34;");
string=string.replace(/\'/g,"&#39;");
string=string.replace(/</g,"&lt;");
string=string.replace(/>/g,"&gt;");
return string;
}

//vbscript那样的trim函数
String.prototype.trim=function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}
//计算字符串的长度（一个双字节字符长度计2，ASCII字符计1）
String.prototype.len=function(){
return this.replace(/[^\x00-\xff]/g,"aa").length;
}

//复制功能
function copyToClipboard(txt){
clipboardData.setData('text',txt);
alert('内容已复制, 粘贴请按Ctrl+V');
}

//属性切换
function switchProperty(type){
	for(var i=0;i<=arrDiv.length-1;i++){
	document.getElementById(arrDiv[i]).style.display="none";
	}
	document.getElementById(arrDiv[type]).style.display="block";
}

function isResetPswd(){
	var obj=document.getElementById("frmisresetpswdtag");
	if(obj.checked==true){
		document.getElementById("frmisresetpswd").value=1;
		document.getElementById("frmoldpswd").value="unknow";
	}else{
		document.getElementById("frmisresetpswd").value=0;
		document.getElementById("frmoldpswd").value="";
	}
}