/// <reference path="Extjs_Intellisense.js" /> 
/// <reference path="src/data/XmlStore.js" /> 

connectwhileclick=false;

var getPicNow=false;
var _nowsavedir="c:\\";
var cmdId=0;
var getListCmd=0;
__ActionFromFullScreen=false;
var cmdobj;			
function getObjByID(idmsg)
{
    return $(idmsg);
}


//向下表框中加一个节点
function addItem(value,itemMsg,call_preset)
{
	try
	{
		call_preset.options[call_preset.length]=new Option(itemMsg,value);	
		return ;
	}catch(e){}
}


function showPreSetForm()
{
	try
	{
		var obj=getObjByID("divsetpoint");
		$("changePreSetForm").src="ptz/images/more.jpg";
		obj.style.display="block";
		obj.style.left=10;
		obj.style.top = 478;
		obj.style.hight=10;	
		hiddiv(getObjByID("divTitle"));
		hiddiv(getObjByID("divTitle"));
	}catch(eee){}
}

function hiddenPreSetForm()
{
	try
	{
		var obj=$("divsetpoint");
		obj.style.display="none";
		getObjByID("changePreSetForm").src="ptz/images/more1.jpg";	
	}catch(eee)
	{
	
	}	
}

function changePresetFormState()
{
		var obj=getObjByID("divsetpoint");
		if(obj.style.display!="none")
		{
			hiddenPreSetForm();			
		}else
		{
			showPreSetForm();
		}
}




 

//检查时间格式是否有效，同时检查时间是否有交叉
function CheckTimeData(str)
{
		try
		{		
			var i=0;
			var list=str.split('#');			
			type=list[0].replace(/[0-9]+/g,"");
			if(list.length!=2)
			{
				oldAlert(GetDefaultLang("lang_formaterror200","格式不正确,输入应为{type}编号#HH:00-HH:00").replace("{type}",type));
				return false;
			}
			var list2=list[1].split('-');
			if(list2.length!=2)
			{
				oldAlert(GetDefaultLang("lang_formaterror201","格式不正确,输入应为{type}编号#HH:00-HH:00").replace("{type}",type));
				return false;
			}		
			if(!isTimeFormat(list2[1]) || !isTimeFormat(list2[0]))
			{
				oldAlert(GetDefaultLang("lang_formaterror202","格式不正确,输入应为{type}编号#HH:00-HH:00").replace("{type}",type));
				return false;
			}
			if(	Math.abs(list2[0].replace(/:/g,""))>=Math.abs(list2[1].replace(/:/g,""))	)
			{
				oldAlert(GetDefaultLang("lang_formaterror203","开始时间必须小于结束时间!"));
				return false;				
			}									
			var del_preset=$("delpreset");
			for(i=0;i<del_preset.options.length;i++)
			{
				var vl=del_preset.options[i].value;
				var temp1=vl.split('#');
				if(temp1.length<=1)continue;//不是时间段
				var timels=temp1[1].split("-");
				var timetype=""+temp1[0].replace(/[0-9]+/g,"");;
				if( (timetype=="" && type!="") || (timetype!="" && type=="") )
				{//定时归位与其它类型可以重复
					continue;
				}
								
				if(timeInStr(list2[0],vl) || timeInStr(list2[1],vl)  || timeInStr(timels[0],str)  || timeInStr(timels[1],str) )
				{//开始时间或结束时间互相包含
					oldAlert(GetDefaultLang("lang_formaterror204","时间段与现有的设置有重叠!"));
					return false;				
				}	
			}
			return true;
		}catch(eee){}
		return false;
}

// 判断time是否在str之间 
function timeInStr(time,str)
{
	try
	{
		var ls1=str.split('#');
		if(ls1.length!=2)return false;
		var ls2=ls1[1].split('-');
		if(ls2.length!=2)return false;
		ls2[0]="1" + ls2[0].replace(/:/g,"");
		ls2[1]="1" + ls2[1].replace(/:/g,"");
		time2="1" + time.replace(/:/g,"");
		if(parseInt(ls2[0])<=parseInt(time2) && parseInt(ls2[1])>=parseInt(time2))
		{// 时间段包含关系 
			return true;
		}
	}catch(eee){}
	return false;
}

//判断时间格式是否合法24:00是合法的时间格式
function isTimeFormat(str)
{
	try
	{
		var ls=str.split(':');
		if(ls.length!=2)
		{
			return false;
		}
		if(parseInt(ls[1])==0 && parseInt(ls[0])==24 )return true;//24:00为合法时间
		if(parseInt(ls[0])<0 ||  parseInt(ls[0])>23)return false;
		if(parseInt(ls[1])<0 ||  parseInt(ls[1])>59)return false;
		return true;
	}catch(eee)
	{
	}
	return false;
}


//增加预置点
function DOaddpre()
{		
	try
	{
		var flag=1;
		var str =$("inppreset").value;
		var cmd="setpreset"
		var tmp="";
		switch(str.charAt(0))
		{
			case 's':
				if(!CheckTimeData(str))
				{
					return false;
				}
				cmd="SetOrbit";
				var ls1=str.split('#');
				var ls2=ls1[1].split('-');//取得时间段
				var preset=ls1[0].replace(/[^0-9]/g,"");//取得编号
				if(preset.replace(/[0-9]/g,"")!="" || Math.abs(preset)>8 || Math.abs(preset)<=0)
				{
					oldAlert(GetDefaultLang("lang_formaterror205","输入的预置点只能是1-8"));
					return false;
				}
				tmp="<xml>\n<cmd>"+cmd+"</cmd><preset>"+preset+"</preset><flag>"+flag+"</flag><r><b>"+ls2[0]+"</b><e>"+ls2[1]+"</e></r></xml>\n";
				break;
			case 'o':
				if(!CheckTimeData(str))return false;
				cmd="SetScan";
				flag = 1;
				var ls1=str.split('#');
				var ls2=ls1[1].split('-');
				var preset=ls1[0].replace(/[^0-9]/g,"");
				if(preset.replace(/[0-9]/g,"")!="" || Math.abs(preset)>8 || Math.abs(preset)<=0)
				{
					oldAlert(GetDefaultLang("lang_formaterror206","输入的预置点只能是1-8"));
					return false;
				}
				tmp="<xml>\n<cmd>"+cmd+"</cmd><preset>"+preset+"</preset><flag>"+flag+"</flag><r><b>"+ls2[0]+"</b><e>"+ls2[1]+"</e></r></xml>\n";
				break;
			default:	
				//预置点处理
				var list=str.split('#');
				if(list.length==1)
				{//预置点
					if(str.replace(/[0-9]/g,"")!="" || Math.abs(str)>65 || Math.abs(str)<=0)
					{
						oldAlert(GetDefaultLang("lang_formaterror207","输入的预置点只能是1-65"));
						return false;
					}
					cmd="setpreset";
					preset=Math.abs(str);
					tmp="<xml>\n<cmd>"+cmd+"</cmd><preset>"+preset+"</preset><flag>"+flag+"</flag></xml>\n";
				}else if(list.length==2)
				{//定时归位
					if(!CheckTimeData(str))return false;
					cmd="setpreset";
					flag = 1;
					var ls1=str.split('#');
					var ls2=ls1[1].split('-');
					var preset=ls1[0].replace(/[^0-9]/g,"");
					if(preset.replace(/[0-9]/g,"")!="" || Math.abs(preset)>65 || Math.abs(preset)<=0)
					{
						oldAlert(GetDefaultLang("lang_formaterror208","输入的预置点只能是1-65"));
						return false;
					}
					tmp="<xml>\n<cmd>"+cmd+"</cmd><preset>"+preset+"</preset><flag>"+flag+"</flag><r><b>"+ls2[0]+"</b><e>"+ls2[1]+"</e></r></xml>\n";
				}else
				{
					oldAlert(GetDefaultLang("lang_formaterror209","格式不正确,输入应为{type}编号#HH:00-HH:00").replace("{type}",type));
					return false;
				}
				break;
		}
		sendMsg(tmp);
		window.setTimeout("UpdatePresetList()",2*60*1000);
		return true;
	}catch(eee){}
	
	window.setTimeout("UpdatePresetList()",2*60*1000);
	return false;	
}





