/*
版本：1.2
最後修改日期：2006/12/21
ITS tool kit
List All Object
1.ToolBox                   :工具箱，像local.live.com            :80%
2.TackBar                   :拉條                                :80%
3.ListMapImageToStatus      :列出地圖圖片名                      :50%
4.MoveButton1               :像local.live.com 的移動地圖按鈕     :未制作
5.ToolTip1                  :像是title tag 的功能                :制作中
6.LinkMessage               :簡單的訊息狀態列                    :滿意
7.HttpLink                  :http通訊  註.XMLHttpRequest組裝成的 :滿意
8.Roll_api                  :一段式div向上收及向左收的api        :
9.Multi_Roll_api            :多段式div向上收及向左收的api    

*/
var DomIframe = document.createElement('iframe');
var DomDiv = document.createElement("div");
var DomImg = document.createElement("img");
var DomTable = document.createElement('table');
var DomTbody = document.createElement('tbody');
var DomTr = document.createElement('tr');
var DomTd = document.createElement('td');
var hl = new HttpLink();

//ToolBox 工具箱~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
//fo: father object       : object { object & not null }                   //                     //要被插入的物件
//sw: size wide           : string { int | null }                          // now not px or %     //物件外觀寬
//sl: size length         : string { int | null }                          // now not px or %     //物件外觀高
//pt: place top           : string { int | px | null }                     //                     //物件位置 上
//pb: place bottom        : string { int | px | null }                     //                     //物件位置 下
//pl: place left          : string { int | px | null }                     //                     //物件位置 左
//pr: place right         : string { int | px | null }                     //                     //物件位置 右
//pz: place z-index       : string { int | px | null }                     //                     //物件位置 z
//tw: title wide          : int    { int | null }                          //                     //標題列 高
//twd: title word         : string { string | null }                       //                     //標題 名稱
//mt: matter type         : string { string( 'Div' | 'Iframe' ) | null }   // in new              //matter 類型
//lk: link uri            : string { uri }                                 // in new              //internet link
//return:                 : not return                                                            //
*/
/*
this.GetMatterObject      : object { div }                                                        //取得要被插入物件
*/ 
function ToolBox(fo,sw,sl,pt,pb,pl,pr,pz,tw,twd,mt,lk)
{ 

	//private
	var tbo=DomDiv.cloneNode(true);
	tbo.style.cssText = 'background-color: #FFFFFF;border: 1px solid #C0C0C0; position: absolute; width:'+sw+'; height:'+sl+'; top:'+pt+';bottom:'+pb+';left:'+pl+';right:'+pr+';z-index:'+pz+';';

  var box = fo.appendChild( tbo );
  
  var tcb=DomImg.cloneNode(true);
  tcb.src = './images/ITS/x1.gif';
  tcb.width=12;
  tcb.height=12;
  tcb.align = "right";
  tcb = box.appendChild( tcb );
  tcb.onclick= function () 
  {
  	this.parentNode.style.display = 'none';
  };
  
  tcb=DomImg.cloneNode(true);
  tcb.src = './images/ITS/u1.gif';
  tcb.width=12;
  tcb.height=12;
  tcb.align = "right";
	tcb =box.appendChild( tcb );
	//上捲下捲
  tcb.onclick= function () 
  {
   Roll_api(this,1,tw,sl);
  };
  box.appendChild(document.createTextNode(twd));
    
	var tbo = NaN;
	switch ( mt )
	{
 		case 'Iframe':
 		   tbo = DomIframe.cloneNode(true);
			 tbo.src = lk;
			 tbo.width = sw;
			 tbo.height=sl-tw;
			 
 		break;
 		default:
 	     tbo=DomDiv.cloneNode(true);
	     tbo.style.cssText = 'background-color: #ffffff;border: 1px solid #C0C0C0; position: absolute; width:'+sw+'; height:'+(sl-tw)+'; top:'+tw+';left:0';
  
    break;
  }
  tcb = box.appendChild( tbo );
	
	//public
	this.GetMatterObject = box.lastChild;

}// end of ToolBox~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//TackBar 拉條~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
//fo: father object       : object { object & not null }
//MapBase: MapBase object : object { object & not null }
//sw: size wide           : string { int | null } // now not px or %
//sl: size length         : string { int | null } // now not px or %
//pt: place top           : string { int | px | null }
//pb: place bottom        : string { int | px | null }
//pl: place left          : string { int | px | null }
//pr: place right         : string { int | px | null }
//pz: place z-index       : string { int | px | null }
//return:                 : not return
*/
function TackBar( fo,MapBase, sw, sl, pt, pb, pl, pr, pz  )
{
	maxLevel = MapBase.getMapMaxLevel();
	box = DomDiv.cloneNode(true);
	box.style.cssText = 'border:1px solid #C0C0C0; position: absolute; background-color: #CAE4FF; width:'+sw+'; height:'+sl+'; top:'+pt+';bottom:'+pb+';left:'+pl+';right:'+pr+';z-index:'+pz+';';
	var tbox = fo.appendChild( box );
	img = DomImg.cloneNode(true);
	img.style.cssText = 'position: absolute; right: 0;';
	img.src = './images/ITS/add.gif';
  img = box.appendChild( img );
  img.onclick = function ()
  {
  	tmp = MapBase.getMapLevel()+1;
  	if (tmp <= maxLevel )
  	{
  		
  	MapBase.putMapLevel(tmp);
		MapBase.RefreshMap(true, true);
		}
  };
  img = DomImg.cloneNode(true);
  img.style.cssText = 'position: absolute; left: 0;';
	img.src = './images/ITS/dec.gif';
  img = box.appendChild( img );
 	img.onclick = function ()
  {
  	tmp = MapBase.getMapLevel()-1;
  	if (tmp >=1 )
  	{
  		//MapBase.putMapLevel2(tmp);
		//MapBase.RefreshMap(true, true);
  	MapBase.putMapLevel(tmp);
		MapBase.RefreshMap(true, true);
		}
  };

  box = DomDiv.cloneNode(true);
  
  box.style.cssText = 'cursor: hand;border:2px ridge #c0c0c0; position:absolute; background-color: #CAE4FF; width:15; height:'+sl+';top:-1;left:'+(sl)+';';
 
	box.style.overflow = 'hidden';

  bar = tbox.appendChild( box );
  
  tbox.onmousedown = function(evn )
  {
  	tmpx = CatchEvent(evn).screenX;
  	this.onmousemove = function(evn)
  	{
  		
  		mpl =(parseInt(bar.style.left)+(CatchEvent(evn).screenX)-tmpx);
  		tmpx = CatchEvent(evn).screenX;
  		//window.status =  mpl+'/'+CatchEvent(evn).screenX+'/'+tmpx+'/'+parseInt(this.style.left);
  		if (mpl >=(sl) && mpl<=(sw-(sl)-parseInt(bar.style.width)))
  		{
  		  bar.style.left = mpl;
  		//  S = ( (mpl-sl)* maxLevel / ((sw-2*sl)) );
  		 S = ( (mpl-(sl))* maxLevel / ((sw-2*(sl)-parseInt(bar.style.width))) );
  		window.status = S +'/'+ mpl+'/'+sl +'/'+(parseInt(bar.style.width));
				MapBase.putMapLevel2(S);
				MapBase.RefreshMap(false, true);
  		}
  	//	window.status = CatchOffsetX(evn)+'/'+mpl;
  	};
  	this.onmouseup = function (evn)
	  {
			MapBase.putMapLevel(S);
			MapBase.RefreshMap(true, true);
	  	this.onmousemove = null;
	  	this.onmouseout = null;	  	
	  	this.onmouseup = null;
	  };
	  
	//  this.onmouseout = function (evn)
  //	{
	//		MapBase.putMapLevel(S);
	//		MapBase.RefreshMap(true, true);
  //		this.onmousemove = null;
  //		this.onmouseup = null;
	//  	this.onmouseout = null;
	//  };
	  
  }; //end of bar.onmousedown
  
  this.RebuildElement = function()
	{
	};
	
	this.UpdateElement = function(imgRatio)
	{
		this.LevelMapTo(MapBase.getMapLevel());
	};
	
	this.LevelMapTo = function(mapLevel)
	{
		
		if (mapLevel > maxLevel) mapLevel = maxLevel;
		if (mapLevel != 1)            
		{
			bar.style.left = mapLevel * (sw-2*(sl)-parseInt(bar.style.width))/ maxLevel +(sl) ;
			//window.status = bar.style.left+"/"+mapLevel;
		}
		bar.clientHeight;
	};
}//end of TackBar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//ListMapImageToStatus 列出地圖圖片名~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//MapBase: MapBase object : object { object & not null }
function ListMapImageToStatus(MapBase)
{

	this.RebuildElement = function()
	{
	};
	
	this.UpdateElement = function()
	{
		this.LevelMapTo(MapBase.getMapLevel());
	};
	
	this.LevelMapTo = function()
	{	
	//	window.status = 'pis:'+MapBase.getHObject().firstChild.childNodes.length;
	};
	
}//end of ListMapImageToStatus

