<!--
var ActiveObj = 0;		//记录当前mouse下的物件
var MouseStatus = 0; //0 up 1 down 2 drag
var OffsetX = 0;
var OffsetY = 0;
var SaveX=0;
var SaveY=0;
var ActiveObjX = 0;
var ActiveObjY = 0;

function pick_face_init() { //初始化，截取浏览器关于鼠标的调用
	window.document.onmousemove = mouseMove;
	window.document.onmousedown = mouseDown;
	window.document.onmouseup = mouseUp;
	window.document.ondragstart = mouseStop;
	document.oncontextmenu = nocontextmenu;  // for IE5+，不要弹出右键菜单
}

function nocontextmenu() //不要右键菜单
{
	event.cancelBubble = true
	event.returnValue = false;

	return false;
}

function mouseUp() { //鼠标松开，移动结束，将移动状态去除
	MouseStatus = 0;
}

function mouseOver(CurrentObj) { //鼠标移入范围，针对鼠标下的对象进行操作
	ActiveObj=CurrentObj;
}

function mouseOut() { //鼠标移出了范围，则没有针对的操作对象了
	ActiveObj=0;
}

function mouseStop() { //鼠标将其他物品拖入，不作响应
	return false;
}

function mouseDbClick() { //鼠标双击，跳到下一个操作

}

function mouseDown() { //鼠标按下！
	//右键操作，切换到下一种功能
	if (ActiveObj && window.event.button==2) { 
		if (document.all.mouseAction.selectedIndex++>=2) {
			document.all.mouseAction.selectedIndex = 0;
		}
		changeCursor(document.all.mouseAction.selectedIndex);
		return false;
	}

	//左键操作，如果是拖动操作则设置拖动状态，如果是选眼睛则调用选眼睛方法
	if (ActiveObj && window.event.button==1) {
		if (document.all.mouseAction.value=="Drug") {
			MouseStatus = 2;
			OffsetX = window.event.clientX - parseInt(ActiveObj.style.left);
			OffsetY = window.event.clientY - parseInt(ActiveObj.style.top);
			//setNote("Start drug X-offset: "+window.event.clientX+"-"+parseInt(ActiveObj.style.left));
		}
		else { 
			chooseEyePosition();
		}
	}

}

function moveInDiv(_obj){
    if (_obj && window.event.button==1) {
		OffsetX = window.event.clientX - parseInt(_obj.style.left+0);
		OffsetY = window.event.clientY - parseInt(_obj.style.top);
		document.onmousemove=function(){
		    _obj.style.left=window.event.clientX;
		    _obj.style.top = window.event.clientY;
		}
	}
}

function mouseOverImage(_objId){
    if(document.getElementById("imageCount")){
        if(document.getElementById("imageCount").value=="1"){
           if(document.getElementById("mouseActionRadio_0")){
               if(document.getElementById("mouseActionRadio_0").checked){
	                if(document.getElementById("rightEye").value=="1"){
	                    var image = "<img src=\"../_images/popup_2_03.gif\" border=\"0\">"; 
	                }else{
	                    var image = "<img src=\"../_images/popup_2_01.gif\" border=\"0\">";
	                }
	                document.getElementById(_objId).innerHTML = image;
	            }
           }
        }
        document.getElementById(_objId).style.top = "195px";
        document.getElementById(_objId).style.left = "250px";
        document.getElementById(_objId).style.display = "inline"; 
    }
}

function mouseOverImage_2(_imageObj,_objId){
    _imageObj.style.cursor='hand';
    if(document.getElementById(_objId)){
        document.getElementById(_objId).style.top = "210px";
        document.getElementById(_objId).style.left = "400px";
        document.getElementById(_objId).style.display = "inline"; 
     }
}

function mouseOutImage(_objId){
    if(document.getElementById(_objId)){
        document.getElementById(_objId).style.display = "none";
    }
}

function mouseMove() { //鼠标移动，如果有操作对象且正在移动，则位移操作对象
	if (ActiveObj && MouseStatus == 2) {
		SaveX = window.event.clientX - OffsetX;
		SaveY = window.event.clientY - OffsetY;
		ActiveObjX = parseInt(ActiveObj.style.left);
		ActiveObjY = parseInt(ActiveObj.style.top);
		ActiveObj.style.left = SaveX;
		ActiveObj.style.top = SaveY;
		//setNote("Active: ["+ActiveObj.style.left+","+ActiveObj.style.top+"], Mouse: ["+SaveX+","+SaveY+"]");
	}
}

function changeSelect( n ) { //控制下拉框
	document.all.mouseAction.selectedIndex = n;
	changeCursor(n);
}

