//------------MBS JavaScript Collection----2008/12/02-------------------------------------------------------------------M*B*S--


// 1. Fusion Charts
// 2. Flash Player Version Detector - Rev 1.6
// 3. Flash IE7 Debugger
// 4. Tab Evevnts 2009.03.02
// 5. Flash IE7 Debugger - Transparent 2009.01.10



//==============================================  Fusion Chart  ================================================================

if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();
infosoftglobal.FusionCharts = function(swf, chartTitle, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){
  if (!document.getElementById) { return; }
  this.initialDataSet = false;
  this.params = new Object();
  this.variables = new Object();
  this.attributes = new Array();
  if(swf) { this.setAttribute('swf', swf); }
  if(chartTitle) { this.setAttribute('chartTitle', chartTitle); }
  if(id) { this.setAttribute('id', id); }
  if(w) { this.setAttribute('width', w); }
  if(h) { this.setAttribute('height', h); }
  if(c) { this.addParam('bgcolor', c); }
  this.addVariable('chartTitle', chartTitle);
  this.addParam('quality', 'high');
  this.addParam('allowScriptAccess', 'always');
  this.addVariable('chartWidth', w);
  this.addVariable('chartHeight', h);
  debugMode = debugMode ? debugMode : 0;
  this.addVariable('debugMode', debugMode);
  this.addVariable('DOMId', id);
  registerWithJS = registerWithJS ? registerWithJS : 0;
  this.addVariable('registerWithJS', registerWithJS);
  scaleMode = scaleMode ? scaleMode : 'noScale';
  this.addVariable('scaleMode', scaleMode);
  lang = lang ? lang : 'EN';
  this.addVariable('lang', lang);
  this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;
  this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;
  this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();

  if (!window.opera && document.all && this.installedVer.major > 7) {
    infosoftglobal.FusionCharts.doPrepUnload = true;
  }
}

infosoftglobal.FusionCharts.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  addParam: function(name, value){
    this.params[name] = value;
  },
  getParams: function(){
    return this.params;
  },
  addVariable: function(name, value){
    this.variables[name] = value;
  },
  getVariable: function(name){
    return this.variables[name];
  },
  getVariables: function(){
    return this.variables;
  },
  getVariablePairs: function(){
    var variablePairs = new Array();
    var key;
    var variables = this.getVariables();
    for(key in variables){
      variablePairs.push(key +"="+ variables[key]);
    }
    return variablePairs;
  },
  getSWFHTML: function() {
    var swfNode = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
      swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"  ';
      swfNode += ' chartTitle="'+ this.getAttribute('chartTitle') +' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
      var params = this.getParams();
      for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
      var pairs = this.getVariablePairs().join("&");
      if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
      swfNode += '/>';
    } else {
      swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
      swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
      swfNode += '<param name="chartTitle" value="'+ this.getAttribute('chartTitle') +'" />';
      var params = this.getParams();
      for(var key in params) {
        swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
      }
      var pairs = this.getVariablePairs().join("&");
      if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
      swfNode += "</object>";
    }
    return swfNode;

  },
  setDataURL: function(strDataURL){
    if (this.initialDataSet==false){
      this.addVariable('dataURL',strDataURL);
      this.initialDataSet = true;
    }else{
      var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
      chartObj.setDataURL(strDataURL);
    }
  },

//---------SetVariable---------------------------------M*B*S--
  setVari: function(strVari, varVari){

    this.addParam(strVari, varVari);
    this.addVariable(strVari, varVari);

  },
//=============================================================

  setDataXML: function(strDataXML){
    if (this.initialDataSet==false){
      this.addVariable('dataXML',strDataXML);
      this.initialDataSet = true;
    }else{
      var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
      chartObj.setDataXML(strDataXML);
    }
  },
  render: function(elementId){
    if((this.detectFlashVersion==1) && (this.installedVer.major < 6)){
      if (this.autoInstallRedirect==1){
        var installationConfirm = window.confirm("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");
        if (installationConfirm){
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
        }else{
          return false;
        }
      }else{
        return false;
      }
    }else{
      var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
      n.innerHTML = this.getSWFHTML();
      if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
        window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id'));
      return true;
    }
  }
}