//MoveButton1 像local.live.com 的移動地圖按鈕
//MapBase: MapBase object : object { object & not null }
function MoveButton1( fo,MapBase, sw, sl, pt, pb, pl, pr, pz )
{
	box = DomDiv.cloneNode(true);
	box.style.cssText = 'border:1px solid #C0C0C0; position: absolute; background-color: #CAE4FF; width:'+sw+'; height:'+sl+'; top:'+pt+';bottom:'+pb+';left:'+pl+';right:'+pr+';z-index:'+pz+';';
	var tbox = fo.appendChild( box );
	DomImg.cssText = 'position: absolute; width: 16; height: 16;';
	LeftUpImg = tbox.appendChild( DomImg.cloneNode(true) );
	LeftUpImg.style.left = 0; 
	LeftUpImg.style.top = 0;
	LeftUpImg.src = 'images/ITS/add.gif';

	
	
	
	
}//end of MoveButton1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//ToolTip1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function ToolTip1 (fo,sw,sl,pt, pb, pl, pr,pz,str,mt)
{
	//private
	box = DomDiv.cloneNode(true);
	box.style.cssText = 'border:1px solid #C0C0C0; position: absolute; background-color: #CAE4FF; width:'+sw+'; height:'+sl+'; top:'+pt+';bottom:'+pb+';left:'+pl+';right:'+pr+';z-index:'+pz+';';
  tbox = fo.appendChild( box );
  switch(mt) 
  {
  	case 1:
			box = DomIframe.cloneNode(true);
			box.src = "SearchTraffic.htm";
			box.width = sw;
			box.height=sl;
			break;
		default :
		box = DomDiv.cloneNode(true)
		break;
	}
	gg=tbox.appendChild(box);
	//gg.width = 100;

	//public
	this.SetXY = function(ix,iy)
	{
		tbox.style.top = iy ; 
		tbox.style.left = ix ;
	//	ss();
	};	
	
	//return tbox;
}//end of ToolTip1~~~~~~~~~~~~~~~~~~~~~~~~~~~

