// added David [N4B] - for incontext editing and general usefulness
	//override the default error handler

//	window.onerror = handleError;
//	function handleError() {
//		return true;
//	}

// Netscape 4 ignores stylesheets on reload. This rectifies it.   
NS4 = document.layers;
if (NS4) {
   origWidth = innerWidth;
   origHeight = innerHeight;
}


// Change the windowLocation
function gotoURL(url){
	switch(url) {
		case "reactor" :
			window.location="/products/the-reactor/the-reactor.cfm";
			break;	
		case "valseg" :
			window.location="/products/values-segments/values-segments.cfm";
			break;
		case "ast" :
			window.location="/products/asteroid/asteroid.cfm";
			break;
		case "ss" :
			window.location="/products/single-source/single-source_home.cfm";
			break;
		case "broadband" :
			window.location="/products/broadband-report/broadband-report_home.cfm";
			break;
		case "fmcg" :
			window.location="/industries/fmcg.cfm";
			break;
		case "gambling" :
			window.location="/industries/gambling.cfm";
			break;
		case "media" :
			window.location="/industries/media.cfm";
			break;
		case "finance" :
			window.location="/industries/finance.cfm";
			break;
		case "beverage" :
			window.location="/industries/beverages.cfm";
			break;
		case "customised" :
			window.location="/services/customised-research.cfm";
			break;
		case "automotive" :
			window.location="/industries/automotive.cfm";
			break;
	}
}

function reDo() {
   if (innerWidth != origWidth || innerHeight != origHeight)
      location.reload();
}
if (NS4) onresize = reDo;
   
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
   
	function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	 	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	 	obj.visibility=v; }
	}

function popupWindow(url) {
	window.open(url,"new_window","toolbar=no,width=580,height=500");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_executeFlashDispatcher(){
  var args = MM_executeFlashDispatcher.arguments;
  MM_FlashDispatch(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
}

// Netscape 4 ignores stylesheets on reload. This rectifies it.   
   NS4 = document.layers;
   if (NS4) {
      origWidth = innerWidth;
      origHeight = innerHeight;
   }
   function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
         location.reload();
   }
   if (NS4) onresize = reDo;
   //-->
var MM_FlashSnifferURL = "detectFlash.swf";
var MM_latestPluginRevision = new Object();
MM_latestPluginRevision["5.0"] = new Object();
MM_latestPluginRevision["4.0"] = new Object();
MM_latestPluginRevision["3.0"] = new Object();
MM_latestPluginRevision["2.0"] = new Object();
MM_latestPluginRevision["5.0"]["Windows"] = 30;
MM_latestPluginRevision["5.0"]["Macintosh"] = 30;
MM_latestPluginRevision["4.0"]["Windows"] = 28;
MM_latestPluginRevision["4.0"]["Macintosh"] = 27;
MM_latestPluginRevision["4.0"]["Unix"] = 12;
MM_latestPluginRevision["3.0"]["Windows"] = 10;
MM_latestPluginRevision["3.0"]["Macintosh"] = 10;
MM_latestPluginRevision["2.0"]["Windows"] = 11;
MM_latestPluginRevision["2.0"]["Macintosh"] = 11;
var MM_FlashControlInstalled;	// is the Flash ActiveX control installed?
var MM_FlashControlVersion;	// ActiveX control version if installed
function MM_FlashInfo()
{
    if (navigator.plugins && navigator.plugins.length > 0)
    {
	this.implementation = "Plug-in";
	this.autoInstallable = false;	// until Netscape SmartUpdate supported

	if (navigator.plugins["Shockwave Flash"])
	{
	    this.installed = true;
	    var words =
		navigator.plugins["Shockwave Flash"].description.split(" ");

	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;

		this.version = words[i];

		this.revision = parseInt(words[i + 1].substring(1));
	    }
	}
	else
	{
	    this.installed = false;
	}
    }
    else if (MM_FlashControlInstalled != null)
    {
	this.implementation = "ActiveX control";
	this.installed = MM_FlashControlInstalled;
	this.version = MM_FlashControlVersion;
	this.autoInstallable = true;
    }
    else if (MM_FlashDetectedSelf())
    {
	this.installed = true;
	this.implementation = "Plug-in";
	this.autoInstallable = false;
    }

    this.canPlay = MM_FlashCanPlay;
}

var MM_FlashPluginsPage = "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";

