var xmlHttp;
var obj_;
var url_;
var para_;
var tolPage=0;
var count=0;
var curPage=1;
var PageSize=25;
var order='';
var param_other_='';
var if_head=0;
var if_tail=1;
var if_checkP=0;
var userdefine='';
var ajtr='';
var listok=false;
//定义一个公共的颜色
var bgcolor="B5D4D6";
function init(urlC)
{
	xmlHttp=GetXmlHttpObject(showtype)
	xmlHttp.open("GET", urlC , true)
	xmlHttp.send(null)		
}
function initPage(urlC,paraC)
{
	url_ = urlC;
	curPage=1;
	para_ = paraC;
	showPage(curPage);
}
//刷新本页
function FlashPage(){
	if(document.getElementById("tablelist")){
		showPage(curPage);
	}
}
//排序
function OrderBy(str){
	order=str;
	showPage(curPage);
}
function showPage(curPageC)
{  
	ajtr='';
	curPage=curPageC;
	PageSize=getPageSizeCookie(PageSize);
	var url = url_+"?aj_count="+Math.random() * 1000+"&PageSize="+PageSize+"&userdefine="+userdefine+"&CurPage="+curPageC+para_+param_other_+order;
	//alert(url);
	xmlHttp=GetXmlHttpObject(showList);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}
