﻿// JScript 文件

function setHandleImage()
{
  for(var i=0;i<arguments.length;i++)
  {
    var handleTag="<div id=\"handleImage"+i+"\" class=\"handleImage\" title=\"拖拽可调整大小\" style=\"display:none\"></div>";
    document.getElementById(arguments[i]).parentNode.innerHTML+=handleTag;
    startHandleImage(arguments[i],i);
   }
}

function startHandleImage(img,imgIndex)
{
  //build by ztl.施宗建 2007.6.16
  var chartImage=getimgobj(img);
  var handleImage=document.getElementById("handleImage"+imgIndex);
  var width=chartImage.width;
  var height=chartImage.height;
  chartImage.className="frameImage";
   handleImage.style.marginTop="-16px";
   handleImage.style.display="";
   chartImage.onmousewheel=function(e)//统计图的鼠标滑轮放大缩小
   {/*
     if(document.all)
     {
      var o=event.srcElement;
      var zoom=parseInt(o.style.zoom, 10)||100;
      zoom+=event.wheelDelta/12;
      if (zoom>0)
         o.style.zoom=zoom+'%'; 
      changeImg1(img,'w',Math.round(o.width*zoom/100.0));
      changeImg1(img,'h',Math.round(o.height*zoom/100.0));
      o.style.zoom="100%";
      return false;
     }*/
    }
   chartImage.onmousemove=function(e)//激活X轴左右移
   {
     o=chartImage;
      if(o.width==529 && o.height==326)
      {
        if(o.style.cursor!="pointer")
        {
         o.style.cursor="pointer";
         if(document.all)
             o.alt="请登录或者注册新会员";
         else
             o.title="请登录或者注册新会员";
         }
         return;
      }
     if(o.getAttribute("nolr"))
       return false;
     if(document.all)//id
     {
	     if(event.offsetY<o.clientHeight-30)
         {
           if(event.offsetX <= o.clientWidth/2 )
           {
		      if( !o.style.cursor.match("w-resize") )
			     o.style.cursor = "url("+"http://www.bjfang.com/cursor/w-resize.ani"+")";
		      if( o.alt != "点击X轴左移" )
			     o.alt = "点击X轴左移";
	        }
	        else if( !o.style.cursor.match("e-resize") )
	        {	
		       o.style.cursor="url("+"http://www.bjfang.com/cursor/e-resize.ani"+")";
		       if( o.alt != "点击X轴右移" )
			     o.alt = "点击X轴右移";
	         }
	      }
	      else
	      {
	         o.style.cursor="default";
	       }
	  }
	  else//firefox 主要是为了兼容firefox 好烦人啊
	  {
	     o.style.position="relative";
	     if(e.layerY<o.clientHeight-30)
         {
           if(e.layerX <= o.clientWidth/3 )
           {
		      if( !o.style.cursor!="w-resize" )
			     o.style.cursor = "w-resize";
		      if( o.title != "点击X轴左移" )
			     o.title = "点击X轴左移";
	        }
	        else if(e.layerX>=o.clientWidth*2/3)
	        {
	          if(!o.style.cursor!="e-resize" )
	          {	
		        o.style.cursor="e-resize";
		        if( o.title != "点击X轴右移" )
			      o.title = "点击X轴右移";
	           }
	        }
	        else
	        {
	           o.style.cursor="default";
	           o.title="拖动右下角可以缩放图片大小";
	           if(o.style.position!="static")
	           o.style.position="static";
	         }
	      }
	      else
	      {
	         o.style.cursor="default";
	       }
	  }
	  return true;
   }
   chartImage.onmouseout=function(e)//主要是为了兼容firefox 烦人啊
   {
     if(chartImage.style.position!="static")
        chartImage.style.position="static";
   }
   chartImage.onclick=function(e)//X轴左右移
   {
      o=chartImage;
      if(o.width==529 && o.height==326)
      {
         window.location="/login.aspx";
         return;
      }
      if(o.style.cursor.match("w-resize"))
      {
        changeImg2(img,"--");//向左
      }
      else if(o.style.cursor.match("e-resize"))
      {
        changeImg2(img,"++");//向右
      }
   }
   handleImage.onmouseover=function(e)//拖动柄激活状态
   {
      chartImage.className="resizingImage";
   }
   handleImage.onmouseout=function(e)//拖动柄Normal状态
   {
      chartImage.className="frameImage";
   }
   dragapproved=false;
   handleImage.onmousedown=function(e)//拖动柄拖动状态
   {
    z = (window.event)?event.srcElement:e.target;
   if (z.className=="handleImage")
  {
  dragapproved=true
  x1=(window.event)?event.clientX:e.pageX;
  y1=(window.event)?event.clientY:e.pageY;
  width=chartImage.width;
  height=chartImage.height;
  document.onmousemove=function(e)//随意大小
  {
  if(document.all)//ie
  {
   if (event.button==1&&dragapproved)
   {
     if(event.clientX-x1>0-width && event.clientY-y1>0-height)
     {
     chartImage.width=width+(event.clientX-x1)*2;//一般是图片居中，否则左对齐就不用*2
     chartImage.height=height+event.clientY-y1;
     }
    }
  }
  else//firefox
  {
   if(e.button==0 && dragapproved)
   {
     if(e.pageX-x1>0-width && e.pageY-y1>0-height)
     {
        chartImage.width=width+(e.pageX-x1)*2;
        chartImage.height=height+e.pageY-y1;
      }
    }
  }
  return false;
  }
  document.onmouseup=function(e)//改变实际大小
  {
     if(dragapproved)
     {
     changeImg1(img,'w',chartImage.width);
     changeImg1(img,'h',chartImage.height);
     dragapproved=false;
     }
  }
 }
}
}