function MM_FlashDispatch(contentURL, contentVersion, requireLatestRevision,
			  upgradeURL, install, installURL, altURL,
			  overridePluginsPage)
{
    if (overridePluginsPage == null)
    {
	alert("ERROR: MM_FlashDispatch() called with too few arguments.");
	return;
    }


    if (overridePluginsPage && installURL.substring(0, 7) != "http://")
    {
	alert("ERROR: MM_FlashDispatch() called with relative URL" +
	    " for PLUGINSPAGE (" + installURL + ")");

	return;
    }


    var player = new MM_FlashInfo();

    if (player.installed == null)
    {
	var sniffer =
	    "<EMBED HIDDEN=\"true\" TYPE=\"application/x-shockwave-flash\"" +
		  " WIDTH=\"18\" HEIGHT=\"18\"" +
		  " BGCOLOR=\"" + document.bgcolor + "\"" +
		  " SRC=\"" + MM_FlashSnifferURL +
			"?contentURL=" + contentURL + "?" +
			"&contentVersion=" + contentVersion +
			"&requireLatestRevision=" + requireLatestRevision +
			"&latestRevision=" +
			    MM_FlashLatestPluginRevision(contentVersion) +
			"&upgradeURL=" + upgradeURL +
			"\"" +
		  " LOOP=\"false\" MENU=\"false\"" +
		  " PLUGINSPAGE=\"" +
		    (overridePluginsPage ? installURL : MM_FlashPluginsPage) +
		    "\"" +
	    ">" +
	    "</EMBED>";

	document.open();
	document.write("<HTML><TITLE>");
	document.write("Checking for the Flash Player");
	document.write("</TITLE>");
	document.write("<BODY BGCOLOR=\"" + document.bgcolor + "\">");
	document.write(sniffer);
	document.write("</BODY>");
	document.write("</HTML>");
	document.close();
    }
    else if (player.installed)
    {
	if (player.canPlay(contentVersion, requireLatestRevision))
	{
	    location = contentURL;
	}
	else
	{
	    location = player.autoInstallable ? contentURL : upgradeURL;
	}
    }
    else if (install)
    {
	location = player.autoInstallable ? contentURL : installURL;
    }
    else
    {
	location = altURL;
    }
}
function MM_FlashRememberIfDetectedSelf(count, units)
{

    if (document.location.search.indexOf("?") != -1)
    {
	if (!count) count = 60;
	if (!units) units = "days";

	var msecs = new Object();

	msecs.minute = msecs.minutes = 60000;
	msecs.hour = msecs.hours = 60 * msecs.minute;
	msecs.day = msecs.days = 24 * msecs.hour;

	var expires = new Date();

	expires.setTime(expires.getTime() + count * msecs[units]);

	document.cookie =
	    'MM_FlashDetectedSelf=true ; expires=' + expires.toGMTString();
    }
}



function MM_FlashDemur(count, units)
{
    if (!count) count = 60;
    if (!units) units = "days";

    var msecs = new Object();

    msecs.minute = msecs.minutes = 60000;
    msecs.hour = msecs.hours = 60 * msecs.minute;
    msecs.day = msecs.days = 24 * msecs.hour;

    var expires = new Date();

    expires.setTime(expires.getTime() + count * msecs[units]);

    document.cookie =
	'MM_FlashUserDemurred=true ; expires=' + expires.toGMTString();


    if (!MM_FlashUserDemurred())
    {
	alert("Your browser must accept cookies in order to " +
	      "save this information.  Try changing your preferences.");

	return false;
    }
    else
	return true;
}

function MM_FlashUserDemurred()
{
    return (document.cookie.indexOf("MM_FlashUserDemurred") != -1);
}

function MM_FlashLatestPluginRevision(playerVersion)
{
    var latestRevision;
    var platform;

    if (navigator.appVersion.indexOf("Win") != -1)
	platform = "Windows";
    else if (navigator.appVersion.indexOf("Macintosh") != -1)
	platform = "Macintosh";
    else if (navigator.appVersion.indexOf("X11") != -1)
	platform = "Unix";

    latestRevision = MM_latestPluginRevision[playerVersion][platform];

    return latestRevision;
}

function MM_FlashCanPlay(contentVersion, requireLatestRevision)
{
    var canPlay;

    if (this.version)
    {
	canPlay = (parseInt(contentVersion) <= this.version);

	if (requireLatestRevision)
	{
	    if (this.revision &&
		this.revision < MM_FlashLatestPluginRevision(this.version))
	    {
		canPlay = false;
	    }
	}
    }
    else
    {
	canPlay = MM_FlashDetectedSelf();
    }

    return canPlay;
}

function MM_FlashDetectedSelf()
{
    return (document.cookie.indexOf("MM_FlashDetectedSelf") != -1);
}

// ------------------------------------------------------------------------
// rmk http://www.roymorgan.com/index.cfm?3AD0BE9B-1143-337D-B43F-D02D207A4416

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}