/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.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 _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,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");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

/* document.getElementsBySelector(selector)
   - returns an array of element objects from the current document
     matching the CSS selector. Selectors can contain element names, 
     class names and ids and can be nested. For example:
     
       elements = document.getElementsBySelect('div#main p a.external')
     
     Will return an array of all 'a' elements with 'external' in their 
     class attribute that are contained inside 'p' elements that are 
     contained inside the 'div' element which has id="main"

   New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
   See http://www.w3.org/TR/css3-selectors/#attribute-selectors

   Version 0.4 - Simon Willison, March 25th 2003
   -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
   -- Opera 7 fails 
*/

function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
  // Attempt to fail gracefully in lesser browsers
  if (!document.getElementsByTagName) {
    return new Array();
  }
  // Split selector in to tokens
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
      continue; // Skip to next token
    }
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}

/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
  \---/  \---/\-------------/    \-------/
    |      |         |               |
    |      |         |           The value
    |      |    ~,|,^,$,* or =
    |   Attribute 
   Tag
*/


//PSCRAT.JS

/* MISC FUNCTIONS */
function doUnload(webpath, cmpy_cd) {
	if (event.clientY < 0) {
		window.open(webpath + 'form_templates/exit_survey.cfm?cmpy_cd=' + cmpy_cd, 'exit_survey', 'height=400,width=400,scrollbars=yes,location=no,status=no,resizeable=no');
	}
}

function hideSubs() {
	document.getElementById("curriculum_rollover").style.display='none';
	document.getElementById("assessment_rollover").style.display='none';
	document.getElementById("se_info_rollover").style.display='none';
	document.getElementById("ed_learning_rollover").style.display='none';
	document.getElementById("fam_learning_rollover").style.display='none';
	document.getElementById("curriculum_early_rollover").style.display='none';
	document.getElementById("curriculum_elem_rollover").style.display='none';
	document.getElementById("curriculum_second_rollover").style.display='none';
	document.getElementById("assessment_early_rollover").style.display='none';
	document.getElementById("assessment_individual_rollover").style.display='none';
	document.getElementById("ed_professional_rollover").style.display='none';
}

function showSub(subname) {
	document.getElementById(subname + "_rollover").style.display='block';
}

function checkMouse(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY')
		reltg= reltg.parentNode
	if (reltg== tg) return;

	hideSubs();
}

function hideSelect()
{if (document.all){document.all.searchpageselect.style.visibility="hidden";}}

function unhideSelect()
{if (document.all){document.all.searchpageselect.style.visibility="visible";}}