//LinkMessage 訊息狀態列~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
//fo: father object       : object { object & not null }                   //                     //要被插入的物件
//sw: size wide           : string { int | null }                          // now not px or %     //物件外觀寬
//sl: size length         : string { int | null }                          // now not px or %     //物件外觀高
//pt: place top           : string { int | px | null }                     //                     //物件位置 上
//pb: place bottom        : string { int | px | null }                     //                     //物件位置 下
//pl: place left          : string { int | px | null }                     //                     //物件位置 左
//pr: place right         : string { int | px | null }                     //                     //物件位置 右
//pz: place z-index       : string { int | px | null }                     //                     //物件位置 z
//mt: message string      : string { string( string | null ) | null }      // in new              //訊息文字

//return:                 : not return
*/
function LinkMessage(fo,sw,sl,pt,pb,pl,pr,pz,mt)
{
  var f,ff,t;
  this.Text=function(s)
  {
    t.nodeValue = s;
  }
  this.Close=function()//刪除元件
  {
    f.parentNode.removeChild(f);
  }
  this.IsHide=function()//判斷是否隱形
  {
    return f.style.display=='none'? true:false;
  }
  this.Show = function(s)//設定顯示狀態
  {
   f.style.display= ( s==true ? '': 'none');
  }
  var tbo=DomDiv.cloneNode(true);
  tbo.style.cssText = 'background-color: #FF0000;border: 1px solid #C0C0C0; position: absolute; width:'+sw+'; height:'+sl+'; top:'+pt+';bottom:'+pb+';left:'+pl+';right:'+pr+';z-index:'+pz+';';
  f=fo.appendChild( tbo );
  ff=f.appendChild(document.createElement('font'));
  f.style.color='#FFFFFF';
  t=f.appendChild(document.createTextNode(mt));
}//end of LinkMessage~~~~~~~~~~~