/* ---- detection functions ---- */
infosoftglobal.FusionChartsUtil.getPlayerVersion = function(){
  var PlayerVersion = new infosoftglobal.PlayerVersion([0,0,0]);
  if(navigator.plugins && navigator.mimeTypes.length){
    var x = navigator.plugins["Shockwave Flash"];
    if(x && x.description) {
      PlayerVersion = new infosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
    }
  }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){
    var axo = 1;
    var counter = 3;
    while(axo) {
      try {
        counter++;
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
        PlayerVersion = new infosoftglobal.PlayerVersion([counter,0,0]);
      } catch (e) {
        axo = null;
      }
    }
  } else {
    try{
      var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
    }catch(e){
      try {
        var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
        PlayerVersion = new infosoftglobal.PlayerVersion([6,0,21]);
        axo.AllowScriptAccess = "always";
      } catch(e) {
        if (PlayerVersion.major == 6) {
          return PlayerVersion;
        }
      }
      try {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      } catch(e) {}
    }
    if (axo != null) {
      PlayerVersion = new infosoftglobal.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
    }
  }
  return PlayerVersion;
}
infosoftglobal.PlayerVersion = function(arrVersion){
  this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
  this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
  this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {
  var objects = document.getElementsByTagName("OBJECT");
  for (var i = objects.length - 1; i >= 0; i--) {
    objects[i].style.display = 'none';
    for (var x in objects[i]) {
      if (typeof objects[i][x] == 'function') {
        objects[i][x] = function(){};
      }
    }
  }
}
if (infosoftglobal.FusionCharts.doPrepUnload) {
  if (!infosoftglobal.unloadSet) {
    infosoftglobal.FusionChartsUtil.prepUnload = function() {
      __flash_unloadHandler = function(){};
      __flash_savedUnloadHandler = function(){};
      window.attachEvent("onunload", infosoftglobal.FusionChartsUtil.cleanupSWFs);
    }
    window.attachEvent("onbeforeunload", infosoftglobal.FusionChartsUtil.prepUnload);
    infosoftglobal.unloadSet = true;
  }
}
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
infosoftglobal.FusionChartsUtil.getChartObject = function(id)
{
  var chartRef=null;
  if (navigator.appName.indexOf("Microsoft Internet")==-1) {
    if (document.embeds && document.embeds[id])
      chartRef = document.embeds[id];
    else
      chartRef  = window.document[id];
  }
  else {
    chartRef = window[id];
  }
  if (!chartRef)
    chartRef  = document.getElementById(id);

  return chartRef;
}

infosoftglobal.FusionChartsUtil.updateChartXML = function(chartId, strXML){
  var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(chartId);
  chartObj.SetVariable("_root.dataURL","");
  chartObj.SetVariable("_root.isNewData","1");
  chartObj.SetVariable("_root.newData",strXML);
  chartObj.TGotoLabel("/", "JavaScriptHandler");
}
var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;
var updateChartXML = infosoftglobal.FusionChartsUtil.updateChartXML;
var FusionCharts = infosoftglobal.FusionCharts;

// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


//=========================================Flash Player Version Detection - Rev 1.6 ======================================
// 
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
  var version;
  var axo;
  var e;

  try {
    // version will be set for 7.X or greater players
    axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
    version = axo.GetVariable("$version");
    document.write(flashVer);
  } catch (e) {
  }

  if (!version)
  {
    try {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
      version = "WIN 6,0,21,0";
      axo.AllowScriptAccess = "always";
      version = axo.GetVariable("$version");

    } catch (e) {
    }
  }

  if (!version)
  {
    try {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
      version = axo.GetVariable("$version");
    } catch (e) {
    }
  }

  if (!version)
  {
    try {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
      version = "WIN 3,0,18,0";
    } catch (e) {
    }
  }

  if (!version)
  {
    try {
      axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      version = "WIN 2,0,0,11";
    } catch (e) {
      version = -1;
    }
  }

  return version;
}

function GetSwfVer(){
  var flashVer = -1;

  if (navigator.plugins != null && navigator.plugins.length > 0) {
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
      var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
      var descArray = flashDescription.split(" ");
      var tempArrayMajor = descArray[2].split(".");
      var versionMajor = tempArrayMajor[0];
      var versionMinor = tempArrayMajor[1];
      var versionRevision = descArray[3];
      if (versionRevision == "") {
        versionRevision = descArray[4];
      }
      if (versionRevision[0] == "d") {
        versionRevision = versionRevision.substring(1);
      } else if (versionRevision[0] == "r") {
        versionRevision = versionRevision.substring(1);
        if (versionRevision.indexOf("d") > 0) {
          versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
        }
      }
      var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;

    }
  }
  else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
  else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
  else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
  else if ( isIE && isWin && !isOpera ) {
    flashVer = ControlVersion();
  }
  return flashVer;
}