/* Used by Main Navigation drop downs to simulate Hover on an A tag */
sfHover = function() {

	var sfEls = document.getElementById("nav").getElementsByTagName("LI");	
	for (var i=0; i<sfEls.length; i++) {	
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}			
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

//if (window.attachEvent) window.attachEvent("onload", sfHover);


/* IMAGE RELATED CODE */

/* Exchanges Broken images with a hidden alternate and Switches the blank image to a missing image image - Used with PMDb */
function UpdateBrokenImages(img, imgAlt, errorImg) {

	if (typeof errorImg == "undefined") { errorImg = 'http://assets.pearsonschool.com/acornImages/imgNAThumb.gif'; };

	if(imgAlt) {
		img.hide();
		imgAlt.show();
	}

	img.src = errorImg;

	/* Suppress any further onerror errors if the missing image isn't available */
	img.onerror=null;
}



/* PRODUCT RELATED CODE */

// Used to open and close product descriptions.
function descriptionUpDown(obj) {

	Effect.toggle(obj, 'slide', {duration:0.5, queue: {position:'end', scope: 'eventDropDown', limit:3}});
}



// Used to filter the component product list.
function ProductFilter() {

	this.productFilterList = new Array(); // Contains the classes of all the filters we want to see

	this.toggleFilter = function(criteria) {



		// Loop through filters, to see if the new filter has already been selected or not.

		var foundCriteria = false;

		var criteriaIndex = "";



		for(var i = 0; i < this.productFilterList.length; i++) {

				// If filter is in array, then remember where.

				if (this.productFilterList[i] == criteria) {

					foundCriteria = true;
					criteriaIndex = i;

				}

		}

		// If filter already in array, remove it.

		if(foundCriteria) {

			this.productFilterList.splice(criteriaIndex,1);

			$(criteria).removeClassName('selectedFilter');

		// Else add filter to array.

		} else {

			this.productFilterList.push(criteria);

			$(criteria).addClassName('selectedFilter');

		}


		// If no filters chosen, then show all products.

		if (this.productFilterList.length == 0) {

			// Show all products

			var arrayOfProducts = $$('.prodFilters');

			for(var i = 0; i < arrayOfProducts.length; i++) {

					arrayOfProducts[i].show();

			}

		// Else hide all products, then show the ones with the selected filters.

		} else {

			// Hide all products

			var arrayOfProducts = $$('.prodFilters');

			for(var i = 0; i < arrayOfProducts.length; i++) {

					arrayOfProducts[i].hide();

			}

			// Show selected products

			for(var i = 0; i < this.productFilterList.length; i++) {

				var arrayOfProducts = $$('.' + this.productFilterList[i]);

				for(var j = 0; j < arrayOfProducts.length; j++) {

						arrayOfProducts[j].show();

				}

			}

		}


		return false;

	}
}



/* TABS */
/* PearsonSchool Tab controller: Requires Prototype */

/* 

CONFIGS

Four ways of configuring starting tab: 
1 - Tell it which tab to start on in URL. (Default true) 
	Prefers to use URL #name, but can use a querystring value. 
	Default Querystring variable name is tabId, or set your own. 
	(url: true, urlName: 'myUrlVariableName')
2 - Tell it which tab to start on using previously set cookie. (Default false)
	Appends 'tab_' to cookie name. 
	A default cookie is set from Acorn URL variables: locator_PMDbProgramId.
	(cookie: true; cookieName: 'myCookie')
3 - Tell it which tab to start on in the Javascript. (Default false)
	(defaultTab: 'Tab_B')
4 - Default to a tab, which uses two methods:
	1 - Show First Tab (Default)
	2 - Show a random tab (random: true)

In addition you can make the tabs auto rotate using autoRotate. (Default false)
	(autoRotate: 10) - Will rotate to next tab ever 10 seconds.

HTML
	
<div id='tab_control'>
	<div class="tabs">
		<ul>
			<li><a href="#Tab_A"><span><span>Tab A</span></span></a></li>
			<li><a href="#Tab_B"><span><span>Tab B</span></span></a></li>
		</ul>
	</div>
	<div id="Tab_A" class="PS_tab_page">
		Content A
		<div class="clear">&nbsp;</div>
	</div>
	<div id="Tab_B" class="PS_tab_page">
		Content B
		<div class="clear">&nbsp;</div>
	</div>
</div>

<script language='JavaScript1.2'>
	myTab = new TabControl('tab_control', {url: false, urlName: false, cookie: false, cookieName: 'bob', random: false});
</script>


USEFUL EXTERNAL METHODS

showTab('TabName')
	Jumps to the secified tab. 
	Examples: 
		<p><a href="javascript:myTab.showTab('Tab_C');">Click for C</a></p>
		<p><a href="javascript:myTab.showTab('Tab_D');">Click for D</a></p>
		
nextTab()
	Jumps to the next tab.
	Example:
		<p><a href="javascript:myTab.nextTab();">Next Tab</a></p>
		
previousTab()
	Jumps to the previous tab.
	Example:
		<p><a href="javascript:myTab.previousTab();">Previous Tab</a></p>

autoRotate()
	Starts rotating (timing of rotation is set in config, but you can override here).
	Example:
		<p><a href="javascript:myTab.autoRotate();">Start Rotating</a></p>
		<p><a href="javascript:myTab.autoRotate(3);">Start rotating every 3 second</a></p>

autoRotateStop()
	Stops rotating. (can be combined with other commands, such as nextTab(), to cause rotation to stop.
	Example:
		<p><a href="javascript:myTab.autoRotateStop();">Stop Rotating</a></p>
		<p><a href="javascript:myTab.autoRotateStop();myTab.nextTab();">Next tab and stop rotating</a></p>

autoRotatePaused - Property
	1 = auto rotate is paused
	0 = auto rotate rotating
	
*/
	
TabControl = function(tabId, options) {

	this.tabId = tabId;

	this.divId = "#" + this.tabId; 	/* Create a CSS selector for the div that contains the tabs */
	
	this.tabList = $$(this.divId + ' div.tabs ul li a');	/* Get all divs with this CSS selector */
	
	/* Config Options defaulted for browsers that error is a variable is undefined */
	this.options = options;
	if (typeof this.options == "undefined") { this.options = []; };
	if (typeof this.options['url'] == "undefined") { this.options['url'] = true; };
	if (typeof this.options['urlName'] == "undefined") { this.options['urlName'] = false; };
	if (typeof this.options['cookie'] == "undefined") { this.options['cookie'] = false; };
	if (typeof this.options['cookieName'] == "undefined") { this.options['cookieName'] = false; };
	if (typeof this.options['defaultTab'] == "undefined") { this.options['defaultTab'] = false; };
	if (typeof this.options['random'] == "undefined") { this.options['random'] = false; };
	if (typeof this.options['autoRotate'] == "undefined") { this.options['autoRotate'] = false; };
	if (typeof this.options['backgrounds'] == "undefined") { this.options['backgrounds'] = false; };

	this.defaultTab = this.options['defaultTab'];
	
	this.currentTab = "";
	
	this.cookieName = "";
	
	this.autoRotateDelay = false;
	
	this.autoRotatePaused = 1;	/* Is autoRotating paused (1 = paused, 0 = rotating)? */
	
	this.init = function() {
	
		var tempDefaultTab = false;

		var debugTracking = "";

		/* If Url enabled check for url based default. */
		if(this.options['url'] && !tempDefaultTab) {
			tempDefaultTab = this.getDefaultTabByUrl();
			debugTracking = debugTracking + " - Url Checked, result: " + tempDefaultTab;
		};
	
		/* If Cookies enabled check for cookie based default. */
		if(this.options['cookie'] && !tempDefaultTab) {
			tempDefaultTab = this.getDefaultTabByCookie();
			debugTracking = debugTracking + " - Cookie Checked, result: " + tempDefaultTab;
		};

		/* If Default Tab enabled. */
		if(this.options['defaultTab'] && !tempDefaultTab) {
			tempDefaultTab = this.getDefaultTabByConfig();
			debugTracking = debugTracking + " - Configured Tab Checked, result: " + tempDefaultTab;
		};
		
		/* If not got something - get something */
		if(!tempDefaultTab) {

			debugTracking = debugTracking + " - Resort to defaults";
			
			if(this.options['random']) {
				tempDefaultTab = this.getRandomTab();
				debugTracking = debugTracking + " - Random Tab, result: " + tempDefaultTab;
			} else {
				tempDefaultTab = this.getFirstTab();
				debugTracking = debugTracking + " - First Tab, result: " + tempDefaultTab;
			};

		};
		
		this.currentTab = tempDefaultTab;
		
		/* Set the cookie for this tab selection */
		if(this.options['cookie']) {
			this.setCookie('tab_' + this.cookieName, tempDefaultTab);
		};
		
		/* DEBUG alert(debugTracking); */
		
		this.CachedClickHandler = this.clickHandler.bindAsEventListener(this);
		
		for(var i=0;i<this.tabList.length;i++) {
		
			var page = this.tabList[i].getAttribute('href').match(/[-_\w]+$/i)[0];
			
			/* JW: if current tab matches default tab, show content and tab highlight */
			if (page == tempDefaultTab) {
			
				this.showTab(page);
			
				/* 
				$(page).show();
				$(this.tabList[i].parentNode).addClassName('on');
				if(this.options['backgrounds']) {
					window.document.body.style.backgroundImage = 'url(' + this.options['backgrounds'][i] + ')';
				};
				*/
			} else {
				$(this.tabList[i].parentNode).removeClassName('on');
				$(page).hide();
			};

			Event.observe(this.tabList[i], 'click', this.CachedClickHandler);

		};

		if(this.options['autoRotate']) {
		
			if (this.isNumeric(this.options['autoRotate'])) {
				this.autoRotateDelay = this.options['autoRotate'] * 1000;
			} else {
				this.autoRotateDelay = 30 * 1000;	/* Default rotate once every 30 seconds */
			};
			
			this.autoRotate();
			
		};
		
	};
	
	this.clickHandler = function(event) {

		if (!event) {
			var event = window.event;
		};

		var target = event.target != null ? event.target : event.srcElement;

		/* Due to event bubbling we need to work up the dom tree to find the A element */
		while(target.nodeName != 'A' && target.parentNode) {
			target=target.parentNode;			
		};
		
		var page = target.getAttribute('href').match(/[-_\w]+$/i)[0];
		
		this.showTab(page);
		
		this.autoRotateStop();

		Event.stop(event);

	};
	
	this.showTab = function(page) {
	
		/* Remove any active items */
		$$(this.divId + ' div.tabs ul li.on').each(function(e) {
			e.removeClassName('on');
		});

		/* Everything that isn't our page hide */
		$$(this.divId + ' .PS_tab_page[id!='+page+']').each(function(e) { e.hide(); });		

		/* Add active to our boy */
		for(var i=0;i<this.tabList.length;i++) {
			if(this.tabList[i].getAttribute('href').match(/[-_\w]+$/i)[0] == page) {
				$(this.tabList[i].parentNode).addClassName('on');
				if(this.options['backgrounds']) {
					window.document.body.style.backgroundImage = 'url(' + this.options['backgrounds'][i] + ')';
				};
				
			};
		};

		/* Set the cookie for this tab selection */
		if(this.options['cookie']) {
			this.setCookie('tab_' + this.cookieName, page);
		};

		$(page).show();
		
		this.currentTab = page;

	}.bind(this);

	this.nextTab = function() {
		
		var nextTabIndex = 0;
		
		while(this.tabList[nextTabIndex].getAttribute('href').match(/[-_\w]+$/i)[0] != this.currentTab && nextTabIndex < this.tabList.length) {
			nextTabIndex++;
		};
		
		nextTabIndex++;
		
		if(nextTabIndex >= this.tabList.length) {
			nextTabIndex = 0;
		};
		
		this.showTab(this.tabList[nextTabIndex].getAttribute('href').match(/[-_\w]+$/i)[0]);
		
	};

	this.previousTab = function() {
	
		var previousTabIndex = this.tabList.length - 1;
		
		while(this.tabList[previousTabIndex].getAttribute('href').match(/[-_\w]+$/i)[0] != this.currentTab && previousTabIndex >= 0) {
			previousTabIndex--;
		};
		
		previousTabIndex--;
		
		if(previousTabIndex < 0) {
			previousTabIndex = this.tabList.length - 1;
		};
		
		this.showTab(this.tabList[previousTabIndex].getAttribute('href').match(/[-_\w]+$/i)[0]);
		
	};
	
	this.checkTabExists = function(tabName) {
	
		/* Loop through and find if the default tab we expect to exist does */
		var tabExists = false;

		this.tabList.each(function(a) {

			if (a.getAttribute('href').match(/[-_\w]+$/i)[0] == tabName) { tabExists = true; };

		});

		return tabExists;
	
	};

	this.getRandomTab = function() {
	
		var randNum = Math.floor(Math.random() * this.tabList.length); 
	
		var defaultTab = this.tabList[randNum].getAttribute('href').match(/[-_\w]+$/i)[0];
	
		return defaultTab;

	};		
	

	this.getFirstTab = function() {
	
	 	/* Get the URL name that defaults to tabId, or can be overridden in options. */
	 	
		var defaultTab = this.tabList[0].getAttribute('href').match(/[-_\w]+$/i)[0];
	
		return defaultTab;
		
	};		

	this.getDefaultTabByConfig = function() {
	
	 	/* Get the URL name that defaults to tabId, or can be overridden in options. */
		var defaultTab = this.options['defaultTab'];

		if(this.checkTabExists(defaultTab)) {
			return defaultTab;
		} else {
			return false;
		};
		
	};		
		
	this.getDefaultTabByUrl = function() {
	
		var defaultTab = "";
	
	 	/* Get the URL name that defaults to tabId, or can be overridden in options. */
		var urlName = "tabId";
	
		if(this.options['urlName']) {
			urlName = this.options['urlName'];
		};

		defaultTab = this.getURLName(urlName);
		
		/* If we've not got a working value, check for URl Values */
		if(!this.checkTabExists(defaultTab)) {
		
			defaultTab = this.getURLVar(urlName);
		
		};
		
		if(this.checkTabExists(defaultTab)) {
			return defaultTab;
		} else {
			return false;
		};
		
	};
	
	this.autoRotateReset = function() {
	
		clearTimeout(this.timerHandle);
		
		return true;
		
	};

	this.autoRotateStop = function() {
	
		/* if a user clicks a tab, then stop rotating */
		if (this.autoRotatePaused == 0) {
				
			this.autoRotateReset();

			this.autoRotatePaused = 1;

		};
			
	};	
	
	this.autoRotate = function(rotateDelay) {
	
		/* will pause for length of time set in config, or you can supply a new time as argument */
		if (typeof rotateDelay != "undefined" && this.isNumeric(rotateDelay)) { 
		
			this.autoRotateReset();
			
			this.autoRotateDelay = rotateDelay * 1000;
			
		};
		
		var storedThis = this;
		
		this.autoRotatePaused = 0;
		
		var timedProcess = function() {
		
			storedThis.nextTab();
			
			storedThis.autoRotate();
		
		};
		
		storedThis.timerHandle = setTimeout(timedProcess, storedThis.autoRotateDelay);
		
	};
		
	this.setCookieName = function() {

		/* Get the cookie name that default to locator/PMDbProgramId combo, or can be passed in option. */
		var cookieName = this.getURLVar('locator') + '_' + this.getURLVar('PMDbProgramId');

		if(this.options['cookieName']) {
			cookieName = this.options['cookieName'];
		};

		this.cookieName = cookieName; /* For later reuse */
	
	};
		
	this.getDefaultTabByCookie = function() {
	
		var defaultTab = "";
	
		defaultTab = this.getCookie('tab_' + this.cookieName);

		if(this.checkTabExists(defaultTab)) {
			return defaultTab;
		} else {
			return false;
		};
				
	};

	this.setCookie = function (name, value, expires, path, domain, secure) {
		
		/* alert("Setting Cookie - Name: " + name + " value: " + value); */
	
		document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	};	
		
	this.getCookie = function(name) {
	
		/* alert("Getting Cookie - Name: " + name); */

		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);

		if (begin == -1) {
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		} else {
			begin += 2;
		};

		var end = document.cookie.indexOf(";", begin);

		if (end == -1) {
			end = dc.length;
		};

		return unescape(dc.substring(begin + prefix.length, end));

	};

	this.deleteCookie = function(name, path, domain) {

		if (getCookie(name)) {
			document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		};

	};		
		
		
	this.getURLName = function(urlVarName) {	

		var urlVarValue = false;
	
		/* Use the Name attribute if possible, as it more accessible */
		
		var urlNameParts = String(document.location).split('#');
		
		if(urlNameParts.length == 2) {
		
			urlVarValue = String(urlNameParts[1]).split('?')[0];
		
		};
		
		return urlVarValue; 
	
	};
		
	this.getURLVar = function(urlVarName) {
	
		var urlVarValue = '';

		//divide the URL in half at the '?'
		var urlHalves = String(document.location).split('?');

		if(urlHalves[1]){

			//load all the name/value pairs into an array
			var urlVars = urlHalves[1].split('&');

			//loop over the list, and find the specified url variable
			for(i=0; i<=(urlVars.length); i++){

				if(urlVars[i]){

					//load the name/value pair into an array
					var urlVarPair = urlVars[i].split('=');

					if (urlVarPair[0] && urlVarPair[0] == urlVarName) {

						//I found a variable that matches, load it's value into the return variable
						urlVarValue = urlVarPair[1];

					};

				};

			};

		};
		
		return urlVarValue;   

	};
	
	/* numeric test */
	this.isNumeric = function(val) {

	    if (val != parseInt(val)) {

		  return false;

	     };

	     return true;

	};
	

	/* If using cookie, set the name of the cookie */
	if(this.options['cookie']) {
		this.setCookieName();
	};
	
	this.init();
		
}
	












