function getEvent(){     //同时兼容ie和ff的写法
         if(document.all)    return window.event;        
         func=getEvent.caller;            
         while(func!=null){    
             var arg0=func.arguments[0];
             if(arg0){
                 if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
                     || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
                     return arg0;
                 }
             }
             func=func.caller;
         }
         return null;
 }

try
{
	HTMLElement.prototype.__defineGetter__("children",
	function () {
	var returnValue = new Object();
	var number = 0;
	for (var i=0; i<this.childNodes.length; i++) {
	if (this.childNodes[i].nodeType == 1) {
	returnValue[number] = this.childNodes[i];
	number++;
	}
	}
	returnValue.length = number;
	return returnValue;
	}
	);
}
catch(e){}


var ajControl=
{
    //在一个层上显示漂浮的内容
    overContent:function(obj,innerHTML)
    {
        var o=typeof(obj)=="object"?obj:document.getElementById(obj);
	    if (window.attachEvent)
	    {
		    o.attachEvent("onmousemove",mousemove); 
	    }
	    if (window.addEventListener)
	    {
		    o.addEventListener("mousemove",mousemove,false);
	    } 

	    if (window.attachEvent)
	    {
		    o.attachEvent("onmouseout",mouseout); 
	    }
	    if (window.addEventListener)
	    {
		    o.addEventListener("mouseout",mouseout,false);
	    } 
        

	    function mousemove()
	    {
		    var event=getEvent();
		    var x=event.clientX;
		    var scrollTop=document.body.scrollTop;
		    if(scrollTop==0)
		    {
		        scrollTop=document.documentElement.scrollTop;
		    }
		    var y=event.clientY+scrollTop+10;
		    var div=document.getElementById("OverFloatDiv");
		    if(!div)
		    {
			    div=document.createElement("div");
			    div.setAttribute("id","OverFloatDiv");
			    document.body.appendChild(div);
		    }
		    div.innerHTML=innerHTML;
		    div.style.position="absolute";
		    div.style.left=x+"px";
		    div.style.top=y+"px";
	    }

	    function mouseout()
	    {
		    var div=document.getElementById("OverFloatDiv");
		    if(div)
		    {
			    document.body.removeChild(div);
		    }
	    } 
    },
    //移动层对象
    dragObj:function(obj)
	{
		var o=getObj(obj);
		var XY=getXY(o);
		o.setAttribute("moveable","false");
		var cx=0;
		var cy=0;
		try
		{
			cx=arguments[1];
			cy=arguments[2];
		}
		catch (e)
		{
		}
		var x0=0;
		var y0=0;
		o.onmousedown=function()
		{
			var event=getEvent();
			var XY=getXY(o);
			x0=event.clientX-XY.X;
			y0=event.clientY-XY.Y;
			o.setAttribute("moveable","true");
		}
		o.onmouseup=function()
		{
			o.setAttribute("moveable","false");
		}

		o.onmousemove=function()
		{
			var availableMove=false;
			try
			{
				availableMove=eval(o.getAttribute("moveable"));
			}
			catch (e){}
			if(!availableMove)
				return;
			var event=getEvent();
			var x=event.clientX-x0;
			var y=event.clientY-y0;
			o.style.position="absolute";
			o.style.display="block";
			o.style.left=x+"px";
			o.style.top=y+"px";
		}
		function getXY(obj)
		{
			var o=obj;
			var x=o.offsetLeft;
			var y=o.offsetTop;
			while(o=o.offsetParent)
			{
				x+=o.offsetLeft;
				y+=o.offsetTop;
			}
			return {X:x,Y:y}
		}

		function getEvent(){
				 if(document.all)    return window.event;        
				 func=getEvent.caller;            
				 while(func!=null){    
					 var arg0=func.arguments[0];
					 if(arg0){
						 if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
							 || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
							 return arg0;
						 }
					 }
					 func=func.caller;
				 }
				 return null;
		 }
		function getObj(obj)
		{
			var o;
			if(typeof(obj)=="string")
			{
				o=document.getElementById(obj);
			}
			else
			{
				o=obj;
			}
			return o;
		}
	},
	///缩小obj区域中的图片大小
	smallInnerImg:function(obj,width,height)
    {
	    var value=[];
	    var o=getObj(obj);
    	
	    LoadAllEvent();

	    function getrunelement(obj)
	    {
		    try
		    {
			    if(obj.children.length>0)
			    {
				    for(var i=0;i<obj.children.length;i++)
				    {
					    var o=obj.children[i];
    					
					    if(o.tagName=="IMG")
					    {
						    value[value.length]=o;
					    }
					    getrunelement(o);
				    }
			     }
		    }
		    catch(e){}
	    }
    	
	    function getRunElement()
	    {
		    value=[];
		    getrunelement(o);
		    return value;
	    }
	    function LoadAllEvent()
	    {
		    var elements=getRunElement();
		    var obj=null;
		    for(var i=0;i<elements.length;i++)
		    {
			    obj=elements[i];
			    if(obj.width>width||obj.height>height)
			    {
				    obj.width=width;
				    obj.height=height;
				    obj.style.width=width+"px";
				    obj.style.height=height+"px";
			    }
		    }
	    }
    	

	    function getObj(obj)
	    {
		    var o;
		    if(typeof(obj)=="string")
		    {
			    o=document.getElementById(obj);
		    }
		    else
		    {
			    o=obj;
		    }
		    return o;
	    }
    }
}