/**************************************************
Trivantis (http://www.trivantis.com)

This JavaScript code uses techniques found at
The Dynamic Duo - http://www.dansteinman.com/dynduo/
**************************************************/

// InlineObject Object
function InlineObject(name,x,y,width,height,visible,zorder,color) {
    this.name = name
    this.x = x
    this.y = y
    this.w = width
    this.h = height
    if( visible ) 
        this.v = (is.ns4)? "show" : "visible"
    else
        this.v = (is.ns4)? "hide" : "hidden"
    this.z = zorder
    this.bgColor = color
    this.obj = this.name+"Object"
    this.parmArray = new Array
    this.numParms = 0
    this.hrefPrompt = 'javascript:;'
    eval(this.obj+"=this")
}

function InlineObjectAddParm( newParm ) {
    this.parmArray[this.numParms++] = newParm;
}
function InlineObjectActionGoTo( destURL, destFrame ) {
    this.lyr.actionGoTo( destURL, destFrame );
}
function InlineObjectActionPlay( ) {
    this.lyr.actionPlay();
}
function InlineObjectActionStop( ) {
    this.lyr.actionStop();
}
function InlineObjectActionShow( ) {
    this.lyr.actionShow();
}
function InlineObjectActionHide( ) {
    this.lyr.actionHide();
}
function InlineObjectActionLaunch( ) {
    this.lyr.actionLaunch();
}
function InlineObjectActionExit( ) {
    this.lyr.actionExit();
}
function InlineObjectActionChangeContents( varValue, align ) {
    var div
    if( is.ns ){
    if( varValue == "~~~null~~~" ) div = '<span class="' + this.lyr.id + 'Font1">' + '</span>'
    else div = '<span class="' + this.lyr.id + 'Font1">' + varValue + '</span>'
    }
    else { 
        if( varValue == "~~~null~~~" ) div = '<div class="' + align + '"><span class="' + this.lyr.id + 'Font1">' + '</span></div>' 
        else div = '<div class="' + align + '"><span class="' + this.lyr.id + 'Font1">' + varValue + '</span></div>'
    }
    if( is.ns5 ) this.lyr.elm.innerHTML = div
    else this.lyr.write( div );
}
function InlineObjectActionTogglePlay( ) {
    this.lyr.actionTogglePlay();
}
function InlineObjectActionToggleShow( ) {
    this.lyr.actionToggleShow();
}
InlineObject.prototype.addParm = InlineObjectAddParm
InlineObject.prototype.build = InlineObjectBuild
InlineObject.prototype.activate = InlineObjectActivate
InlineObject.prototype.down = InlineObjectDown
InlineObject.prototype.over = InlineObjectOver
InlineObject.prototype.out = InlineObjectOut
InlineObject.prototype.capture = 0
InlineObject.prototype.onOver = new Function()
InlineObject.prototype.onOut = new Function()
InlineObject.prototype.onSelect = new Function()
InlineObject.prototype.onDown = new Function()
InlineObject.prototype.actionGoTo = InlineObjectActionGoTo
InlineObject.prototype.actionPlay = InlineObjectActionPlay
InlineObject.prototype.actionStop = InlineObjectActionStop
InlineObject.prototype.actionShow = InlineObjectActionShow
InlineObject.prototype.actionHide = InlineObjectActionHide
InlineObject.prototype.actionLaunch = InlineObjectActionLaunch
InlineObject.prototype.actionExit = InlineObjectActionExit
InlineObject.prototype.actionChangeContents = InlineObjectActionChangeContents
InlineObject.prototype.actionTogglePlay = InlineObjectActionTogglePlay
InlineObject.prototype.actionToggleShow = InlineObjectActionToggleShow
InlineObject.prototype.writeLayer = InlineObjectWriteLayer

function InlineObjectBuild() {
    var other = '';
    
    if( this.capture & 4 && !is.ns4 ) other=' style="cursor:hand"'
    
    if( this.bgColor ) this.css = css(this.name,this.x,this.y,this.w,this.h,this.v,this.z,this.bgColor,other)
    else {
		if( is.ns4 ) {
            var right = this.w + this.x;
            if( right <= window.innerWidth + 4 ) this.css = css(this.name,this.x,this.y,this.w,null,this.v,this.z,this.bgColor,other)
            else this.css = css(this.name,this.x,this.y,this.w,this.h,this.v,this.z,this.bgColor,other)
        }
		else {
            this.css = css(this.name,this.x,this.y,this.w,null,this.v,this.z,this.bgColor,other)
		}
	}
    var divStart
    var divEnd
    if( is.ns4 )
    {
        divStart = '<div id="'+this.name+'"><a name="'+this.name+'">'
        divEnd   = '</a></div>'
        
        if( this.capture & 4 )
        {
            divStart = divStart + '<A HREF="' +this.hrefPrompt+'">'
            divEnd   = '</A>' + divEnd 
        }
        
    }
    else
    {
        divStart = '<div id="'+this.name+'">'
        divEnd   = '</div>'
    }
    
    this.div = divStart + '\n'

    for (var i=0; i < this.numParms; i++) {
        this.div = this.div + this.parmArray[i]
    }

    this.div = this.div + divEnd + '\n'
}
function InlineObjectActivate() {
    this.lyr = new DynLayer(this.name)
    if( this.lyr && this.lyr.css )
        this.lyr.css.visibility = this.v
    
    if( this.capture & 4 ) {
        if (is.ns4) this.lyr.elm.captureEvents(Event.MOUSEDOWN)
        this.lyr.elm.onmousedown = new Function(this.obj+".down(); return false;")
    }
    if( this.capture & 1 )
        this.lyr.elm.onmouseover = new Function(this.obj+".over(); return false;")
    if( this.capture & 2 )
        this.lyr.elm.onmouseout = new Function(this.obj+".out(); return false;")
}
function InlineObjectDown() {
    this.onSelect()
    this.onDown()
}
function InlineObjectOver() {
    this.onOver()
}
function InlineObjectOut() {
    this.onOut()
}
function InlineObjectWriteLayer( newContents ) {
    this.lyr.write( newContents )
}