//Embed.JS

/**
 * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
 */

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	if (!p["id"] || p["id"] == "") {
		var divName = "flashcontent";	
	} else {
		var divName = p["id"];
	}
	
	document.write('<div id="' + divName + '">&nbsp;</div>');
	
	/* 1.5 method (using) */
	var so = new SWFObject(p["src"], divName, p["width"], p["height"], "7", "#ffffff");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addParam("flashvars", p["flashvars"]);
	so.write(divName);	
	
	/* 2.1 method (not using)
	var swfFlashVars = false;

	var swfParams = {};
	swfParams.flashvars = p["flashvars"];
	swfParams.quality = "high";
	swfParams.wmode = "transparent";

	var swfAttribs = {};
	swfAttribs.id = p["id"];
	swfAttribs.name = p["name"];
	swfAttribs.aligm = p["align"];

	swfobject.embedSWF(p["src"], divName, p["width"], p["height"], "7", false, "file=http://pearsondigital.com/videos/web/bio_intro.flv&image=http://www.pearsonschool.com/live/images/custom/biology/movie.jpg&bufferlength=10", swfParams, swfAttribs);
	*/
}

//AC_RunActiveContent.JS

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  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];
			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;
		}
	}
	// 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] + '" ';
    }
    str += '>';
    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_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  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;
}

