var oMouseoverTR;
var winID = null;
var x,y;
var OWinID= null;
var smsWinID= null;
//var vurl='';

function wopen(url,name,w,h)
{	if (! OWinID || OWinID.closed)
    {	OWinID = window.open(url,name,'height='+h+',width='+w+',top=200,left=300,toolbar=no,menubar=no,scrollbars=no,resizable=no, location=no,status=no')
	}
	else
    {	OWinID.focus();
    }
}

function vopen(url,name,w,h)
{//	if (! OWinID || OWinID.closed)
   OWinID = window.open(url,name,'height='+h+',width='+w+',top=100,left=150,toolbar=no,menubar=no,scrollbars=yes,resizable=yes, location=no,status=no')
   OWinID.focus();
}

function smsopen(tel)
{	if (smsWinID && smsWinID.open && !smsWinID.closed)
	{	smsWinID.document.sms.dst.value=smsWinID.document.sms.dst.value+'\r\n'+tel;
	}
	else
	{	smsWinID = window.open('/usetup/sms.xt?tel='+tel,'','height=400,width=600,top=200,left=300,toolbar=no,menubar=no,scrollbars=yes,resizable=yes, location=no,status=no');
	}
	smsWinID.focus();
}


function changeRowColor(obj,flag)
{	if (oMouseoverTR!=null)
	{	oMouseoverTR.style.backgroundColor='';
	}
	if (flag==0)
	{	if (obj!=null)
		{	oMouseoverTR=obj;
		}
		var color='#FFFF99';
		if(document.all)
		{	if(obj.style.backgroundColor=='')
			{	obj.style.backgroundColor=color;
			}
			else
			{	obj.style.backgroundColor='';
			}
		}
	}
}

function mm() 
{	x=document.body.scrollLeft+event.clientX; 
	y=document.body.scrollTop+event.clientY; 
}; 

function show_me()
{	mm();
	change.style.posLeft=x-20;
	change.style.posTop=y+10;
	change.style.visibility='visible';
};

function show_he_view(obj)
{	obj.style.visibility='visible';
};

function show_he(obj)
{	mm();
	obj.style.posLeft=x-10;
	obj.style.posTop=y-10;
	obj.style.visibility='visible';
};
function hide_he(obj)
{	obj.style.visibility='hidden';
}

function hide_me()
{	change.style.visibility='hidden';
}

function show()
{	change.style.visibility='visible';
}

function winput(ffname,comname,field,dtname,did,crc)
{	if (! winID || winID.closed)
    {	winID = window.open('/system/ff.xt?ff='+ffname+'&cn='+comname+'&field='+field+'&dtname='+dtname+'&did='+did+'&crc='+crc,"_blank","toolbar=no,resizable,scrollbars,dependent,width=650,height=450");
	}
	else
    {	winID.focus();
    }
}

function wclose()
{	if (winID && winID.open && !winID.closed)
	{	winID.close();
	}
}

document.write('<iframe id=CalFrame name=CalFrame frameborder=0 src="css/calendar.htm" style=display:none;position:absolute;z-index:100></iframe>');
document.onclick=hideCalendar;

