var $is_IE=document.all,//判断非IE浏览器
     $Mouse=false;
     document.onmousemove=function(event){
       $Mouse=window.event || arguments[0];
     };
//*返回元素对象*/
function func_id($r){
         var $len=arguments.length,$arr=[];
		 if($len==1){
		    return document.getElementById($r);
		 }else if($len>1){
		  for (var i=0; i<$len; i++) {
			$arr.push(func_id(arguments[i]));
		  }
          return $arr;
		 }
}
function getIFrameDocument(aID) { //返回指定iframe的document 
    var rv = null; 
    if (document.getElementById(aID).contentWindow.document){ 
        // if contentDocument exists, W3C compliant (Mozilla) 
        rv = document.getElementById(aID).contentWindow.document; 
    } else { 
        // IE 
        rv = document.frames[aID].document; 
    } 
    return rv; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*增加元素对象*/
function func_cEle($r){
 return document.createElement($r);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*CSS样式*/
function s_s($r){return $r.style;}//样式
function s_float($r,$rr){//浮动
 if($is_IE){
    s_s($r).styleFloat=$rr; 
 }else{
   s_s($r).cssFloat=$rr;
 }
}
function s_width($r,$w){s_s($r).width=$w+"px";}
function s_height($r,$h){s_s($r).height=$h+"px";}
function s_show($r){s_s($r).display="block";}
function s_hide($r){s_s($r).display="none";}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*增加和删除事件函数*/
function func_addEvent($obj,$type,func) {//添加事件函数
        var $arrs = Array.prototype.slice.call(arguments,3),
	       funcs=func_addArgs(func,$arrs);
	if ($is_IE) {
		$obj.attachEvent("on"+$type,funcs);
	}else{
        $obj.addEventListener($type,funcs,false);
	}
}
function func_delEvent($obj,$type,func) {//删除事件函数
        if ($is_IE) {
			$obj.detachEven("on"+$type,func);
        }else {
			$obj.removeEventListener($type,func,false);
        }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*为函数添加参数*/
function func_addArgs(func,$arr) {//为函数添加参数
	var funcs=function() {
		if (!$arr) {
			$arr.push(0);
		}
		func.apply(null,$arr);
	};
	return funcs;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*移动函数*/
function func_move($obj,evt) {//元素移动函数
	var $e=window.event||evt,
		   $MouseStatus=false,
		   $win=$obj,
	       $PX1=$e.clientX,
	       $PY1=$e.clientY,
	       $MouseStatus=true;
	       s_s($win).position="absolute"; 
	        document.onmouseup=function(){
		        $MouseStatus=false;
	        };
	        document.onmousemove=function(event){
			        if($MouseStatus){
			            var $Mouse=window.event || arguments[0],
			                $PX2=$Mouse.clientX,
			                $PY2=$Mouse.clientY,
			                $PX=$PX2-$PX1,
			                $PY=$PY2-$PY1;
				        s_s($win).left=($win.offsetLeft+$PX)+"px";
				        s_s($win).top=($win.offsetTop+$PY)+"px";
				        $PX1=$PX2;
				        $PY1=$PY2;
			        }
            };
 }///////////////////////////////////////////////////////////////////////////////////
 /*
        拉伸函数
        func_stretch 显示拉伸鼠标
        func_stretchS 拉升实现
*/
function func_stretch($obj,$e){
       var $e=window.event || arguments[0],
           $x=$e.clientX,  //前X点
             $y=$e.clientY,  //前Y点
           $status=false,
             $objX=$obj.offsetLeft,
           $objY=$obj.offsetTop,
           $objW=$obj.offsetWidth,
           $objH=$obj.offsetHeight,
           $objX2=$objX+$objW;// 后X点
		   $objY2=$objY+$objH;//  后Y点
		     if((($x>$objX-15 && $x<$objX+15)&&($y>$objY-15 && $y<$objY+15)) || (($x>$objX2-15 && $x<$objX2+15)&&($y>$objY2-15 && $y<$objY2+15))){
                      s_s($obj).cursor="se-resize";
                  }else if((($x>$objX2-15 && $x<$objX2+15) &&($y>$objY-15 && $y<$objY+15)) ||(($y>$objY2-15 && $y<$objY2+15) && ($x>$objX-15 && $x<$objX+15))){
                      s_s($obj).cursor="ne-resize";
                  }else if(($x>$objX && $x<$objX2 && $y>$objY-15 && $y<$objY+15) || ($x>$objX && $x<$objX2 && $y>$objY2-15 && $y<$objY2+15)){
                       s_s($obj).cursor="n-resize";
                  }else if(($x>$objX-15 && $x<$objX+15 && $y>$objY && $y<$objY2) ||($x>$objX2-15 && $x<$objX2+15 && $y>$objY && $y<$objY2 )){
                       s_s($obj).cursor="e-resize";
                  }else{
                      s_s($obj).cursor="default";
                  }
           document.onmousedown=new Function("$status=true");
           document.onmousemove=function(event){
			   if($status){
			        var $evt2=window.event || arguemnts[0],
			            $x2=$evt2.clientX,
			            $y2=$evt2.clientY,
			            $w=$obj.offsetWidth,
			            $h=$obj.offsetHeight;
			            s_width($obj,$x2-$x1+$w);
			            s_height($obj,$y2-$y1+$h);
			       }
           };
    
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*-----------------------------以下为修改系统方法/----------------------------*/


var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
    if (typeof fRef == 'function') {
        var argu = Array.prototype.slice.call(arguments,2);
        var f = (function(){ fRef.apply(null, argu); });
        return _st(f, mDelay);
    }
    return _st(fRef,mDelay);
};



//////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*-----------------------------以下自定义对象/----------------------------*/

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*XmlHttp对象*/
function Class_XmlHttp() {
	this.Pool=[];//存放xmlhttp对象
}
Class_XmlHttp.prototype.Obj=function(){
	if (window.ActiveXObject) {
		try {
			return new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e) {
            try {
			    return new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) {
				alert("XMLHTTP ERROR!");
            }
		}
	}else {
		return new XMLHttpRequest();
	}
};
Class_XmlHttp.prototype.Conn=function(){
      for (var i=0; i<this.Pool.length; i++) {
		  if (!this.Pool[i].readyState || this.Pool[i].readyState==4) {
			  return this.Pool[i];
		  }
      }
      this.Pool.push(this.Obj());
	  return this.Pool[this.Pool.length-1];
};
Class_XmlHttp.prototype.SendData=function($url,$data,$func,$update,$server) {
	var $ajax=this.Conn(),
	    $args=[];
	    if(arguments.length>5){
	       for(var $i=5;$i<arguments.length;$i++){
	           $args.push(arguments[$i]);
	       }
	    }
	    
		$url=$url.concat(".php?");
		if ($update) {
		   $data=$data.concat("&updates="+Math.random());	
		}
		$data+=$data.concat("&func="+$server);
        $ajax.open("POST",$url,true);
        $ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
        $ajax.send($data);
		$ajax.onreadystatechange=AjaxRequest;
        function AjaxRequest(){
             if($ajax.readyState==4){
                if($ajax.status==200){
                   $func($ajax.responseText,$args);
                }
             }
        }
};
//////////////////////////////////////////////////////////////////////////////
/*window对象*/
function Class_Window(){
this.Win=false;
this.Top=false;
this.Title=false;
this.Icon=false;
this.Min=false;
this.Max=false;
this.Close=false;
this.Content=false;

this.ArrWin=[];
this.ArrTop=[];
this.ArrTitle=[];
this.ArrIcon=[];
this.ArrMin=[];
this.ArrMax=[];
this.ArrClose=[];
this.ArrContent=[];



this.x=1;
this.y=1;
this.b=false;
this.w=400;
this.h=250;
this.zIndex="999";
}
Class_Window.prototype.Init=function($icon,$title,$content,$min,$max,$close,$x,$y,$zIndex){// 初始化窗口对象

   var $boolWin=false;
   for(var $i=0;$i<this.ArrWin.length;$i++){
       if(s_s(this.ArrWin[$i]).display=="none"){
        $boolWin=!$boolWin;
        break;
       }
   }


      if($boolWin){
           this.Win=this.ArrWin[$i];
		    this.Top=this.ArrTop[$i];
			  this.Title=this.ArrTitle[$i];
			    this.Icon=this.ArrIcon[$i];
			    this.Min=this.ArrMin[$i];
			  this.Max=this.ArrMax[$i];
			 this.Close=this.ArrClose[$i];
		    this.Content=this.ArrContent[$i];
      }else{
          this.Win=func_cEle("div");this.ArrWin.push(this.Win);
          
		    this.Top=func_cEle("div");this.ArrTop.push(this.Top);
		    
			  this.Title=func_cEle("div");this.ArrTitle.push(this.Title);
			  
			    this.Icon=func_cEle("div");this.ArrIcon.push(this.Icon);
			    
			    this.Min=func_cEle("div");this.ArrMin.push(this.Min);
			    
			  this.Max=func_cEle("div");this.ArrMax.push(this.Max);
			  
			 this.Close=func_cEle("div");this.ArrClose.push(this.Close);
			 
		    this.Content=func_cEle("div");this.ArrContent.push(this.Content);
			   
			this.Win.appendChild(this.Top);
			this.Win.appendChild(this.Content);
			     this.Top.appendChild(this.Icon);
			     this.Top.appendChild(this.Title);
			     this.Top.appendChild(this.Close);
			     this.Top.appendChild(this.Max);
			     this.Top.appendChild(this.Min);
			   
			   this.x=document.documentElement.offsetWidth/2-250;
			   this.y=document.documentElement.offsetHeight/2-200;
		      	 s_s(this.Win).top=this.y+"0px";
			     s_s(this.Win).left=this.x+"px";
                 s_s(this.Win).overflow="hidden";
			   
			   s_width(this.Win,this.w);
			   s_height(this.Win,this.h);
			   s_height(this.Top,30);
			   s_width(this.Icon,20);
			   s_height(this.Icon,25);
       		   s_width(this.Title,100);
			   s_height(this.Title,22);
			   
               s_width(this.Min,20);
			   s_height(this.Min,20);
			   s_width(this.Max,20);
			   s_height(this.Max,20);
			   s_width(this.Close,20);
			   s_height(this.Close,20);
			     
			 s_float(this.Title,"left");
			 s_float(this.Icon,"left");
			 s_float(this.Close,"right");
			 s_float(this.Max,"right");
			 s_float(this.Min,"right");
			 
			 s_s(this.Win).position="absolute"; 
			 s_s(this.Win).border="2px #ccc outset";
			 s_s(this.Win).background="#fff";
			 s_s(this.Win).zIndex="999";
				 s_s(this.Top).background="#5482ba";
				  this.Top.disable=true;
				  s_s(this.Top).borderBottom="1px #ccc solid";
				  s_s(this.Top).lineheight="30px";
					 s_s(this.Close).border=s_s(this.Min).border=s_s(this.Max).border="1px #fff solid";
				
				s_s(this.Title).color="#fff";
				s_s(this.Title).fontWeight="600";
				s_s(this.Title).fontSize="18px";
                s_s(this.Icon).background=s_s(this.Title).background=s_s(this.Close).background=s_s(this.Min).background=s_s(this.Max).background="#5482ba";
				s_s(this.Icon).lineHeight=s_s(this.Title).lineHeight=s_s(this.Close).lineHeight=s_s(this.Min).lineHeight=s_s(this.Max).lineHeight="22px";	 
				s_s(this.Icon).margin=s_s(this.Title).margin=s_s(this.Close).margin=s_s(this.Min).margin=s_s(this.Max).margin="4px 0 0 0";
                s_s(this.Icon).unselectable=s_s(this.Title).unselectable=s_s(this.Close).unselectable=s_s(this.Min).unselectable=s_s(this.Max).unselectable="on";      
					 
					 s_s(this.Icon).textAlign=s_s(this.Close).textAlign=s_s(this.Min).textAlign=s_s(this.Max).textAlign="center";
					 s_s(this.Min).margin=s_s(this.Max).margin="4px 3px 0 0";  
					 s_s(this.Close).marginRight="2px";   
			       s_s(this.Content).padding="2px";
 
                   s_s(this.Content).overflowY="scroll";
                   s_s(this.Content).height="100%";
			       s_s(this.Icon).cursor=s_s(this.Title).cursor=s_s(this.Close).cursor=s_s(this.Min).cursor=s_s(this.Max).cursor="default";
			 document.body.appendChild(this.Win);
			 var $evtDown=false;
			 document.onmousedown=function(event){$evtDown=window.event || arguments[0];};
var $Pobj=[this.Win,this.Top,this.Title,this.Icon,this.Min,this.Max,this.Close,this.x,this.y,this.b,this.w,this.h,this.zIndex];
			
             func_addEvent(this.Top,"mousedown",func_move,this.Win,$evtDown);
			 func_addEvent(this.Close,"mouseup",s_hide,this.Win);
			 
			 
			 
			 /*系统按钮样式*/
			 func_addEvent(this.Close,"mouseover",piv_move_transparent,this.Close);
             func_addEvent(this.Max,"mouseover",piv_move_transparent,this.Max);
             func_addEvent(this.Min,"mouseover",piv_move_transparent,this.Min);
               /*-------------------------------------------------------------*/

			 func_addEvent(this.Top,"dblclick",piv_max_min);//双击标题栏
			 func_addEvent(this.Max,"click",piv_max_min);//窗口还原
			 func_addEvent(this.Min,"click",piv_min);//窗口最小化

      }


		         this.Close.innerHTML=($close)?($close):("×");
			     this.Max.innerHTML=($max)?($max):("□");
			     this.Min.innerHTML=($min)?($min):("＿");
			     this.Icon.innerHTML=($icon)?($icon):("");
			     this.Title.innerHTML=($title)?($title):("标题");
			     this.Content.innerHTML=($content)?($content):("内容");
		         s_s(this.Win).zIndex=($zIndex)?($zIndex):(this.zIndex);
		     	  this.y=($y)?($y):(this.y);
			      this.x=($x)?($x):(this.x);
		          s_show(this.Win);
		          s_s(this.Win).top=this.y+"px";
			      s_s(this.Win).left=this.x+"px";
			      s_height(this.Win,this.h);
		          s_width(this.Win,this.w);
return $i;	
////////////////////////////////////////////////////
function piv_max_min(){
if(!$Pobj[9]){
		    s_height($Pobj[0],document.documentElement.clientHeight-10);
		    s_width($Pobj[0],document.documentElement.clientWidth-10);
		    s_s($Pobj[0]).left=s_s($Pobj[0]).top="2px";
		}else{
		    s_height($Pobj[0],$Pobj[11]);
		    s_width($Pobj[0],$Pobj[10]);
		}
		$Pobj[9]=!$Pobj[9];
}
function piv_move_transparent($r){
   $r.className="transpanter";
}


function piv_min(){
   s_s($Pobj[0]).top=(document.documentElement.clientHeight-30)+"px";
   s_width($Pobj[0],$Pobj[10]);
   s_height($Pobj[0],30);
   $Pobj[9]=false;
}
};
      




