



//-------------------------------------------------------------------------------------
//OBJECT REFERENCE
//version :2.0
//author  :duncan ion
//company :interactive1.com
//date    :06/02/01
//required:Browser Object


//OBJECT REFERENCE FUNCTION used to access 
//all div/layer elemnts correctly
//------------------------------------------------
function i1_ObjectReference(obj,nest){ 
  nest=(!nest) ? "":'document.'+nest+'.'
  this.ref       = is.dom?document.getElementById(obj):is.ie4?document.all[obj]:is.ns4?eval(nest+"document.layers." +obj):0;
  this.css       = (is.dom||is.ie4)?this.ref.style:this.ref;
  this.xPos      = parseInt(this.css.left)||this.css.pixelLeft||this.ref.offsetLeft||0;
  this.yPos      = parseInt(this.css.top)||this.css.pixelTop||this.ref.offsetTop||0
  this.width     = this.ref.offsetWidth||this.css.clip.width||this.ref.width||this.css.pixelWidth||0; 
  this.height    = this.ref.offsetHeight||this.css.clip.height||this.ref.height||this.css.pixelHeight||0;
  
  this.clip      = 0 //Clip values
  if((is.dom || is.ie4) && this.css.clip) {
	this.clip    = this.css.clip; 
	this.clip    = this.clip.slice(5,this.clip.length-1); 
	this.clip    = this.clip.split(' ');
	for(var i=0;i<4;i++){
	this.clip[i] =parseInt(this.clip[i])
	}
  }
  this.clipTop   = this.css.clip.top||this.clip[0]||0; 
  this.clipRight = this.css.clip.right||this.clip[1]||this.width||0
  this.clipBottom= this.css.clip.bottom||this.clip[2]||this.height||0; 
  this.clipLeft  = this.css.clip.left||this.clip[3]||0
  this.obj       = obj + "Object"; 
  eval(this.obj + "=this");
  return this
}




//PROTOTYPED METHOD CALLS TO ACCESS THE 
//ELEMENTS PROPERTIES AND METHODS GENERICALLY
//------------------------------------------------
//------------------------------------------------
//REFERENCE STYLE
//---------------

//set visibility of element
i1_ObjectReference.prototype.hide = function(){
	this.css.visibility = "hidden"; 
	this.IsVisible = 0;
}
i1_ObjectReference.prototype.show = function(){
	this.css.visibility = "visible"; 
	this.IsVisible = 1;
}


//getVisibility & setVisibility SHOULD NOT BE USED. USE hide() and show INSTEAD
i1_ObjectReference.prototype.setVisibility = function(val){this.css.visibility = val;}
i1_ObjectReference.prototype.getVisibility = function(){return this.css.visibility;}

//set x position
i1_ObjectReference.prototype.setXPos = function(val){
	this.xPos     = val;
	this.css.left = val;
}
//set y position
i1_ObjectReference.prototype.setYPos = function(val){
	this.yPos    = val;
	this.css.top = val;
}
//move to defined x, y position
i1_ObjectReference.prototype.moveTo = function(x,y){
  this.xPos    =x;
  this.yPos    =y; 
  alert(this.ref);
  this.css.left=x;
  this.css.top =y;
  	
}
//move by amount defined in x,y
i1_ObjectReference.prototype.moveBy = function(x,y){
  this.xPos    +=x;
  this.css.left = this.xPos;
  this.yPos    +=y;
  this.css.top  = this.yPos;
}

//set background color
i1_ObjectReference.prototype.setBackgroundColor = function(val){
	if(is.dom||is.ie4){this.css.backgroundColor = val;
	}else if (is.op5) {this.css.background      = val;
	}else if(is.ns4)  {this.css.bgColor         = val;}
}

//set clip
i1_ObjectReference.prototype.clipTo = function(top,right,bottom,left,setwidth){ 
  this.clipTop    = top; 
  this.clipRight  = right; 
  this.clipBottom = bottom; 
  this.clipLeft   = left;
  if(is.ns4){
    this.css.clip.top     = top;
    this.css.clip.right   = right;
    this.css.clip.bottom  = bottom;
    this.css.clip.left    = left;
  }else{
    if(top<0)   {top    =0;}
    if(right<0) {right  =0;}
    if(bottom<0){bottom =0;}
    if(left<0)  {left   =0;}
    this.css.clip="rect("+top+","+right+","+bottom+","+left+")";
    if(setwidth){
    	this.css.pixelWidth  = this.css.width  = right;
    	this.css.pixelHeight = this.css.height = bottom;
    }
  }
}

//set clip by
i1_ObjectReference.prototype.clipBy = function(top,right,bottom,left,setwidth){ 
  this.clipTo((this.clipTop+top),
  			  (this.clipRight+right),
  			  (this.clipBottom+bottom),
  			  (this.clipLeft+left),
  			  setwidth
  			 )
}

//animate clip 
i1_ObjectReference.prototype.clipIt = function(top,right,bottom,left,step,fn,wh){
  tstep=Math.max(Math.max(Math.abs((top-this.clipTop)/step),Math.abs((right-this.clipRight)/step)),
    Math.max(Math.abs((bottom-this.clipBottom)/step),Math.abs((left-this.clipLeft)/step)))
  if(!this.clipactive){
    this.clipactive=true; 
    if(!wh) wh=0; 
    if(!fn) fn=0;
    this.clipobj(top,right,bottom,left,(top-this.clipTop)/tstep,(right-this.clipRight)/tstep,
    (bottom-this.clipBottom)/tstep,(left-this.clipLeft)/tstep,tstep,0, fn,wh)
  }
}

//clip
i1_ObjectReference.prototype.clipobj = function(top,right,bottom,left,ts,rs,bs,ls,tstep,astep,fn,wh){
  if(astep<tstep){
    if(wh){eval(wh)}; 
    astep++;
    this.clipBy(ts,rs,bs,ls,1);
    setTimeout(this.obj+".clipobj("+top+","+right+","+bottom+","+left+","+ts+","+rs+","
      +bs+","+ls+","+tstep+","+astep+",'"+fn+"','"+wh+"')",50);
  }else{
    this.clipactive=false; 
    this.clipTo(top,right,bottom,left,1);
    if(fn)eval(fn);
  }
}



//------------------------------------------------
//REFERENCE ELEMENT
//---------------

//update content
i1_ObjectReference.prototype.innerHTML = function(val){
  if(is.dom&&!is.op5){
		this.ref.innerHTML = val +"\n";
  }else{
	with(this.css.document){
		open("text/html");
		write(val);
		close();
	}
  }
}
//set css class
i1_ObjectReference.prototype.setClassName = function(val){
	if(is.dom||is.ie4){this.ref.className = val;}
}
//return css class
i1_ObjectReference.prototype.getClassName = function(){
	if(is.dom||is.ie4){return this.ref.className;}
}

//-------------------------------------------------------------------------------------