//删除预置点
function DOdelpre()
{
	try
	{
		 var str=$("delpreset").value;
		 var cmd=""
		 var tmp="";
		 if(str=="")return false;
		 var id="";
		 switch(str.charAt(0))
		 {
			case 's':
				cmd="DelOrbit";
				id=str.substr(1);
				if((Math.abs(id)<1)||(Math.abs(id)>8))return false;
				break;
			case 'o':
				cmd="DelScan";
				id=str.substr(1);
				if((Math.abs(id)<1)||(Math.abs(id)>8))return false;
				break;
			default:
				cmd="clearpreset";
				id=str;
				break;
		 }
		var	tmp = '<xml>\n'+'<cmd>'+cmd+'</cmd>\n'+'<preset>'+id+'</preset>\n'+'</xml>';
		sendMsg(tmp);		
	}catch(eee){}
	 window.setTimeout("UpdatePresetList()",2*60*1000);
}


//更改速度
function changepanspeed(obj)
{
	try
	{
		var valuemsg=obj.value;
		var obj3=$("panspeed");
		if(obj3.value!=valuemsg)
		{
			obj3.value=valuemsg;
		}
	}catch(eee){}
}


//更改速度
function changetitlespeed(obj)
{
	try
	{
		var valuemsg=obj.value;
		var obj3=$("titlespeed");
		if(obj3.value!=valuemsg)
		{
			obj3.value=valuemsg;
		}
	}catch(eee){}
}

//调用预置点
function DOcallpre()
{
	try
	{
		var selObj=getObjByID("gotopreset");
		if(selObj.options.length==0 || selObj.SelectedIndex<0)return false;
		var preset = selObj.value;
		tmp = '<xml>\n<cmd>callpreset</cmd>\n<preset>'+preset+'</preset>\n</xml>';
		sendMsg(tmp);		
	}catch(eee){}
	window.setTimeout("UpdatePresetList()",2*60*1000);
}


var timeouthand=null;

 

///取得云台预置点
function UpdatePresetList()
{
	try
	{
		if(timeouthand!=null)
		{
			try{window.clearTimeout(timeouthand);}catch(ee){}
			timeouthand=null;
		}		
		cmdobj=$("loginobj");
		if(typeof(cmdobj)!="object")
		{ 
		    return false;
		}
		if(LastCmdOkDevId=="")
		{//还没有连上云台
			timeouthand=window.setTimeout("UpdatePresetList()",2000);
			return false;
		}
		sendMsg("<xml>\n<cmd>GetPresetList</cmd>\n</xml>");//发现要求取得列表信息
		if(need_readptztimer)
		{
		    timeouthand=window.setTimeout("UpdatePresetList()",50000);
		}
	}catch(ee)
	{
		timeouthand=window.setTimeout("UpdatePresetList()",2000);
		return false;
	}	
}


var __lastRectPresetListStrMsg="";