//LinkMessage2 訊息狀態列~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
//tp: type                : int    { 1|2 }                                 //                     //1為loading圖，2為表格
//strHtml: table          : string { string }                              // now not px or %     //表格

//return:                 : not return
*/
function LinkMessage2(){

	this.setOpacity = function(obj,opacity){
		if(opacity>=1)opacity=opacity/100;
		try{ obj.style.opacity=opacity; }catch(e){}
		try{ 
			if(obj.filters.length>0&&obj.filters("alpha")){
				obj.filters("alpha").opacity=opacity*100;
			}else{
				obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
			}
		}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
		
	//	if (++c > 20){clearInterval(ad);return 0;}
		this.setOpacity(shield,25);
	}
	var alertFram;
	var shield;
 this.ad =function(tp,strHtml){
	shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-225px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "450px";
	alertFram.style.height = "150px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "center";
	//alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";
  
  if (tp==1)
	strHtml  = '<div>	<img border="0" src="./images/ITS/loadingAnimation.gif" width="100" height="100" id="do_OK"></div>\n';
	
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
 	 this.doAlpha();
 	// document.getElementById("do_OK").focus();
	
	document.body.onselectstart = function(){return false;}
	//document.body.oncontextmenu = function(){return false;}
 	 }
	this.doOk = function(){
		alertFram.style.display = "none";
		shield.style.display = "none";
		 
		document.body.removeChild(alertFram);
		document.body.removeChild(shield);
		document.body.onselectstart = function(){return true;}
	//	document.body.oncontextmenu = function(){return true;}
	}
}//end of LinkMessage~~~~~~~~~~~

//HttpLink http通訊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
this.makeReques()
//uri:http link                     : URI { http + (GET | POST) }           //                     //網址可帶參數
//sr:HttpLink object                : Object { Object(HttpLink ) }          //                     //通訊物件本身
//mh:message send mode              : String { string('get'|'post') }       //                     //參數傳遞的方式 get or post
//mf:message object upper levels    : Object { object( div|body)}           //                     //訊息要插的那個物件
//ld:loading cue                    : bool { true|false }                   //                     //是否要loading
*/

function HttpLink()
{
  this.HpptRequest = null;
  this.makeReques = _makeRequest;
  this.HpptRequest = HttpObj;
  this.SetLinkFinish = SetLinkFinish;
  this.SetLinkLoss = SetLinkLoss;
  function SetLinkFinish(sr)
  {
  //eval(sr.HpptRequest.responseText);
  
  }
  function SetLinkLoss(sr)
  {
    alert('發生錯誤，請通知系統維護人員');
  }
  function HttpObj()
  {
    if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
	  return ( new XMLHttpRequest() );
	} 
	else if (window.ActiveXObject)
	{ // IE
	  try 
	  {
	    return ( new ActiveXObject("Msxml2.XMLHTTP") );
	  }catch (e)
	  {
	  	try 
	  	{
	  	  return ( new ActiveXObject("Microsoft.XMLHTTP"));
	  	}catch (e)
	  	{
	  	}
	  }
	}
  }//end of function HttpObj()~~~

