function errorTrap(message, url, lineno)
{
   return true;
}
window.onerror = errorTrap;

/****************************************************************************************
contents of function postDebug are written based on the inclusion of rdb.js
****************************************************************************************/
document.write('<SCRIPT ID=postDebug LANGUAGE="JavaScript">');
document.write('function postDebug(message)                ');
document.write('{                                          ');

//if function rdb() is an available function then message will be sent to rdb()
if (window.rdb != null)
{
   document.write('window.setTimeout(\'rdb(\"\' + message + \'\");\', 100);  ');
}
                                                           
document.write('}                                          ');
document.write('</SCRIPT>                                  ');
postDebug("Debug Window Initialized");

/****************************************************************************************
Check browser type. Result is used for other functions in this script
****************************************************************************************/
if ( navigator.appName == "Netscape" )
   var bNetscape = true;
else
   var bNetscape = false;

/****************************************************************************************
Support for creation of display fields
****************************************************************************************/
var field = new Array;

function initializeFields(numberOfFields)
{
   for (i=1;i<=numberOfFields;i++) field[i] = new Object;
}

function writeFields(numberOfFields)
{
   for (i=1;i<=numberOfFields;i++)
   {
      postDebug("Creating "+field[i].id+" field");
      if (bNetscape) //If Netscape, create fields as Layers
      {
         document.write('<layer id='+field[i].id+' left='+field[i].left+' top='+field[i].top+'></layer>');
         document.layers[field[i].id].clip.height=field[i].height;
      }
      else //otherwise, create fields as Divs
      {
         document.write('<div id='+field[i].id+' style="position: absolute; top:'+field[i].top+'px; left:'+field[i].left+'px; height: '+field[i].height+'px; overflow: hidden;" nowrap></div>');
      }
   }
}

/****************************************************************************************
updateLayer function is actually only used if the browser is Netscape
****************************************************************************************/
function updateLayer(layerType, fieldValue)
{   
   postDebug("Updating field: "+layerType+" for Netscape version");
   document.layers[layerType].document.open();
	document.layers[layerType].document.write('<p id=' + layerType + '>' + fieldValue + '</p>');
	document.layers[layerType].document.close();	
}

function WriteProcessFunctions()
{
if (!bNetscape) 
{
   //alwaysHidden IFrame is used as a separate document to launch button requests for new windows
   //Without separate alwaysHidden IFrame, audio would stop
   document.write('<iframe id="alwaysHidden" scrolling="no" style="background-color: black;');
   document.write('position: absolute; left:-1px; top:-1px; width:1px; height:1px;');
   document.write('visibility: hidden">');
   document.write('</iframe>');
}
else
{
   document.write('<layer id="alwaysHidden"></layer>');
   //document.layers["alwaysHidden"].visibility="hide";
}


//Write Script Header
document.write('<SCRIPT ID=processFunctions LANGUAGE="JavaScript">');
/****************************************************************************************
Dynamically write processMessage function depending on parameters specified
****************************************************************************************/

document.write('function processMessage(command, data)            ');
document.write('{                                                 ');
document.write('   switch (command.toUpperCase())                 ');
document.write('   {                                              ');
   
//case of OAItem should be present in all versions
if (window.OAItem != null) 
{
postDebug("Writing ProcessMessage for OAITEM Case");
document.write('      case "OAITEM":                              ');
document.write('         OAItem(data);                            ');
document.write('         break;                                   ');
}

//cases of Cue and Show are present only in Deluxe version
if (window.Cue != null) 
{
postDebug("Writing ProcessMessage for CUE Case");
document.write('      case "CUE":                                 ');
document.write('         Cue(data);                               ');
document.write('         break;                                   ');
}
if (window.Show != null) 
{
postDebug("Writing ProcessMessage for SHOW Case");
document.write('      case "SHOW":                                ');
document.write('         Show(data);                              ');
document.write('         break;                                   ');
}

//cases of OpenEvent and Event are present in any version that adds SplitStream
if (window.OpenEvent != null) 
{
postDebug("Writing ProcessMessage for OPENEVENT Case");
document.write('      case "OPENEVENT":                           ');
document.write('         MediaPlayer_ScriptCommand(command, data);');
document.write('         break;                                   ');
}
if (window.Event != null) 
{
postDebug("Writing ProcessMessage for EVENT Case");
document.write('      case "EVENT":                               ');
document.write('         MediaPlayer_ScriptCommand(command, data);');
document.write('         break;                                   ');
}

//case of default catches unknown Messages
postDebug("Writing ProcessMessage for default Case");
document.write('      default:                                    ');
document.write('   }                                              ');
document.write('}                                                 ');

/****************************************************************************************
Dynamically write updateStatusMessage function to actually execute if field is present
****************************************************************************************/
document.write('function updateStatusMessage(message)                                ');
document.write('{                                                                    ');

if(bNetscape) //uses updateLayer()
   if (document.statusMessage != null)
      document.write('window.setTimeout( updateLayer, 100, "statusMessage", message);');
   else;
else if (window.statusMessage != null) //not Netscape, check for statusMessage
      document.write('statusMessage.innerText=message;                               ');

document.write('}                                                                    ');

/****************************************************************************************
Dynamically write updateTitle function to actually execute if field is present
****************************************************************************************/
document.write('function updateTitle(newTitle)                                       ');
document.write('{                                                                    ');

if(bNetscape) //uses updateLayer()
   if (document.title != null)
      document.write('window.setTimeout( updateLayer, 100, "title", newTitle);       ');
   else;
else if (window.title != null) //not Netscape, check for title
   document.write('title.innerText=newTitle;                                         ');

document.write('}                                                                    ');
/****************************************************************************************
Dynamically write updateOwner function to actually execute if field is present
****************************************************************************************/
document.write('function updateOwner(newOwner)                                       ');
document.write('{                                                                    ');

if(bNetscape) //uses updateLayer()
   if (document.owner != null)
      document.write('window.setTimeout( updateLayer, 100, "owner", newOwner);       ');
   else;
else if (window.owner != null) //not Netscape, check for owner
   document.write('owner.innerText=newOwner;                                         ');

document.write('}                                                                    ');

/****************************************************************************************
Dynamically write showBuyMeButton function to actually execute if button is present
****************************************************************************************/
document.write('function showBuyMeButton(displayType)                      ');
document.write('{                                                          ');

if(bNetscape)
   
   if (document.buyButton != null)
   {
      document.write('if (displayType == "visible")                        ');
      document.write('   NSdisplayType = "show";                           ');
      document.write('else                                                 ');
      document.write('   NSdisplayType = "hide";                           ');
      document.write('document.buyButton.visibility = NSdisplayType;       ');
   }
   else;

else if (document.buyMeBtn != null) 
   
   document.write('   document.all.buyMeBtn.style.visibility = displayType;');

document.write('}                                                          ');

/****************************************************************************************
DONE
****************************************************************************************/
//Close Script
document.write('</SCRIPT>');
}



function WriteBODYCode()
{
   WriteProcessFunctions();
   loadAttributeParser();
   if (window.WriteBODYCodeNEXT != null) 
      WriteBODYCodeNEXT();
}

function window_onload() 
{
	ActivateMediaPlayerObject();
   
   if (window.window_onloadNEXT != null) 
      window_onloadNEXT();
}

