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

var ocmOrig = document.oncontextmenu
var ocmNone = new Function( "return false" )

// Inline Object
function ObjInline(n,a,x,y,w,h,v,z,c,d) {
  this.name = n
  this.altName = a
  this.x = x
  this.y = y
  this.w = w
  this.h = h
  this.v = v
  this.z = z
  this.iType = '';
  this.isGrp = false
  this.hasOnUp = false
  this.hasOnRUp = false
  this.bgColor = c
  this.obj = this.name+"Object"
  this.parmArray = new Array
  this.numParms = 0
  this.alreadyActioned = false;
  this.eatOnUp=false;
  this.eatOnRUp=false;
  eval(this.obj+"=this")
  if ( d != 'undefined' && d!=null )
    this.divTag = d;
  else  
    this.divTag = "div";
  this.childArray = new Array  
}

function ObjInlineGetNS( tagName) { 
	var flashName = "swf" + this.name;

	if (navigator.appVersion.indexOf("Mac")!=-1) 
		return eval( "swf" + this.name );

	var objects = document.getElementsByTagName( String(tagName) );
	for (var i=0; i < objects.length; i++) {
		if ( objects[i].name == flashName || objects[i].id == flashName) {
			return window.document.embeds[i];
			break;
		}
	}
}

function ObjInlineAddParm( newParm ) {
  this.parmArray[this.numParms++] = newParm;
}

function ObjInlineAddChild( newChild ) {
  this.childArray[this.childArray.length] = newChild;
}

function ObjInlineActionGoTo( destURL, destFrame ) {
  this.objLyr.actionGoTo( destURL, destFrame );
}

function ObjInlineActionGoToNewWindow( destURL, name, props ) {
  this.objLyr.actionGoToNewWindow( destURL, name, props );
}

function ObjInlineActionPlay( ) {
  if( this.iType == 'flash' ) 
  {
    var mc = null;
    if( is.ie ) mc = eval( "document.swf" + this.name )
    else mc = this.getNS("object");
  
    mc.Play();
  }
  else this.objLyr.actionPlay();
}

function ObjInlineActionStop( ) {
  if( this.iType == 'flash' ) 
  {
    var mc = null;
    if( is.ie ) mc = eval( "document.swf" + this.name );
    else mc = this.getNS("object");

    mc.Rewind();
    mc.StopPlay();
  }
  else this.objLyr.actionStop();
}

function ObjInlineActionShow( ) {
  if( this.isGrp || !this.isVisible() )
    this.onShow();
}

function ObjInlineActionHide( ) {
  if( this.isGrp || this.isVisible() )
    this.onHide();
}

function ObjInlineActionLaunch( ) {
  this.objLyr.actionLaunch();
}

function ObjInlineActionExit( ) {
  this.objLyr.actionExit();
}