function _makeRequest(uri,sr,mh,mf,ld)
{
	this.HpptRequest = HttpObj();
//  var ff= new LinkMessage(mf,null,20,5,null,null,5,null,'建立');	
  if( ld != false)
  {
    var ff =new LinkMessage2();
    ff.ad(1,null);
  }
  if (!this.HpptRequest)
  {
	alert('Giving up :( Cannot create an XMLHTTP instance');
	return false;
  }
  this.HpptRequest.onreadystatechange =function ()
  {	
	switch( sr.HpptRequest.readyState )
	{
	  case 0:
	  break;
	  case 1:
	  //ff.Text('讀取中');
	 
	  break;
      case 2:
      //ff.Text('已讀取');
	  break;
      case 3:
      //ff.Text('資訊交換中');
	  break;
	  case 4:
	 // ff.Text('完成');
	 if( ld != false)
   {
	   ff.doOk();
	 }
	    switch ( sr.HpptRequest.status )
	    {
	      case 200:
	        sr.SetLinkFinish(sr);
		  break;
		  default:
		    sr.SetLinkLoss(sr);
		  break;
	    }
	  break;
	}
  }
  this.HpptRequest.open(mh, uri, true);
  this.HpptRequest.send(null);
}//end of _makeRequest
//ajax()
  if (this.HpptRequest.overrideMimeType)
  {
    this.HpptRequest.overrideMimeType('text/xml');
  }
}// end of HttpLink~~~~~~~~~~~~~









/*
ITS API kit
*/

//開合div   : 下開上合
//objin:   the ruled            : object { object & no null }
//smin:    size minimum         : int    { int & no null }
//smax:    size maximum         : int    { int & no null }
function Roll_api(objin,type,smin,smax)
{
	var obj = objin.parentNode;
	while( obj.tagName !='DIV')
	{
		obj=obj.parentNode;
	}
	obj.style.overflow = 'hidden';
this._up = function()
									{
										if(parseInt(obj.style.height) > smin)
										{		
										obj.style.height = parseInt(obj.style.height) -10;	
										setTimeout( 'this._up()',1);
										}									
									};
this._down = function()
									{	
										if(parseInt(obj.style.height) <smax)
										{
										obj.style.height = parseInt(obj.style.height) +10;
										setTimeout('this._down()',1);
										}
									};
this._toLeft = function()
									{
										if(parseInt(obj.style.width) > smin)
										{		
										obj.style.width = parseInt(obj.style.width) -10;	
										setTimeout( 'this._toLeft()',1);
										}									
									};
this._toRight = function()
									{	
										if(parseInt(obj.style.width) <smax)
										{
										obj.style.width = parseInt(obj.style.width) +10;
										setTimeout('this._toRight()',1);
										}
									};


	switch(type)
	{
	    case 1:
		if (parseInt(obj.style.height) >smin)
		{
			this._up();
			objin.src = './images/ITS/d1.gif'
		}
		else 
		{
			this._down();
			objin.src = './images/ITS/u1.gif'
		}
		break;
		case 2:
		
		if (parseInt(obj.style.width) >smin)
		{
			this._toLeft();
			objin.src = './images/ITS/r1.gif'
		}
		else 
		{
			this._toRight();
			objin.src = './images/ITS/l1.gif'
		}
		break;
	}
}

//多段開合div   : 下開上合  右開左合
//objin:   the ruled            : object { object & no null }
//type:   direction        : int    { int & no null }
//sa:    array        : int    { int & no null }

