//CURRENT NEWSLETTER POPUP
function getParameter( parameterName ) {
  var queryString = window.location.search.substring(1).toLowerCase();
  //alert(queryString);
  //if (queryString.length==0) {return "null";}
  var parameters = new Array();
  parameters = queryString.split('&');
  for(var i = 0; i < parameters.length; i++) {
    //alert(parameters[i]);
    //alert(parameters[i].indexOf(parameterName));
    if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {
      //alert(parameters[i]);
      var parameterValue = new Array();
      parameterValue = parameters[i].split('=');
      return parameterValue[1];
    }
  }
  return "null";
}


function currentNewsletter(location) {
	
	var currentNewsletter = "insights_JAN-2010.html";
	
	if (location == "homePage") {
		url = "newsletters/"+currentNewsletter;
	} else {
		url = "../newsletters/"+currentNewsletter;
	}
	
	winLocX=screen.width/2-660/2;
	winLocY=60;
	win = window.open(url,'insightsWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,menu=0,width=800,height=600,screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
	win.focus();
	
}


//POPUP FUNCTION
function openPopup(url,theWidth,theHeight) {
	winLocX=screen.width/2-theWidth/2;
	winLocY=60;
	window.open(url,'popUpWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,menu=0,width='+theWidth+',height='+theHeight+',screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
}


//POPUP FUNCTION
function openVideo() {
	winLocX=screen.width/2-486/2;
	winLocY=60;
	window.open('video/movie.html','Vidwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,menu=0,width=486,height=409,screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
}

function openVideo2(vidLink) {
	winLocX=screen.width/2-486/2;
	winLocY=60;
	window.open(vidLink,'Vidwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,menu=0,width=486,height=409,screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
}


function tellAFriend() {
	winLocX=screen.width/2-410/2;
	winLocY=60;
	window.open('tell_a_friend.htm','TAFWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,menu=0,width=529,height=410,screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
}


function tellAFriendFromHomePage() {
	winLocX=screen.width/2-410/2;
	winLocY=60;
	window.open('news_articles/tell_a_friend.htm','TAFWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,menu=0,width=529,height=410,screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
}


//FORM VALIDATION
function formSubmit() {
	var f = document.forms.form1;
	var err = "";
		
	if (f.First_Name.value.search(/\S/) == -1) {
		err += "Please enter your first name.\n";
	}
	
	if (f.Last_Name.value.search(/\S/) == -1) {
		err += "Please enter your last name.\n";
	}
	
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;	

	if (f.Email.value.search(/\S/) == -1) {
		err += "Please enter your email address.\n";
	}
	else {
		if(((f.Email.value.search(exclude) != -1)||(f.Email.value.search(check)) == -1)||(f.Email.value.search(checkend) == -1)) {
			err +="Please enter a valid email address.\n";
		}
	}
	
	if (err == "") {
		f.submit();
	} else {
		alert(err);
	}
}


//TELL A FRIEND FORM VALIDATION
function formTAFSubmit() {
	var f = document.forms.form1;
	var err = "";
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;
	
	if (f.Recip_Name.value.search(/\S/) == -1) {
		err += "Please enter the recipient's name.\n";
	}
	
	if (f.Recip_Email.value.search(/\S/) == -1) {
		err += "Please enter the recipient's email address.\n";
	}
	else {
		if(((f.Recip_Email.value.search(exclude) != -1)||(f.Recip_Email.value.search(check)) == -1)||(f.Recip_Email.value.search(checkend) == -1)) {
			err +="Please enter a valid email address for the recipient.\n";
		}
	}
		
	if (f.Your_Name.value.search(/\S/) == -1) {
		err += "Please enter your name.\n";
	}
	
	if (f.Email.value.search(/\S/) == -1) {
		err += "Please enter your email address.\n";
	}
	else {
		if(((f.Email.value.search(exclude) != -1)||(f.Email.value.search(check)) == -1)||(f.Email.value.search(checkend) == -1)) {
			err +="Please enter a valid email address.\n";
		}
	}
	
	if (err == "") {
		f.submit();
	} else {
		alert(err);
	}
}





//NEWSLETTER POPUP - from news & articles page
function popLetter() {
	var f = document.forms.f3;
	var url = f.newsletter.options[f.newsletter.selectedIndex].value;
	winLocX=screen.width/2-660/2;
	winLocY=60;
	win = window.open(url,'insightsWin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,menu=0,width=660,height=600,screenx='+winLocX+',screeny='+winLocY+',left='+winLocX+',top='+winLocY);
	f.newsletter.selectedIndex = 0;
	win.focus();
}

//NEWSLETTER POPUP - from newsletters
function changeLetter() {
	var f = document.forms.f3;
	var url = f.newsletter.options[f.newsletter.selectedIndex].value;
	location.href = '../'+url;
}


//QUOTES
var texts = new Array(
'"I was able to try, experiment what I had been taught in a safe and supportive environment."<BR><BR><I>Air Canada Technical Services, Consultative Selling Skills</I>',
'"It made me understand the value of communication and brought the idea of not selling but helping to buy."<BR><BR><I>Air Canada Technical Services, Consultative Selling Skills</I>',
'"Very positive attitude! You did a great job of engaging a not so enthusiastic Friday morning crowd. You made it relevant to all of us. Thank you!"<BR><BR><I>Gowlings, Business Development Skills</I>',
'"Helped bring to light many aspects of communication that I previously took for granted."<BR><BR><I>Gowlings, Business Development Skills</I>',
'"Great progression of content, it was easy to follow and very helpful."<BR><BR><I>AUDIENCE, Negotiation Skills</I>',
'"It was both active and interactive and I never got bored!<BR><BR><I>J&J Women\'s Health, Influencing Doctors</I>"',
'"I liked the facilitator\'s ability to apply to this session to what we have already learned from previous training."<BR><BR><I>J&J Women\'s Health, Influencing Doctors</I>',
'"Made me aware of the areas where I was wasting my time and where I would be better suited to allocate my time."<BR><BR><I>St. Jude Medical, Strategic Account Management</I>',
'"Today\'s session created new tangible action steps to help me reach specific goals."<BR><BR><I>St. Jude Medical, Strategic Account Management</I>',
'"This is the best sales exercise I have ever experienced. Very focused, well organized and it ended with a terrific account plan. Great job!"<BR><BR><I>St. Jude Medical, Strategic Account Management</I>',
'"Well done, well thought out! The facilitator\'s knowledge of our business is impressive. It\'s nice that you keep us on our toes!"<BR><BR><I>St. Jude Medical, Strategic Account Management</I>',
'"It helped me to notice my technique and force me to try to change them into something positive."<BR><BR><I>Vision Group, Business Development Skills</I>',
'"Working together on everyone\'s issues helped me understand problems faced by both sides of the office."<BR><BR><I>OLA (Ontario Library Association), Consultative Selling Skills</I>',
'"Teaching me the ability to watch others and to learn from them allowed me to see where improvement is needed."<BR><BR><I>OLA (Ontario Library Association), Consultative Selling Skills</I>');

var texts2 = new Array(
'"The purpose of education is to replace an empty mind with an open one."<BR><BR><I>-Malcolm Forbes</I>',
'"If you think education is expensive, try ignorance."<BR><BR><I>-Derek Bok</I>',
'"The widest mind has something to learn."<BR><BR><I>-George Santayana</I>',
'"I am always willing to learn, however I do not always like to be taught."<BR><BR><I>-Winston Churchill</I>',
'"Learning is not attained by chance, it must be sought for with ardour and attended to with diligence."<BR><BR><I>-Abigail Adams</I>',
'"That is what learning is. You suddenly understand something you\'ve understood all your life, but in a new way."<BR><BR><I>-Doris Lessing</I>',
'"I hear and I forget.<BR>I see and I remember.<BR>I do and I understand."<BR><BR><I>-Confucious</I>',
'"Learning is not compulsory... neither is survival."<BR><BR><I>-W. Edwards Deming</I>',
'"All it takes is one match to light a forest fire."<BR><BR><I>-Anonymous</I>',
'"Knowing is not enough, we must apply. Willing is not enough, we must do."<BR><BR><I>-Goethe</I>');

var bgcolor = "#FFFFFF"; // background color, must be valid browser hex color (not color names)
var fcolor = "#FFFFFF";  // foreground or font color
var steps = 20; // number of steps to fade
var show = 5000; // milliseconds to display message
var sleep = 10; // milliseconds to pause inbetween messages
var loop = true; // true = continue to display messages, false = stop at last message

// Do Not Edit Below This Line
var colors = new Array(steps);
getFadeColors(bgcolor,fcolor,colors);
var color = 0;
var step = 1;
var p = 0;

// fade: magic fader function
function fade(text) {

//var text = 0;
// insert fader color into message
var text_out = texts[text].replace("{COLOR}", colors[color]); // texts should be defined in user script, e.g.: var texts = new Array("<font color='{COLOR}' sized='+3' face='Arial'>howdy");

// actually write message to document
if (document.all) fader.innerHTML = text_out; // document.all = IE only
if (document.getElementById("fader")) document.getElementById("fader").innerHTML = text_out; // NS 6+
if (document.layers) { document.fader.document.write(text_out); document.fader.document.close(); } // document.layers = Netscape only

// select next fader color
color += step; 

// completely faded in?
if (color >= colors.length-1) {
step = -1; // traverse colors array backward to fade out

// stop at last message if loop=false
if (!loop && text >= texts.length-1) return; // loop should be defined in user script, e.g.: var loop=true;
}

// completely faded out?
if (color == 0) {
step = 1; // traverse colors array forward to fade in again

// select next message
text += 1;
if (text == texts.length) text = 0; // loop back to first message
}
p = text;
// subtle timing logic...
setTimeout("fade(p);", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
}

function fade2(text) {

//var text = 0;
// insert fader color into message
var text_out = texts2[text].replace("{COLOR}", colors[color]); // texts should be defined in user script, e.g.: var texts = new Array("<font color='{COLOR}' sized='+3' face='Arial'>howdy");

// actually write message to document
if (document.all) fader.innerHTML = text_out; // document.all = IE only
if (document.getElementById("fader")) document.getElementById("fader").innerHTML = text_out; // NS 6+
if (document.layers) { document.fader.document.write(text_out); document.fader.document.close(); } // document.layers = Netscape only

// select next fader color
color += step; 

// completely faded in?
if (color >= colors.length-1) {
step = -1; // traverse colors array backward to fade out

// stop at last message if loop=false
if (!loop && text >= texts2.length-1) return; // loop should be defined in user script, e.g.: var loop=true;
}

// completely faded out?
if (color == 0) {
step = 1; // traverse colors array forward to fade in again

// select next message
text += 1;
if (text == texts2.length) text = 0; // loop back to first message
}
p = text;
// subtle timing logic...
setTimeout("fade2(p);", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
}

// getFadeColors: fills Colors (predefined Array)
// with color hex strings fading from ColorA to ColorB

// note: Colors.length equals the number of steps to fade
function getFadeColors(ColorA, ColorB, Colors) {
len = Colors.length; 

// strip '#' signs if present 
if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);

// substract rgb compents from hex string 
var r = HexToInt(ColorA.substring(0,2));
var g = HexToInt(ColorA.substring(2,4));
var b = HexToInt(ColorA.substring(4,6));
var r2 = HexToInt(ColorB.substring(0,2));
var g2 = HexToInt(ColorB.substring(2,4));
var b2 = HexToInt(ColorB.substring(4,6));

// calculate size of step for each color component
var rStep = Math.round((r2 - r) / len);
var gStep = Math.round((g2 - g) / len);
var bStep = Math.round((b2 - b) / len);

// fill Colors array with fader colors
for (i = 0; i < len-1; i++) {
Colors[i] = "#" + IntToHex(r) + IntToHex(g) + IntToHex(b);
r += rStep;
g += gStep;
b += bStep;
}
Colors[len-1] = ColorB; // make sure we finish exactly at ColorB
}

// IntToHex: converts integers between 0-255 into a two digit hex string.
function IntToHex(n) {
var result = n.toString(16);
if (result.length==1) result = "0"+result;
return result;
}

// HexToInt: converts two digit hex strings into integer.
function HexToInt(hex) {
return parseInt(hex, 16);
}




// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
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;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	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];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------
// -->