//AUTO AJAX SELECT LIST

/* 
NOTES:
Requires Prototype 1.6 if using to update options in a select list. IE 6/7 don't allow element.update of options in select

OBJECT: AutoAJAXSelectList: Takes a text box, monitors if you type in it and AJAX updates a results panel.

ATTRIBUTES:
textBoxObj: Text box to monitor (required)
appendObj: Where the results of the AJAX go (required)
dataApp: The address of the AJAX app (required)
hideSchoolResults: A DOM Obj that is made visible when there are results and hides otherwise
progressObj: A DOM Obj that is made visible during the AJAX call and hides otherwise
leftOffset: Offset of results box
topOffset: Offset of results box
defaultAlignment: 'right' (default), 'left' - alignment of results box.

FUNCTIONS:
reset(): Hides and clears the results panel.
*/




function AutoAJAXSelectList(
		textBoxObj, 
		appendObj, 
		dataApp, 
		hideSchoolResults, 
		progressObj, 
		leftOffset, 
		topOffset, 
		defaultAlignment, 
		pmdbSiteId,
		appName, 
		appGroup,
		productLocaleCode		
		) {

	this.textBoxObj = textBoxObj;

	this.appendObj = appendObj;
	
	this.dataApp = dataApp;
	
	this.hideSchoolResults = hideSchoolResults;
	
	this.progressObj = progressObj;
	
 	this.leftOffset = leftOffset;
 	
 	this.topOffset = topOffset;
	
	this.boxAligned = false;
	
	this.defaultAlignment = defaultAlignment;
	
	this.currentSubmissionID = 1;

	this.pmdbSiteId = pmdbSiteId;
	
	this.appGroup = appGroup;
	
	this.appName = appName;	
	
	this.productLocaleCode = productLocaleCode || 'US';
	
	this.delay = 300;
	
	this.count = 0;
	
	this.searchTerm = "";

	/* Start monitoring textbox and turn off autocomplete */
	this.init = function () {
	
		this.textBoxObj.setAttribute("autocomplete","off");
		
		this.CachedTypeHandler = this.checkAdd.bindAsEventListener(this);

		Event.observe(this.textBoxObj, 'keyup', this.CachedTypeHandler);		

		this.CachedFocusHandler = this.focusHandler.bindAsEventListener(this);

		Event.observe(this.textBoxObj, 'focus', this.CachedFocusHandler);
		
	}

	/* Hides and clears results panel */
	this.reset = function () {
	
		this.searchTerm = "";
		
		clearTimeout(this.timerHandle);
		
		if (this.hideSchoolResults) {
			this.hideSchoolResults.hide();
		}

		if(this.progressObj) {
			this.progressObj.hide();
		}		

		while(this.appendObj.childNodes.length > 0) {
			this.appendObj.removeChild(this.appendObj.childNodes[0]);
		}

	}

	/* On a successful update, show results and hide progress */
	this.updateSuccess = function(responseTest) {
		currentResponse = responseTest.responseText.split('CurrentSubmissionID');
		
		if (currentResponse[0] == this.currentSubmissionID && this.searchTerm.length >= 3) {

			this.appendObj.update(currentResponse[1]);
		
			if (this.hideSchoolResults) {
				this.alignResultsBox();
				this.hideSchoolResults.show();
			}

			if(this.progressObj) {
				this.progressObj.hide();
			}	
			
		}
		
	}.bind(this);

	/* On a keypress this prompts the AJAX */
	this.checkAdd = function(event) {
	
		this.keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

		if(this.keyCode == 13 || this.keyCode == 39 ) { // Keypressed is enter or tab - prevent form submit

			event.cancelBubble = true;
			event.returnValue = false;
			event.stopPropagation(); 

			return false;
			
		} else if (Event.element(event).value.length < 3) {
		
			this.reset();	
			
		} else if((Event.element(event).value.length) >= 3) {
		
			/* Each event kills the previous queued event, except let every 5th through to make typing progressive */
		
			if(this.progressObj) {
				this.progressObj.show();
			};
			
			this.sendQueue(Event.element(event).value);
			
		}

	};


	/* Event is queued to run after [this.delay] seconds. New events will cancel this queue. */
	this.sendQueue = function(searchTerm) {

		var self = this;
		
		/* Combo key press like shift can trigger the same search term to fire */
		
		if (this.searchTerm != searchTerm) {
		
			clearTimeout(this.timerHandle);

			this.searchTerm = searchTerm;

			var process = function() {

				self.sendRequest();

			};

			if (this.searchTerm.length % 5 == 0) {

				this.sendRequest();

			} else { 

				this.timerHandle = setTimeout(process, this.delay);

			};
			
		}
		
	}.bind(this);

	/* When an event has finished being queued it is sent via this function */
	this.sendRequest = function() {
	
		if(this.searchTerm.length >= 3) {
	
			this.currentSubmissionID++;

			new Ajax.Request(this.dataApp, {

				method: 'get',

				onSuccess: this.updateSuccess,

				onFailure : function(resp) {
					alert("Oops, there's been an error.");
				},

				parameters : { 
					q: this.searchTerm, 
					currentSubmissionID: this.currentSubmissionID, 
					pmdbSiteId: this.pmdbSiteId, 
					appGroup: this.appGroup, 
					appName: this.appName, 
					productLocaleCode: this.productLocaleCode 
				}

			});
			
		};

	};


	/* On first focus clear the box, then stop tracking focus. */
	this.focusHandler = function () {
	
		this.textBoxObj.value = "";
		
		Event.stopObserving(this.textBoxObj, 'focus', this.CachedFocusHandler);
	
	}

	/* This function finds the elements offset from the top left corner of the entire page, no mater what it's nested in */
	this.findPos = function(obj) {

		var curleft = curtop = 0;

		if (obj.offsetParent) {
		
			curleft = obj.offsetLeft

			curtop = obj.offsetTop

			while (obj = obj.offsetParent) {

				curleft += obj.offsetLeft

				curtop += obj.offsetTop

			}
		}

		return [curleft,curtop];

	}

	/* Force the results box to align with an offset as input, no matter what it's nested inside of */
	this.alignResultsBox = function() {
	
		if (!this.boxAligned) {

			this.hideSchoolResults.show();

			this.hideSchoolResults.style.top = this.hideSchoolResults.offsetTop - (this.findPos(this.hideSchoolResults)[1] - this.findPos(this.textBoxObj)[1]) + (this.textBoxObj.offsetHeight - 1) + this.topOffset + 'px';

			if (this.defaultAlignment == 'right') {

				this.hideSchoolResults.style.left = this.hideSchoolResults.offsetLeft - (this.findPos(this.hideSchoolResults)[0] - this.findPos(this.textBoxObj)[0]) + this.leftOffset - (this.hideSchoolResults.offsetWidth - this.textBoxObj.offsetWidth) + 'px';
			
			} else {
			
				this.hideSchoolResults.style.left = this.hideSchoolResults.offsetLeft - (this.findPos(this.hideSchoolResults)[0] - this.findPos(this.textBoxObj)[0]) + this.leftOffset + 'px';			
			
			}
			
			this.hideSchoolResults.hide();
			
			this.boxAligned = true;
			
		}
		
	}

	this.init();

}