function changeCursor( n ) { //根据不同的功能变换不同的光标类型
	if (n==0) {
		document.all.main_photo.style.cursor = "move";
		document.all.left_eye.style.cursor = "move";
		document.all.right_eye.style.cursor = "move";

	} else {
		document.all.main_photo.style.cursor = "crosshair";
		document.all.left_eye.style.cursor = "crosshair";
		document.all.right_eye.style.cursor = "crosshair";
		document.all.mouseActionRadio.value = "ChooseLeft";
	}
	eval("document.all.mouseActionRadio_"+n+".checked = true;");
}

function chooseEyePosition() { //选眼睛位置
	var offsetx_obj,offsety_obj,eye_obj;
	MouseStatus = 0;
	if (document.all.mouseAction.value=="ChooseLeft") {
		if(document.getElementById("mouseActionRadio_1").checked){
            var image = "<img src=\"../_images/popup_2_02.gif\" border=\"0\">";
            document.getElementById("tipDiv").innerHTML = image;
        }
		offsetx_obj = document.all.left_eye_offset_x;
		offsety_obj = document.all.left_eye_offset_y;
		eye_obj = document.all.left_eye;
		document.getElementById("tipDiv").style.top = "195px";
        document.getElementById("tipDiv").style.left = "250px";
        document.getElementById("tipDiv").style.display = "inline"; 
	}
	else {
		if(document.getElementById("mouseActionRadio_2").checked){
            var image = "<img src=\"../_images/popup_2_03.gif\" border=\"0\">";
            document.getElementById("tipDiv").innerHTML = image;
        }
		offsetx_obj = document.all.right_eye_offset_x;
		offsety_obj = document.all.right_eye_offset_y;
		eye_obj = document.all.right_eye;
		document.getElementById("rightEye").value="1";
		document.getElementById("tipDiv").style.top = "195px";
        document.getElementById("tipDiv").style.left = "250px";
        document.getElementById("tipDiv").style.display = "inline"; 
	}
	eye_obj.style.display = "block";
	eye_obj.style.left = window.event.x-2;
	eye_obj.style.top = window.event.y-2;
	offsetx_obj.value = eye_obj.style.left;
	offsety_obj.value = eye_obj.style.top;

	if (document.all.left_eye_offset_x.value != "" &&
		document.all.left_eye_offset_y.value != "" &&
		document.all.right_eye_offset_x.value != "" &&
		document.all.right_eye_offset_y.value != "" &&
		(parseInt(document.all.left_eye_offset_x.value) > parseInt(document.all.right_eye_offset_x.value))) {
		setNote("错误了！左右眼位置放错了！！");
	}else {
		
		setNote("完毕");
	}
}

function setPicSrc( fileObj ) {
	if(!checkFileType(fileObj)){
	    alert("文件格式错误，请上传[.bmp .jpg .png .BMP .JPG .PNG]后缀文件");
	    return false;
	}
	var main_photo = document.all.main_photo;
	//var image = new Image();
	//image.src=fileObj.value;
	//var heightOffset = document.all("heightOffset");
	//var widthOffset = document.all("widthOffset");
	//if(image.readyState=="complete"){
	 //   if(image.height>209 ||image.width>251){
	//	    if(image.height>209){
	//	         main_photo.height="209";
	//	         heightOffset.value=parseFloat(image.height)-209;
	//	         var percent = (parseFloat(image.height)-209)/parseFloat(image.height);
	//	         main_photo.width=image.width*(1-percent);
	//	         widthOffset.value=parseFloat(image.width)-main_photo.width;
	//	    }
	//	    if(main_photo.width>251){
	//	         var imageWidth = main_photo.width;
	//	         main_photo.width="251";
	//	         widthOffset.value = parseFloat(widthOffset.value)+parseFloat(imageWidth)-251;
	//	         var percent = (parseFloat(imageWidth)-251)/parseFloat(imageWidth);
	//	         main_photo.height=main_photo.height*(1-percent);
	//	         heightOffset.value = parseFloat(heightOffset.value)+parseFloat(main_photo.height)*percent;
	//	    }
	//	}
	//}
	//var left = (251-parseInt(main_photo.width))/2;
	//var top = (209-parseInt(main_photo.height))/2;
	//document.all("imageDiv").style.left = left;
	//document.all("imageDiv").style.top = top;
	main_photo.src = fileObj.value;
	document.getElementById("imageCount").value="1";
}

function checkFileType(fileObj){
    var fileTxtArr = ["bmp","jpg","png"];
    Array.prototype.indexOf = function (_obj){
        for(var i=this.length;i-- && this[i]!=_obj;){
        }
        return i;
    }
    var fileTxt = fileObj.value.substr(fileObj.value.lastIndexOf(".")+1);
    if(fileTxt == null || fileTxt=="undefined"){
        return false;
    }
    fileTxt = fileTxt.toLowerCase();
    if(fileTxtArr.indexOf(fileTxt)== -1){
        return false;
    }
    return true;
}