function ObjInlineActionChangeContents( value, align, fntId ) {
  var varValue = ''
  varValue += value
  if (arguments.length>1) {
    var div = null
    var fntName = this.objLyr.id + 'Font' + fntId
 
    if( varValue.split ) {
      var test = escape( varValue )
 
      var ca = test.split('%5Cr')
      if( ca.length ) {
        var newVarValue=''
    
        for(var i=0;i<ca.length;i++) {
          newVarValue += ca[i]
          if( i < ca.length-1 ) 
            newVarValue += '<br />'
        }
        varValue = newVarValue
      }
      
      test = varValue;
      
      var ca = test.split('%')
      if( ca.length ) {
        var newVarValue=''
    
        for(var i=0;i<ca.length;i++) {
          var tempStr, holdStr;
          var uni = 0;
          if( i )
          {
            if( ca[i].charAt( 0 ) == 'u' )
            {
              uni = 1;
              holdStr = ca[i].substring( 5 );
            }
            else
              holdStr = ca[i].substring( 2 );
          }
          else
            holdStr = ca[i];
            
          if( i && i < ca.length ) 
          {
            if( uni )
              tempStr = ca[i].substring( 1, 5 )
            else
              tempStr = ca[i].substring( 0, 2 )

            var hexValue = parseInt( tempStr, 16 )

            if( hexValue == 32 )
              newVarValue += ' '
            else
              newVarValue += '&#' + hexValue + ';'

            newVarValue += holdStr
          }
          else
            newVarValue += holdStr
        }
        varValue = newVarValue
      }
    }
    
    var splitID = '<!--split=' + this.objLyr.id + 'ter' + '-->';
	if( !is.ns4 ) {
      var parts = this.objLyr.ele.innerHTML.split(splitID);
      if ( parts.length == 3 )
      {
        if( is.ns ){
          if( varValue == "~~~null~~~" ) div = parts[0] + splitID + '<span class="' + fntName + '">' + '</span>' + splitID + parts[2]; 
          else div = parts[0] + splitID + '<span class="' + fntName + '">' + varValue + '</span>' + splitID + parts[2]; 
        }
        else { 
          if( varValue == "~~~null~~~" ) div = parts[0] + splitID + '<' + this.divTag + ' class="' + align + '"><span class="' + fntName + '">' + '</span></' + this.divTag + '>'  + splitID + parts[2]; 
          else div =  parts[0] + splitID + '<' + this.divTag + ' class="' + align + '"><span class="' + fntName + '">' + varValue + '</span></' + this.divTag + '>' + splitID + parts[2]; 
        }
      }
    }
    if( !div )
    {
      if( is.ns ){
        if( varValue == "~~~null~~~" ) div = '<span class="' + fntName + '">' + '</span>'
        else div = '<span class="' + fntName + '">' + varValue + '</span>'
      }
      else { 
        if( varValue == "~~~null~~~" ) div = '<' + this.divTag + ' class="' + align + '"><span class="' + fntName + '">' + '</span></' + this.divTag + '>' 
        else div = '<' + this.divTag + ' class="' + align + '"><span class="' + fntName + '">' + varValue + '</span></' + this.divTag + '>'
      }
    }
    if( is.ns5 ) this.objLyr.ele.innerHTML = div
    else this.objLyr.write( div );
  }
  else {
    if ( this.parmArray[1] ) {
      if( varValue.length == 0 )
      {
        var off = this.parmArray[1].indexOf( 'value=' )
        if( off >= 0 )
	  varValue = this.parmArray[1].substring( off + 7, this.parmArray[1].length-2 )

        //Fixup parm 0
        off = this.parmArray[0].indexOf( 'width=' )
        var front = this.parmArray[0].substring( 0, off + 7 )
        var end   = this.parmArray[0].substring( off + 7 )
        off = end.indexOf( "'" )
        var newString = front + this.w + end.substring( off )
        off = newString.indexOf( 'height=' )
        var front = newString.substring( 0, off + 8 )
        var end   = newString.substring( off + 8 )
        off = end.indexOf( "'" )
        this.parmArray[0] = front + this.h + end.substring( off )
      }

      this.parmArray[1] = "<param name='movie' value='" + varValue + "'>";
      this.parmArray[3] = "<embed src='" + varValue + "' width='" + this.w + "'   height='" + this.h + "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' name='" + this.name + "' swliveconnect='true'>";
      this.build();
      var str = "";
      for (var i=0; i < this.numParms; i++) str = str + this.parmArray[i]
      if( is.ns5 ) this.objLyr.ele.innerHTML = str
      else this.objLyr.write( str );
    }
    else {
      document.getElementById(this.name).style.width = this.w
      document.getElementById(this.name).style.height = this.h
    }
  }
}

function ObjInlineActionTogglePlay( ) {
  if( this.iType == 'flash' ) 
  {
      var mc = null;
      if( is.ie ) mc = eval( "document.swf" + this.name );
      else mc = this.getNS("object");
  
      if( mc.IsPlaying() ) mc.StopPlay();
      else mc.Play();
  }
  else this.objLyr.actionTogglePlay();

}

function ObjInlineActionToggleShow( ) {
  if( this.isGrp ) {
    for ( var i=0; i<this.childArray.length; i++ )
       eval( this.childArray[i] + ".actionToggleShow()");
  }
  else if(this.objLyr.isVisible()) 
    this.actionHide();
  else 
    this.actionShow();
}

function ObjInlineSizeTo( w, h ) { 
    this.w = w
    this.h = h
    this.build()
    this.activate()
    if( this.objLyr )
    	this.objLyr.clipTo( 0, w, h, 0  )
    this.actionChangeContents( '' )
}