function showCalendar(sImg,bOpenBound,sFld1,sFld2,sCallback)
{
	var fld1,fld2;
	var cf=document.getElementById("CalFrame");
	var wcf=window.frames.CalFrame;
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
	if(!sFld1){alert("输入控件未指定！");return;}
	fld1=document.getElementById(sFld1);
	if(!fld1){alert("输入控件不存在！");return;}
	if(fld1.tagName!="INPUT"||fld1.type!="text"){alert("输入控件类型错误！");return;}
	if(sFld2)
	{
		fld2=document.getElementById(sFld2);
		if(!fld2){alert("参考控件不存在！");return;}
		if(fld2.tagName!="INPUT"||fld2.type!="text"){alert("参考控件类型错误！");return;}
	}
	//if(!wcf.bCalLoaded){alert("日历未成功装载！请刷新页面！");return;}
	if(cf.style.display=="block"){cf.style.display="none";return;}
	
	var eT=0,eL=0,p=oImg;
	var sT=document.body.scrollTop,sL=document.body.scrollLeft;
	var eH=oImg.height+25,eW=oImg.width;
	while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
	cf.style.top=(document.body.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height;
	cf.style.left=(document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL+eW-cf.width;
	cf.style.display="block";
	
	wcf.openbound=bOpenBound;
	wcf.fld1=fld1;
	wcf.fld2=fld2;
	wcf.callback=sCallback;
	wcf.initCalendar();
	fld = fld1
}
function hideCalendar()
{
	var cf=document.getElementById("CalFrame");
	cf.style.display="none";
}

var OCFUNC =new Function ('x','');
function out2sel(s,v)
{	
	ss=oC_Var;
	s.length=0;
	a=0;b=0;
	while (b==0)
	{	a=ss.indexOf('<DATA><ID>',a);
		if (a==-1) {b=1;}
		else
		{	a=a+10;
			c=ss.indexOf('</ID><NAME>',a);
			id=ss.substring(a,c);
			a=c+11;
			c=ss.indexOf('</NAME></DATA>',a);
			name=ss.substring(a,c);
			var oo=new Option(name,id);
			
			if (id==v.value)
			{	oo.selected=true;
			}
			s.add(oo,0);
		}
	}
	
}

var	x=0;
var	y=0;
var	sx=0;
var	sy=0;

function reportMove() 
{	sx=window.document.body.scrollLeft;
	sy=window.document.body.scrollTop;
	x= window.event.x+sx;
	y=window.event.y+sy;
}


function openpopshow()
{	
	var	xx=x;
	var	yy=y;
	var	w=document.body.offsetWidth;
	var	h=document.body.offsetHeight+document.body.scrollTop;
	var	width;
	var	height;
	var	left;
	var	top;

	if(w<=480){
		width=w;
		left=0;
	}else{
		width=480;
		if((w-xx)<=300)	left=w-600;
		else	if(xx<=270)	left=20;
				else		left=xx-250;
	}

	if(h<=250){
		height=h;
		top=0;
	}else{
		height=250;
		if((h-yy)<=250)	top=h-260;
		else			top=yy;
	}
	popshow.style.left=left;
	popshow.style.top=top;
	popshow.style.width=width;
	popshow.style.height=height;
	popshow.style.visibility="visible";
}

function close_window(){
	document.all.popshow.style.visibility="hidden";
	document.all.gedit.innerHTML='';
	OCFUNC =new Function ('x','');oC_run= new Function('x','');
}


var  ppundis= new Function('x','');

var dragswitch=0
var nsx
var nsy
var nstemp
var whichIt = null;
var dragapproved=false

function drag_dropns(name){
	temp=eval(name)
	temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
	temp.onmousedown=gons
	temp.onmousemove=dragns
	temp.onmouseup=stopns
}

function gons(e){
	temp.captureEvents(Event.MOUSEMOVE)
	nsx=e.x
	nsy=e.y
}
function dragns(e){
	if (dragswitch==1){
		temp.moveBy(e.x-nsx,e.y-nsy)
		return false
	}
}

function stopns(){
	temp.releaseEvents(Event.MOUSEMOVE)
}

function drag_dropie(){
	if (dragapproved==true){
		temp.style.pixelLeft=tempx+event.clientX-iex
		temp.style.pixelTop=tempy+event.clientY-iey
		return false
	}
}

function initializedragie(name){
	whichIt=name
	temp=whichIt
	iex=event.clientX
	iey=event.clientY
	tempx=temp.style.pixelLeft
	tempy=temp.style.pixelTop
	dragapproved=true
	document.onmousemove=drag_dropie
}

if (document.all){
	document.onmouseup=new Function("dragapproved=false")
}
	function SUser(oT,oc,str)
	{	if(oc.checked)
		{	
			if (oT.value.indexOf(str+',')==-1)	
			{	oT.value=oT.value+str+',';
			}
		}
		else
		{	pa=new RegExp(str+',','g');
			oT.value=oT.value.replace(pa,'');
		}	
	}

function setQlistChk(the_form, do_check)
{   var elts = document.forms[the_form].elements['sel_id[]'];
	 var elts_cnt  = (typeof(elts.length) != 'undefined') ? elts.length: 0;
     if (elts_cnt)
	 {  for (var i = 0; i < elts_cnt; i++) 
		{ elts[i].checked = do_check;
        }
	 }
	 else 
	 { elts.checked= do_check;
     } 
    return true;
} 