﻿/*################################
### Core Opacity Functions     ###
################################*/


function objOpacity(obj)
{

	this.Object;
	
	this.Load = function(obj)
				{
					if (!isObject(obj))
						obj = document.getElementById(obj); 
					
					if (!isObject(obj))
						return false;
					
					this.Object = obj;

					return true;
				}
	

	this.OpacityTransition = function(intOpacBegin, intOpacEnd, intMilliseconds)
								{
								
									// Speed for each frame
									var speed = Math.round(intMilliseconds / 100);
									var timer = 0;
								
									// Determine the direction for the blending, if start and end are the same nothing happens
									if (intOpacBegin > intOpacEnd)
									{
										for(i = intOpacBegin; i >= intOpacEnd; i--)
										{
											setTimeout("SetObjectOpacity(" + i + ", '" + this.Object.id + "')",(timer * speed));
											timer++;
										}
									}
									else if (intOpacBegin < intOpacEnd)
									{
										for(i = intOpacBegin; i <= intOpacEnd; i++)
										{
											setTimeout("SetObjectOpacity(" + i + ", '" + this.Object.id + "')",(timer * speed));
											timer++;
										}
									}
									
									return true;
									
								}
								
	this.GetOpacity = function()
                        {
                            return this.Object.style.opacity;
                        }
								
	this.SetOpacity = function(intOpacity)
						{
						    //alert(intOpacity);
						    //intOpacity = intOpacity / 100
						    //alert(this.Object.id + ' to ' + intOpacity);
						        
							SetObjectOpacity(intOpacity, this.Object.id);
							return;
							if (!isObject(this.Object))
							{
							    if (isObject(strID))
							        this.Object = document.getElementById(strID);
							    
							    if (!isObject(this.Object))
							        return false;
							}
							
							alert(this.Object.id);
							this.Object.opacity = (intOpacity / 100);
							this.Object.MozOpacity = (intOpacity / 100);
							this.Object.KhtmlOpacity = (intOpacity / 100);
							this.Object.filter = 'alpha(opacity=' + intOpacity + ')';
							
							return true;
						}
	
    this.Load(obj);
		
	return this;

}



// Change the opacity for different browsers
function SetObjectOpacity(intOpacity, strID)
{
    //if (intOpacity > 0)
	//    show(strID);
    //else
	//    hide(strID);
		
	//alert(strID + ' to ' + intOpacity);
	/*
	if (intOpacity == 100)
	    alert(strID + ' to ' + intOpacity);
    */
    
    var obj = new objController(strID);
    
    var object = obj.Object.style;
	
    object.opacity = (intOpacity / 100);
    object.MozOpacity = (intOpacity / 100);
    object.KhtmlOpacity = (intOpacity / 100);
    object.filter = 'alpha(opacity=' + intOpacity + ')';
    
    /* if (intOpacity > 0)
        obj.Show('absolute');
    else // if (intOpacity < 10)
    {
        //alert('Hide ' + obj.Object.id);
        obj.Hide();
        alert(ActiveStageItemDiv);
    }
    
    if (obj.Object.style.visibility == 'hidden' && intOpacity > 0)
        alert('problem!');
        
    */
	

}