function ObjInlineGoToFrame( frame ) {
   if( this.iType == 'flash' ) 
   {
      var mc = null;
      if( is.ie ) mc = eval( "document.swf" + this.name );
      else mc = this.getNS("object");
     
      mc.GotoFrame(frame);
   }

}

function ObjInlineGoToNextFrame() {
   if( this.iType == 'flash' ) 
   {
      var mc = null;
      if( is.ie ) mc = eval( "document.swf" + this.name );
      else mc = this.getNS("object");
        
      var frame = mc.CurrentFrame()+1;
      mc.GotoFrame(frame);
   }

}

function ObjInlineGoToPrevFrame() {
  if( this.iType == 'flash' ) 
  {
      var mc = null;
      if( is.ie ) mc = eval( "document.swf" + this.name );
      else mc = this.getNS("object");
          
      var frame = mc.CurrentFrame()-1;
      mc.GotoFrame(frame);
   }
}

function ObjInlineGoToLabel( label ) {
  if( this.iType == 'flash' ) 
  {
     var mc = null;
     if( is.ie ) mc = eval( "document.swf" + this.name );
     else mc = this.getNS("object");
          
     mc.TGotoLabel('/', String(label) );
   }
}

function ObjInlineGetFlashVar ( varName ) {
     var mc = null;
     if( is.ie ) mc = eval( "document.swf" + this.name );
     else mc = this.getNS("object");
            
     return mc.GetVariable( String(varName) );

	
}

function ObjInlineSetFlashVar( varName,myValue ) {
  var mc = null;
  if( is.ie ) mc =  eval( "document.swf" + this.name);
  else var mc = this.getNS("object");

  mc.SetVariable( String(varName), String(myValue) );
}

function ObjInlinePause() {
  if( this.iType == 'flash' ) 
  {
     var mc = null;
     if( is.ie ) mc = eval( "document.swf" + this.name );
     else mc = this.getNS("object");
            
     mc.StopPlay();
   }
    
}

{ // Setup prototypes
var p=ObjInline.prototype
p.addParm = ObjInlineAddParm
p.build = ObjInlineBuild
p.init = ObjInlineInit
p.activate = ObjInlineActivate
p.up = ObjInlineUp
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.onUp = new Function()
p.onRUp = new Function()
p.actionGoTo = ObjInlineActionGoTo
p.actionGoToNewWindow = ObjInlineActionGoToNewWindow
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
p.onShow = ObjInlineOnShow
p.onHide = ObjInlineOnHide
p.isVisible = ObjInlineIsVisible
p.onSelChg = new Function()
p.addChild = ObjInlineAddChild
p.doTrans = ObjInlineDoTrans
p.sizeTo  = ObjInlineSizeTo
p.goToFrame     = ObjInlineGoToFrame
p.goToNextFrame = ObjInlineGoToNextFrame
p.goToPrevFrame = ObjInlineGoToPrevFrame
p.goToLabel     = ObjInlineGoToLabel
p.getFlashVar   = ObjInlineGetFlashVar
p.setFlashVar   = ObjInlineSetFlashVar
p.getNS         = ObjInlineGetNS
p.getFlashVars  = ObjInlineGetFlashVar
p.pause			= ObjInlinePause
p.offset = ObjInlineOffset
}

function ObjInlineBuild() {
  if( this.bgColor ) this.css = buildCSS(this.name,this.x,this.y,this.w,this.h,this.v,this.z,this.bgColor)
  else {
    var prefix=this.name.substring(3)
    if(prefix == 'tex') {
      var maxHeight = parseInt( this.h * 5 / 4, 10 )
      this.css = buildCSS(this.name,this.x,this.y,this.w,maxHeight,this.v,this.z,this.bgColor)
    }
    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)
      else this.css = buildCSS(this.name,this.x,this.y,this.w,this.h,this.v,this.z,this.bgColor)
    }
    else this.css = buildCSS(this.name,this.x,this.y,this.w,null,this.v,this.z,this.bgColor)
  }
  var divStart
  var divEnd
  divStart = '<' + this.divTag + ' id="'+this.name+'"'
  if( this.altName ) divStart += ' alt="'+this.altName+'"'
  else { if( this.altName != null ) divStart += ' alt=""' }
  divStart += '><a name="'+this.name+'anc"'
  if( this.hasOnUp ) divStart += ' href="javascript:' +this.name+ '.onUp()"'
  divStart += '>'
  divEnd   = '</a></' + this.divTag + '>'
  this.div = divStart + '\n' + divEnd + '\n'
}

