
// this object was created by Thomas K Pickett tom.pickett@refinery.com

// this is an object that helps with the differences between ie and netscape.
function imageplus()
	{
		// data members 
		this.isMinNS4 = (document.layers) ? 1 : 0;
        this.isMinIE4 = (document.all)    ? 1 : 0;
		this.imagepartner;
		this.image;
		this.test=0;
		this.selected = false;
		this.originalsrc;
		this.copysrc;
		this.childimg = new Array();
		this.init = false;
		
		// member functions
	    this.getwidth = imageplus_getwidth;
		this.getheight = imageplus_getheight;
		this.getleft = imageplus_getleft;
		this.gettop = imageplus_gettop;
	    this.swap = imageplus_swap;
	    this.initialize = imageplus_initialize;
		this.returnposx = imageplus_returnposx;
		this.returnposy = imageplus_returnposy;
		this.swaptooriginal = imageplus_swaptooriginal;
		this.swaptocopy = imageplus_swaptocopy;
		this.setimagepartner = imageplus_setimagepartner;
		this.replaceimg = imageplus_replaceimg;
		// initialize
		this.initialize(arguments);
	}


function imageplus_initialize()
	{
		if(arguments[0].length == 1)
			{
				if(isNaN(arguments[0][0]))
					{
						this.image = arguments[0][0]; 
			    		this.originalsrc = this.image.src;		
					}
				
				this.setimagepartner();
			}
			
		if(arguments[0].length > 2)
			{
				this.image = new Array();
				
				for(var i=0; i< arguments[0].length; i++)
					{
						this.image[i] = new Image();
						this.image[i].src = arguments[0][i];
					}
				
			} 	
			
	}	
	
function imageplus_getwidth()
	{
		if(this.isMinNS4)
		return this.image.width;
		
		if(this.isMinIE4)
		return this.image.offsetWidith;
	}
	
function imageplus_getheight()
	{ 
		if(this.isMinNS4)
		return this.image.height;
		
		if(this.isMinIE4)
		return this.image.offsetWidith;
	}	
	
function imageplus_getleft()
	{
	   		
		if(this.isMinNS4)
			{ return this.image.x;}
			
		if(this.isMinIE4)
			{ 
				var temp = new Array();
				temp[0] = 0;
				this.returnposx(this.image,temp);
				return temp[0];
			}
	
	}	

	
function imageplus_gettop()
	{
		if(this.isMinNS4)
			{ return this.image.y;}
			
		if(this.isMinIE4)
			{ 
				var temp = new Array();
				temp[0] = 0;
				this.returnposy(this.image,temp);
				return temp[0]; 	
			}
	
	}	


	
// just for ie	
function imageplus_returnposx(obj,point)
  {
        
		if(!(obj.offsetParent))
           { 
			 return point[0] 
           } else {
             if(obj.offsetLeft)
			 point[0] = point[0] + obj.offsetLeft;
			 // alert(point);
			 this.returnposx(obj.offsetParent,point);
           }
            
  }	
	
// just for ie
function imageplus_returnposy(obj,point)
  {
        if(!(obj.offsetParent))
           { 
             return point[0]; 
           } else {
             point[0] = point[0] + obj.offsetTop;
			 this.returnposy(obj.offsetParent,point);
           }
            
  }	

function imageplus_swap(w)
	{
		if(this.image.complete)
			{
				if(!(this.selected))
					{
					  if(this.imagepartner)
					  	{
							if(w == 0)
								{
									this.image.src = this.originalsrc; 
								
								}
							
							if(w==1)
								{
									this.image.src = this.copysrc; 
								}
							
						}
					}
			}
	}


	
	
		
function imageplus_swaptooriginal()
	{
	  // if(this.image.complete)
			// {
			  if(this.imagepartner)
			 	{
					this.image.src = this.originalsrc; 	
					this.imagepartner.src = this.copysrc;
					this.selected = false;
					/*
					for(var i=0; i < this.childimg.length; i++)
						{
							this.childimg[i].swaptooriginal();
						
						}
					*/
				}	
			// }
	
	}	

function imageplus_swaptocopy()
	{
	  // if(this.image.complete)
			// {
			  if(this.imagepartner)
			  	{
					this.image.src = this.copysrc;
					this.imagepartner.src = this.originalsrc;
					this.selected = true;
					/*
					if(this.childimg.length > 0)
						{
							for(var i=0; i < this.childimg.length; i++)
								{
									this.childimg[i].swaptocopy();
								
								}
						}
					*/
					
				}	 	
			// }
	}	


function imageplus_setimagepartner()
	{
		// assuming on refinery's standards
		var pattern = new RegExp('-out');
		this.imagepartner = new Image();
		this.imagepartner.src = this.image.src.replace(pattern,'-over');
		this.copysrc = this.imagepartner.src;
	}
	
function imageplus_replaceimg(src)
	{
	
		this.image.src = src;
	
	}		
	
	
	
	
	
	
	
	
	
