﻿/*
  BlueWinEffects等是精灵部落的原创代码，在作者未正式决定将其开源发布之前，任何组织和个人不得以任何方式获得
和传播此代码，
  不得以任何方式修改和使用此代码，否则，精灵部落将追究责任。 
   
  严正声明现在精灵部落正处在测试期间，所有代码均可能存在不稳定因素，所有代码除特别声明开源的，一律暂
不开源，一
  律严格保留所有权以及其他一切合法权益。谢谢！
  作者：廖彩彪 2007年12月 联系我：email  ——ublue2006@163.com——
*/
var BlueWinEffects={
resizeWin:function(options)
{
  var Win=options.Win?options.Win:null;
  var EndWidth=options.EndWidth?options.EndWidth:null;
  var EndHeight=options.EndHeight?options.EndHeight:null;
  var StartWidth=options.StartWidth?options.StartWidth:Win.win.offsetWidth;
  var StartHeight=options.StartHeight?options.StartHeight:Win.win.offsetHeight;
  var HasEffect=(options.HasEffect||options.HasEffect==false)?options.HasEffect:null;
  var Store=(options.Store||options.Store==false)?options.Store:true;
  var EndX=(options.EndX||options.EndX==0)?options.EndX:null;
  var EndY=(options.EndY||options.EndY==0)?options.EndY:null; 
 
  if(Win!=null)
  {
        //var WinContent=document.getElementById(Win.id+"_table_content");
        var Content=document.getElementById(Win.id+"_content");
        if(EndWidth!=null&&EndHeight!=null){
             if(HasEffect==true){
             
				 function ReSizeStop(){	
				  try{				 
				  var _statuscontent=document.getElementById(Win.id+"_statuscontent");
				  var _statuscontenttd=document.getElementById(Win.id+"_statuscontenttd");
				  var _title=document.getElementById(Win.id+"_title");
				  var _titletd=document.getElementById(Win.id+"_titletd");
				  	_statuscontent.style.height="50px";
				  	_statuscontent.style.width=(EndWidth-Win.storage.subWidth-80)+"px";
				  	_title.style.width=(EndWidth-Win.storage.subWidth-120)+"px";
				  	_statuscontent.style.display="block";				  	
				  	_title.innerHTML=Win.options.title;}catch(err){}
				 // alert("stop");				 
				 			 
                  if(Win.options.url!=null){
				  var ChildWin=document.frames(Win.id+"_content");				
				  try{ChildWin.ReSizeStop()}catch(err){};}
				 	 
				  }
				  
				  function ReSizeStart(){                  
				  try{
				 // alert("start");
				  var _statuscontent=document.getElementById(Win.id+"_statuscontent");
				  var _statuscontenttd=document.getElementById(Win.id+"_statuscontenttd");
				  var _title=document.getElementById(Win.id+"_title");
				  var _titletd=document.getElementById(Win.id+"_titletd");
				  	_statuscontent.style.display="none";				  	
				  	_title.innerHTML="&nbsp;";
				  	_title.style.width="50px";
				  	}catch(err){}				  		 
				  }
				  
				  
                  if(EndWidth>=Win.options.minwidth&&EndHeight>=Win.options.minheight){
                      BlueEffects.SizeShow({Obj:Win.win,StartWidth:StartWidth,StartHeight:StartHeight,EndWidth:EndWidth,EndHeight:EndHeight,ChangeTime:10,ChangeTimes:5,Start:ReSizeStart,Stop:ReSizeStop});      
                      BlueEffects.SizeShow({Obj:Content,StartWidth:StartWidth-Win.storage.subWidth,StartHeight:StartHeight-Win.storage.subHeight,EndHeight:EndHeight-Win.storage.subHeight,EndWidth:EndWidth-Win.storage.subWidth,ChangeTime:10,ChangeTimes:5});
                  }
                  
                  if(Store==true&&EndWidth>=Win.options.minwidth&&EndHeight>Win.options.minheight){      
                      Win.storage.width=EndWidth;
                      Win.storage.height=EndHeight;
                  }
                  
             }
             else{ 
             
                 if(EndHeight>=Win.options.minheight){
                 try{
                     Win.win.style.height=EndHeight+"px";
                     Content.style.height=EndHeight-Win.storage.subHeight+"px";}catch(err){}                     
                 }
                 
                 if(EndWidth>=Win.options.minwidth){ 
                   try{				
				  var _statuscontent=document.getElementById(Win.id+"_statuscontent");
				  var _statuscontenttd=document.getElementById(Win.id+"_statuscontenttd");
				  var _title=document.getElementById(Win.id+"_title");
				  var _titletd=document.getElementById(Win.id+"_titletd");
				  	_statuscontent.style.display="none";				  	
				  	_title.innerHTML="&nbsp;";
				  	_title.style.width="50px";
				  	}catch(err){}	
                  
                  try{ 
                  
                     Win.win.style.width=EndWidth+"px";
                     Content.style.width=EndWidth-Win.storage.subWidth+"px"; }catch(err){} 
                     
                      try{				 
				  var _statuscontent=document.getElementById(Win.id+"_statuscontent");
				  var _statuscontenttd=document.getElementById(Win.id+"_statuscontenttd");
				  var _title=document.getElementById(Win.id+"_title");
				  var _titletd=document.getElementById(Win.id+"_titletd");
				  	_statuscontent.style.height="50px";
				  	_statuscontent.style.width=(EndWidth-Win.storage.subWidth-80)+"px";
				  	_title.style.width=(EndWidth-Win.storage.subWidth-120)+"px";
				  	_statuscontent.style.display="block";				  	
				  	_title.innerHTML=Win.options.title;}catch(err){}                       
                 }  
                        
                 if(Store==true){
                     if(EndWidth>=Win.options.minwidth)  
                     Win.storage.width=EndWidth;
                     if(EndHeight>Win.options.minheight)
                     Win.storage.height=EndHeight;
                 }
                 
                 
             }
        }
        if(EndX!=null&&EndY!=null){
             if(HasEffect==true){
                      BlueEffects.Move({Obj:Win.win,EndX:EndX,EndY:EndY,ChangeTime:10,ChangeTimes:5});
                       
                  if(Store==true){
                      Win.storage.x=EndX;
                      Win.storage.y=EndY;     
                  } 
             }
             else{
                     Win.win.style.left=EndX+"px";
                     Win.win.style.top=EndY+"px";
                  if(Store==true){
                      Win.storage.x=EndX;
                      Win.storage.y=EndY;     
                  }    
             }
        }     
  }
},

InitReSize:function(options)
{
    if(options.ReSizeBar!=null&&options.Win!=null) //假如移动对象不为空
  {
    var Win=options.Win;
   
    var ReSizeBar=options.ReSizeBar;
    var ReSizeObj=Win.win;
       
    var ReSizeState="ReSizeWait";
    var X;
    var Y;
    var StartX;
    var StartY; 
    
    ReSizeObj.style.position="absolute";    
      
   function Mousedown(event)
   {     
    // alert("mousedown");
	 
	 ReSizeState="ReSizeStarted";
	 ReSizeBar.style.cursor="nw-resize";
		 
     X=ReSizeObj.offsetWidth;
     Y=ReSizeObj.offsetHeight;
     
     StartX=event.clientX;
     StartY=event.clientY;     
   
    BlueEffects.addEvent(document,"mousemove",Mousemove);  
    BlueEffects.addEvent(document,"mouseup",Mouseup); 
    BlueEffects.ShowDragCover();
     
     if(options.Start!=null){
       try{options.Start();}catch(err){}
     } 	
   } 
   
   function Mousemove(event)
   {       
       if(ReSizeState=="ReSizeStarted")
	   {
	   var tempX=event.clientX-StartX;	   
	   var tempY=event.clientY-StartY;	  
	   
	   BlueWinEffects.resizeWin({Win:Win,HasEffect:false,EndWidth:X+tempX,EndHeight:Y+tempY});
       
       if(options.Move!=null){
       try{options.Move();}catch(err){}}
	   }
	  
   }
   
   function Mouseup(event)
   {     
      ReSizeState="ReSizeEnded";
       
      BlueEffects.removeEvent(document,"mousemove",Mousemove);  
      BlueEffects.removeEvent(document,"mouseup",Mouseup); 
      BlueEffects.HideDragCover();
             
       if(options.Stop!=null){
       try{ options.Stop(); }catch(err){}
       }   
   }
    	
    BlueEffects.addEvent(ReSizeBar,"mousedown",Mousedown);
    
  }  
},

show:function(options)
{
  var Win=options.Win?options.Win:null;
  var HasEffect=options.HasEffect?options.HasEffect:null;
  
  if(Win!=null)
  {
  if(HasEffect==true)
   {    
   
      function hidefilter()
      {
        if(document.all){
        var id=Win.id;
        
        
        var StatusArea=document.getElementById(id+"_StatusArea");
        StatusArea.style.display="none";
         
        
        if(Win.options.closable==true)
        {
          var closebtn=document.getElementById(id+"_close");
           closebtn.style.display="none"; 
        }
         if(Win.options.minsizeable==true)
        {
          var minsizbtn=document.getElementById(id+"_minimize");
           minsizbtn.style.display="none"; 
        }
         if(Win.options.maxsizeable==true)
        {
          var maxsizebtn=document.getElementById(id+"_maximize");
           maxsizebtn.style.display="none"; 
        }
        }
      }
      
      function showfilter()
      {
         if(document.all){
        var id=Win.id;
        
        var StatusArea=document.getElementById(id+"_StatusArea");
        StatusArea.style.display="block"; 
        
        if(Win.options.closable==true)
        {
          var closebtn=document.getElementById(id+"_close");
           closebtn.style.display="block"; 
        }
         if(Win.options.minsizeable==true)
        {
          var minsizbtn=document.getElementById(id+"_minimize");
           minsizbtn.style.display="block"; 
        }
         if(Win.options.maxsizeable==true)
        {
          var maxsizebtn=document.getElementById(id+"_maximize");
           maxsizebtn.style.display="block"; 
        }
        }
      }
   
    BlueEffects.AlphaShow({Obj:Win.win,StartAlpha:0,EndAlpha:100,ChangeTime:500,ChangeTimes:10,Start:function(){hidefilter();},Stop:function(){
    Win.win.style.filter = null ;  
    Win.win.style.MozOpacity=null; 
    showfilter();
    
    }});
    Win.win.style.display="block";
    if(Win.storage.drager.canDrag==true)  
    Win.storage.state="onshow";
    else
    Win.storage.state="onmaxsize";    
    }
    else
    {
    Win.win.style.display="block";
    if(Win.storage.drager.canDrag==true)  
    Win.storage.state="onshow";
    else
    Win.storage.state="onmaxsize";  
    }
  }
},

hide:function(options)
{ 
  var Win=options.Win?options.Win:null;
  var HasEffect=options.HasEffect?options.HasEffect:null;
  //alert(Win);
  if(Win!=null)
  {  
  if(HasEffect==true)
   {  
    
     function hidefilter()
      {
         if(document.all){
        var id=Win.id;
        var StatusArea=document.getElementById(id+"_StatusArea");
        StatusArea.style.display="none"; 
        
        if(Win.options.closable==true)
        {
          var closebtn=document.getElementById(id+"_close");
           closebtn.style.display="none"; 
        }
         if(Win.options.minsizeable==true)
        {
          var minsizbtn=document.getElementById(id+"_minimize");
           minsizbtn.style.display="none"; 
        }
         if(Win.options.maxsizeable==true)
        {
          var maxsizebtn=document.getElementById(id+"_maximize");
           maxsizebtn.style.display="none"; 
        }}
      }
     
    BlueEffects.AlphaShow({Obj:Win.win,StartAlpha:100,EndAlpha:0,ChangeTime:500,ChangeTimes:10,Start:function(){hidefilter();},Stop:function(){Win.win.style.display="none";}});  
    Win.storage.state="onhide";
   }
    else
    {
    Win.win.style.display="none";
    Win.storage.state="onhide";
    }
  }
},

close:function(options)
{ 
  var Win=options.Win?options.Win:null;
  var HasEffect=options.HasEffect?options.HasEffect:null;
  //alert(Win);
  if(Win!=null)
  {  
   if(HasEffect==true)
   {
      function hidefilter()
      {
        if(document.all){
        var id=Win.id;
        var StatusArea=document.getElementById(id+"_StatusArea");
        StatusArea.style.display="none"; 
        
        if(Win.options.closable==true)
        {
          var closebtn=document.getElementById(id+"_close");
           closebtn.style.display="none"; 
        }
         if(Win.options.minsizeable==true)
        {
          var minsizbtn=document.getElementById(id+"_minimize");
           minsizbtn.style.display="none"; 
        }
         if(Win.options.maxsizeable==true)
        {
          var maxsizebtn=document.getElementById(id+"_maximize");
           maxsizebtn.style.display="none"; 
        }}
      }  
    BlueEffects.AlphaShow({Obj:Win.win,StartAlpha:100,EndAlpha:0,ChangeTime:500,ChangeTimes:10,Start:function(){hidefilter();},Stop:function(){BlueWindows.removewin(Win.id);BlueTaskBar.RemoveIcon(Win.taskiconid);}});    
   }
   else
   {
   Win.win.style.display="none";
   BlueWindows.removewin(Win.id);
   BlueTaskBar.RemoveIcon(Win.taskiconid);   
   }
  }
}

}


