/**************************************************
Trivantis (http://www.trivantis.com)
**************************************************/

// Inline Object
function ObjInline(n,x,y,w,h,v,z,c) {
  this.name = n
  this.x = x
  this.y = y
  this.w = w
  this.h = h
  if( v ) this.v = (is.ns4)? "show" : "visible"
  else this.v = (is.ns4)? "hide" : "hidden"
  this.z = z
  this.bgColor = c
  this.obj = this.name+"Object"
  this.parmArray = new Array
  this.numParms = 0
  this.hrefPrompt = 'javascript:;'
  eval(this.obj+"=this")
}

function ObjInlineAddParm( newParm ) {
  this.parmArray[this.numParms++] = newParm;
}

function ObjInlineActionGoTo( destURL, destFrame ) {
  this.objLyr.actionGoTo( destURL, destFrame );
}

function ObjInlineActionPlay( ) {
  this.objLyr.actionPlay();
}

function ObjInlineActionStop( ) {
  this.objLyr.actionStop();
}

function ObjInlineActionShow( ) {
  this.objLyr.actionShow();
}

function ObjInlineActionHide( ) {
  this.objLyr.actionHide();
}

function ObjInlineActionLaunch( ) {
  this.objLyr.actionLaunch();
}

function ObjInlineActionExit( ) {
  this.objLyr.actionExit();
}

function ObjInlineActionChangeContents( varValue, align ) {
  var div
  if( is.ns ){
    if( varValue == "~~~null~~~" ) div = '<span class="' + this.objLyr.id + 'Font1">' + '</span>'
    else div = '<span class="' + this.objLyr.id + 'Font1">' + varValue + '</span>'
  }
  else { 
    if( varValue == "~~~null~~~" ) div = '<div class="' + align + '"><span class="' + this.objLyr.id + 'Font1">' + '</span></div>' 
    else div = '<div class="' + align + '"><span class="' + this.objLyr.id + 'Font1">' + varValue + '</span></div>'
  }
  if( is.ns5 ) this.objLyr.ele.innerHTML = div
  else this.objLyr.write( div );
}

function ObjInlineActionTogglePlay( ) {
  this.objLyr.actionTogglePlay();
}

function ObjInlineActionToggleShow( ) {
  this.objLyr.actionToggleShow();
}

{ // Setup prototypes
var p=ObjInline.prototype
p.addParm = ObjInlineAddParm
p.build = ObjInlineBuild
p.activate = ObjInlineActivate
p.down = ObjInlineDown
p.over = ObjInlineOver
p.out = ObjInlineOut
p.capture = 0
p.onOver = new Function()
p.onOut = new Function()
p.onSelect = new Function()
p.onDown = new Function()
p.actionGoTo = ObjInlineActionGoTo
p.actionPlay = ObjInlineActionPlay
p.actionStop = ObjInlineActionStop
p.actionShow = ObjInlineActionShow
p.actionHide = ObjInlineActionHide
p.actionLaunch = ObjInlineActionLaunch
p.actionExit = ObjInlineActionExit
p.actionChangeContents = ObjInlineActionChangeContents
p.actionTogglePlay = ObjInlineActionTogglePlay
p.actionToggleShow = ObjInlineActionToggleShow
p.writeLayer = ObjInlineWriteLayer
}

function ObjInlineBuild() {
  var other = '';
  if( this.capture & 4 && !is.ns4 ) other=' style="cursor:hand"'
  if( this.bgColor ) this.css = buildCSS(this.name,this.x,this.y,this.w,this.h,this.v,this.z,this.bgColor,other)
  else {
    var prefix=this.name.substring(3)
    if(prefix == 'tex') {
      var maxHeight = parseInt( this.h * 5 / 4)
      this.css = buildCSS(this.name,this.x,this.y,this.w,maxHeight,this.v,this.z,this.bgColor,other)
    }
    else if( is.ns4 ) {
      var right = this.w + this.x;
      if( right <= window.innerWidth + 4 ) this.css = buildCSS(this.name,this.x,this.y,this.w,null,this.v,this.z,this.bgColor,other)
      else this.css = buildCSS(this.name,this.x,this.y,this.w,this.h,this.v,this.z,this.bgColor,other)
    }
    else this.css = buildCSS(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 ObjInlineActivate() {
  this.objLyr = new ObjLayer(this.name)
  if( this.objLyr && this.objLyr.styObj ) this.objLyr.styObj.visibility = this.v
  if( this.capture & 4 ) {
    if (is.ns4) this.objLyr.ele.captureEvents(Event.MOUSEDOWN)
    this.objLyr.ele.onmousedown = new Function(this.obj+".down(); return false;")
  }
  if( this.capture & 1 ) this.objLyr.ele.onmouseover = new Function(this.obj+".over(); return false;")
  if( this.capture & 2 ) this.objLyr.ele.onmouseout = new Function(this.obj+".out(); return false;")
}

function ObjInlineDown() {
  this.onSelect()
  this.onDown()
}

function ObjInlineOver() {
  this.onOver()
}

function ObjInlineOut() {
  this.onOut()
}

function ObjInlineWriteLayer( newContents ) {
  this.objLyr.write( newContents )
}