/* Monitors an option in a select box. When it's pressed it redirects the page to the options value. Used by ProductQuickFind. */

function RedirectingOptionList(selectObj, dataApp, appName, appGroup) {

	this.selectObj = selectObj;
	
	this.dataApp = dataApp;
	
	this.appGroup = appGroup;
		
	this.appName = appName;	
	
	this.selectedOption = '';
	
	this.init = function () {
	
		this.CachedChangeHandler = this.changeHandler.bindAsEventListener(this);

		Event.observe(this.selectObj, 'click', this.CachedChangeHandler);
	
	}



	this.redirectByAjaxHandler = function(t) {
	
		document.location.href = t.responseText;

	}.bind(this);	
	
	
	

	this.changeHandler = function (event) {
		
		this.selectedOption = Event.element(event);
		
		if (this.selectedOption.value.length > 0) {
		
		
			// If result needs further processing look for the AJAX: Flag
			if (this.selectedOption.value.indexOf("AJAX:") == 0) {
				
				new Ajax.Request(this.dataApp, {
				
					method: 'get',

					onSuccess: this.redirectByAjaxHandler,

					onFailure : function(resp) {
						alert("Oops, there's been an error.");
					},

					parameters: { q: this.selectedOption.value, appGroup: this.appGroup, appName: this.appName}

				});
			
			
			} else {
		
				document.location.href = this.selectedOption.value; 			
				
			}
		
		}
		
	}

	this.init();

}


