//detection script lib
	var FlashVer = 0;
	var ShockWaveVer = 0;
	
function FlashShockwaveDetection() {  
//***************************
// A few variables to help figure out what platform we're on

var ie  = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
var ns  = (navigator.appName.toLowerCase().indexOf("netscape") != -1);
var win = (navigator.platform.toLowerCase().indexOf("win") != -1);
var mac = (navigator.platform.toLowerCase().indexOf("mac") != -1);
var browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) : navigator.appVersion);

	//alert (" ie ?: " + ie);
	//alert (" win ? :  " + win);
	
  if (ie && win) { // Use the active control parts
 		FlashVer = FlashDetectAxVer(); 	// Flash part detection 
		ShockWaveVer = shockwaveDetectAxVer(); 	// Shockwave detection.
  } else { //Netscape version  
		FlashVer = detectFlash(); 	// Flash part detection  
		ShockWaveVer = shockwaveDetectNsVer(); 	// Shockwave detection.  
  }

}

function detectFlash(){	

var flash2Installed = false;		// boolean. true if flash 2 is installed
var flash3Installed = false;		// boolean. true if flash 3 is installed
var flash4Installed = false;		// boolean. true if flash 4 is installed
var flash5Installed = false;		// boolean. true if flash 5 is installed
var flash6Installed = false;		// boolean. true if flash 6 is installed
var flash7Installed = false;		// boolean. true if flash 7 is installed
var flash8Installed = false;		// boolean. true if flash 8 is installed
var flash9Installed = false;		// boolean. true if flash 9 is installed
var maxVersion = 9;			// highest version we can actually detect
var actualVersion = 0;			// version the user really has
var hasRightVersion = false;		// boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;			// the version of javascript supported

	if (navigator.plugins){						// does navigator.plugins exist?
		if (navigator.plugins["Shockwave Flash 2.0"] 	// yes>> then is Flash 2 
		|| navigator.plugins["Shockwave Flash"]){		// or flash 3+ installed?
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

			// we know the version, now set appropriate version flags
			flash2Installed = flashVersion == 2;		
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion == 8;
			flash9Installed = flashVersion == 9;
		}
	}
	
	// loop through all versions we're checking, and set actualVersion to highest detected version
	for (var i = 2; i <= maxVersion; i++) {	
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}

	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;	
	return (actualVersion);
}

function shockwaveDetectAxVer(reqVer) {
  // this function should only be called from Internet Explorer for Windows
    for (i=8;i>0;i--) {
      versionString = VBGetShockwaveVer(i);
      if (versionString != "0.0") {
        // if we get 1.0 we assume it is actually 6.0
        versionNum = (versionString == "1.0" ? 6.0 : parseFloat(versionString))
        return (reqVer ? versionNum >= reqVer : versionNum);
      }
    }
  return (reqVer ? false : 0.0);
}

function FlashDetectAxVer() {
  // this function should only be called from Internet Explorer for Windows
	var versionString = 0.0;
    for (i=5;i>0;i--) {
      versionString = VBGetFlashVer(i);
      if (versionString != "0.0") {
        return versionString;
      }
    }
  return versionString;
}
//end browser detection

//start shockwave detection


function shockwaveDetectNsVer()
{
   // Set local variables to avoid crashing bug
   var thearray = navigator.plugins;
   var arraylength = thearray.length;

   for (i=0; i < arraylength; i++)
   {
      theplugin = thearray[i];            // Retrieve the plugin
      thename   = theplugin.name;         // Get the plugin name
      thedesc   = theplugin.description;  // Get the plugin description
      if (thedesc.indexOf("Shockwave") != -1 && thedesc.indexOf("Director") != -1)
      { 
         versionString = thedesc.substring(thedesc.indexOf("version ") + 8); 
         majorVersion = parseInt(versionString);
         return majorVersion;
      } 
   } 
   return 0;
}

function canDetectShockwave()
{
  // Determine the browser (IE or Netscape) using navigator.appName
  var ie = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
  var ns = (navigator.appName.toLowerCase().indexOf("netscape") != -1);

  // Determine the platform using navigator.platform
  var win = (navigator.platform.toLowerCase().indexOf("win") != -1);
  var mac = (navigator.platform.toLowerCase().indexOf("mac") != -1);

  // Determine the browser version
  var browserVer = parseFloat(ie ?
                     navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) :
                     navigator.appVersion);

  // Return the appropriate value based on the browser, version and platform
  if (ie && win) return (browserVer >= 4.0) // Works in Windows IE 4.0 and better
  if (ie && mac) return (browserVer >= 5.0) // Works in Mac IE 5.0 and better 
  if (ns)        return (browserVer >= 3.0) // Works in Netscape 3.0 and better

  // If none of the above conditions matched, the browser is
  // unknown and likely doesn't support detection
  return false;
}
//end shockwave detection