var reqMajorVer = 8;
var reqMinorVer = 0;
var reqRevision = 0;

function DetectFlashVer()
{
  versionStr = GetSwfVer();
  if (versionStr == -1 ) {
    return versionArray;
  } else if (versionStr != 0) {
    if(isIE && isWin && !isOpera) {
      // Given "WIN 2,0,0,11"
      tempArray         = versionStr.split(" ");
      tempString        = tempArray[1];
      versionArray      = tempString.split(",");
    } else {
      versionArray      = versionStr.split(".");
    }
    var versionMajor      = versionArray[0];
    var versionMinor      = versionArray[1];
    var versionRevision   = versionArray[2];
    if (versionMajor > parseFloat(reqMajorVer)) {
      return versionArray;
    } else if (versionMajor == parseFloat(reqMajorVer)) {
      if (versionMinor > parseFloat(reqMinorVer))
        return versionArray;
      else if (versionMinor == parseFloat(reqMinorVer)) {
        if (versionRevision >= parseFloat(reqRevision))
          return versionArray;
      }
    }
    return versionStr;
  }
}



/* Flash File Name */
function selectFile(flash6, flash8){
  var str = new String(DetectFlashVer());
  if (Number(str.substring(0,1))<6.1){
    return flash6;
  }
  else{
    return flash8;
  }

}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


//================================================== Flash IE7 Debugger =================================================
//

function flashdebugger(obj, wid, hei, trans, link, target){
  if (link == null) {
    link = ''
  }
  document.write('<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj'+Math.random(10000)+'" ');
  document.write('codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" ');
  document.write('border="0" width="'+wid+'" height="'+hei+'">');
  document.write('<param name="movie" value="'+obj+'">');
  document.write('<param name="quality" value="High">');
  document.write('<param name="allowScriptAccess" value="always">');

  if (trans == 'trans'){
    document.write('<param name=wmode value=transparent>');
  }
  if (link != ''){
    for (var i=0;i<=link.length;i++){
      if (link.slice(i-1, i)=="&"){
        var fs = link.slice(0, i-1);
        var es = link.slice(i, link.length);
        link = fs;
        link += '%26';
        link += es;
        //alert(link);
      }
    }
    document.write('<param name="link" value='+link+'"/>');
    document.write('<param name="target" value='+target+'"/>');
    document.write('<param name="flashvars" value="link='+link+'&target='+target+'" />');
  }


  document.write('<embed src="'+obj+'" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"');
  document.write('name="obj1" width="'+wid+'" height="'+hei+'" ');

  if (trans == 'trans'){
    document.write('wmode="transparent" ');
  }

  document.write('quality="High"></EMBED></object>');
}

// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


//================================================== Tab Events =================================================
//

function tab_click(obj, totalNumber){

  //	tabA_1 tabA_c1 tabA_c1div
  var objNameHeader = new String(obj.id.substr(0, 5));
  //	return tabA_
  var tabNumber = new Number(obj.id.charAt(5));
  //	return 1
  var tabID = new String('_'+obj.id.charAt(3));
  //	return -A for selected_A

  for (i=1; i<=totalNumber; i++){
    document.getElementById(objNameHeader+i).className = '';
    document.getElementById(objNameHeader+'c'+i+'div').className = '';
    document.getElementById(objNameHeader+'c'+i+'div').style.backgroundPosition = 'right';
    document.getElementById(objNameHeader+'c'+(i+1)+'div').className = '';
  }

  document.getElementById(obj.id).className = ' selected'+tabID;
  document.getElementById(objNameHeader+'c'+tabNumber+'div').className += ' selected'+tabID;
  document.getElementById(objNameHeader+'c'+tabNumber+'div').style.backgroundPosition = 'right';
  document.getElementById(objNameHeader+'c'+(tabNumber+1)+'div').className += ' selected'+tabID;
  document.getElementById(objNameHeader+'c'+(tabNumber+1)+'div').style.backgroundPosition = 'left';

}



// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^