// Flash version detector based on Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// Edited and adjusted for News.com by Bernie McGinn and Andrew Lottmann, 9/14/2006

var requiredVersion = 7;

function getFlashVersion() {
   var installedFlashVersion = 0;
   var latestFlashVersion = 9;
   var agent = navigator.userAgent.toLowerCase();

	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               installedFlashVersion = i;
               break;
            }
         }
		}
	}
	// IE4+ Win32:  attempt to create an ActiveX object without using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
		for (var i=latestFlashVersion; i>0; i--) {
			try {
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				installedFlashVersion = i;
				break;
			} catch(e){}
		}
	}

	// Ignoring all other cases
	else installedFlashVersion = -1;

	return installedFlashVersion;
}

function openBigPic(info) {
    var afterLoad = (info.complete) ? info.complete : function(){};
    var url='/'+info.pageType+'-'+info.nodeID+'_3-'+info.assetID+'.html';
    new ajax(url,{
    	method:'get',
    	update: 'bigPic',
    	fireNow: false,
    	onComplete: afterLoad
    }).request();
}

function getBigPic(info) {
   info.pageType = (info.pageType) ? info.pageType : 2244;
   info.nodeID = (info.nodeID) ? info.nodeID : 12;
   if (neGetCookie("isFlash7")) {
      openBigPic(info);
   } else {
      var flashVersion = getFlashVersion();
      if (flashVersion >= requiredVersion) {
         openBigPic(info);
         neSetCookie("isFlash7",1);
      } else {
         $("bigPic").innerHTML = '<div id="upgradeFlash"><h3>The Big Picture requires Flash version 7 or later.<\/h3><p>The Big Picture displays the relationship between the newsmakers, companies, and topics reported here at News.com. <a href="http:\/\/bigpicture.news.com\/" target="_blank">Learn more about the Big Picture.<\/a><\/p><p><a href="http:\/\/www.macromedia.com\/go\/getflashplayer">Please upgrade to the latest version of the Flash Player. <\/a><\/p><\/div>';
      }
   }
}