function showList()
{	
	table = document.getElementById("tablelist");
	table.innerHTML="<img src='/images/ing.gif'>系统正在处理请求,请稍候 ...";
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		var response = xmlHttp.responseText;	
		count=response.substring(0,response.indexOf("#"));
		curPage = (count==0) ? 0 : ( (count<0) ? 1 : curPage );
     	response=response.substring(response.indexOf("#")+1);
		tolPage=response.substring(0,response.indexOf("#"));
		response=response.substring(response.indexOf("#")+1);
		var pageBefore =""
		pageBefore+="共 "+count+" 条 ";
		if (curPage >1){
			pageBefore += "&nbsp;<a href='javascript:showPage("+(curPage-1)+")'><img src='/images/upPage.gif' alt='上一页' width='16' height='15' border='0' align='absmiddle' ></a>";
		}
		pageBefore+="&nbsp;&nbsp;"+curPage;
		if (parseInt(curPage) != parseInt(tolPage)&&parseInt(tolPage)>1){
			pageBefore += "&nbsp;<a href='javascript:showPage("+(parseInt(curPage)+1)+")'><img src='/images/nextPage.gif' alt='下一页' width='46' height='15' border='0' align='absmiddle' ></a>";
		}
		//分页
      	var pageAhref ="";
		pageAhref +="共 "+count+" 条记录 ";
		if (curPage >1){
			pageAhref += "&nbsp;<a href='javascript:showPage("+(curPage-1)+")'><img src='/images/upPage.gif' alt='上一页' width='16' height='15' border='0' align='absmiddle' ></a>";
		}
		if (curPage >5){
			pageAhref += "&nbsp;<a class='pageNum' href='javascript:showPage(1)'>1</a>";
			pageAhref += "&nbsp;<a class='pageNum' href='javascript:showPage(2)'>2</a>";
			pageAhref += "&nbsp;<span class='gray3'>...</span>";
		}else{
			for(i=1;i<parseInt(curPage)-2;i++){
				if(curPage==i){
					pageAhref += "&nbsp;<span class='pageCurrent'>"+curPage+"</span>";
				}else{
					if(i<=tolPage&&i>0){
						pageAhref += "&nbsp;<a class='pageNum' href='javascript:showPage("+i+")'>"+i+"</a>";
					}
				}			
			}
		}
		for(i=(parseInt(curPage)-2);i<(parseInt(curPage)+3);i++){
			//alert(i);
			if(curPage==i){
				pageAhref += "&nbsp;<span class='pageCurrent'>"+curPage+"</span>";
			}
			else if(i<=tolPage&&i>0){
				pageAhref += "&nbsp;<a class='pageNum' href='javascript:showPage("+i+")'>"+i+"</a>";
			}			
		}
		if(parseInt(curPage)<(parseInt(tolPage)-4)){
			pageAhref += "&nbsp;<span class='gray3'>...</span>";
		}
		if(parseInt(curPage)<(parseInt(tolPage)-3)){
			pageAhref += "&nbsp;<a class='pageNum' href='javascript:showPage("+(parseInt(tolPage)-1)+")'>"+(parseInt(tolPage)-1)+"</a>";
		}
		if(parseInt(curPage)<(parseInt(tolPage)-2)){
			pageAhref += "&nbsp;<a class='pageNum' href='javascript:showPage("+tolPage+")'>"+tolPage+"</a>";
		}	
		if (parseInt(curPage) != parseInt(tolPage)&&parseInt(tolPage)>1){
			pageAhref += "&nbsp;<a href='javascript:showPage("+(parseInt(curPage)+1)+")'><img src='/images/nextPage.gif' alt='下一页' width='46' height='15' border='0' align='absmiddle' ></a>";
		}
		pageAhref += "&nbsp;转到第<input id='pager_goto_page' name='pageNo' onKeyUp=checkBaseNumber(this) type='text' class='inputTurnpage' size='2' value='"+curPage+"' /> 页&nbsp;";
		pageAhref += "&nbsp;当页显示<input id='pager_goto_pagesize' name='pageNo' onKeyUp=checkBaseNumber(this) type='text' class='inputTurnpage' size='2' maxLength=2 value='"+PageSize+"' /> 条&nbsp;";//
		pageAhref+="<input type=button value='确定' width=34 style='height: 18px;background:url('/images/2gezi.gif');' onclick='javascript:PageSize=document.getElementById(\"pager_goto_pagesize\").value;setPageSizeCookie(PageSize);showPage(document.getElementById(\"pager_goto_page\").value)'>";
		if(document.getElementById("pagenum")){
			document.getElementById("pagenum").innerHTML=pageAhref;
		}
		if(document.getElementById("pagenum2")){
			document.getElementById("pagenum2").innerHTML=pageAhref;
		}
		if(curPage==0&&count>0){
			showPage(1);
		}
		//alert(response.substring(1000));
		table.innerHTML=response;
		saveHistory();
		listok=true;
	}
}
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null	
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	}
	else
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}
function showBox(pro,obje,type){
	if(pro==""){CloseDivId();return;}
	if(pro.indexOf("ajax0-")>=0){
		var pp=pro.replace("ajax0-","");
		var j=0;
		pro="";
		for (j=0;j<parseInt(pp)+1;j++){
			pro+=j+"$";
		}
	}
	if(pro=="hour"){
		pro="00$01$02$03$04$05$06$07$08$09$10$11$12$13$14$15$16$17$18$19$20$21$22$23$";
	}
	if(pro=="min"){
		pro="00$01$02$03$04$05$06$07$08$09$10$11$12$13$14$15$16$17$18$19$20$21$22$23$";
		for (j=24;j<60;j++){
			pro+=j+"$";
		}
	}
	obj_=obje;
	var str="$"+obje.value;
	table = document.getElementById("tablepage");
	//alert();
	var temp="";
	var name="";
	var ifcheck="ifcheck";
	var ifradio="ifradio";
	if(type.indexOf("radio")>=0){
		pro+="无$";
	}
	if(type=="radi"){
		type="radio";
	}
	if(type.length>6&&type.indexOf("radio")>=0){
		ifradio=type.substring(6);
		type="radio";
	}
	if(type.length>6&&type.indexOf("radi_")>=0){
		ifradio=type.substring(5);
		type="radio";
	}
	temp+="<table border='0' cellspacing='0' cellpadding='0'>";
	temp+="<tr><td width='9' colspan='2'></td>";
	temp+="    <td height='1'  bgcolor='4E5B6C'></td>";
	temp+="    <td width='9' colspan='2'></td></tr>";
	temp+="<tr onclick='javascript:CloseDivId()'><td width='9' height='15' align=left colspan=2><img src='/images/div1.jpg' border=0 ></img></td>";
	temp+="    <td height='9' align='right' bgcolor='white'><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0 wifth=14 height=14></img></a></td>";
	temp+="    <td width='9' colspan='2' align='right'><img src='/images/div2.jpg' border=0 ></img></td></tr>";
	temp+="<tr><td height='1' colspan='5' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td class=ajtd>";
	//插入内容开始
	temp+="<table border=0 cellspacing=1 cellpadding=0 align=center>";
	//temp+="<tr><td  id=bgbody colspan=3><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0 wifth=18 height=18></img></a></td></tr>";
	var i=0;
	while(pro.indexOf("$")>0){
           name=pro.substring(0,pro.indexOf("$"));
           pro=pro.replace(name+"$","");
		   name=name.replace(" ","");
           if(i%3==0){
               temp+="<tr>";
		    }
            temp+="<td  nowrap>&nbsp;&nbsp;<input type="+type+" name=pro value=1 "+(str.indexOf("$"+name+"$")>=0?"checked":"")+
                    " onclick="+(type.indexOf("check")>=0?""+ifcheck+"(\""+name+"\")":""+ifradio+"(\""+name+"\")")+">"+name; //
            temp+="&nbsp;&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   while(i%3!=0){
	        temp+="<td  nowrap>&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   temp+="</table>";
//插入内容结束
	temp+="    </td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr class=ajtd>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='8' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="<tr bgcolor='4E5B6C'>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='1' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="</table>";

   table.innerHTML=temp;
   displayLayer();
}
function showDouble(str,type,obje){
	if(str==""){CloseDivId();return;}
    obj_=obje;
	table = document.getElementById("tablepage");
	var temp="";
	var t="";
	var name="";
	var id="";
	table.innerHTML="请稍候 ...";
	var temp="";

	temp+="<table border='0' cellspacing='0' cellpadding='0'>";
	//temp+="<tr><td align=right colspan=3 bgcolor='red'><a href='javascript:CloseDivId()'>关闭</a></td></tr>";

	temp+="<tr><td width='9' colspan='2'></td>";
	temp+="    <td height='1'  bgcolor='4E5B6C'></td>";
	temp+="    <td width='9' colspan='2'></td></tr>";
	temp+="<tr onclick='javascript:CloseDivId()'><td width='9' height='15' align=left colspan=2><img src='/images/div1.jpg' border=0 ></img></td>";
	temp+="    <td height='9' align='right' bgcolor='white'><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0 wifth=14 height=14></img></a></td>";
	temp+="    <td width='9' colspan='2' align='right'><img src='/images/div2.jpg' border=0 ></img></td></tr>";
	temp+="<tr><td height='1' colspan='5' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td class=ajtd>";
	//插入内容开始
	temp+="<table border=0 cellspacing=1 cellpadding=0  align=center>";
	//temp+="<tr><td colspan=3><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0></img></a></td></tr>";
    var i=0;
    while(str.indexOf("$")>0){
		t=str.substring(0,str.indexOf("$"));
        id=t.substring(0,t.indexOf("^"));
        t=t.substring(t.indexOf("^")+1);
		name=t.substring(0,t.indexOf("^"));
        str=str.replace(id+"^"+name+"^"+"$","");
        if(i%3==0){
			temp+="<tr>";
        }
        temp+="<td nowrap>&nbsp;&nbsp;<a href='javascript:"+type+"(\""+id+"\",\""+name+"\")'>"+name+"</a>"; //<font color=red>选中</font>
        //temp+="&nbsp;&nbsp;</a>";
        temp+="&nbsp;&nbsp;</td>";
        i++;
        if(i%3==0){
            temp+="</tr>";
        }
		if(i==99){
			break;
		}
     }
	 if(i==99){
		temp+="<tr><td nowrap colspan=3>&nbsp;&nbsp;<font color=red>本页只显示100条数据,如无选择,请输入更详细内容！</font></td></tr>";
	 }
     while(i%3!=0){
        temp+="<td nowrap>&nbsp;</td>";
        i++;
        if(i%3==0){
            temp+="</tr>";
        }
     }
    temp+="</table>";
//插入内容结束
	temp+="    </td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr class=ajtd>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='8' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="<tr bgcolor='4E5B6C'>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='1' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="</table>";
	table.innerHTML=temp;  
	displayLayer();
}

function ifcheck(str){
	if(obj_.value.indexOf(str+'$')=='-1'){
		obj_.value+=str+'$';
	}
	else{
		obj_.value=obj_.value.replace(str+'$','');
	}
}
function ifradio(str){
	if(str=='无'){
		obj_.value="";
	}
	else{
		obj_.value=str;//+'$'
	}
	CloseDivId();
}
function CloseDivId(){
	if_checkP=0;
	divid.style.visibility = 'hidden'; 
}
function Show(divid) { 
	//alert(event.y);
	var y=event.y-10;
	if(event.y>300){
		y =300;
	}
	divid.style.top=y;
	divid.style.left = event.x-500;
	divid.style.visibility = 'visible'; 
} 
function Hide(divid) { 
	divid.style.visibility = 'hidden'; 
} 

function showUrl(url,tablename){
	table = document.getElementById(tablename);
	xmlHttp=GetXmlHttpObject(showTable)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
}
function showTable(){
	table.innerHTML="<img src='/images/ing.gif'>请稍候 ...";
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		var response = xmlHttp.responseText;
		table.innerHTML=response;
		//divcenter(table);
	}
}
function GotoPage(str){
	if(str==""||!isBaseNumber(str)){
		showPage(1);
	}
	else if(parseInt(str)>parseInt(tolPage)){
		showPage(tolPage);
	}
	else{
		showPage(str);
	}
}
function showImage(obj){
    obj_=obj;
	if(obj.value==''){
		return;
	}
	table = document.getElementById("tablepage");
	var temp="";
	temp+="<table border=0 cellspacing=1 cellpadding=0 id=bgtable align=center style='background:#FFFFFF;border: 1px dashed #FF0000;'>";
	temp+="<tr><td  id=bgbody colspan=3><a href='javascript:CloseDivId()'>关闭</a></td></tr>";
	temp+="<tr><td  id=bgbody colspan=3><img src="+obj.value+"></td></tr>";
	temp+="<tr><td  id=bgbody colspan=3><a href='javascript:CloseDivId()'>关闭</a></td></tr>";
    temp+="</table>";
    table.innerHTML=temp;
	displayLayer();
}
function showImage2(obj){
	table = document.getElementById("div2");
	div2.style.visibility = 'visible';
	var temp="";
	temp+="<table border=0 cellspacing=1 cellpadding=0 id=bgtable align=center style='background:#FFFFFF;border: 1px dashed #FF0000;'>";
	temp+="<tr><td  id=bgbody colspan=3><a href='javascript:CloseDivId2()'>关闭</a></td></tr>";
	temp+="<tr><td  id=bgbody colspan=3><img src="+obj+"></td></tr>";
	temp+="<tr><td  id=bgbody colspan=3><a href='javascript:CloseDivId2()'>关闭</a></td></tr>";
    temp+="</table>";
    table.innerHTML=temp;
}
function showImagelist(pro,obje,type){
	if(pro==""){CloseDivId();return;}
	obj_=obje;
	var str="$"+obje.value;
	table = document.getElementById("tablepage");
	//alert();
	var temp="";
	var name="";
	temp+="<table border='0' cellspacing='0' cellpadding='0'>";
	temp+="<tr><td width='9' colspan='2'></td>";
	temp+="    <td height='1'  bgcolor='4E5B6C'></td>";
	temp+="    <td width='9' colspan='2'></td></tr>";
	temp+="<tr onclick='javascript:CloseDivId()'><td width='9' height='15' align=left colspan=2><img src='/images/div1.jpg' border=0 ></img></td>";
	temp+="    <td height='9' align='right' bgcolor='white'><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0 width=14 height=14></img></a></td>";
	temp+="    <td width='9' colspan='2' align='right'><img src='/images/div2.jpg' border=0 ></img></td></tr>";
	temp+="<tr><td height='1' colspan='5' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td class=ajtd>";
	//插入内容开始
	temp+="<table border=0 cellspacing=1 cellpadding=0 align=center>";
	var i=0;
	var link="";
	while(pro.indexOf("$")>0){
           name=pro.substring(0,pro.indexOf("$"));
           pro=pro.replace(name+"$","");
           if(i%3==0){
               temp+="<tr>";
		    }//
			link=name;
			link=link.replace('/','$');
			link=link.replace('/','$');
            temp+="<td  nowrap>&nbsp;&nbsp;<a href='javascript:OkImage(\""+name+"\")'><img src="+name+" width=150 heigth=150 border=0></a>"; //
            temp+="&nbsp;&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   while(i%3!=0){
	        temp+="<td  nowrap>&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   temp+="</table>";
//插入内容结束
	temp+="    </td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr class=ajtd>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='8' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="<tr bgcolor='4E5B6C'>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='1' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="</table>";
   table.innerHTML=temp;
   displayLayer();
}
function CheckChar(obj,checkOK){
	var checkStr=trim(obj.value);
	var temp=trim(obj.value);
	var ch_h="";
	for (i=0;i<checkStr.length;i++){
		ch_h=checkStr.charAt(i);
		if(checkOK.indexOf(ch_h)<0){
			alert(checkOK);
			alert(ch_h);
	        temp=temp.replace(ch_h,"");
	        obj.value=temp;		
		}
	}
	return obj.value;
}
function CheckNum(str,checkOK){
	var checkStr=trim(str);
	var temp=trim(str);
	var ch_h="";
	for (i=0;i<checkStr.length;i++){
		ch_h=checkStr.charAt(i);
		//判断是否为数字
		if(checkOK.indexOf(ch_h)<0){
	        temp=temp.replace(ch_h,"");		
		}
		//判断第一位是否为小数点
		else if(checkStr.substring(0,1)=='.'){
			temp=temp.replace(ch_h,"");
		}
		//判断第一位是否为0的整数
		else if(checkStr.length>1){
			if(checkStr.substring(0,1)=='0' && checkStr.substring(1,2)!='.'){
				temp=temp.replace(temp,temp.substring(1,temp.length));
				break;
			}
		}
		//判断是否有多个小数点
		if(checkStr.indexOf('.')>0){
			if((checkStr.substring(checkStr.indexOf('.')+1,checkStr.length)).indexOf('.')>=0){
				temp=temp.replace(temp,temp.substring(0,temp.length-1));
				break;
			}
		}
	}
	return temp;
}
function checkPointNumber(obj){
	if(obj.value!=''){
		obj.value=CheckNum(obj.value,"0123456789.");
		obj.focus();
	}
}
function checkBaseNumber(obj){
	if(obj.value!=''){
		obj.value=CheckNum(obj.value,"0123456789");
		obj.focus();
	}
}
function checkNumChat(obj){
	if(obj.value!=''){
		obj.value=CheckNum(obj.value,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
		obj.focus();
	}
}
function format_num(obj,num){
	var v=obj.value;
	while(parseInt(num-v.length)>0){
		v="0"+v;
	}
	obj.value=v;
}
function format_num_point(obj){
	var v=obj.value;
	if(v.indexOf(".")<0){
		obj.value=v+".00";
		return;
	}
	var i=v.length-v.indexOf(".");
	//alert(v.length-v.indexOf("."));
	if(i==2){
		obj.value=v+"0";
	}
	else {
		obj.value=v.substring(0,v.indexOf(".")+3);
	}
}
function checkNull(obj1,obj2,content,if_click){
	if(obj1.value==''){
		alert(content);
		if(if_click==1){
			obj2.onclick();
		}
		else if(if_click==0){
			obj2.focus();
		}
		return false;
	}
	else{
		return true;
	}
}
function checkTian(str1,str2,obj1,obj2,content,if_click){
	if(str1.indexOf("$"+str2+"$")>=0){
		if(obj1.value==''){
			alert(content);
			if(if_click==1){
				obj2.onclick();
			}
			else if(if_click==0){
				obj2.focus();
			}
			return false;
		}
		else{
			return true;
		}
	}
	else{
		return true;
	}
}
function replaceAll(value_,v1,v2){
	while(value_.indexOf(v1)>=0){
		value_=value_.replace(v1,v2);
	}
	return value_;
}
function getParam(param,value_){
	value_=replaceAll(value_,'&','§');
	value_=replaceAll(value_,'%','％');
	value_=replaceAll(value_,'=','＝');
	return "&"+param+"="+value_;
}
function checkPosition(){
	if(if_checkP==1){
		if_checkP=2;
	}
	else if(if_checkP==2&&!divid.contains(document.elementFromPoint(event.clientX,event.clientY))){
		CloseDivId();		
	}
}
function showImagelist(pro,obje,type){
	if(pro==""){CloseDivId();return;}
	obj_=obje;
	var str="$"+obje.value;
	var table = document.getElementById("tablepage");
	//alert();
	var temp="";
	var name="";
	temp+="<table border='0' cellspacing='0' cellpadding='0'>";
	temp+="<tr><td width='9' colspan='2'></td>";
	temp+="    <td height='1'  bgcolor='4E5B6C'></td>";
	temp+="    <td width='9' colspan='2'></td></tr>";
	temp+="<tr onclick='javascript:CloseDivId()'><td width='9' height='15' align=left colspan=2><img src='/images/div1.jpg' border=0 ></img></td>";
	temp+="    <td height='9' align='right' bgcolor='white'><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0 width=14 height=14></img></a></td>";
	temp+="    <td width='9' colspan='2' align='right'><img src='/images/div2.jpg' border=0 ></img></td></tr>";
	temp+="<tr><td height='1' colspan='5' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td>";
	temp+="    <td width='8' bgcolor='A0C1E6'></td>";
	temp+="    <td bgcolor='A0C1E6'>";
	//插入内容开始
	temp+="<table border=0 cellspacing=1 cellpadding=0 align=center>";
	var i=0;
	var link="";
	while(pro.indexOf("$")>0){
           name=pro.substring(0,pro.indexOf("$"));
           pro=pro.replace(name+"$","");
           if(i%3==0){
               temp+="<tr>";
		    }//
			link=name;
			link=link.replace('/','$');
			link=link.replace('/','$');
            temp+="<td  nowrap>&nbsp;&nbsp;<a href='javascript:OkImage(\""+name+"\")'><img src="+name+" width=150 heigth=150 border=0></a>"; //
            temp+="&nbsp;&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   while(i%3!=0){
	        temp+="<td  nowrap>&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   temp+="</table>";
//插入内容结束
	temp+="    </td>";
	temp+="    <td width='8' bgcolor='A0C1E6'></td>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr bgcolor='A0C1E6'>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='8' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="<tr bgcolor='4E5B6C'>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='1' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="</table>";
   table.innerHTML=temp;
   displayLayer();
}
function Okuser(id,name){
	CloseDivId();
	form1.username.value=name;
	form1.userid.value=id;
}
function Okdept(id,name){
	form1.deptname.value=name;
	form1.deptid.value=id;
	CloseDivId();
}
function Okdeptall(id,name){
	form1.deptname.value=name;
	form1.deptid.value=id;
	form1.deptnameall.value=top.department.getDeptNmaeAll(id);
	CloseDivId();
}
function AutomateExcel(dctable){ 
	var table2 = document.getElementById(dctable);
	var i,j; 
	// Start Excel and get Application object. 
	var oXL = new ActiveXObject("Excel.Application"); 
	oXL.Visible = true; 
	var oWB = oXL.Workbooks.Add(); 
	var oSheet = oWB.ActiveSheet; 
	for(i=0;i<table2.rows.length;i++) 
		for(j=0;j<table2.rows(i).cells.length;j++) 
			oSheet.Cells(i+1, j+1).Value = "'"+table2.rows(i).cells(j).innerText 
	oXL.Visible = true; 
	oXL.UserControl = true; 
} 
function AutomateWord(dctable){ 
	var table2 = document.getElementById(dctable);
    var oWD = new ActiveXObject("Word.Application");
    var oDC = oWD.Documents.Add("",0,1);
    var oRange =oDC.Range(0,1);
    var sel = document.body.createTextRange();
    sel.moveToElementText(table2);
    sel.select();
    sel.execCommand("Copy");
    oRange.Paste();
    oWD.Application.Visible = true;
}
function AutomateText(dctable){ 
	var table2 = document.body;
    var sel = document.body.createTextRange();
    sel.moveToElementText(table2);
    sel.select();
    sel.execCommand("Copy");
}
//奥运版本 新脚本
function back(){
	if(top.workspace.main.workspace.newcontent.rows=="0,*,0,0"){
		top.workspace.main.workspace.newcontent.rows="*,0,0,0";
		return;
	}
	history.back();
}
function transwin(url){
    top.workspace.main.workspace.newcontent.rows="0,*,0";
	window.open(url,"open2","");
}
//把table中的tr颜色全部清除
function clearTrColor(tablename) {
   var theCells = null;
   if (typeof(document.getElementById(tablename).getElementsByTagName('TR')) != 'undefined') {
        theCells = document.getElementById(tablename).getElementsByTagName('TR');
    } 
    for (c = 0; c < theCells.length; c++) { theCells[c].style.backgroundColor = "#f7f5f0"; }
    return true;
}
//获取table中是否有点击项
function ifhaveclick(tablename){
	if(document.getElementById(tablename)==null){
		return false;
	}
	var theCells = null;
	if (typeof(document.getElementById(tablename).getElementsByTagName('TR')) != 'undefined') {
        theCells = document.getElementById(tablename).getElementsByTagName('TR');
	} 
	for (c = 0; c < theCells.length; c++) { 
		//alert(theCells[c].style.backgroundColor);
		if(theCells[c].style.backgroundColor!=''&&theCells[c].style.backgroundColor!="#f7f5f0"){
			//alert("ok");
			return true;
		}
	}
	return false;
}
//关闭div2
function CloseDivId2(){
	if(document.getElementById("div2"))
	div2.style.visibility = 'hidden'; 
}
//对于面积 户型 价格 房龄 区间 的选择
function showBoundBox(pro,obje){
	if(pro==""){CloseDivId();return;}
	if(pro.indexOf("ajax")>=0){
		var pp=pro.replace("ajax","");
		var tt=pp.substring(0,1);
		pp=pp.substring(pp.length-2);
		var j=0;
		pro="";
		for (j=1;j<parseInt(pp)+1;j++){
			pro+=""+j+"^"+j+"^"+j+"^$";
		}
	}
	obj_=obje;
	//////////////////////////////////////////////////
	var box_down="";
	var box_up="";
	var str=obje.value;
	if(str!=""){
		box_down=str.substring(0,str.indexOf("-"));
		box_up=str.substring(str.indexOf("-")+1);
	}
	////////////////////////////////////////////////////
	table = document.getElementById("tablepage");
	var temp="";
	temp+="<table border='0' cellspacing='0' cellpadding='0'>";
	temp+="<tr onclick='javascript:CloseDivId()'><td width='9' height='15' align=left colspan=2><img src='/images/div1.jpg' border=0 ></img></td>";
	temp+="    <td height='9' align='right' bgcolor='white'><a href='javascript:CloseDivId()'><img src='/images/close2.gif' border=0 wifth=14 height=14></img></a></td>";
	temp+="    <td width='9' colspan='2' align='right'><img src='/images/div2.jpg' border=0 ></img></td></tr>";
	temp+="<tr><td height='1' colspan='5' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td class=ajtd>";
	//插入内容开始
	temp+="<table border=0 cellspacing=1 cellpadding=0  align=center>";
	var i=0;
	var name="";
	var dowm="";
	var up="";
	var t="";
	pro+="无^无^无^$";
	while(pro.indexOf("$")>0){
			t=pro.substring(0,pro.indexOf("$"));
			name=t.substring(0,t.indexOf("^"));
			t=t.substring(t.indexOf("^")+1);
			dowm=t.substring(0,t.indexOf("^"));
			t=t.substring(t.indexOf("^")+1);
			up=t.substring(0,t.indexOf("^"));
			pro=pro.replace(name+"^"+dowm+"^"+up+"^"+"$","");

           if(i%3==0){
               temp+="<tr>";
		    }
            temp+="<td  nowrap>&nbsp;&nbsp;<a href='javascript:"+(name=="无"?"obj_.value=\"\";CloseDivId();":"Bound("+dowm+","+up+")")+"'>"+name; //
            temp+="</a>&nbsp;&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
   while(i%3!=0){
	        temp+="<td  nowrap>&nbsp;</td>";
            i++;
            if(i%3==0){
                temp+="</tr>";
            }
     }
	 //// bgcolor='FFFFFF'
	temp+="<tr><td colspan='3' nowrap akign=center>&nbsp;&nbsp;手选:&nbsp;&nbsp;";
	temp+="<input class=myinput name=box_down value='"+box_down+"' size=5 onKeyUp=checkPointNumber(this)>&nbsp;-&nbsp;";
	temp+="<input class=myinput name=box_up value='"+box_up+"' size=5 onKeyUp=checkPointNumber(this)>&nbsp;&nbsp;&nbsp;&nbsp;";
	temp+="<input type=button value=确定 class=mybutton onclick=BoundOK()>";
	temp+="</td></tr>";
   temp+="</table>";
//插入内容结束
	temp+="    </td>";
	temp+="    <td width='8' class=ajtd></td>";
	temp+="    <td width='1' bgcolor='4E5B6C'></td></tr>";
	temp+="<tr class=ajtd>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='8' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="<tr bgcolor='4E5B6C'>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="    <td height='1' ></td>";
	temp+="    <td width='9' colspan=2></td>";
	temp+="</tr>";
	temp+="</table>";
   table.innerHTML=temp;
   displayLayer();
}
function Bound(down,up){
	document.getElementById("box_down").value=down;
	document.getElementById("box_up").value=up;
	obj_.value=down+"-"+up;
}
function BoundOK(){
	if(document.getElementById("box_down").value==""){
		document.getElementById("box_down").value="0";
	}
	if(document.getElementById("box_up").value!=""){
		if(parseFloat(document.getElementById("box_down").value)>parseFloat(document.getElementById("box_up").value)){
			alert("下限大于上限,请重新选择!");
			return;
		}
	}
	obj_.value=document.getElementById("box_down").value+"-"+document.getElementById("box_up").value;
	CloseDivId();
}
function repalceall(str,r,t){
	while(str.indexOf(r)>=0){
		str=str.replace(r,t);
	}
	return str;
}
function replaceall(str,r,t){
	while(str.indexOf(r)>=0){
		str=str.replace(r,t);
	}
	return str;
}
/*以当前控件的绝对位置显示层*/
function displayLayer(){ 
	var o=obj_;				  //控件名称 必须要传递给另外一个obj 不然会导致异常
	var t  = o.offsetTop;     //TT控件的定位点高
	var h  = o.clientHeight;  //TT控件本身的高
	var l  = o.offsetLeft;    //TT控件的定位点宽
	var ttyp  = o.type;       //TT控件的类型
	while (o = o.offsetParent){t += o.offsetTop; l += o.offsetLeft;}
	var layerY  = (ttyp=="image")? t + h : t + h + 6; //层的 Y 坐标
	var layerX = l + 1;							      //层的 X 坐标
	divid.style.top = layerY;
	divid.style.left =layerX;
    divid.style.visibility = 'visible';
	if_checkP=1;
}
//////////////////////////////
//新增 修改 删除后刷新 界面的方法集成
function initurl(url)
{
	xmlHttp=GetXmlHttpObject(saveajax)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)		
}
function saveajax(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		var response = xmlHttp.responseText;
		if(response.indexOf("</SCRIPT>")>0){
			response=response.substring(response.indexOf("</SCRIPT>")+9);
		}
		flash(response);
	}
}
function flash(str){
	if(str.indexOf("0")==0){
		if(str.length>1){
			alert(str.substring(1));
		}
		CloseDivId2()
		FlashPage();
	}
	else if(str.indexOf("1")==0){
		if(str.length>1){
			alert(str.substring(1));
		}
		CloseDivId2()
		FlashPage2();
	}
	else if(str.indexOf("2")==0){
		window.location.reload();
	}
	else{
		alert(str);
		return false;
	}	
}
////////////////////////////////
//div的拖动
var drag=false, cx=0, cy=0;
function dragdiv(divname){
	if(drag){
		o =divname;
		if(o.style.left=='')o.style.left=0; if(o.style.top=='')o.style.top=0;
		o.style.left = parseInt(o.style.left) + window.event.clientX-cx;
		o.style.top  = parseInt(o.style.top)  + window.event.clientY-cy;
	}
}
function dragStart(){
	cx=window.event.clientX; 
	cy=window.event.clientY; 
	drag=true;
}
///////////////
function checkP(){
	if(if_checkP==1){
		if_checkP=2;
	}
	else if(if_checkP==2&&divid&&!divid.contains(document.elementFromPoint(event.clientX,event.clientY))){
		CloseDivId();		
	}
}
//点击列表后 有些按钮需要隐藏
function hidButton(bid,ifshow){
	if(document.getElementById(bid)){
		document.getElementById(bid).style.display = 'none';
		if(ifshow) document.getElementById(bid).style.display = '';
	}
}
function hidButton2(bid,ifshow,win){
	if(win.document.getElementById(bid)){
		win.document.getElementById(bid).style.display = 'none';
		if(ifshow) win.document.getElementById(bid).style.display = '';
	}
}
//添加图片的共用方法
function insertImage(title,obj,dir){
	showMod('/servlet/oyeall.ajax.up_image?title='+title+'&obj='+obj+'&direc='+dir+'&aj_count='+Math.random() * 1000,title,window,500,500);	

	//var strURL='/servlet/oyeall.ajax.up_image?title='+title+'&obj='+obj+'&direc='+dir+'';
	//window.open (strURL,'_blank',    'status=no,resizable=0,toolbar=no,menubar=no,scrollbars=auto,width=400,height=450');
}
//添加附件的共用方法
function insertFile(title,obj,dir){
	//var strURL='/servlet/oyeall.ajax.up_file?title='+title+'&obj='+obj+'&direc='+dir+'';
	showMod("/servlet/oyeall.ajax.up_file?title="+title+"&obj="+obj+"&direc="+dir+"aj_count="+Math.random() * 1000,title,window,400,200);

	//window.open (strURL,'_blank',    'status=no,resizable=0,toolbar=no,menubar=no,scrollbars=auto,width=400,height=200');
}
//弹出模态对话框
function showMod(url,title,obj,width,height){
	url=replaceAll(url,'&','[1]');
	url=replaceAll(url,'%','[2]');
	url=replaceAll(url,'=','[3]');
	window.showModalDialog("/servlet/oyeall.ajax.dialog?title="+title+"&url="+url,obj,"help=0;status=no;resizable=yes;scroll=yes;dialogWidth="+width+"px;dialogHeight="+height+"px;");
}
//弹出非模态对话框
function showLessMod(url,title,obj,width,height){
	url=replaceAll(url,'&','[1]');
	url=replaceAll(url,'%','[2]');
	url=replaceAll(url,'=','[3]');
	window.showModelessDialog("/servlet/oyeall.ajax.dialog?title="+title+"&url="+url,obj,"help=0;status=no;resizable=yes;scroll=yes;dialogWidth="+width+"px;dialogHeight="+height+"px;");
}
//模态对话框 提交后的操作
function SubmitMod(str){
	var obj = window.dialogArguments;
	window.close();
	obj.flash(str);
}
//显示图片的 模态对话框
function showModimg(url,title){
	window.showModelessDialog("/servlet/oyeall.ajax.dialog?title="+title+"&imgurl="+url,window,"help=0;status=no;resizable=yes;scroll=yes;dialogWidth=800px;dialogHeight=600px;");
}
//让所有的input 对象都变成 disabled
function setReadonly(obj){
	var inputs=null;
	if (typeof(obj.getElementsByTagName('input')) != 'undefined') {
        inputs = obj.getElementsByTagName('input');
		for(cc=0;cc<inputs.length;cc++){ 
			inputs[cc].disabled="disabled";
		}
    } 	
}

var h_list=new Array(20); 
var h_list2=new Array(20);
var h_index=-1; 
function saveHistory(){ 
	if(document.getElementById('tablelist')) { 
		if(h_index==19) { 
			h_index=-1; 
		}
		else{ 
			h_index++; 
		} 
		h_list[h_index]=document.getElementById("tablelist").innerHTML;
		if(document.getElementById('hisStoryFrame')) {
			document.getElementById('hisStoryFrame').src='/about.htm?'+h_index; 
		}
		if(document.getElementById('pagenum')) { 
			h_list2[h_index]=document.getElementById("pagenum").innerHTML;
		} 
	} 
} 
function getHisStory(curIndex){ 
	if(curIndex!=h_index){ 
		if(h_list[curIndex]){ 
			h_index=curIndex; 
			if(document.getElementById('tablelist')) {
				document.getElementById("tablelist").innerHTML=h_list[curIndex]; 
			}
			if(document.getElementById('pagenum')) {
				document.getElementById("pagenum").innerHTML=h_list2[curIndex]; 
			}
			if(document.getElementById('pagenum2')) {
				document.getElementById("pagenum2").innerHTML=h_list2[curIndex]; 
			}
		} 
	} 
}
//读取cookies 主要是读取 列表上的每页显示的条数
function setPageSizeCookie(pagesize){
	var url=document.URL;
	if(url.indexOf("?")>0){
		url=url.substring(0,url.indexOf("?"));
	}
	var cname=url+"pagesize=";
    var Days = 300;
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = cname + "="+ escape (pagesize) + ";expires=" + exp.toGMTString();
}
function getPageSizeCookie(value){
	var url=document.URL;
	if(url.indexOf("?")>0){
		url=url.substring(0,url.indexOf("?"));
	}
	var cname=url+"pagesize=";
    var arr,reg=new RegExp("(^| )"+cname+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg)){
		return unescape(arr[2]);
	}
    else{
		return value;
	}
}
function delPageSizeCookie(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 showTom(){
	if(window.parent.ealltom&&window.parent.ealltom.document.getElementById("ealldetail")){
		if(window.parent.ealltom.document.getElementById("ealldetail").style.display=="none"){
			window.parent.ealltom.document.getElementById("_normal").onclick();
		}
	}
}
//新方法：当文本框得到焦点和失去焦点的时候 要执行的方法
function blurfocus(obj,type,moren_value){
	//得到焦点
	if(type==1){
		if(trim(obj.value)==moren_value){
			obj.value="";
		}
	}
	//失去焦点
	else if(type==0){
		if(trim(obj.value)==""){
			obj.value=moren_value;
		}
	}
}
//键盘事件 能方便的给程序员调试 按F12键就可以复制出整个HTML的代码 焦点必须在窗口上
function document.onkeydown(){
	var temp="";
	if(ajtr.indexOf("ajtr")==0){
		temp=repalceall(ajtr,'ajtr','');
	}
	if(event.keyCode==123){
		window.clipboardData.setData('Text',document.body.innerHTML);
	}
	else if(event.keyCode==38&&temp&&temp!=""){
		if(document.getElementById("ajtr"+(parseInt(temp)-1))){
			document.getElementById("ajtr"+(parseInt(temp)-1)).onclick();
		}
	}
	else if(event.keyCode==40&&temp&&temp!=""){
		if(document.getElementById("ajtr"+(parseInt(temp)+1))){
			document.getElementById("ajtr"+(parseInt(temp)+1)).onclick();
		}
	}
}
//确定出是第几个弹出窗口,从而得到 如何去加载部门和区域
function Setdeptobj(){
	return GetTopWin().top.department;
}
function Setdiswin(){
	return GetTopWin().top.district;
}
function GetTopWin(){
	var dd=window.dialogArguments;
	var ee=window;
	while(dd){
		ee=dd;
		dd=dd.window.dialogArguments;
	}
	return ee;
}
//验证电话号码
function isTel(str){
     var reg=/^([0-9]|[\-])+$/g ;
     if(str.length<7 || str.length>18){
        return false;
     }
     else{
        return reg.exec(str);
     }
}
function document.onclick(){ 
	if(top&&top.district){
		top.district.cursum=0;
	}
	else if(Setdiswin()){
		Setdiswin().cursum=0;
	}
} 
document.onclick();

function gjdel(id){
	if(confirm('是否确定删除该跟进信息？')){	
		var url = "/servlet/oyeall.sp.xk_action?action=gjdel&id="+id+"&aj_count="+Math.random() * 1000;
		initurl(url);		
	}
}