function ObjInlineInit() {
  this.objLyr = new ObjLayer(this.name)
}

function ObjInlineActivate() {
  if( this.objLyr && this.objLyr.styObj && !this.alreadyActioned ) {
    if( this.isGrp ) {
      if( this.v ) {
        for ( var i=0; i<this.childArray.length; i++ )
        {
          if ( eval( this.childArray[i] + ".isVisible()") )
            eval( this.childArray[i] + ".actionShow()");
        }
      }
    }
    else
      if( this.v ) this.actionShow()
  }
  if( this.capture & 4 ) {
    if (is.ns4) this.objLyr.ele.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
    this.objLyr.ele.onmousedown = new Function("event", this.obj+".down(event); return false;")
    this.objLyr.ele.onmouseup = new Function("event", this.obj+".up(event); 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;")
  if( this.numParms ) {
    var str = "";
    for (var i=0; i < this.numParms; i++) str = str + this.parmArray[i]
    if( is.ns5 ) this.objLyr.ele.innerHTML = str
    else this.objLyr.write( str );
  }
}

function ObjInlineDown(e) {
  if( is.ie ) e = event
  if( is.ie && !is.ieMac && e.button!=1 && e.button!=2 ) return
  if( is.ieMac && e.button != 0 ) return
  if( is.ns && !is.ns4 && e.button!=0 && e.button!=2 ) return
  if( is.ns4 && e.which!=1 && e.which!=3 ) return
  this.onSelect()
  this.onDown()
}

function ObjInlineUp(e) {
  if( is.ie ) e = event
  if( is.ie && !is.ieMac && e.button!=1 && e.button!=2 ) return
  if( is.ieMac && e.button!=0 ) return
  if( is.ns && !is.ns4 && !is.nsMac && e.button!=0 && e.button!=2 ) return
  if( is.ns4 && e.which!=1 && e.which!=3 ) return
  if( ( !is.ns4 && e.button==2 ) || ( is.ns4 && e.which==3 ) )
  {
    if( this.hasOnRUp )
    {
      document.oncontextmenu = ocmNone
      this.onRUp()
      setTimeout( "document.oncontextmenu = ocmOrig", 100)
    }
  }
  else if( !is.ns5 )
    this.onUp()
}

function ObjInlineOver() {
  this.onOver()
}

function ObjInlineOut() {
  this.onOut()
}

function ObjInlineWriteLayer( newContents ) {
  if (this.objLyr) this.objLyr.write( newContents )
}

function ObjInlineOnShow() {
  this.alreadyActioned = true;
  this.objLyr.actionShow();
  for ( var i=0; i<this.childArray.length; i++ )
  {
    if ( !eval( this.childArray[i] + ".isVisible()") )
      eval( this.childArray[i] + ".actionShow()");
  }
}

function ObjInlineOnHide() {
  this.alreadyActioned = true;
  for ( var i=0; i<this.childArray.length; i++ )
     eval( this.childArray[i] + ".actionHide()");
  this.objLyr.actionHide();
}

function ObjInlineIsVisible() {
  if( this.objLyr.isVisible() )
    return true;
  else
    return false;
}

function ObjInlineDoTrans(tNum,dur,fn,ol,ot,fl,ft,fr,fb,il) {
  if( !this.isVisible() )
  {
    for ( var i=0; i<this.childArray.length; i++ )
    {
      if ( eval( this.childArray[i] + ".isVisible()") )
        eval( this.childArray[i] + ".actionShow()");
    }
  }
  this.objLyr.doTrans(tNum,dur,fn,ol,ot,fl,ft,fr,fb,il);
}

function ObjInlineOffset( off ) {
  var maxY = 0;
  for ( var i=0; i<this.childArray.length; i++ )
  {
     var obj = eval( this.childArray[i] )
     obj.objLyr.moveBy( null, off );
     var bottom = obj.objLyr.ele.offsetTop + obj.objLyr.ele.offsetHeight;
     if( maxY < bottom ) maxY = bottom;
  }
  
  return maxY;
}

