/******************************************************************************
* File: ie_md8lib.js                                                          *
*                                                                             *
* Copyright MatchWare A/S                                                     *
* Author: Jens Ø. Nielsen                                                     *
******************************************************************************/

var isns6 = IsNetscape6();

function BrowserInit() {
}

function GetObjLeft( obj) {
  return isns6 ? parseInt( obj.style.left) : obj.style.pixelLeft;
}

function GetObjTop( obj) {
  return isns6 ? parseInt( obj.style.top): obj.style.pixelTop;
}

function GetObjWidth( obj) {
 if ( isns6) 
   return parseInt( obj.style.width);
 if ( obj.style.pixelWidth)
   return obj.style.pixelWidth;
 else
   return obj.clientWidth;
}

function GetObjHeight( obj) {
 if ( isns6) 
   return parseInt( obj.style.height);
 if ( obj.style.pixelHeight)
   return obj.style.pixelHeight;
 else
   return obj.clientHeight;
}

function SetObjPosition( obj,left,top) {

 if ( isns6) {
   obj.style.left = left;
   obj.style.top  = top;
 }
 else {
   obj.style.pixelLeft = left;
   obj.style.pixelTop  = top;
 }
}

function IsObjVisible( obj) {
 return obj.style.visibility == "visible";
}

function ShowObject( obj,visible) {
 obj.style.visibility = visible ? "visible" : "hidden";
}

function FindObject( name) {
 if ( bIsIE4Final)
   return document.all( name);
 else
   return document.getElementById( name);
}

//------------------------------------

var PAGE_ACTION_POST_FIX = "_ie.htm";

//------------------------------------

var effects = new Array();
effects.BoxIn      = 0;
effects.BoxOut     = 1;
effects.CircleIn   = 2;
effects.CircleOut  = 3;
effects.WipeUp     = 4;
effects.WipeDown   = 5;
effects.WipeRight  = 6;
effects.WipeLeft   = 7;
effects.HorzBlinds = 9;
effects.Dissolve        = 12;
effects.SplitVerticalIn = 13;
effects.Normal          = 100;
effects.Fade            = 101;

//------------------------------------

function HideAction( obj,duration,effecttype) {

 this.m_Obj        = FindObject( obj);
 this.m_Duration   = duration;
 this.m_EffectType = effecttype;

 this.Start = HideAction_Start;
}


function HideAction_Start() {

 if ( this.m_Obj.style.visibility == "hidden") return;
 if ( isns6) {
  this.m_Obj.style.visibility = "hidden";
  return;
 }
 switch ( this.m_EffectType) {
  case effects.Normal :
    this.m_Obj.style.visibility = "hidden";
    break;
  case effects.Fade :
    this.m_Obj.style.filter = "blendTrans(duration=" + (this.m_Duration / 1000) + ")";
    this.m_Obj.filters.blendTrans.stop();
    this.m_Obj.filters.blendTrans.apply();
    this.m_Obj.style.visibility="hidden";
    this.m_Obj.filters.blendTrans.play();
    break;
  default :
    this.m_Obj.style.filter = "revealTrans(duration==" + (this.m_Duration / 1000) + ", transition=" + this.m_EffectType + ")";
    this.m_Obj.filters.revealTrans.stop();
    this.m_Obj.filters.revealTrans.apply();
    this.m_Obj.style.visibility="hidden";
    this.m_Obj.filters.revealTrans.play();
    break;
 }
}

//------------------------------------


function ShowAction( obj,duration,effecttype) {

 this.m_Obj        = FindObject( obj);
 this.m_Duration   = duration;
 this.m_EffectType = effecttype;

 this.Start = ShowAction_Start;
}


function ShowAction_Start() {

 if ( this.m_Obj.style.visibility == "visible") return;
 if ( isns6) {
  this.m_Obj.style.visibility = "visible";
  return;
 }

 switch ( this.m_EffectType) {
  case effects.Normal :
    this.m_Obj.style.visibility = "visible";
    break;
  case effects.Fade :
    this.m_Obj.style.filter = "blendTrans(duration=" + (this.m_Duration / 1000) + ")";
    this.m_Obj.filters.blendTrans.stop();
    this.m_Obj.filters.blendTrans.apply();
    this.m_Obj.style.visibility = "visible";
    this.m_Obj.filters.blendTrans.play();
    break;
  default :
    this.m_Obj.style.filter = "revealTrans(duration==" + (this.m_Duration / 1000) + ", transition=" + this.m_EffectType + ")";
    this.m_Obj.filters.revealTrans.stop();
    this.m_Obj.filters.revealTrans.apply();
    this.m_Obj.style.visibility = "visible";
    this.m_Obj.filters.revealTrans.play();
    break;
 }
}

//------------------------------------

function SoundAction( sound,repeat,cancelmidi,cancelwave) {

 var pos = sound.lastIndexOf( ".");
 var ext = sound.substring( pos).toLowerCase();

 this.m_Sound      = sound;
 this.m_Repeat     = repeat;
 this.m_CancelMidi = cancelmidi;
 this.m_CancelWave = cancelwave;
 this.m_Midi       = ext == ".mid";

 this.Start = SoundAction_Start;
}

function SoundAction_Start() {

 if ( window.parent == self) return;

 if ( this.m_CancelMidi) 
   top.global.mediaplayer1.Stop();
 if ( this.m_CancelWave) 
   top.global.mediaplayer2.Stop();

 if ( this.m_Sound == "") return;

 var player = this.m_Midi ? top.global.mediaplayer1 : top.global.mediaplayer2;
 if ( player.PlayState == 2) return; // Already playing

 player.FileName  = this.m_Sound;
 player.PlayCount = this.m_Repeat ? 0 : 1;
 player.Volume    = 0; // Full volume
 player.Play();
}

//------------------------------------

function SetCursorAction( type) {

 this.m_Type = type;

 this.Start = SetCursorAction_Start;
}


function SetCursorAction_Start() {

 if ( isns6) return;
 var aDivs = document.body.all.tags("DIV");
 if ( ! aDivs) return;

 for ( var i=0;i < aDivs.length; i++) 
   aDivs( i).style.cursor = this.m_Type;

 aDivs = document.body.all.tags("IMG");
 if ( ! aDivs) return;

 for ( var i=0;i < aDivs.length; i++) 
   aDivs( i).style.cursor = this.m_Type;

 aDivs = document.body.all.tags("INPUT");
 if ( ! aDivs) return;

 for ( var i=0;i < aDivs.length; i++) 
   aDivs( i).style.cursor = this.m_Type;
}

//------------------------------------

function N6Button( id) {
 if ( ! isns6) return;
 var obj = FindObject( id + "_JSGinner");
 var b = parseInt( obj.style.borderWidth)*2;
 obj.style.width = parseInt( obj.style.width) - b;
 obj.style.height = parseInt( obj.style.height) - b;
}