/* 

This function resizes select boxes when they are interacted with - this is to get round the IE problem that select box size is same size as it's options list
USE: 
var testB = new SelectResize($('testerB'), 500, 200);
	
*/

function SelectResize (targetObj, openWidth, closeWidth) {

	this.targetObj = targetObj;

	this.openWidth = openWidth;

	this.closeWidth = closeWidth;

	this.init = function () {

		if(this.openWidth < this.closeWidth) {
			var temp = this.closeWidth;
			this.closeWidth = this.openWidth;
			this.openWidth = temp;
		};

		this.targetObj.setStyle({width: this.closeWidth + 'px'});

		this.cachedMouseOnHandler = this.mouseOnHandler.bindAsEventListener(this);

		this.cachedMouseOutHandler = this.mouseOutHandler.bindAsEventListener(this);

		this.cachedChangeHandler = this.changeHandler.bindAsEventListener(this);

		Event.observe(this.targetObj, 'mouseover', this.cachedMouseOnHandler);

		Event.observe(this.targetObj, 'mouseout', this.cachedMouseOutHandler);

		Event.observe(this.targetObj, 'change', this.cachedChangeHandler);

	};

	this.mouseOnHandler = function (event) {

		this.targetObj.setStyle({width: this.openWidth + 'px'});

	};


	this.changeHandler = function (event) {

		this.targetObj.setStyle({width: this.closeWidth + 'px'});

	};


	this.mouseOutHandler = function (event) {

		currentDOMObj = Event.element(event);

		var reltg = (event.relatedTarget) ? event.relatedTarget : event.toElement;

		if (reltg != null) {

			this.targetObj.setStyle({width: this.closeWidth + 'px'});

		};

	};

	this.init();

};













