// JavaScript Document
function handleError ( ) {
  return true;
}

window.onerror = handleError;

var hasFlash = function( ) {
  var a = 6;
  if ( navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1 ) {
    document.write( '<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n' );
    if ( window.hasFlash != null ) {
      return window.hasFlash;
    }
  }
  if( navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin ) {
    var b = ( navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"] ).description;
    return parseInt( b.charAt( b.indexOf( "." ) -1 ) ) >= a
  }
  return false
}

function rgbConvert ( myColor ) {
  if ( myColor.indexOf( "rgb") != -1 ) {
    myColor = myColor.replace( "rgb(", "" );
    myColor = myColor.replace( ")", "" );
    var k = 0;
    var RGB = new Array(256);
    var hex = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
    for ( var i = 0; i < 16; i++ ) {	
      for ( var j = 0; j < 16; j++ ) {		
        RGB[ k ] = String( String( hex[ i ] ) + ""+ String( hex[ j ] ) );
        k = parseInt( parseInt( k ) + 1 );
      }
    }
    var colorArray = myColor.split( "," ); 
    var R = colorArray[0];
    var G = colorArray[1];
    var B = colorArray[2];
    return ( ( String( String( RGB[ parseInt( R ) ] ) + ""+ String( RGB[ parseInt( G ) ] ) + ""+ String( RGB[ parseInt( B ) ] ) ) ).toUpperCase( ) );
  } else {
    return ( myColor.replace( "#", "" ).toUpperCase( ) );
  }
}

function replaceHeading ( htmltag ) {
  for ( var i = 0; i < document.getElementsByTagName( htmltag ).length; i++ ) {
    myValue = document.getElementsByTagName( htmltag )[i].innerHTML;
    var regExp=/<span[^>]*>/gi;
    myValue = myValue.replace( regExp, "<STRONG>" );
    var regExp=/<\/span>/gi;
    myValue = myValue.replace( regExp, "</STRONG>" );
    var regExp=/<b>/gi;
    myValue = myValue.replace( regExp, "<STRONG>" );
    var regExp=/<\/b>/gi;
    myValue = myValue.replace( regExp, "</STRONG>" );
    var regExp=/<strong>/gi;
    myValue = myValue.replace( regExp, "<STRONG>" );
    var regExp=/<\/strong>/gi;
    myValue = myValue.replace( regExp, "</STRONG>" );
    if ( myValue != undefined ) {
      if ( document.getElementsByTagName( htmltag )[i].className.indexOf( "flash" ) != -1 ) {
        flashurl = "../libraries/flash/flashVarsExTitle.swf";
        if ( document.getElementsByTagName( htmltag )[i].style.color ) {
          myColor = rgbConvert ( String( document.getElementsByTagName( htmltag )[i].style.color ) );
        } else {
          myColor = "000000";
        }
        myObj = document.getElementsByTagName( htmltag )[i];
        myParent = myObj.parentNode;
        width = myObj.offsetWidth;
        height = myObj.offsetHeight;
        myFlash = (
           '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" id="myTitle" align="middle" title="' + myValue + '">'
         +'  <param name="allowScriptAccess" value="sameDomain" />'
         +'  <param name="wmode" value="transparent" />'
         +'  <param name="movie" value="' + flashurl +'" />'
         +'  <param name="FlashVars" value="myTitle=' + myValue + '&myColor=0x' + myColor + '" />'
         +'  <param name="quality" value="high" />'
         +'  <param name="scale" value="noscale" />'
         +'  <param name="salign" value="lt" />'
         +'  <param name="bgcolor" value="#FFFFFF" />'
         +'  <embed'
         +'    src="' + flashurl +'" '
         +'    FlashVars="myTitle=' + myValue + '&myColor=0x' + myColor + '" '
         +'    quality="high" '
         +'    wmode="transparent" '
         +'    scale="noscale" '
         +'    salign="lt" '
         +'    bgcolor="#91A80C" '
         +'    width="' + width + '" '
         +'    height="' + height + '" '
         +'    name="myTitle" '
         +'    align="middle" '
         +'    allowScriptAccess="sameDomain" '
         +'    type="application/x-shockwave-flash" '
         +'    pluginspage="http://www.macromedia.com/go/getflashplayer"'
         +'  />'
         +'</object>'
        );
        replaceDiv = document.createElement('div');
        replaceDiv.innerHTML = myFlash;
        replaceDiv.style.margin = "0px 0px 0px 0px";
        replaceDiv.style.padding = "0px 0px 0px 0px";
        myParent.replaceChild( replaceDiv, myObj );
        i--;
      } else if ( document.getElementsByTagName( htmltag )[i].className.indexOf( "listtitle" ) != -1 ) {
        flashurl = "../libraries/flash/flashVarsExList.swf";
        if ( document.getElementsByTagName( htmltag )[i].style.color ) {
          myColor = rgbConvert ( String( document.getElementsByTagName( htmltag )[i].style.color ) );
        } else {
          myColor = "000000";
        }
        myObj = document.getElementsByTagName( htmltag )[i];
        myParent = myObj.parentNode;
        width = myObj.offsetWidth;
        height = myObj.offsetHeight;
        myFlash = (
           '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '" id="myTitle" align="middle" title="' + myValue + '">'
         +'  <param name="allowScriptAccess" value="sameDomain" />'
         +'  <param name="wmode" value="transparent" />'
         +'  <param name="movie" value="' + flashurl +'" />'
         +'  <param name="FlashVars" value="myTitle=' + myValue + '&myColor=0x' + myColor + '" />'
         +'  <param name="quality" value="high" />'
         +'  <param name="scale" value="noscale" />'
         +'  <param name="salign" value="lt" />'
         +'  <param name="bgcolor" value="#FFFFFF" />'
         +'  <embed'
         +'    src="' + flashurl +'" '
         +'    FlashVars="myTitle=' + myValue + '&myColor=0x' + myColor + '" '
         +'    quality="high" '
         +'    wmode="transparent" '
         +'    scale="noscale" '
         +'    salign="lt" '
         +'    bgcolor="#91A80C" '
         +'    width="' + width + '" '
         +'    height="' + height + '" '
         +'    name="myTitle" '
         +'    align="middle" '
         +'    allowScriptAccess="sameDomain" '
         +'    type="application/x-shockwave-flash" '
         +'    pluginspage="http://www.macromedia.com/go/getflashplayer"'
         +'  />'
         +'</object>'
        );
        replaceDiv = document.createElement('div');
        replaceDiv.innerHTML = myFlash;
        replaceDiv.style.margin = "0px 0px 0px 0px";
        replaceDiv.style.padding = "0px 0px 0px 0px";
        myParent.replaceChild( replaceDiv, myObj );
        i--;
      }
    }
  }
}

if ( hasFlash( ) && document.getElementsByTagName ) {
  replaceHeading( "div" );
}