//Popup Window for FBTG


function openpopup(){
	var popurl="http://funbraintogo.com/ftg/get_parents/1,3903,87-29710,00.html?wtlAC=fb_kids,link-fb"
		winpops=window.open(popurl,"fbtg","width=507,height=336,")
}

//end popup for fbtg

function openStaticWindow(ThisURL,ThisWidth,ThisHeight){
  mypage = ''+ThisURL;
myname = "blank";
w = ThisWidth;
h = ThisHeight;
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+(wint-20)+',';
      settings +='left='+winl+',';
      settings +='scrollbars=yes,';
      settings +='resizable=yes';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


// Return query string portion of given URL
// Apply prefix to return value only if return value not zero length
function fb_getqstr(url, prefix)
{
  var parsed = url.split('?');
  var qstr_parms = '';
  if (parsed.length > 1)
    qstr_parms = parsed[1];
  if (prefix.length == 0)
    return qstr_parms;

  if (qstr_parms.length > 1)
    return prefix + qstr_parms;

  return '';
}

// Generate code to embed Flash movie.
// Arguments are
//	Movie URL
//	Object attributes (generally width & height)
//	Background color
function fb_openFlash(movie, attr, bgcolor, opacity)
{
 var codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0';
 var pluginspage = 'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash';

 document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
 document.write(' codebase="' + codebase + '" ' + attr + '>\n');
 document.write('<param name="movie" value="' + movie + '" />\n');
 document.write('<param name="quality" value="high">\n');
 document.write('<param name="bgcolor" value="' + bgcolor + '">\n');
 document.write('<param name="wmode" value="' + opacity + '">\n');
 document.write('<embed src="' + movie + '" quality="high" bgcolor="' + bgcolor + '" ' +
                  attr + 'type="application/x-shockwave-flash"' +
                  ' pluginspage="' + pluginspage + '">\n');
 document.write('</object>\n');
}

// Set up QueryString object
var fb_qstr = new Object();
fb_qstr.keys = new Array();
fb_qstr.values = new Array();

function fb_qstr_parse()
{
        var query = window.location.search.substring(1);
        var pairs = query.split("&");

        for (var i=0;i<pairs.length;i++)
        {
                var pos = pairs[i].indexOf('=');
                if (pos >= 0)
                {
                        var argname = pairs[i].substring(0,pos);
                        var value = pairs[i].substring(pos+1);
                        fb_qstr.keys[fb_qstr.keys.length] = argname;
                        fb_qstr.values[fb_qstr.values.length] = value;
                }
        }

}

// Get value from query string corresponding to given name
function fb_qstr_value(key)
{
	fb_qstr_parse();

        var value = null;
        for (var i=0;i<fb_qstr.keys.length;i++)
        {
                if (fb_qstr.keys[i]==key)
                {
                        value = fb_qstr.values[i];
                        break;
                }
        }
        return value;
}


// Allow for client 1x1 pixel tracking for games, brain game over logos, and specialized ads that can't do their own tracking
function loadTrackingPixel(URLtoTrigger)
{
	dcord = Math.random() * 100000000;
	dcpix = new Array();
	dcpix[0] = new Image();
	dcpix[0].src = URLtoTrigger;
}


// Write cookies (triggered from Flash)
function writeCookie() {

 	var today = new Date();
 	var expire = new Date();

 	expire.setTime(today.getTime() + 3600000*24*14);

	for(i=0;i<writeCookie.arguments.length;i++) {
		ckThing = writeCookie.arguments[i] + '=' + writeCookie.arguments[i+1]
		i++
		document.cookie = ckThing + '; path=/; expires=' + expire.toGMTString()
	}
}


// Get cookies for a Flash piece
function getCookiesForFlash() {
	cookString = "?" 
	// does the visitor have a cookie? 
	if(document.cookie != "") {
		theCook = document.cookie.split("; ")
		// add each part of the cookie to a string variable
		for (i = 0; i < theCook.length; i ++) {
			cookString += theCook[i] + "&"
		}
	}
}