/* EXTEND PROTOTYPE FORM ELEMENT TO ALLOW FOR COPY TO CLIPBOARD (jeff)

REMOVED AS ERRORING: john

Object.extend(Form.Element.Methods, {
  // Uses a combination of:
  // http://www.jeffothy.com/weblog/clipboard-copy/
  // http://www.rodsdot.com/ee/cross_browser_clipboard_copy_with_pop_over_message.asp
  copyToClipboard: function(element, swf)
  {
    if (Object.isUndefined(swf)) swf = 'http://assets.dev.pearsonschool.com/swf/_clipboard.swf';
    if (window.clipboardData)
      window.clipboardData.setData("Text", element.getValue());
    else
    {
      if(!$('flash_clipboard_container'))
        $(document.body).insert(new Element('div', {id: 'flash_clipboard_container'}));
 
      var content = encodeURIComponent(element.getValue());
 
      if (!(typeof SWFObject == "undefined"))
      {
        var so = new SWFObject(swf, 'copy_contents', '0', '0', '4');
        so.addVariable('clipboard', content);
        so.write('flash_clipboard_container');
      }
      else
      {
        $('flash_clipboard_container').update(
          new Element('embed',
            {width: 0,
            height: 0,
            flashvars: 'clipboard=' + content,
            quality: 'high',
            name: 'copy_contents',
            id: 'copy_contents',
            src: swf,
            type: 'application/x-shockwave-flash'})
        );
      }
    }
  }
});
 
Element.addMethods();

*/