///更新列表
function UpdatePresetListByStr(PresetList,devid)
{
    try
    {
        LastRecvPtzString[devid]=PresetList;
    }catch(eeee){}
	try
	{
	    if(__lastRectPresetListStrMsg==PresetList)
	    {
	        return false;
	    }
	    __lastRectPresetListStrMsg=PresetList;
		var call_preset=getObjByID("gotopreset");
		var clear_goto=getObjByID("delpreset"); 
		
		var delid=clear_goto.selectedIndex;
		var calid=call_preset.selectedIndex;
		try
		{
			call_preset.length=0;
			clear_goto.length=0; 
		}catch(eee){}
		
		var listarray = PresetList.split("^");
		var presetnum = parseInt(listarray[0]);
		var bhour;
		var bmin;
		var ehour;
		var emin;
		for(var i=0;i<presetnum;i++)
		{
			var tmparray = listarray[i+1].split("#");
			if(tmparray.length==2)
			{
				var posnum = parseInt(tmparray[0]);		
				var bpos = 0;
				var epos = tmparray[1].indexOf(':');
				bhour = parseInt(tmparray[1].substring(bpos,epos),10);				
				bpos = epos+1;
				epos = tmparray[1].indexOf('-',bpos);
				bmin = parseInt(tmparray[1].substring(bpos,epos),10);						    
				bpos = epos+1;
				epos = tmparray[1].indexOf(':',bpos);
				ehour = parseInt(tmparray[1].substring(bpos,epos),10);
				bpos = epos+1;
				epos = tmparray[1].length;
				emin = parseInt(tmparray[1].substring(bpos,epos),10);
				var msgstr = tmparray[0]+'#'+bhour+'-'+ehour;
				var valuestr = tmparray[0];
				try
				{
					//addItem(listarray[i+1],msgstr,clear_goto);
					//addItem(listarray[i+1],msgstr,clear_goto2);
					addItem(listarray[i+1],listarray[i+1],clear_goto);
				}catch(ee){}
				/*
				if(((tmparray[0].charAt(0)!='s')&&(tmparray[0].charAt(0)!='o')))
				{
					try
					{
						//addItem(listarray[i+1],msgstr,call_preset);
						//addItem(listarray[i+1],msgstr,call_preset2);
						addItem(listarray[i+1],listarray[i+1],call_preset);
						addItem(listarray[i+1],listarray[i+1],call_preset2);
					}catch(ee){}
				}
				*/
			}else
			{
				tmp = parseInt(listarray[i+2]);
				try
				{
					addItem(listarray[i+1],listarray[i+1],call_preset);
					addItem(listarray[i+1],listarray[i+1],clear_goto);
					//addItem(listarray[i+1],listarray[i+1],call_preset2);
					//addItem(listarray[i+1],listarray[i+1],clear_goto2);
				}catch(eee){}
			}
		}
		PresetList = '';
		try
		{
			if(delid<0)delid=0;
			if(calid<0)calid=0;
			clear_goto.selectedIndex=delid;
			call_preset.selectedIndex=calid;			
			//clear_goto2.selectedIndex=delid;
			//call_preset2.selectedIndex=calid;
		}catch(eee){}
		return true;
	}catch(eee)
	{
		window.setTimeout("UpdatePresetList()",2000);
		return false;
	}
}

				//重新连接云台控制
				function reLinkCmd()
				{
					try
					{
						cmdobj=$("loginobj");
					}catch(eedd){}
					UpdatePresetList();
				}
					
				

				function init()
				{
					
				}
				
				
				
				function ShowNowDir(pathmsg)
				{
						try
						{
							$("savedirpath").innerText=pathmsg;
							$("savedirpath").title=pathmsg;
						}catch(ee){}
//						try
//						{
//							$("savedirpath2").innerText=pathmsg;
//							$("savedirpath2").title=pathmsg;
//						}catch(ee){}
				}
				
				
				function ChangeSaveDir()
				{
					try
					{  
						var obj=GetPlayerById(selectPlayerId);
						obj.SetCaptureDir(1,"");
						var nowpath=obj.GetCaptureDir(1);
						if(	nowpath!=undefined && nowpath!="undefined" && nowpath!="" )
						{
							_nowsavedir=nowpath;
						}else
						{
							_nowsavedir="c:\\";
						}
					}catch(ee)
					{
						_nowsavedir="c:\\";
					}
					ShowNowDir(_nowsavedir);
				}
				
				
				function GetNowSaveDir()
				{
				    if(!_nowsavedir)
				    {
						_nowsavedir="c:\\";
				    }
				    return _nowsavedir;
				}
				
				
				
				function getpic()
				{
					var obj=GetPlayerById(selectPlayerId);
					try
					{
					    if(!CheckPlayerIsPlaying(obj))
					    {
					        oldAlert(GetDefaultLang("lang_formaterror220","请在视频开始播放后再进行抓图操作!"));
					        return false;
					    }
						try
						{//最新控件
							obj.SetCaptureDir(1,_nowsavedir);
							//obj.CapturePicture(1);
							obj.SnapShot(_nowsavedir);
						}catch(ee){}
						getPicNow=true;
						$("snap").src="ptz/images/a4r.jpg";
						window.setTimeout("ReSetPhotoButton();",300);	
					}catch(ee){}
				}
				
				//闪一下
				function ReSetPhotoButton()
				{
					 //a4o.jpg
					 try
					 {
						$("snap").src="ptz/images/a4o.jpg";
					 }catch(eee){}
					 getPicNow=false;					 
				}
				 
				
				function selectDir()
				{	
					try
					{	
						var nowpath=obj.SetCaptureDir(1,"");
						if(	nowpath!=undefined && nowpath!="undefined")
						{
							_nowsavedir=nowpath;
						}else
						{
							_nowsavedir="c:\\";
						}
						return _nowsavedir;
					}catch(eee)
					{
						return "c:/";
					}
				}
				
				
				function getPhotoPath()
				{
					return _nowsavedir;
				}
				
				
				
				
				function ChangeRecordPic(clickobj,ty)
				{
					try
					{
						var obj=document.getElementById(selectPlayerId);
						var recordstatus="" + obj.GetRecordStatus();
						if(recordstatus=="0")
						{// 
							img_rec=new Image;
							haveStartRecord=false;
							img_rec.src="ptz/images/a5n.jpg";
							//$("record3").src=img_rec.src;
							$("record").src=img_rec.src;
						}else
						{//
							img_rec=new Image;
							img_rec.src="ptz/images/a5r.jpg";
							//$("record3").src=img_rec.src;
							$("record").src=img_rec.src;
							haveStartRecord=true;
						}
					}catch(eee){}	
				}





				var haveStartRecord=false;
				function recordFile()
				{
					//var dir="c:\\";
					var obj=document.getElementById(selectPlayerId);
					try
					{
						recordstatus="" + obj.GetRecordStatus();//  是否在录像，1表示是，0表示不是  

						if(recordstatus=="1")
						{// 要停止录像 
							try{obj.StopRecord();}catch(eee){}
							var newstatus=""+obj.GetRecordStatus();
							if(newstatus=="0")
							{//  状态没有变化 ，要提示不成功  
								img_rec=new Image;
								haveStartRecord=false;
								img_rec.src="ptz/images/a5n.jpg";
								//$("record3").src=img_rec.src;
								$("record").src=img_rec.src;								
							}
						}else
						{
							try
							{//最新控件
								obj.SetCaptureDir(1,_nowsavedir);
								_nowsavedir=obj.GetCaptureDir(1);
								if(_nowsavedir==undefined || _nowsavedir=="" || _nowsavedir=="undefined")
								{
								    _nowsavedir="c:\\";
								}
								ShowNowDir(_nowsavedir);
							}catch(ee){}						
							try{obj.StartRecord();}catch(eeee){}//新版	
							//try{obj.RecordVideo();}catch(eeee){}//旧版
							//try{obj.BeginRecord();}catch(eeee){}//新版
							var newstatus=""+obj.GetRecordStatus();
							if(newstatus=="1")
							{//  状态没有变化 ，要提示不成功 
								img_rec=new Image;
								img_rec.src="ptz/images/a5r.jpg";
								//$("record3").src=img_rec.src;
								$("record").src=img_rec.src;						
								haveStartRecord=true;
							}
						}						
					}catch(ee){}
				}
				

				

				function sendMsg(str)
				{
					try
					{
						cmdobj=$("loginobj");
						if(typeof(cmdobj)!="object")
						{
						    if(!__ActionFromFullScreen)
						    {
						        oldAlert(GetDefaultLang("lang_formaterror250","云台控件未安装，无法进行云台控制！"));
						    }
						    __ActionFromFullScreen=false;
						    return ;
						}
						
//						if(LastCmdOkDevId=="")
//						{
//						    if(!__ActionFromFullScreen)
//						    {
//							    oldAlert("请先连接视频并单击对应的视频对其进行控制!"); 
//							}
//						    __ActionFromFullScreen=false;
//							return false;
//						}

                        if(LastCmdOkDevId=="" || LastCmdOkDevId==undefined || LastCmdOkDevId==null)
                        {
						    if(!__ActionFromFullScreen)
						    {
						        if(LastCmdStatusMsg!="")
						        {
							        oldAlert(LastCmdStatusMsg);
							    }else
							    {
							        oldAlert(GetDefaultLang("lang_formaterror251","云台连接错误，请重新单击要控制的视频窗口进行重新连接!")); 
							    }
							}
                            return false;
                        }
                        if(GetRightByDevId(LastCmdOkDevId,"ptz")!="")
                        {
						    if(!__ActionFromFullScreen)
						    {
							    oldAlert(GetRightByDevId(LastCmdOkDevId,"ptz"));
                                //oldAlert("没有云台或者没有控制权限!"); 
							}
                            return false;
                        }
                        						
						if(LastCmdOkDevId!="" )
						{
//						    try
//						    {
//                                var searhplan=GetTablPanel();
//						        var selectid=searhplan.getActiveTab().getId();
//						        if(selectid!="showrealtime")
//						        {
//						            searhplan.activate('showrealtime');
//						        }
//						    }catch(ee){}
                            if(!connectwhileclick)
                            {
                                InvitePTZControl(LastCmdOkDevId);
                            }
						    var ret=cmdobj.SendPTZCmd(LastCmdOkDevId,1,str);
						    //WriteWebLog("send xml:"+str+"，返回"+ret);
						}
						return true;
					}catch(eeee)

					{
						return false;
					}		
					return false;								
				}
				
				
				


				//选择摄像头
				function selectXst(camNumb,nickName)
				{
					try
					{
							
					}catch(E){
						oldAlert(GetDefaultLang("lang_formaterror254",'初始化失败'));
					}
						
				}

				//离开页面注销控件
				function unInit()
				{

				}

				//打开摄像头
				function openvideo(camNumb)
				{
					var nowVideoId=selectPlayerId;//"player"; selectPlayerId
					try
					{//旧版
						GetPlayerById(nowVideoId).Play();						
					}catch(eeee){}					
				}

				//关闭摄像头
				function closevideo()
				{
					try
					{
						GetPlayerById(selectPlayerId).Stop();
					}catch(eeee){}					
				}
				
				
				//拍照BMP
				function snapPic(imgPath)
				{
					
				}


				var panspeed=3;
				var tiltspeed=3;
 				//发送云台控制命令，命令名为对象的ID值
				function doMoveFunc(obj)
				{
					panspeed=$("panspeed").value;
					tiltspeed=$("titlespeed").value;
					var cmd=obj.getAttribute("id");
					var sendstr='<xml>\n'+'<cmd>'+cmd+'</cmd>\n'+'<panspeed>'+panspeed+'</panspeed>\n'+'<tiltspeed>'+tiltspeed+'</tiltspeed>\n'+'</xml>';
					sendMsg(sendstr);
				}
				
				//发送停止操作命令
				function sendStop()
				{
					var sendstr='<xml>\n'+'<cmd>stop</cmd>\n'+'<panspeed>'+panspeed+'</panspeed>\n'+'<tiltspeed>'+tiltspeed+'</tiltspeed>\n'+'</xml>';
					sendMsg(sendstr);					
				}
				//放大
				function DOzoomup()
				{
					var sendstr='<xml>\n'+'<cmd>zoomtele</cmd>\n'+'<panspeed>'+panspeed+'</panspeed>\n'+'<tiltspeed>'+tiltspeed+'</tiltspeed>\n'+'</xml>';
					sendMsg(sendstr);	
				}
				//缩小
				function DOzoomdown()
				{
					var sendstr='<xml>\n'+'<cmd>zoomwide</cmd>\n'+'<panspeed>'+panspeed+'</panspeed>\n'+'<tiltspeed>'+tiltspeed+'</tiltspeed>\n'+'</xml>';
					sendMsg(sendstr);	
				}
				
				
				function STOPleft_up(){sendStop();}
				function STOPright_up(){sendStop();}
				function STOPleft_down(){sendStop();}
				function STOPright_down(){sendStop();}
				function STOPzoomup(){sendStop();}
				function STOPzoomdown(){sendStop();}
				function STOPleft(){sendStop();}
				function STOPright(){sendStop();}
				function STOPup(){sendStop();}
				function STOPtop(){sendStop();}
				function STOPdown(){sendStop();}
				function STOPleft(){sendStop();}
				//function STOPbrightnessdesc(){sendMsg("<xml><cmd>irisclose</cmd></xml>");}//减亮度
				//function STOPbrightnessadd(){sendMsg("<xml><cmd>irisopen</cmd></xml>");}//加亮度				
				//function STOPcontrastdesc(){sendMsg("<xml><cmd>FocusNear</cmd></xml>");}//对比度
				//function STOPcontrastadd(){sendMsg("<xml><cmd>FocusFar</cmd></xml>");}//对比度
				//sendMsg("<xml><cmd>FocusAutoOff</cmd></xml>");
				function STOPbrightnessdesc(){sendStop();}//减亮度
				function STOPbrightnessadd(){sendStop();}//加亮度
				function STOPcontrastdesc(){sendStop();}//对比度
				function STOPcontrastadd(){sendStop();}//对比度

				
				
				
				//垂直巡航
				function valignScan()
				{

				}
				
				
				//水平巡航
				function alignScan()
				{

				}
				
				
				//恢复到初始状态
				function resetStatus()
				{
					
				}
				
				
				//加速
				function PanAccelerateSet()
				{
					 panspeed++;
					 tiltspeed++;
				}
				
				
				//减速
				function PanSlowdownSet()
				{
					 panspeed--;
					 tiltspeed--;
				}

				//调节亮度+
				function BrightnessAdd(camNumb)
				{
					//sendMsg("<xml><cmd>IrisAutoOff</cmd></xml>");	//停止自动光圈
					sendMsg("<xml><cmd>IrisOpenAutoOff</cmd></xml>");			
				}

				//调节亮度-
				function BrightnessDesc(camNumb)
				{
					//sendMsg("<xml><cmd>IrisAutoOff</cmd></xml>");//停止自动光圈
					sendMsg("<xml><cmd>IrisCloseAutoOff</cmd></xml>");
				}
				

				//调节亮度 复位
				function BrightnessReplace(camNumb)
				{//即自动光圈
					sendMsg("<xml><cmd>IrisAutoOn</cmd></xml>");				
				}
				
				

				//调节对比度+ 改为聚焦+
				function ContrastAdd(camNumb)
				{//<xml><cmd>FocusAutoOff</cmd></xml>
					//sendMsg("<xml><cmd>FocusAutoOff</cmd></xml>");//停止自动聚焦
					sendMsg("<xml><cmd>FocusFarAutoOff</cmd></xml>");
				}
				

				//调节对比度- 改为聚集-
				function ContrastDesc(camNumb)
				{ 
					//sendMsg("<xml><cmd>FocusAutoOff</cmd></xml>");//停止自动聚焦
					sendMsg("<xml><cmd>FocusNearAutoOff</cmd></xml>");	
				}

 
				


				//调节对比度 复位  改为聚集复位
				function ContrastReplace(camNumb)
				{				
					sendMsg("<xml><cmd>FocusAutoOn</cmd></xml>");
				}

				//--调节对比度
				function AlertSet()
				{

				}
				
				
				function getScriptMsg(url)
				{
					var msg="<script src='"+url+"' type='text/javascript' ></"+"script>";
					return msg;
				}

				//调节图象质量 ＋＋
				function ImageQAdd(camNumb)
				{
					showUpdateIng();
					$("runscript").setAttribute("src","");			
				}

				//调节图象质量 －－
				function ImageQDesc(camNumb)
				{
					showUpdateIng();
					$("runscript").setAttribute("src","");	
				}

				function showUpdateIng()
				{
					try
					{
						document.getElementById("showbitrate").innerText=GetDefaultLang("lang_formaterror255","等待");
						document.getElementById("showFramerate").innerText=GetDefaultLang("lang_formaterror256","等待");
					}catch(eeep)
					{}					
				}
				
				//调节帧率 ＋＋
				function FrameRateAdd(camNumb)
				{
					showUpdateIng();
					$("runscript").setAttribute("src","");	
				}

				//调节帧率 --
				function FrameRateDesc(camNumb)
				{
					showUpdateIng();
					$("runscript").setAttribute("src","");
				}
				
				//调节分辨率
				function FrameSize()
				{
					window.parent.document.getElementById("ifrm").width="670";
					window.parent.document.getElementById("ifrm").height="600";
					try
					{
						window.top.document.getElementById("videoType").value="b";
					}catch(eeeep){}
					window.location.href="";
			 	}



				
				//图片变换效果,实现mouseover,mouseup,mouseout图片转换
				//0,1,2,3,out,over,down,up
				function PTZClick(mage, number)
				{
				    if(mage && mage.disabled)
				    {
				        //oldAlert("你没有权限进行此操作!");
				        return false;
				    }
					var imgName=mage.src;//取得图片文件名
					if(imgName==undefined || imgName==null)return ;//错误的
					var n1=imgName.lastIndexOf('/')+1　　　
					var n2=imgName.lastIndexOf('.')
					var imgPrefix=imgName.substring(n1,(n2-1));
										
					if(getPicNow  && mage.id == "snap")
					{
						return true;						
					}
					
					img1=new Array(3);	
					img1[0]=new Image; img1[0].src="ptz/images/"+ imgPrefix +"n.jpg";
					img1[1]=new Image; img1[1].src="ptz/images/"+ imgPrefix +"o.jpg";
					img1[2]=new Image; img1[2].src="ptz/images/"+ imgPrefix +"d.jpg";
					
					if(number==3)
					{//up
						try
						{
							eval("STOP"+mage.id+"();");
						}catch(eeeedddd)
						{}
						mage.src=img1[0].src;	
						return;										
					}else
					{
						mage.src=img1[number].src;
					}
					if(number == 2)
					{	
						var thisid=mage.getAttribute("id");
						if(thisid=="top"  || thisid == "up"  || thisid == "down"  || thisid == "left" || thisid =="right"  || thisid =="left_up"  || thisid =="left_down"  || thisid =="right_up"  || thisid =="right_down"  || thisid =="back" )
						{
							doMoveFunc(mage);
						}
						else if(mage.id == "hscan")
						{
							//左右巡航
		 					//alignScan();
						}
						else if(mage.id == "vscan")
						{
							//上下巡航
							//valignScan();
						}
						else if(mage.id == "snap")
						{
							getpic();
						}
						else if(mage.id == "record" || mage.id == "record2" || mage.id == "record3")
						{
							recordFile();
						}
						else if(mage.id == "open")
						{
							openvideo();
						}
						else if(mage.id == "close")
						{
							closevideo();
						}
						else if(mage.id == "contrastadd")
						{
							ContrastAdd('EPdha801');
						}
						else if(mage.id == "contrastreset")
						{
							//对比度 复位
							ContrastReplace('EPdha801');
						}
						else if(mage.id == "contrastdesc")
						{
							ContrastDesc('EPdha801');
						}
						else if(mage.id == "brightnessadd")
						{
							//增强亮度
							BrightnessAdd('EPdha801');
						}
						else if(mage.id == "brightnessreset")
						{
							//亮度 复位
							BrightnessReplace('EPdha801');
						}
						else if(mage.id == "brightnessdesc")
						{
							//降低亮度
							BrightnessDesc('EPdha801');
						}
						else if(mage.id == "imageqadd")
						{//showFramerate
							//增强图象质量
							ImageQAdd('EPdha801');
						}
						else if(mage.id == "imageqdesc")
						{
							//降低图象质量
							ImageQDesc('EPdha801');
						}
						else if(mage.id == "imageqreset")
						{
							//复位图象质量
							ImageQReset('EPdha801');
						}
						else if(mage.id == "framerateadd")
						{//showbitrate
							//增强帧率
							FrameRateAdd('EPdha801');

						}
						else if(mage.id == "frameratedesc")
						{
							//降低帧率
							FrameRateDesc('EPdha801');
						}
						else if(mage.id == "framesize")
						{
							//分辨率
							FrameSize();
						}else
						{
							try
							{
								eval("DO"+mage.id+"();");
							}catch(eee){}
						}
					
					}
					
				}
				
			
				

				function RecordClick(mage,number)
				{
					 if(haveStartRecord  && number !=2) 
					 {
						return true;			
				 	 }
				
					if(number == 1)
					{
						if (mage.src.indexOf("a5")>0) {
							mage.src="ptz/images/a5o.jpg";
						}
						
					}
					if(number == 0)
					{						
						if (mage.src.indexOf("a5")>0)
						{
							mage.src="ptz/images/a5n.jpg";
						}						
					}
					if(number == 2)
					{						
						mRec_onClick(mage);
					}
				}

				function mRec_onClick(mage)
				{	
					recordFile();
				}

				//录像开始和关闭

				function start_record()
				{

				}

				function stop_record()
				{

				}
				
				
				

				//图象质量值转换
				function imageParse(value)
				{
					if(value=="1"){
						return "@lang_level1";
					}
					else if(value=="2"){
						return "@lang_level2"
					}
					else if(value=="3"){
						return "@lang_level3"
					}
					else if(value=="4"){
						return "@lang_level4"
					}
					else if(value=="5"){
						return "@lang_level5"
					}
					else {
						return "";
					}	
				}
				init();


				function getPhotoSavePath()
				{
					
					var photoSavePath ;
					if(true){
						photoSavePath = 'C:';	
					}
					else {
						photoSavePath ="";//
					}
					
					return photoSavePath;
				}



				function getVideoSavePath()
				{
					
					var videoSavePath;
					if(true)
					{
						videoSavePath = 'C:';	
					}
					else 
					{
						videoSavePath ="";
					}
					
					
					return videoSavePath;
				}
				  
				function get_FrameRate()
				{
					
				}



				function get_ImageQ()
				{
					 
				}
				
				
				
				function callandset(obj)
				{
					try
					{
						var cmd = obj.value;
						if(cmd == '0') return ;
						if((cmd == "RWB")||(cmd == "BWB")||(cmd == "MWB")||(cmd == "GWB"))
						{
							cmd="AWBOff";
						}
						sendMsg("<xml><cmd>"+cmd+"</cmd></xml>");
					}catch(eee){}
				}
				
				function callandsetup(obj)
				{
					try
					{
						var cmd = obj.value;
						if((cmd == "RWB")||(cmd == "BWB")||(cmd == "MWB")||(cmd == "GWB"))
						{
							sendMsg("<xml><cmd>"+cmd+"</cmd></xml>");
						}
					}catch(eee){}
				}
				
				function scanset(obj)
				{
					var cmd = obj.value;
					if(cmd == '0') return ;
					sendMsg("<xml><cmd>"+cmd+"</cmd></xml>");
				}
				
								
				function changeDelPreset()
				{
				       
				}
				
				
				//更改视频
			    function changeVideo(obj,value)
				{
				          
				}
				
				
				
				
				
				
					 
	var obj_istestmode=false;//用于测试时	
	var obj_mouse_isdown=false;
	var obj_mouse_downx=0;
	var obj_mouse_downy=0;
	var obj_lastclick_obj=null;	
	var lastacton="";
	var speedchange=true;
	
	var __timerforzoom=null;
	var __lastCmdValue="";
	var __lastCmdTime=0;
	
				
	function showTestMsg(msg)
	{
	    //if(obj_istestmode)
	    {
	        WriteWebLog(msg);
	    }
	}
	
	function getNowTimeValue()
	{
	    var da=new Date();
	    return da.getTime();
	}
	
	
	///视频窗口上控制视频命令
	function doSendEventCmd(strname)
	{
	    __ActionFromFullScreen=true;
	    showTestMsg("doSendEventCmd ="+strname);
		if(speedchange==false && __lastCmdValue==strname && __lastCmdTime>=getNowTimeValue()-500)
		{//此处表示
		    
			__lastCmdTime=getNowTimeValue();
			try
			{
				if(__timerforzoom!=null)
				{
					window.clearTimeout(__timerforzoom);
					__timerforzoom=null;
				}
			}catch(eee){}
			if(strname=="zoomdown" || strname=="zoomup")
			{
				__timerforzoom=window.setTimeout("PTZClick($('"+strname+"'),3);try{__timerforzoom=null;}catch(ee){}",500);//0.1秒后自动停
			}
			return ;
		}
		__lastCmdTime=getNowTimeValue();
		__lastCmdValue=strname;
		if(strname=="zoomdown" || strname=="zoomup")
		{
			lastacton=strname;
			obj_lastclick_obj=$(strname);
			if(!obj_istestmode)
			{
		        if(obj_lastclick_obj!=null)
		        {
			        PTZClick(obj_lastclick_obj,2);
			        try
			        {
				        if(__timerforzoom!=null)
				        {
					        window.clearTimeout(__timerforzoom);
					        __timerforzoom=null;
				        }
			        }catch(eee){}
			        __timerforzoom=window.setTimeout("PTZClick($('"+strname+"'),3);try{__timerforzoom=null;}catch(ee){}",500);//0.1秒后自动停
				}
			}
			return ;
		}else if( (strname==lastacton) && (!speedchange) )
		{//速度没改变，且发相同的命令不用重发
			return;
		}
		if(obj_lastclick_obj!=null)
		{
			if(!obj_istestmode)
			{
			    PTZClick(obj_lastclick_obj,3);
			}
			obj_lastclick_obj=null;
		}
		if(strname=="stop")
		{
			sendStop();
		}else
		{
			speedchange=false;//标记新速度已发送了命令
			obj_lastclick_obj=$(strname);
			if(!obj_istestmode)
			{
			    PTZClick(obj_lastclick_obj,2);
			}
			lastacton=strname;//记录最后一次发的命令
		}
	}
	
	//处理控件上传过来的速度，用于控制视频
	function doMouseEvent(eventid,wp,xy)
	{
		try
		{
		    if(eventid==3)
		    {
				obj_mouse_isdown=false;
				return false;
		    }
			if(LastCmdOkDevId=="" || selectPlayerId=="")
			{//云台没有连上
			    showTestMsg("云台没有连接上，退出！");
			    return ;
			}
			var x=Math.floor(xy)&0xffff;
			var y=Math.floor(xy/0xffff);
			
			if(eventid==2 || eventid==3)
			{//mouse up
				obj_mouse_downx=0;
				obj_mouse_downy=0;
				obj_mouse_isdown=false;
				showTestMsg("发送停止:stop,x="+x+",y="+y);
				doSendEventCmd("stop");
				return ;
			}else if(eventid==1)
			{//mouse down
			    var nowplyobj=GetPlayerById(selectPlayerId);
			    if(!nowplyobj.GetFullScreen())
			    {
			        return false;
			    }
				obj_mouse_isdown=true;
				obj_mouse_downx=-1;//解决双击时会移动问题
				obj_mouse_downy=-1;//解决双击时会移动问题
				showTestMsg("鼠标按下位置 x="+x+",y="+y);
			}else if(eventid==8)
			{//鼠标滚动
			    //showTestMsg("鼠标滚动,x="+x+",y="+y);
			    //wp 意义，低16位表示键盘状态，高16中，低8位表示滚动数量，高1位表示方向
				var zoomvalue=wp&0xffff;//按键状态
				var typevalue=Math.floor(wp)&0xffff0000;//鼠标滚动信息
				var wpvlaue=Math.floor(wp);
				var postype=wpvlaue& 0xf0000000;//取得方向
				if(postype!=0)
				{//缩小，向用户滚动
					doSendEventCmd("zoomup");
				}else
				{//放大,远离用户滚动
					doSendEventCmd("zoomdown");
				}
				return ;
			}
			var plyobj=GetPlayerById(selectPlayerId);
			var whstr=plyobj.GetWindowSize();		
			var wh=parseInt(whstr);			
			var w=(wh & 0xffff0000)>>16;//plyobj.getAttribute("width");
			var h=(wh & 0xffff);//plyobj.getAttribute("height");			
			showTestMsg("wh="+wh+",str="+whstr+",w="+w+",h="+h);
			//w=parseInt(w);
			//h=parseInt(h);
			
			//if(eventid==7)
			//{
				//showTestMsg("鼠标移动位置 x="+x+",y="+y+",w="+w+",h="+h);
			//}
						
			if(obj_mouse_isdown && obj_mouse_downx==-1 && obj_mouse_downy==-1)
			{//解决双击时会移动问题
				obj_mouse_downx=x;
				obj_mouse_downy=y;
			    return false;
			}
						
			if(obj_mouse_downx<=0 || obj_mouse_downy<=0)
			{
			    return -2;
			}
			
			
			var absx=obj_mouse_downx-x;//w/2-x;
			var absy=obj_mouse_downy-y;//h/2-y;
			var isup=false;
			var isleft=false;
			if(absx>0)isleft=true;			
			if(absy>0)isup=true;
			var allvalue=0;
			allvalue+=(absx*absx);
			allvalue+=(absy*absy);//  对角线值
			if(allvalue<=0)
			{
			    showTestMsg("allvalue<=0 对角线值 return ");
			    return ;
			}
			allvalue=Math.sqrt(allvalue);//开方  
			absx=Math.abs(absx);
			absy=Math.abs(absy);		
			if(absx<10 && absy<10)
			{
			    showTestMsg("absx,absy<=10 return移动太小，不操作 ");
			    return ;//移动太小，不操作	
			}else if(x>w || y>h)
			{
			    showTestMsg("x>w || y>h return,参数值不正常,不操作 ");
			    return ;//移动太小，不操作	
			}
			var value=absx/allvalue;
			var arvalue=Math.asin(value)*180/3.1415926;//  角度			
			if(eventid==7 && obj_mouse_isdown)
			{//mouse  move
				var movex=absx+w/20;
				var movey=absy+h/20;
				var panspeedobj=$("panspeed");
				var titlespeedobj=$("titlespeed");
				var pv=Math.floor(movex*20/w);//5等级量化
				var tv=Math.floor(movey*20/h);//5等级量化
				if(pv>10)pv=10;
				if(tv>10)tv=10;
				speedchange=false;//重置状态
				if(pv!=panspeedobj.value)
				{
					panspeedobj.value=pv;
					speedchange=true;
					eventid=1;
				}
				if(tv!=titlespeedobj.value)
				{
					titlespeedobj.value=tv;
					speedchange=true;
					eventid=1;
				}
				if(obj_istestmode)eventid=1;//如果测试时，只要移动就显示数据
			}//absx/allvalue;
			var showmsg="id="+eventid+",w="+w+",h="+h+"x="+x+",y="+y+"ang="+arvalue+","+obj_mouse_isdown;
			//showTestMsg("id="+eventid+",w="+w+",h="+h+"x="+x+",y="+y+"ang="+arvalue+","+obj_mouse_isdown);			
			if( eventid==1 && obj_mouse_isdown )
			{//发送移动控制命令	
				if(isleft)
				{//左
					if(isup)
					{//上0.72112 0.5
						if(arvalue<30)
						{//上
							showTestMsg(showmsg+",up");
							doSendEventCmd("up");
						}else if(arvalue<60)
						{//左上
							showTestMsg(showmsg+",left_up");
							doSendEventCmd("left_up");
						}
						else
						{//左
							showTestMsg(showmsg+",left");
							doSendEventCmd("left");
						}
					}else
					{//下
						if(arvalue>60)
						{//左
							showTestMsg(showmsg+",left");
							doSendEventCmd("left");
						}else if(arvalue>30)
						{//左下
							showTestMsg(showmsg+",left_down");
							doSendEventCmd("left_down");
						}
						else
						{//下
							showTestMsg(showmsg+",down");
							doSendEventCmd("down");
						}
					}
				}else
				{//右
					if(isup)
					{//上0.72112 0.5
						if(arvalue<30)
						{//上
							showTestMsg(showmsg+",up");
							doSendEventCmd("up");
						}else if(arvalue<60)
						{//右上
							showTestMsg(showmsg+",right_up");
							doSendEventCmd("right_up");
						}
						else
						{//右
							showTestMsg(showmsg+",right");;
							doSendEventCmd("right");
						}
					}else
					{//下
						if(arvalue>60)
						{//右
							showTestMsg(showmsg+",right");
							doSendEventCmd("right");
						}else if(arvalue>30)
						{//右下
							showTestMsg(showmsg+",right_down");
							doSendEventCmd("right_down");
						}
						else
						{//下
							showTestMsg(showmsg+",down");	
							doSendEventCmd("down");
						}
					}
				}
			}//按下按键时响应
			else
			{
				
			}			
			 
			//目前只需要处理
			//EVENT_LBUTTONDOWN  1
			//EVENT_LBUTTONUP 2
			//EVENT_MOUSEMOVE  7
			//EVENT_MOUSEWHEEL 8
			//三个消息。
			
		}
		catch(eee)
		{
		    showTestMsg("出错了,信息:"+eee.description);
		}
	}
	
	
	
	function ChangeUserButtonByString(ptzenable,advptzenable)
	{
	    //ptzenable=true;
	    //advptzenable=false;
	    var ptzlist="down,panspeed,titlespeed,left_up,up,right_up,zoomdown,right,left,back,zoomup,left_down,right_down,snap,contrastadd,contrastreset,contrastdesc,brightnessadd,brightnessrest,brightnessdesc";
	    var advptzlist="scan_set_add,doscanset,goto_x_add,callanset,inppreset,addpre,delpreset,delpre,gotopreset,callpre";
	    var advptzclass="";
	    var ptzclass="";
	    if(advptzenable)
	    {
	        advptzenable=true;
	        ptzenable=true;
	    }else
	    {
	        advptzenable=false;
	        advptzclass="notallowclick";
	    }
	    if(ptzenable)
	    {
	        ptzenable=true;
	    }else
	    {
	        ptzenable=false;
	        ptzclass="notallowclick";
	    }
	    SetEnabled(advptzlist,advptzenable,advptzclass);
	    SetEnabled(ptzlist,ptzenable,ptzclass);	    
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	




//	int m_nSpeedChanged;
//	char m_szLastCmdString[32];
//	DWORD m_nLastSendCmdTime;
//	int m_bMouseIsDown;	
//	int m_nMouseDownX;
//	int m_nMouseDownY;

//	//返回全屏窗口大小W
//	int GetScreenX()
//	{
//		return 600;
//	}

//	//返回全屏窗口大小H
//	int GetScreenY()
//	{
//		return 400;
//	}


//	int SetSpeedValue(int pSpeed,int tSpeed)
//	{

//		return 0;
//	}

//	//type=1,2,1为pSpeed,2这tSpeed
//	int GetSpeedValue(int type)
//	{

//		return 0;
//	}

//	//先发送strname，命令,其中速度为pSpeed和tSpeed，如果nAutoStopTime>0，则要在nAutoStopTime毫秒后自动发送一个stop命令
//	int SendPTZCmd(char *strname,int nAutoStopTime)
//	{
//		int pSpeed=GetSpeedValue(1);
//		int tSpeed=GetSpeedValue(1);

//		return 0;
//	}
//	



//	///视频窗口上控制视频命令
//	int DoSendEventCmd(char * strname)
//	{
//		int bNoSameCmd=strncmp(m_szLastCmdString,strname,strlen(strname));
//		if(m_nSpeedChanged==false && bNoSameCmd && m_nLastSendCmdTime+500>::GetTickCount())
//		{//此处表示
//			m_nLastSendCmdTime=GetTickCount();			 
//			if(strncpy(strname,"zoomdown",8)==0 || strncpy(strname,"zoomup",8)==0 )
//			{//
//				memcpy(m_szLastCmdString,strname,32);
//				SendPTZCmd(strname,500);//500毫秒后自动停止
//			}
//			return -1;
//		}		
//		m_nLastSendCmdTime=GetTickCount();
//		if(strncpy(strname,"zoomdown",8)==0 || strncpy(strname,"zoomup",8)==0 )
//		{//
//			memcpy(m_szLastCmdString,strname,32);
//			SendPTZCmd(strname,500);//500毫秒后自动停止
//		}else if( (!bNoSameCmd) && (!m_nSpeedChanged) )
//		{//速度没改变，且发相同的命令不用重发
//			return -3;
//		}
//		memcpy(m_szLastCmdString,strname,32);
//		return SendPTZCmd(strname,-1);
//	}



//	//eventid目前只需要处理
//	//EVENT_LBUTTONDOWN  1
//	//EVENT_LBUTTONUP 2
//	//EVENT_MOUSEMOVE  7
//	//EVENT_MOUSEWHEEL 8
//	//三个消息。

//	//处理控件上传过来的速度，用于控制视频
//	int DoMouseEvent(int eventid,WPARAM wp,LPARAM xy)
//	{
//		//try
//		//{
//			if(true)//if(LastCmdOkDevId=="" || selectPlayerId=="")
//			{//这里要判断云台是否没有连上
//			    //ShowTestMsg("云台没有连接上，退出！");
//			    return -1;
//			}
//			int w=GetScreenX();//这里要改成你窗口的大小plyobj.getAttribute("width");
//			int h=GetScreenY();//这里要改成你窗口的大小 plyobj.getAttribute("height");
//			int x=xy & 0xffff;
//			int y=(xy & 0xffff0000)>>16;
//			if(eventid==2)
//			{//mouse up
//				m_bMouseIsDown=false;
//				return DoSendEventCmd("stop");
//			}else if(eventid==1)
//			{//mouse down
//				m_bMouseIsDown=true;
//				m_nMouseDownX=x;
//				m_nMouseDownY=y;
//				//ShowTestMsg("鼠标按下位置 x="+x+",y="+y);
//			}else if(eventid==8)
//			{//鼠标滚动
//			    //ShowTestMsg("鼠标滚动,x="+x+",y="+y);
//			    //wp 意义，低16位表示键盘状态，高16中，低8位表示滚动数量，高1位表示方向
//				int zoomvalue=wp & 0xffff;//按键状态
//				int typevalue=wp & 0xffff0000;//鼠标滚动信息
//				int wpvlaue=wp;
//				int postype=wpvlaue & 0xf0000000;//取得方向
//				if(postype!=0)
//				{//缩小，向用户滚动
//					return DoSendEventCmd("zoomup");
//				}else
//				{//放大,远离用户滚动
//					return DoSendEventCmd("zoomdown");
//				}
//			}			
//			if(eventid==7)
//			{
//				//ShowTestMsg("鼠标移动位置 x="+x+",y="+y+",w="+w+",h="+h);
//			}
//			if(m_nMouseDownX<=0 || m_nMouseDownY<=0)
//			{
//				return -2;
//			}
//			int absx=m_nMouseDownX-x;//w/2-x;
//			int absy=m_nMouseDownY-y;//h/2-y;
//			int isup=false;
//			int isleft=false;
//			if(absx>0)isleft=true;			
//			if(absy>0)isup=true;
//			int allvalue=0;
//			allvalue+=(absx*absx);
//			allvalue+=(absy*absy);//  对角线值   
//			if(allvalue<=0)
//			{
//			    //ShowTestMsg("allvalue<=0 对角线值 return ");
//			    return -2;
//			}
//			
//			allvalue=sqrt((double)allvalue);//开方  
//			absx=abs(absx);
//			absy=abs(absy);
//			if(absx<10 && absy<10)
//			{
//			    //ShowTestMsg("absx,absy<=10 return移动太小，不操作 ");
//			    return -3;//移动太小，不操作	
//			}
//			int value=absx/allvalue;
//			int arvalue=(asin((double)value)*180/3.1415926);//  角度			
//			if(eventid==7 && m_bMouseIsDown)
//			{//mouse  move
//				int movex=absx+w/20;
//				int movey=absy+h/20;
//				int pv=floor((double)movex*20/w);//5等级量化
//				int tv=floor((double)movey*20/h);//5等级量化
//				if(pv>10)pv=10;
//				if(tv>10)tv=10;
//				m_nSpeedChanged=false;//重置状态
//				if(pv!=GetSpeedValue(1))
//				{
//					SetSpeedValue(pv,tv);
//					m_nSpeedChanged=true;
//					eventid=1;
//				}
//				if(tv!=GetSpeedValue(2))
//				{
//					SetSpeedValue(pv,tv);
//					m_nSpeedChanged=true;
//					eventid=1;
//				}
//			}//absx/allvalue;

//			//var showmsg="id="+eventid+",w="+w+",h="+h+"x="+x+",y="+y+"ang="+arvalue+","+m_bMouseIsDown;
//			//ShowTestMsg("id="+eventid+",w="+w+",h="+h+"x="+x+",y="+y+"ang="+arvalue+","+m_bMouseIsDown);			
//			if( eventid==1 && m_bMouseIsDown )
//			{//发送移动控制命令	
//				if(isleft)
//				{//左
//					if(isup)
//					{//上0.72112 0.5
//						if(arvalue<30)
//						{//上
//							//ShowTestMsg(showmsg+",up");
//							return DoSendEventCmd("up");
//						}else if(arvalue<60)
//						{//左上
//							//ShowTestMsg(showmsg+",left_up");
//							return DoSendEventCmd("left_up");
//						}
//						else
//						{//左
//							//ShowTestMsg(showmsg+",left");
//							return DoSendEventCmd("left");
//						}
//					}else
//					{//下
//						if(arvalue>60)
//						{//左
//							//ShowTestMsg(showmsg+",left");
//							return DoSendEventCmd("left");
//						}else if(arvalue>30)
//						{//左下
//							//ShowTestMsg(showmsg+",left_down");
//							return DoSendEventCmd("left_down");
//						}
//						else
//						{//下
//							//ShowTestMsg(showmsg+",down");
//							return DoSendEventCmd("down");
//						}
//					}
//				}else
//				{//右
//					if(isup)
//					{//上0.72112 0.5
//						if(arvalue<30)
//						{//上
//							//ShowTestMsg(showmsg+",up");
//							return DoSendEventCmd("up");
//						}else if(arvalue<60)
//						{//右上
//							//ShowTestMsg(showmsg+",right_up");
//							return DoSendEventCmd("right_up");
//						}
//						else
//						{//右
//							//ShowTestMsg(showmsg+",right");;
//							return DoSendEventCmd("right");
//						}
//					}else
//					{//下
//						if(arvalue>60)
//						{//右
//							//ShowTestMsg(showmsg+",right");
//							return DoSendEventCmd("right");
//						}else if(arvalue>30)
//						{//右下
//							//ShowTestMsg(showmsg+",right_down");
//							return DoSendEventCmd("right_down");
//						}
//						else
//						{//下
//							//ShowTestMsg(showmsg+",down");	
//							return DoSendEventCmd("down");
//						}
//					}
//				}
//			}//按下按键时响应
//			else
//			{
//				
//			}
//		/*}
//		catch(eee)
//		{
//		    ShowTestMsg("出错了,信息:"+eee.description);
//		}*/
//		return -10;
//	}