function Multi_Roll_api(objin,type,sa)
{
	var obj = objin.parentNode;
	while( obj.tagName !='DIV')
	{
		obj=obj.parentNode;
	}	var min,max,i,n;
	obj.style.overflow = 'hidden';
  this._toUp = function()
  {
    if(parseInt(obj.clientHeight) <=min)
    {
      this._Close();
    }
    else
    {
      obj.style.height = parseInt(obj.clientHeight) -10;	
      setTimeout( 'this._toUp()',1);
    }    
  };
  this._toDown = function()
	{	
	  if(parseInt(obj.clientHeight) >=max)
		{
		  this._Close();
		}
		else
		{
		  obj.style.height = parseInt(obj.clientHeight) +10;	
		  setTimeout( 'this._toDown()',1);
		}
	};
  this._toLeft = function()
	{ 
		if(parseInt(obj.clientWidth) <=min)
		{
		  this._Close();
		}
		else
		{
		  obj.style.width = parseInt(obj.clientWidth) -10;	
		  setTimeout( 'this._toLeft()',1);
		}	
	};
  this._toRight = function()
	{	
		if(parseInt(obj.clientWidth) >=max)
		{
		  this._Close();
		}
		else
		{
		  obj.style.width = parseInt(obj.clientWidth) +10;
		  setTimeout('this._toRight()',1);
		}
	};
  this._Close = function()
  {
    obj =null;
    min=null;
    max=null;
    i=null;
  };
  function fn(n)
  {
		for ( i = sa.length-2 ; i> -1 ; i-- )
    {
      if ( n> sa[i] )
      {
       min=sa[i];max=sa[i+1];
       break;
      }
    }
  };
  function fn2(n)
  {
    for ( i = 1 ; i<sa.length ; i++ )
    {
      if ( n< sa[i] )
      {    
       min=sa[i-1];max=sa[i];
       break;
      }
    }
  }; 
	switch(type)
	{
	  case 1:
	  n=parseInt(obj.clientHeight );
	  if ( sa[0] == n )
	  {
	   // objin.style.display = 'none';
	    break;
	  }
    fn(n);
    this._toUp();
		//obj.childNodes[1].src = './images/ITS/d1.gif'
      break;
    case 2:
    n=parseInt(obj.clientHeight );
    if ( sa[sa.length-1] == n )
    {
	  //  objin.style.display = 'none';
	    break;
	  }
    fn2(n);      
		this._toDown();
		//obj.childNodes[1].src = './images/ITS/u1.gif'	
		break;
		case 3:
		n=parseInt(obj.clientWidth );
		if ( sa[sa.length-1] <= n )
		{
	   // objin.style.display = 'none';
	    break;
	  }
 	  fn2(n);
		this._toRight();
			//obj.childNodes[1].src = './images/ITS/d1.gif'
		break;
		case 4:
		n=parseInt(obj.clientWidth );
		
		if ( sa[0] >= n )
		{
	  //  objin.style.display = 'none';
	    break;
	  }
    fn(n);
		this._toLeft();
			//obj.childNodes[1].src = './images/ITS/u1.gif'
		break;
		case 5:                //Auto Height Size
		
		  break;
		case 6:                //Auto Width Size
		n=parseInt(obj.clientWidth );
		//alert( sa +"\\"+ n);
		if( Math.abs(sa-n)>=10)
		{
		if ( sa > n )
		{
			min = n;
	    max = sa;
	    this._toRight();    
	  }
	  else
	  {
	  	if ( sa < n)
	  	{
	  		min = sa;
	      max = n;
	  		this._toLeft();
	  	}
	  }
	  
	}
		
		  break;
	}
}


//catch event object
//evn :  event object      : object { object |null }
function CatchEvent(evn)
{
return  evn ==null ? event : evn;
}

function CatchOffsetX(evn)
{
	return evn ==null ? event.offsetX : evn.layerX;
}



/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 * Script featured on Dynamic Drive (http://www.dynamicdrive.com) 12.08.2005
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {
	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;
   
		o.root = oRoot && oRoot != null ? oRoot : o ;
		
		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";  
//	o.root.style.left   = "0px"; 

//	 o.root.style.bottom = "0px";

//alert(o.root.style.left+'/'+o.root.style.top+'/'+o.root.style.right+'/'+o.root.style.bottom);
		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;
		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;
		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper){nx = o.xMapper(y);}
		else if (o.yMapper){	ny = o.yMapper(x);}
		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if ( e  ==null)
		{ e = window.event;
		 e.layerX = e.offsetX;
		 e.layerY = e.offsetY;
	}
		return e;
	}};