/******************************************
 * @company Digitec Interactive Inc.
 * @version 0.1
 * @date 12/14/2010
 *
 * SearchCEE class for searchFrame4 movie of the CEE application
 * CS5 version of com.digitec.cee.SearchCEE
 *
 *******************************************/
package com.digitec.cee {
	import flash.display.MovieClip;
	import flash.events.*;
	//import flash.events.KeyboardEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.events.Event;
	//import flash.text.TextFormat; 	
	import fl.managers.StyleManager;
	import flash.text.TextField;
	import flash.display.Loader;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	import flash.display.Sprite;
	import flash.text.StyleSheet;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.geom.Rectangle;
	import fl.containers.ScrollPane;
	import fl.events.ScrollEvent;
	import fl.controls.UIScrollBar;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.geom.ColorTransform;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.text.*;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;

	public class SearchCEE extends BaseCEE {
		private var xmlLibrary: String = MainConstants.LIBRARY;
		private var xmlTooltipPath: String = "usmap-econ.xml"
		private var myFont1: Font = new Font1();
		private var myFont5: Font = new Font1();
		//SEARCH BY STANDARDS
		private var usmap: m_usa;
		private var sta_Panel: standardsMCnew;
		private var containerSta: Sprite;
		private var sta_textField: TextField;
		private var xmlCorrelations: XMLList;
		private var sta_style: StyleSheet;
		private var statesAbrv: Array = new Array("ak", "al", "ar", "az", "ca", "co", "ct", "de", "fl", "ga", "hi", "ia", "id", "il", "in", "ks", "ky", "la", "ma", "md", "me", "mi", "mn", "mo", "ms", "mt", "nc", "nd", "ne", "nh", "nj", "nm", "nv", "ny", "oh", "ok", "or", "pa", "ri", "sc", "sd", "tn", "tx", "ut", "va", "vt", "wa", "wi", "wv", "wy");
		private var statesName: Array = new Array("Alaska", "Alabama", "Arkansas", "Arizona", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Iowa", "Idaho", "Illinois", "Indiana", "Kansas", "Kentucky", "Louisiana", "Massachusetts", "Maryland", "Maine", "Michigan", "Minnesota", "Missouri", "Mississippi", "Montana", "North Carolina", "North Dakota", "Nebraska", "New Hampshire", "New Jersey", "New Mexico", "Nevada", "New York", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Virginia", "Vermont", "Washington", "Wisconsin", "West Virginia", "Wyoming");
		private var vScrollBar: UIScrollBar;
		private var statetitletxt: String;
		private var tooltipXmlList: XMLList;

		private var myFont: Font = new Font1();
		private var versionField: TextField;
		//FIND LESSONS FOR THIS STANDARDs- PANEL
		private var find_Panel: SearchStandard_movie;
		private var containerFind: Sprite;
		private var find_chkboxArr: Array;
		private var alreadyfound: Array = new Array();
		private var find_gradeFilterArr: Array = new Array();
		private var findonline: Boolean = false;
		private var fsp: ScrollPane;
		private var strBelowis1: String = "Below is a list of CEE lessons that most closely meet the requirements of the selected ";
		private var strBelowis2: String = " standard.";
		private var currentState: String;
		private var dwpasspub: String;
		private var dwpassTips: String;
		private var internetcontext: String = " ";
		private var currentFindLessonsArr: Array;
		private var dssabrv: String;
		//SEARCH BY KEYWORD PANEL
		private var key_Panel: searchMenu_movie;
		private var lessonsXmlList: XMLList;
		private var containerKey: Sprite;
		private var key_chkboxArr: Array;
		private var key_gradeFilterArr: Array = new Array();
		private var key_wordFilter: RegExp = null;
		private var existsContainerKey: Boolean = false;
		private var lessonItemsArray: Array = new Array();
		private var online: Boolean = false;
		private var sp: ScrollPane;
		private var dwpassstate: String;
		//SEARCH BY PUBLICATION PANEL
		private var pub_Panel: searchPubMenu_movie;
		private var pubXmlList: XMLList;
		private var containerPub: Sprite;
		private var pub_chkboxArr: Array;
		private var pub_gradeFilterArr: Array = new Array();
		private var firstTimePublication: Boolean = true;
		private var pubItemsArray: Array = new Array();
		private var psp: ScrollPane;
		private var detailer_btn: btndetailer;

		private var $nc: NetConnection;
		private var $ns: NetStream;
		private var $streampath: String;
		private var $streamurl: String = MainConstants.CEE_SERVER;
		//ALL PANELS
		private var spaceRows: int = 8;
		private var ifisonline: Boolean; //Check if lesson is online then check first for connection

		//private var strBelowis1:String = "Below is a list of NCEE lessons that most closely meet the requirements of the selected ";
		//private var strBelowis2:String ="standard.";  			

		//NEW MAP CODE
		private var count = 0;
		private var defaultMapColor: Number = 0x89BC72;
		private var highlightMapColor: Number = 0xFEE75A;

		private var isBrowsigSearch: Boolean = false;


		/*******************************************************************
		 * CONSTRUCTOR
		 *******************************************************************/
		public function SearchCEE() {
			super(MainConstants.XMLSEARCH);
			setup();
		}

		/*******************************************************************
		 * FUNCTION: SETUP FRAME TEXT_FIELDS  FROM XML
		 *******************************************************************/
		override public function setFramesText(_xml: XML): void {
			this.title_tf.text = _xml.xtitle; //maybe without the this.									
			alreadyfound.push("0");
			var myFormat2: TextFormat = new TextFormat();
			myFormat2.font = myFont5.fontName;
			myFormat2.size = 12;
			myFormat2.color = 0x8DC269;
			myFormat2.bold = true;
			versionField = new TextField();
			versionField.defaultTextFormat = myFormat2;
			versionField.height = 17;
			versionField.width = 50;
			versionField.background = false;
			versionField.border = false;
			versionField.multiline = true;
			versionField.wordWrap = true;
			versionField.x = 415;
			versionField.y = 581;

			versionField.embedFonts = true;
			versionField.text = _xml.xversion2;
			addChild(versionField);
			this.register_tf.text = _xml.xregister;
			this.register_tf.text = _xml.xregister;

			/// BY KEYWORDS PANEL
			key_Panel = new searchMenu_movie();
			key_Panel.x = 41;
			key_Panel.y = 112;
			key_Panel.visible = true;
			addChild(key_Panel);
			this.loadingmc_clip.gotoAndStop(2);
			setChildIndex(loadingmc_clip, numChildren - 1);
			key_Panel.search_btn.addEventListener(MouseEvent.CLICK, searchByKeyword);
			key_Panel.clearSearchBtn.addEventListener(MouseEvent.CLICK, clearSearch);
			key_Panel.search_txt.addEventListener(KeyboardEvent.KEY_DOWN, pressEnterKey);
			//CREATE ARRAY OF CHECKBOX PROPERTIES
			key_chkboxArr = createCheckBoxArray(5);
			//ADD EVENT LISTENER TO CHECKBOXES
			for (var i: uint = 1; i <= 4; i++) {
				key_Panel["chk" + i + "_mc"].addEventListener(MouseEvent.CLICK, checkboxClicked);
			}
			createScrollPane();

			//FIND LESSONS BY STANDARD
			find_Panel = new SearchStandard_movie();
			find_Panel.x = 41;
			find_Panel.y = 112;
			find_Panel.visible = false;
			addChild(find_Panel);
			find_Panel.difSta_btn.addEventListener(MouseEvent.CLICK, hideStandard);
			//CREATE ARRAY OF CHECKBOX PROPERTIES
			find_chkboxArr = createCheckBoxArray(5);
			//ADD EVENT LISTENER TO CHECKBOXES
			for (var iif: uint = 1; iif <= 4; iif++) {
				find_Panel["chk" + iif + "_mc"].addEventListener(MouseEvent.CLICK, checkboxClicked);
			}
			fcreateScrollPane();

			/// BY PUBLICATIONS PANEL
			pub_Panel = new searchPubMenu_movie();
			pub_Panel.x = 41;
			pub_Panel.y = 112;
			pub_Panel.visible = false;
			addChild(pub_Panel);
			//CREATE ARRAY OF CHECKBOX PROPERTIES
			pub_chkboxArr = createCheckBoxArray(4);
			//ADD EVENT LISTENER TO CHECKBOXES
			for (var ip: uint = 1; ip <= 4; ip++) {
				pub_Panel["chk" + ip + "_mc"].addEventListener(MouseEvent.CLICK, checkboxClicked);
			}
			pcreateScrollPane();

			/// BY STANDARDS PANEL			
			usmap = new m_usa();
			usmap.x = 280;
			usmap.y = 300;
			usmap.visible = false;
			addChild(usmap);
			//NEW MAP SETUP
			setupNewMap();

			sta_Panel = new standardsMCnew();
			sta_Panel.x = 34;
			sta_Panel.y = 119;
			sta_Panel.visible = false;
			addChild(sta_Panel);

			//TEXTFIELD FOR STANDARDS
			var myFormat1: TextFormat = new TextFormat();
			myFormat1.font = myFont1.fontName;
			myFormat1.size = 12;
			myFormat1.color = 0x8DC269;


			sta_textField = new TextField();
			sta_textField.defaultTextFormat = myFormat1;
			sta_textField.x = 200;
			sta_textField.y = 38;
			sta_textField.width = 492;
			sta_textField.height = 288;
			sta_textField.multiline = true;
			//sta_textField.selectable = false;		

			sta_textField.wordWrap = true;
			sta_textField.addEventListener(TextEvent.LINK, linkEvent);
			sta_textField.embedFonts = true;


			sta_Panel.addChild(sta_textField);
			createTextScroll();

			//STYLE SHEET FOR STANDARDS

			sta_style = new StyleSheet();
			var date_updated: Object = new Object();
			date_updated.color = "#588527"; // "#00CC00";  electric green
			date_updated.fontSize = "11";
			var contentarea: Object = new Object();
			contentarea.fontWeight = "bold";
			contentarea.fontSize = "14";
			contentarea.color = "#666666";
			var li: Object = new Object();
			li.fontSize = "12";
			li.color = "#666666";
			var ahref: Object = new Object();
			ahref.fontWeight = "bold";
			ahref.fontSize = "12";
			ahref.color = "#009900";
			ahref.textDecoration = "underline";
			sta_style.setStyle(".date_updated", date_updated);
			sta_style.setStyle(".contentarea", contentarea); //class 
			sta_style.setStyle(".li", li);
			sta_style.setStyle("a", ahref); //class		   
			sta_textField.styleSheet = sta_style;
			//STATES BUTTONS						
			//for(var index:int = 0; index < statesAbrv.length; index++ ){				
			//this.usmap[""+ statesAbrv[index] + "_btn"].addEventListener(MouseEvent.CLICK, showState);
			//}			
			//this.usmap.jumpstart_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn
			//this.usmap.ncee_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn						
			//STANDARD BUTTONS			
			sta_Panel.invisi_btn.addEventListener(MouseEvent.CLICK, hideStandard2);

			//var publicationObj:Publication = new Publication();//(Object(parent)).getPublicationObject();						
			//lessonItemsArray = publicationObj.getLessonItemArray();
			//pubItemsArray = publicationObj.getPubItemArray();		
			//trace(xmlLibrary);
			loadLibrary(xmlLibrary);

			//tableByKeywords();
		}

		/*******************************************************************
		 * FUNCTION:  SET COLOR FOR THE NEW MAP
		 *******************************************************************/
		private function setupNewMap() {
			loadXMLtooltips(xmlTooltipPath);
			detailer_btn = new btndetailer();
			detailer_btn.x = 900; //to located out of stage
			detailer_btn.y = 900;
			detailer_btn.scaleX = .7;
			detailer_btn.scaleY = .7;
			addChild(detailer_btn); //to set tooltip in top
			detailer_btn.alpha = 0;

			//STATES BUTTONS						
			for (var index: int = 0; index < statesAbrv.length; index++) {
				this.usmap["" + statesAbrv[index] + "_btn"].addEventListener(MouseEvent.MOUSE_OVER, overState);
				this.usmap["" + statesAbrv[index] + "_btn"].addEventListener(MouseEvent.MOUSE_OUT, outState);
				this.usmap["" + statesAbrv[index] + "_btn"].addEventListener(MouseEvent.CLICK, showState);
				setStateColor(this.usmap["" + statesAbrv[index] + "_btn"], "initial");
			}
			this.usmap.jumpstart_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn
			this.usmap.ncee_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn									
		}

		private function setStateColor(obj: Object, btnstate: String): void {
			var colorT: ColorTransform = new ColorTransform();
			switch (btnstate) {
				case "initial":
				case "rollout":
					colorT.color = defaultMapColor; //0x89BC72;	// 0x628846;	//#89BC72 
					break;
				case "rollover":
					colorT.color = highlightMapColor; // 0xFEE75A; //0xf85a43;//#FEE75A
					break;
				case "inactive":
					colorT.color = 0x9cada9
					break;
				default:
					colorT.color = 0x628846;
			}
			obj.transform.colorTransform = colorT;
		}
		//private var defaultMapColor:Number = 0x89BC72;
		//private var highlightMapColor:Number =0xFEE75A;

		/*******************************************************************
		 * FUNCTION:  TO LOAD LESSONS XML FILE
		 *******************************************************************/
		private function loadLibrary(stream: String): void {
			dwpasspub = stream;
			var streamtemp = $streamurl + dwpasspub
			
			var xmlfullpath = Object(parent).getDpath();
		    loadLibraryFinal(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + dwpasspub);

			//2019-07-11 NO LOAD
			/*
			var pubsLoadertemp: URLLoader = new URLLoader();
			pubsLoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerLib);
			pubsLoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
			var pubsUrltemp: URLRequest = new URLRequest(streamtemp);
			//pubsLoadertemp.addEventListener(Event.COMPLETE,pubsLoaded);
			pubsLoadertemp.load(pubsUrltemp);
			*/
		}
		private function httpStatusHandlerLib(event: HTTPStatusEvent): void {
			//trace("httpStatusHandler: -----------------------------------" + event);
			//trace("status: " + event.status);
			if (event.status == 0) {
				internetcontext = "Unable to locate internet connection";
				var xmlfullpath = Object(parent).getDpath();
				loadLibraryFinal(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + dwpasspub);
			} else {
				loadLibraryFinal($streamurl + dwpasspub);
			}
			//loadLibraryFinal(MainConstants.XMLPATH + dwpasspub);
		}
		private function loadLibraryFinal(stream: String): void {

			var pubsUrl: URLRequest = new URLRequest(stream);
			var pubsLoader: URLLoader = new URLLoader();
			//pubsLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
			pubsLoader.addEventListener(Event.COMPLETE, pubsLoaded);
			pubsLoader.load(pubsUrl);
			function pubsLoaded(event: Event): void {
				var _xml: XML = new XML(pubsLoader.data);
				pubXmlList = new XMLList(_xml.publications.pub);
				lessonsXmlList = new XMLList(_xml.lessons.lesson);
				//trace(lessonsXmlList);

				createObjectsArray();
			}
		}


		private function createScrollPane(): void {
			sp = new ScrollPane();
			sp.move(6, 85); //(6,102);
			sp.setSize(692, 288); //(673,288);          
			sp.scrollDrag = false;
			key_Panel.addChild(sp);
		}

		private function fcreateScrollPane(): void {
			fsp = new ScrollPane();
			fsp.move(6, 85); //(6,102);
			fsp.setSize(692, 288); //(673,288);          
			fsp.scrollDrag = false;
			find_Panel.addChild(fsp);
		}
		private function pcreateScrollPane(): void {
			psp = new ScrollPane();
			psp.move(6, 85); //(6,102);
			psp.setSize(692, 288); //(673,288);          
			psp.scrollDrag = false;
			pub_Panel.addChild(psp);
		}
		private function createTextScroll(): void {
			vScrollBar = new UIScrollBar();
			vScrollBar.scrollTarget = sta_textField;
			vScrollBar.height = sta_textField.height;
			vScrollBar.move(sta_textField.x + sta_textField.width, sta_textField.y);
			sta_Panel.addChild(vScrollBar);
		}

		/*******************************************************************
		 * FUNCTION: CREATE PUBITEMS AND LESSONITEMS ARRAYS
		 *******************************************************************/
		private function createObjectsArray(): void {
			var item: XML;
			for each(item in pubXmlList) {
				var pubItem: PublicationItem = new PublicationItem(item);
				//trace(PublicationItem(item)+"-------------------------------------");
				pubItemsArray.push(pubItem);
			}
			tableByPub();

			for each(item in lessonsXmlList) {
				var lessonItem: LessonItem = new LessonItem(item);

				lessonItemsArray.push(lessonItem);

			}
			trace("trip the tablebykeywords");
			tableByKeywords();

		}
		/*******************************************************************
		 * FUNCTION: CREATE  LESSONITEMS ARRAYS
		 *******************************************************************/
		private function tableByKeywords(): void {
			searchLessonsByKeyword();

		}

		private function populateByKeywords(arr: Array): void {
			containerKey = new Sprite();

			var Xpos: int = 0;
			var Ypos: int = 0;
			var rowsArr: Array = new Array();
			for (var i: uint = 0; i < arr.length; i++) {
				var item: LessonItem = arr[i];
				//trace("clip 1");
				//trace(item.display);
				if (item.display != "false" || item.type == "online") {
					//if (item.gradelevel != "true"){ 
					rowsArr[i] = new RowAreaKeywords();
					rowsArr[i].x = Xpos;
					rowsArr[i].y = Ypos;
					//key_Panel.containerPub.addChild(key_rowsArr[i] );					
					containerKey.addChild(rowsArr[i]);
					Ypos += 10 + rowsArr[i].height;
					rowsArr[i].textHolder.wordWrap = true;
					rowsArr[i].textHolder.mouseWheelEnabled = false;

					var myFormat3: TextFormat = new TextFormat();
					myFormat3.font = myFont1.fontName;
					var pubTitle: String;
					if (item.type == "online") {
						pubTitle = item.source;
					} else {
						pubTitle = getPublicationTitle(item.publication);

					}
					rowsArr[i].textHolder.htmlText = "<p><font size='14' color='#588527'><b><u><a href= 'event:viewLesson," + item.id + "'>" + item.title + "</a></u></b></font></p>" + "<p><font size='14'>" + item.desc + "</font></p>";
					//rowsArr[i].textHolder.embedFonts = true;
					rowsArr[i].textHolder.addEventListener(Event.SCROLL, checkScrl);
					//rowsArr[i].textHolder.addEventListener(MouseEvent.MOUSE_WHEEL, checkScrl, true);
					function checkScrl(e: Event) {

						e.target.scrollV = 0;
						e.stopPropagation();
					}
					rowsArr[i].textHolder.setTextFormat(myFormat3);
					rowsArr[i].textHolder.embedFonts = true;
					rowsArr[i].textHolder.addEventListener(TextEvent.LINK, linkEvent);
					rowsArr[i].textHolder.mouseWheelEnabled = false;
					rowsArr[i].gradeHolder.htmlText = "<p>" + item.gradedisplay + "</p>";
					//rowsArr[i].gradeHolder.embedFonts = true;
					rowsArr[i].gradeHolder.setTextFormat(myFormat3);
					rowsArr[i].gradeHolder.embedFonts = true;
					rowsArr[i].pubHolder.htmlText = "<p>" + pubTitle + "</p>";
					//rowsArr[i].pubHolder.embedFonts = true;
					rowsArr[i].pubHolder.setTextFormat(myFormat3);
					rowsArr[i].pubHolder.embedFonts = true;
				}
			}
			key_Panel.internetcon_txt.text = internetcontext;
			if (internetcontext == "Unable to locate internet connection") {
				key_Panel.warningicon.gotoAndStop(2);
			}

			key_Panel.numDisplay_txt.text = "displaying " + arr.length + " lessons";
			key_Panel.displayoutline.gotoAndPlay(2);
			sp.source = containerKey;

			existsContainerKey = true;
			displayCheckboxStatus("key", key_chkboxArr);
			//CLEAN FILTERS
			loadingmc_clip.play();
			setChildIndex(loadingmc_clip, numChildren - 1);
			key_gradeFilterArr = new Array();
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		private function populateFind(arr: Array): void {
			containerFind = new Sprite();
			var Xpos: int = 0;
			var Ypos: int = 0;
			//trace("arr populate "+arr);
			var rowsArr: Array = new Array();
			for (var i: uint = 0; i < arr.length; i++) {
				var item: LessonItem = arr[i];
				//trace();
				//trace("item.display               "+item.display);
				//trace("item.type               "+item.type);
				if (item.display == "TRUE" || item.type == "online") {
					//trace("make this");
					rowsArr[i] = new RowAreaKeywords();
					rowsArr[i].x = Xpos;
					rowsArr[i].y = Ypos;
					//key_Panel.containerPub.addChild(key_rowsArr[i] );					
					containerFind.addChild(rowsArr[i]);
					Ypos += 10 + rowsArr[i].height;
					rowsArr[i].textHolder.wordWrap = true;
					//rowsArr[i].textHolder.mouseWheelEnabled = false;
					var myFormat4: TextFormat = new TextFormat();
					myFormat4.font = myFont1.fontName;
					var pubTitle: String;
					if (item.type == "online") {
						pubTitle = item.source;
					} else {
						pubTitle = getPublicationTitle(item.publication);

					}
					rowsArr[i].textHolder.htmlText = "<p><font size='14' color='#588527' ><b><u><a href= 'event:viewLesson," + item.id + "'>" + item.title + "</a></u></b></font></p>" + "<p><font size='14'>" + item.desc + "</font></p>";
					rowsArr[i].textHolder.addEventListener(Event.SCROLL, checkScrl);
					//rowsArr[i].textHolder.addEventListener(MouseEvent.MOUSE_WHEEL, checkScrl, true);
					function checkScrl(e: Event) {

						e.target.scrollV = 0;
						e.stopPropagation();
					}
					rowsArr[i].textHolder.setTextFormat(myFormat4);
					rowsArr[i].textHolder.embedFonts = true;
					rowsArr[i].textHolder.addEventListener(TextEvent.LINK, linkEvent);
					rowsArr[i].textHolder.mouseWheelEnabled = false;
					//rowsArr[i].textHolder.embedFonts = true;
					//
					rowsArr[i].gradeHolder.htmlText = "<p>" + item.gradedisplay + "</p>";
					//rowsArr[i].gradeHolder.embedFonts = true;
					rowsArr[i].gradeHolder.setTextFormat(myFormat4);
					rowsArr[i].gradeHolder.embedFonts = true;
					rowsArr[i].pubHolder.htmlText = "<p>" + pubTitle + "</p>";
					//rowsArr[i].pubHolder.embedFonts = true;
					rowsArr[i].pubHolder.setTextFormat(myFormat4);
					rowsArr[i].pubHolder.embedFonts = true;
				}
			}
			find_Panel.numDisplay_txt.text = "displaying " + arr.length + " lessons";

			find_Panel.internetcon_txt.text = internetcontext;
			if (internetcontext == "Unable to locate internet connection") {
				find_Panel.warningicon.gotoAndStop(2);
			}
			fsp.source = containerFind;

			find_Panel.belowis_txt.text = "" + strBelowis1 + strBelowis2;

			//existsContainerKey = true;		
			//trace("find_chkboxArr"+find_chkboxArr);
			displayCheckboxStatus("find", find_chkboxArr);
			//CLEAN FILTERS
			loadingmc_clip.play();
			setChildIndex(loadingmc_clip, numChildren - 1);
			find_gradeFilterArr = new Array();
		}

		/*******************************************************************
		 * FUNCTION: CREATE PUBITEMS ARRAYS
		 *******************************************************************/
		private function tableByPub(): void {
			var arr: Array = new Array();
			for (var i: uint = 0; i < pubItemsArray.length; i++) {
				var item: PublicationItem = pubItemsArray[i];
				//trace(item.img+" "+item.pid+" "+item.ptitle+" "+item.desc+" "+item.gradelevel);
				arr.push({
					Image: item.img,
					Id: item.pid,
					Title: item.ptitle,
					Description: item.desc,
					Grade: item.gradelevel
				});
			}
			populateByPub(arr);
		}

		private function populateByPub(arr: Array): void {

			trace("length o'my array  " + arr.length);
			containerPub = new Sprite();
			var rowsArr: Array = new Array();
			var thumbLoader: Loader;
			var Xpos: int = 8;
			var Ypos: int = 8;
			for (var i: uint = 0; i < arr.length; i++) {
				rowsArr[i] = new RowArea();

				rowsArr[i].x = Xpos;
				rowsArr[i].y = Ypos;

				Ypos += 10 + rowsArr[i].height;
				//pub_Panel.containerPub.addChild(rowsArr[i] );
				containerPub.addChild(rowsArr[i]);

				var myFormat5: TextFormat = new TextFormat();
				myFormat5.font = myFont1.fontName;
				thumbLoader = new Loader();
				thumbLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
				thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
				var fullpubpath = Object(parent).getDpath();
				thumbLoader.load(new URLRequest(fullpubpath + "_VE50DATA/" + "data/pubs/" + arr[i].Image));

				rowsArr[i].holder.addChild(thumbLoader);


				rowsArr[i].textHolder.htmlText = "<p><font size='14' color='#588527' ><b><u><a href= 'event:viewPublication," + arr[i].Id + "'>" + arr[i].Title + "</a></u></b></font></p><p><font size='14'>" + arr[i].Description + "</font></p>";
				//rowsArr[i].textHolder.embedFonts = true;
				rowsArr[i].textHolder.addEventListener(Event.SCROLL, checkScrl);
				//rowsArr[i].textHolder.addEventListener(MouseEvent.MOUSE_WHEEL, checkScrl, true);
				function checkScrl(e: Event) {

					e.target.scrollV = 0;
					e.stopPropagation();
				}
				rowsArr[i].textHolder.setTextFormat(myFormat5);
				rowsArr[i].textHolder.embedFonts = true;
				rowsArr[i].textHolder.addEventListener(TextEvent.LINK, linkEvent);
				rowsArr[i].textHolder.mouseWheelEnabled = false;
				rowsArr[i].gradeHolder.htmlText = arr[i].Grade;
				//rowsArr[i].gradeHolder.embedFonts = true;
				rowsArr[i].gradeHolder.setTextFormat(myFormat5);
				rowsArr[i].gradeHolder.embedFonts = true;
			}
			pub_Panel.numDisplay_txt.text = "displaying " + arr.length + " publications";
			pub_Panel.internetcon_txt.text = internetcontext;
			if (internetcontext == "Unable to locate internet connection") {
				pub_Panel.warningicon.gotoAndStop(2);
			}
			pub_Panel.displayoutline.gotoAndPlay(2);
			//pub_Panel.addChild(containerPub);			
			psp.source = containerPub;
			displayCheckboxStatus("pub", pub_chkboxArr);
			//CLEAN FILTER		
			if (arr.length > 0) {
				loadingmc_clip.play();
			}
			setChildIndex(loadingmc_clip, numChildren - 1);
			pub_gradeFilterArr = new Array();
		}
		private function loadProdComplete(e: Event): void {
			var bit: Bitmap = e.target.content;
			if (bit != null) {
				bit.smoothing = true;
				bit.width = 39;
				bit.height = 50;
			}
		}
		/*******************************************************************
		 * FUNCTIONS: EVENT  HANDLER FOR LINKS
		 *******************************************************************/
		private function linkEvent(e: TextEvent): void {
			var linkContent: Array = e.text.split(",");
			var functionName: String = linkContent[0];
			var args: String = linkContent[1];
			switch (functionName) {
				//running code here in the user event to ensure more success with navigateToURL
				case "viewLesson":
					if (args != null) {
						var weburl: String = isLessonOnline(args);
						//check for online type
						//trace(args);
						//trace(weburl);
						if (weburl == "") {
							Object(parent).setPDFLesson(args, true); //isLessonBrowse type = true
							Object(parent).setLastPDFlessonId(args, true);
						} else {
							try {
								navigateToURL(new URLRequest(weburl), "_blank");
							} catch (e: Error) {
								trace(e.message);
							}
						}
					}
					break;
				case "viewPublication":
					this.viewPublication(args);
					break;
				case "findLessonByStandard":
					//trace("args   state"+args);
					this.findLessonByStandard(args);
					Object(parent).setLastStateSearch("sstate", args, isBrowsigSearch);
					break;
				case "gotoWebPage":
					this.gotoWebPage(args);
					break;
				case "loadstandard":
					loadStateStandard("standards/" + args);
					Object(parent).setLastStateSearch("sstate", "standards/" + args, isBrowsigSearch);
					// this.loadStandardd(args);
					break;
				default:
					trace("function not found");
			}
		}

		private function viewPublication(str: String): void {
			if (str != null) {
				Object(parent).setPublicationLesson(str, true);
			}
			Object(parent).setLastPubId(str, true);
		} //isLessonBrowse type = true

		public function findLessonByStandard(str: String): void {

			if (str != null) {
				//FIND IN SAME XML CORRELATIONS 				
				var arr: Array = HelperFunctions.getArrayAltVersion(str);
				//trace("arr               "+arr);
				//var checkboxtemparray:Array = [];
				//for(var iii:uint = 1; iii < arr.length; iii++){
				//trace("trace array"+arr[iii]);
				find_chkboxArr = [];
				if (arr[1] == "true") {
					find_chkboxArr.push({
						Name: "chk1_mc",
						On: true,
						Position: "1",
						Grades: "K-2"
					});
				} else if (arr[1] == "false") {
					find_chkboxArr.push({
						Name: "chk1_mc",
						On: false,
						Position: "1",
						Grades: "K-2"
					});
				}
				if (arr[2] == "true") {
					find_chkboxArr.push({
						Name: "chk2_mc",
						On: true,
						Position: "2",
						Grades: "3-5"
					});
				} else if (arr[2] == "false") {
					find_chkboxArr.push({
						Name: "chk2_mc",
						On: false,
						Position: "2",
						Grades: "3-5"
					});
				}
				if (arr[3] == "true") {
					find_chkboxArr.push({
						Name: "chk3_mc",
						On: true,
						Position: "3",
						Grades: "6-8"
					});
				} else if (arr[3] == "false") {
					find_chkboxArr.push({
						Name: "chk3_mc",
						On: false,
						Position: "3",
						Grades: "6-8"
					});
				}
				if (arr[4] == "true") {
					find_chkboxArr.push({
						Name: "chk4_mc",
						On: true,
						Position: "4",
						Grades: "9-12"
					});
				} else if (arr[4] == "false") {
					find_chkboxArr.push({
						Name: "chk4_mc",
						On: false,
						Position: "4",
						Grades: "9-12"
					});
				}


				//trace("trace on"+find_chkboxArr.On[iii])
				//} else {
				//trace("false")
				//trace(iii+10);
				//checkboxtemparray = createCheckBoxArray(iii+10);

				//}
				//}
				var arrLessons: Array;

				var item: XML;
				for each(item in xmlCorrelations) {
					if (item.@id == arr[0]) {
						arrLessons = HelperFunctions.getArrayCommaDelimeter(item);
					}
				}

				var arr2: Array = new Array();
				for (var i: uint = 0; i < lessonItemsArray.length; i++) {
					var item2: LessonItem = lessonItemsArray[i];
					for (var ii: uint = 0; ii < arrLessons.length; ii++) {
						if (item2.id == arrLessons[ii]) {
							arr2.push(item2);
						}
					}
				}
				currentFindLessonsArr = arr2; //current array of lesson items for FIND
				//trace("arr2          "+arr2);
				populateFind(arr2);
				findLessonsPanel();
			}
		}

		private function gotoWebPage(str: String): void {
			try {
				navigateToURL(new URLRequest(str), "_blank");
			} catch (e: Error) {
				trace(e.message);
			}
		}

		/*******************************************************************
		 * FUNCTION:  TO LOAD STANDARDS STATES XML FILE
		 *******************************************************************/
		public function loadStateStandard(stream: String): void {
			dwpassstate = stream;
			
			var streamtemp = $streamurl + dwpassstate
			var xmlfullpath = Object(parent).getDpath();
			loadConceptList(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + dwpassstate);
			
			//2019-07-11 NOLOAD
			/*
			var STATELoadertemp: URLLoader = new URLLoader();
			STATELoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerSTATE);
			STATELoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
			//pubsLoadertemp.addEventListener(Event.COMPLETE,pubsLoaded);
			var STATEUrltemp: URLRequest = new URLRequest(streamtemp);
			STATELoadertemp.load(STATEUrltemp);
			*/

		}
		private function httpStatusHandlerSTATE(event: HTTPStatusEvent): void {
			//trace("httpStatusHandler: -----------------------------------" + event);
			//trace("status: " + event.status);
			var xmlfullpath = Object(parent).getDpath();
			if (event.status == 0) {
				internetcontext = "Unable to locate internet connection";
				//var xmlfullpath = Object(parent).getDpath();
				//trace("state xml path"+xmlfullpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate);
				loadConceptList(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + dwpassstate);
			} else {

				//trace("state xml path"+xmlfullpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate);
				//loadConceptList(xmlfullpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate);
				loadConceptList("http://ve.councilforeconed.org/" + dwpassstate);
				//trace("online state "+"http://ve.councilforeconed.org/"+ dwpassstate);
			}
			//loadLibraryFinal(MainConstants.XMLPATH + dwpasspub);
		}
		private function $netStatusHandler(_e: NetStatusEvent): void {

			//   trace('$netStatusHandler:'+_e.info.code);
			// loadConceptList(MainConstants.XMLPATH + dwpassstate);

			for (var _i in _e.info) {
				trace(_i + ':' + _e.info[_i]);
			}
			switch (_e.info.code) {
				case "NetConnection.Connect.Success":
					trace('Success!!!!');
					//loadXML($streamurl);	
					//trace("$streamurl "+ "http://ve.councilforeconed.org/"+ dwpassstate);
					loadConceptList(MainConstants.XMLPATH + dwpassstate);
					//loadConceptList("http://ve.councilforeconed.org/"+ dwpassstate);
					//loadXML(xmlQuiz);			
					break;
				case "NetStream.Play.StreamNotFound":
					internetcontext = "Unable to locate internet connection";
					//trace("Unable to locate video");
					//trace("local"+MainConstants.XMLPATH + dwpassstate);
					loadConceptList(MainConstants.XMLPATH + dwpassstate);
					//loadXML(MainConstants.XMLPATH + MainConstants.XMLCONCEPTS_LIST);			
					break;
			}

		}
		private function $securityErrorHandler(_e: NetStatusEvent): void {
			trace('$securityErrorHandler');
		}
		private function $asyncErrorHandler(_e: AsyncErrorEvent): void {
			trace('$asyncErrorEvent');
		}
		public function checkUrl(urlString: String): void {}

		private function onHttpStatus(event: HTTPStatusEvent): void {
			var httpStatus: int = event.status;
			if (httpStatus < 100) {
				trace("flashError");
			} else if (httpStatus < 200) {
				trace("informational");
			} else if (httpStatus < 300) {
				trace("successful");
			} else if (httpStatus < 400) {
				trace("redirection");
			} else if (httpStatus < 500) {
				trace("clientError");
			} else if (httpStatus < 600) {
				trace("serverError");
			}
			//trace(this.httpStatusType);
		}

		//ul.load(new URLRequest(urlString));
		// ul.load("http://google.com/not.html");


		private function loadConceptList(stream: String): void {
			var loader: URLLoader = new URLLoader();
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatus);
			loader.load(new URLRequest(stream));
			key_Panel.visible = false;
			pub_Panel.visible = false;
			sta_Panel.visible = true;
			find_Panel.visible = false;
			usmap.visible = false;
			//trace("STATE stream "+stream);
			loader.addEventListener(Event.COMPLETE, loadData);
			function loadData(evt: Event): void {
				var _xml: XML = new XML(loader.data);
				/****************************************************************************
				 * REPLACE   'asfunction:'    FOR     'event:function=' TO TRANSLATE HTML USED FOR AS2 TO AS3
				 ***************************************************************************/
				var myPattern: RegExp = /asfunction:/g; //g is global, replace all instances		
				//trace(_xml.title);
				var str: String = _xml.content.text(); //return all text of xml file including the html tags, but not the xml tags and [DATA
				//str = str.replace( myPattern, "event:function=");  //replace "Asfunction:" for "event:function=" in HTML that way we dont have to update about 50 xml old files
				str = str.replace(myPattern, "event:"); //replace "Asfunction:" for "event:function=" in HTML that way we dont have to update about 50 xml old files				
				statetitletxt = String(_xml.title);
				//trace("statetitletxt"+statetitletxt);
				sta_Panel.state_txt.text = "" + statetitletxt;
				sta_textField.htmlText = str; //return as a web page				
				vScrollBar.update();
				vScrollBar.scrollPosition = 0;
				//sta_textField.scroll = 0;
				//FOR findLessonByStandard
				xmlCorrelations = new XMLList(_xml.correlations.standard);
				//trace(xmlCorrelations);
			}
		}

		/*************************************************************************************
		 * FUNCTION: FIND LESSONS BY STANDARDS
		 ************************************************************************************/
		private function findLessonsPanel(): void {
			loadingmc_clip.visible = true;
			usmap.visible = false;
			key_Panel.visible = false;
			pub_Panel.visible = false;
			sta_Panel.visible = false;
			find_Panel.visible = true;
		}

		/*************************************************************************************
		 * FUNCTION: SEARCH BY STANDARDS
		 ************************************************************************************/
		private function standardSearch(ev: MouseEvent): void {
			usmap.visible = true;
			tabStd_mc.gotoAndStop(2);
			tabPub_mc.gotoAndStop(1);
			tabKeyword_mc.gotoAndStop(1);
			loadingmc_clip.visible = false;
			key_Panel.visible = false;
			pub_Panel.visible = false;
			sta_Panel.visible = false;
			find_Panel.visible = false;
			//Object(parent).trackSearch = "sstate";
			//Object(parent).setLastPubId(str, false);
			Object(parent).setLastStateSearch("sstate", "main", isBrowsigSearch);

		}

		/*************************************************************************************
		 * FUNCTION: SEARCH BY PUBLICATIONS
		 ************************************************************************************/
		private function byPubSearch(ev: MouseEvent): void {
			sta_Panel.visible = false;
			loadingmc_clip.visible = true;
			usmap.visible = false;
			key_Panel.visible = false;
			find_Panel.visible = false;
			pub_Panel.visible = true;
			tabStd_mc.gotoAndStop(1);
			tabPub_mc.gotoAndStop(2);
			tabKeyword_mc.gotoAndStop(1);
			//IF FIRST TIME PUBLICATION PANEL IS DISPLAYED
			//Object(parent).trackSearch = "spublication";
			Object(parent).setLastSearch("spublication", isBrowsigSearch);
			if (firstTimePublication == true) {
				tableByPub();
				firstTimePublication = false;
			}
		}

		/*************************************************************************************
		 * FUNCTION: SEARCH BY KEYWORD TAB
		 ************************************************************************************/
		private function byKeywordSearch(ev: MouseEvent): void {
			loadingmc_clip.visible = true;
			tabStd_mc.gotoAndStop(1);
			tabPub_mc.gotoAndStop(1);
			tabKeyword_mc.gotoAndStop(2);
			sta_Panel.visible = false;
			usmap.visible = false;
			pub_Panel.visible = false;
			find_Panel.visible = false;
			key_Panel.visible = true;
			Object(parent).setLastSearch("skeyword", isBrowsigSearch);
			//Object(parent).trackSearch = "skeyword";
		}
		/*************************************************************************************
		 * FUNCTION: SEARCH BY STANDARDS
		 ************************************************************************************/
		public function standardSearch2(): void {
			usmap.visible = true;
			loadingmc_clip.visible = true;
			tabStd_mc.gotoAndStop(2);
			tabPub_mc.gotoAndStop(1);
			tabKeyword_mc.gotoAndStop(1);
			key_Panel.visible = false;
			pub_Panel.visible = false;
			sta_Panel.visible = false;
			find_Panel.visible = false;
			//Object(parent).trackSearch = "sstate";
			//Object(parent).setLastPubId(str, false);
			// Object(parent).setLastSearch("sstate", isBrowsigSearch);
		}

		/*************************************************************************************
		 * FUNCTION: SEARCH BY PUBLICATIONS
		 ************************************************************************************/
		public function byPubSearch2(): void {
			sta_Panel.visible = false;
			loadingmc_clip.visible = true;
			usmap.visible = false;
			key_Panel.visible = false;
			find_Panel.visible = false;
			pub_Panel.visible = true;
			tabStd_mc.gotoAndStop(1);
			tabPub_mc.gotoAndStop(2);
			tabKeyword_mc.gotoAndStop(1);
			//IF FIRST TIME PUBLICATION PANEL IS DISPLAYED
			//Object(parent).trackSearch = "spublication";
			//Object(parent).setLastSearch("spublication", isBrowsigSearch);
			if (firstTimePublication == true) {
				tableByPub();
				firstTimePublication = false;
			}
		}

		/*************************************************************************************
		 * FUNCTION: SEARCH BY KEYWORD TAB
		 ************************************************************************************/
		public function byKeywordSearch2(): void {
			tabStd_mc.gotoAndStop(1);
			loadingmc_clip.visible = true;
			tabPub_mc.gotoAndStop(1);
			tabKeyword_mc.gotoAndStop(2);
			sta_Panel.visible = false;
			usmap.visible = false;
			pub_Panel.visible = false;
			find_Panel.visible = false;
			key_Panel.visible = true;
			//Object(parent).setLastSearch("skeyword", isBrowsigSearch);
			//Object(parent).trackSearch = "skeyword";
		}
		public function byKeywordSearch3(): void {
			tabStd_mc.gotoAndStop(1);
			loadingmc_clip.visible = true;
			tabPub_mc.gotoAndStop(1);
			tabKeyword_mc.gotoAndStop(2);
			sta_Panel.visible = false;
			usmap.visible = false;
			pub_Panel.visible = false;
			find_Panel.visible = false;
			key_Panel.visible = true;
			Object(parent).setLastSearch("skeyword", isBrowsigSearch);
			//Object(parent).trackSearch = "skeyword";
		}
		/*************************************************************************************
		 * FUNCTION:ENTER A WORD IN TXTFIELD AND SEARCH BY KEYWORD, PRESSING BUTTON OR ENTER KEY
		 ************************************************************************************/
		private function searchByKeyword(ev: MouseEvent): void {
			searchLessonsByKeyword();
		}
		private function pressEnterKey(evt: KeyboardEvent): void {
			if (evt.keyCode == 13) {
				searchLessonsByKeyword();
			}
		} //KeyCode = 13 is ENTER key		 

		private function searchLessonsByKeyword(): void {
			//  var arr:Array = new Array();		

			var keyword: String = key_Panel.search_txt.text;
			//trace("keyword               "+keyword);
			if (keyword == "" || keyword == null) {
				key_wordFilter = null;
			} else {
				var dtArray: Array = [];
				var dtreplace: Array = [];
				for (var i23: int = 0; i23 < keyword.length; i23++) {
					//Create an array of grades to filter lessons					
					var dkeychar = keyword.charAt(i23);
					//trace("dkeychar "+dkeychar);
					switch (dkeychar) {
						case "[":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("[")
							break;
						case "]":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("]")
							break;
						case "$":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("$")
							break;
						case "^":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("^")
							break;
						case ".":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push(".")
							break;
						case ",":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push(",")
							break;
						case "?":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("?")
							break;
						case "+":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("+")
							break;
						case "(":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("(T")
							break;
						case ")":
							//trace(i23);
							dtArray.push(i23);
							dtreplace.push("t)")
							break;
						default:
					}

				}
				//trace(dtArray.length);
				var dwcheck = 0;
				for (var i24: int = 0; i24 < dtArray.length; i24++) {
					//if (dtArray.length>1){
					//for(var i25:int = 0; i25 < dtArray.length; i25++){	
					//trace(dtArray[i25]);
					var dtempEnd2: Number = dtArray[i24];
					//var dtempThis=dtreplace[i25];
					//trace(dtempEnd2);
					keyword = keyword.slice(0, dtempEnd2 + dwcheck) + "\\" + keyword.slice(dtempEnd2 + dwcheck, keyword.length)
					//trace("keyword loop "+keyword);
					//keyword.replace(dtempEnd2+dwcheck, "\\"+dtempThis);
					//}
					dwcheck = dwcheck + 1;
					//trace("keyword again "+keyword);
					//trace("here2");
					//var dtemp ='/'
					/* } else {
					 	trace("here3");
					 	var dtempEnd:Number=dtArray[i24];
					 	trace ("i dunno "+keyword.slice(0,dtempEnd)+"\\"+keyword.slice(dtempEnd+1,keyword.length));
					 	keyword=keyword.slice(0,dtempEnd)+"\\"+keyword.slice(dtempEnd,keyword.length)
				 	}*/
					//Create an array of grades to filter lessons					
					//var dkeychar = keyword.charAt(i23);

					//trace(dtArray[i24]);
				}
				key_wordFilter = new RegExp(keyword, "i");
				//trace (key_wordFilter);
			}

			//SET FILTERS							
			var gradeArr: Array = new Array();
			var str: String;
			for (var i: uint = 0; i < key_chkboxArr.length; i++) {
				//Create an array of grades to filter lessons					
				if (key_chkboxArr[i].On == true && i < 4) {
					gradeArr.push("" + key_chkboxArr[i].Grades);
				}
			}
			if (key_chkboxArr.length == 5) {
				if (key_chkboxArr[4].On == true) {
					online = true;
				} else {
					online = false;
				}
			}
			//trace(gradeArr);
			key_gradeFilterArr = gradeArr;
			appliedFiltersKeyPanel();
		}

		/*************************************************************************************
		 * FUNCTION: OPEN STATE
		 ************************************************************************************/
		private function showState(ev: MouseEvent): void {
			var clicked: Object = ev.target;
			var str: String = "" + clicked.name;
			var stateAbr_str: String = str.replace("_btn", "");
			var stateName_str: String;
			//IF JUMPSTART OR NCEE, ELSE SEARCH FOR STATE NAME
			if (stateAbr_str == "jumpstart" || stateAbr_str == "ncee") {
				stateName_str = stateAbr_str;
			} else {
				for (var ind: int = 0; ind < statesAbrv.length; ind++) {
					if (statesAbrv[ind] == stateAbr_str) {
						stateName_str = statesName[ind];
					}
				}
			}
			usmap.visible = false;
			key_Panel.visible = false;
			pub_Panel.visible = false;
			find_Panel.visible = false;
			sta_Panel.visible = true;
			//sta_Panel.state_txt.text = ""+ statetitletxt;			
			currentState = "" + stateName_str; //keep the name of the current state
			loadStateStandard("standards/standards_" + stateAbr_str + "_ve50.xml");
			dssabrv = stateAbr_str;

			Object(parent).setLastStateSearch("sstate", "standards/standards_" + stateAbr_str + "_ve50.xml", isBrowsigSearch);
		}

		//Click here to go to web page



		private function overState(ev: MouseEvent): void {
			//addEventListener(Event.ENTER_FRAME, followCursor);
			detailer_btn.alpha = 100;
			// Mouse.hide();
			detailer_btn.mouseEnabled = false;
			detailer_btn.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);

			var statebtn: Object = ev.target;
			setStateColor(statebtn, "rollover");

			var btnName: String = "" + statebtn.name;
			var stateAcro: String = btnName.replace("_btn", "");

			detailer_btn.detail_mc.tooltip.text = getTooltip(stateAcro); //check XML for year
			detailer_btn.detail_mc.state.htmlText = "<b>" + getStateName(stateAcro) + "</b>";
		}



		private function outState(ev: MouseEvent): void {
			detailer_btn.alpha = 0;
			// Mouse.show();
			detailer_btn.mouseEnabled = true;
			detailer_btn.removeEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
			// detailer_btn.x = 900;
			// detailer_btn.y = 900;			
			//stage.removeChild(this.usmap.detailer_btn);			
			var statebtn: Object = ev.target;
			setStateColor(statebtn, "rollout");
		}

		private function getStateName(stateAbr_str: String): String {
			var stateName_str: String;
			//IF JUMPSTART OR NCEE, ELSE SEARCH FOR STATE NAME
			if (stateAbr_str == "jumpstart" || stateAbr_str == "ncee") {
				stateName_str = stateAbr_str;
			} else {
				for (var ind: int = 0; ind < statesAbrv.length; ind++) {
					if (statesAbrv[ind] == stateAbr_str) {
						stateName_str = statesName[ind];
					}
				}
			}
			return stateName_str;
		}

		private function fl_CustomMouseCursor(event: Event) {
			detailer_btn.x = stage.mouseX - 40;
			detailer_btn.y = stage.mouseY - 15;
		}



		/*************************************************************************************
		 * FUNCTION: HIDE STANDARD
		 ************************************************************************************/
		private function hideStandard(ev: MouseEvent): void {
			key_Panel.visible = false;
			find_Panel.visible = false;
			pub_Panel.visible = false;
			sta_Panel.visible = true;
			usmap.visible = false;
			Object(parent).setLastStateSearch("sstate", "standards/standards_" + dssabrv + "_ve50.xml", isBrowsigSearch);
			//trace("currentState          ++++++++ "+currentState);			//keep the name of the current state

			//Object(parent).setLastStateSearch("sstate", "main", isBrowsigSearch);

		}
		private function hideStandard2(ev: MouseEvent): void {

			key_Panel.visible = false;
			find_Panel.visible = false;
			pub_Panel.visible = false;
			sta_Panel.visible = false;
			usmap.visible = true;
			Object(parent).setLastStateSearch("sstate", "main", isBrowsigSearch);
		}
		/*************************************************************************************
		 * FUNCTION: GET PUBLICATION TITLE PER ID
		 ************************************************************************************/
		private function getPublicationTitle(id_str: String): String {
			var strtitle: String = "";
			if (id_str == null || id_str == "") {
				strtitle = "N/A"
			} else {
				for (var i: uint = 0; i < pubItemsArray.length; i++) {
					var item: PublicationItem = pubItemsArray[i];
					if (item.pid == id_str) {
						strtitle = item.ptitle;
					}
				}
			}
			return strtitle;
		}


		/*******************************************************************
		 * FUNCTION:CREATE AN ARRAY THAT CONTAINS OBJECTS OF PROPERTIES FOR EACH CHECKBOX
		 *******************************************************************/
		private function createCheckBoxArray(numboxes: int): Array {
			var arr: Array = new Array();
			arr.push({
				Name: "chk1_mc",
				On: true,
				Position: "1",
				Grades: "K-2"
			});
			arr.push({
				Name: "chk2_mc",
				On: true,
				Position: "2",
				Grades: "3-5"
			});
			arr.push({
				Name: "chk3_mc",
				On: true,
				Position: "3",
				Grades: "6-8"
			});
			arr.push({
				Name: "chk4_mc",
				On: true,
				Position: "4",
				Grades: "9-12"
			});
			/*
			 if( numboxes == 1 ){ 
				 arr.push( { Name:"chk1_mc", On:true, Position:"1", Grades:"K-2"} ); 
			 } else if( numboxes == 2 ){ 
				  arr.push( { Name:"chk2_mc", On:true, Position:"2", Grades:"3-5"} );
			 } else if( numboxes == 3 ){ 

				 arr.push( { Name:"chk3_mc", On:true, Position:"3", Grades:"6-8"} );

			 }else if( numboxes == 4 ){ 

				 arr.push( { Name:"chk4_mc", On:true, Position:"4", Grades:"9-12"} );
			 }	else if( numboxes == 11 ){ 
				 arr.push( { Name:"chk1_mc", On:false, Position:"1", Grades:"K-2"} ); 
			 } else if( numboxes == 12 ){ 
				  arr.push( { Name:"chk2_mc", On:false, Position:"2", Grades:"3-5"} );
			 } else if( numboxes == 13 ){ 
				 arr.push( { Name:"chk3_mc", On:false, Position:"3", Grades:"6-8"} );

			 }else if( numboxes == 14 ){ 
				 arr.push( { Name:"chk4_mc", On:false, Position:"4", Grades:"9-12"} );
			 }		
			 */
			return arr;
		}

		/*******************************************************************
		 * FUNCTION:CREATE AN ARRAY THAT CONTAINS OBJECTS OF PROPERTIES FOR EACH CHECKBOX
		 *******************************************************************/
		private function displayCheckboxStatus(str: String, arr: Array): void {
			var panel: String = str + "_Panel"; //key_Panel or pub_Panel

			for (var i: uint = 0; i < arr.length; i++) {
				var pos: String = arr[i].Position;
				//trace("arr[i].On "+arr[i].On);
				switch (pos) {
					case "1":
						if (arr[i].On == true) {
							this[panel].chk1_mc.x_mc.visible = true;
						} else {
							this[panel].chk1_mc.x_mc.visible = false;
						}
						break;
					case "2":
						if (arr[i].On == true) {
							this[panel].chk2_mc.x_mc.visible = true;
						} else {
							this[panel].chk2_mc.x_mc.visible = false;
						}
						break;
					case "3":
						if (arr[i].On == true) {
							this[panel].chk3_mc.x_mc.visible = true;
						} else {
							this[panel].chk3_mc.x_mc.visible = false;
						}
						break;
					case "4":
						if (arr[i].On == true) {
							this[panel].chk4_mc.x_mc.visible = true;
						} else {
							this[panel].chk4_mc.x_mc.visible = false;
						}
						break;
						/*case "5":
					 	if( arr[i].On == true ){ this[panel].chk5_mc.x_mc.visible = true; }
						else{ this[panel].chk5_mc.x_mc.visible = false; }
					 break;*/
					default:
						trace("no checkbox");
				}
			}
		}

		/*******************************************************************
		 * FUNCTION: TURN CHECKBOX CLICKED ON - OFF
		 *******************************************************************/
		private function checkboxClicked(evt: MouseEvent): void {
			var arr: Array;
			var gradeArr: Array = new Array();
			alreadyfound = [];
			//CHECK IN WHICH PANEL IS THE CHECKBOX CLICKED
			//IF THE PARENT OF THE CHECKBOX IS A INSTANCE OF 'searchMenu_movie'
			//THEN THE CHECKBOX IS IN THE 'key_Pane'l ELSE IS IN THE 'pub_Panel'				
			var panelName: String = evt.currentTarget.parent.toString(); //[object searchMenu_movie]				
			panelName = panelName.substring(8, panelName.length - 1); //searchMenu_movie				
			if (panelName == "searchMenu_movie") {
				arr = key_chkboxArr;
			}
			//else  { arr = pub_chkboxArr; }				
			else if (panelName == "searchPubMenu_movie") {
				arr = pub_chkboxArr;
			} else {
				arr = find_chkboxArr;
			}

			var chkName: String = evt.currentTarget.name; //chk1_mc
			var checkObj: Object = evt.currentTarget;
			var str: String;
			for (var i: uint = 0; i < arr.length; i++) {
				//Set to TRUE or FALSE the ON property of the checkbox in the array
				if (arr[i].Name == chkName) {
					if (arr[i].On == true) {
						arr[i].On = false;
					} else {
						arr[i].On = true;
					}
				}
				//Create an array of grades to filter lessons					
				if (arr[i].On == true && i < 4) {
					gradeArr.push("" + arr[i].Grades);
				} //dont push online flag in grade filter
			}
			//CHECK FOR ONLINE LESSONS
			if (arr.length == 5 && panelName == "searchMenu_movie") {
				if (arr[4].On == true) {
					online = true;
				} else {
					online = false;
				}
			}
			if (arr.length == 5 && panelName == "SearchStandard_movie") {
				if (arr[4].On == true) {
					findonline = true;
				} else {
					findonline = false;
				}
			}
			//SET CHECK ARRAY FILTER FOR PANEL
			if (panelName == "searchMenu_movie") {
				key_gradeFilterArr = gradeArr;
				appliedFiltersKeyPanel();
			} else if (panelName == "searchPubMenu_movie") {
				pub_gradeFilterArr = gradeArr;
				appliedFiltersPubPanel();
			} else {
				find_gradeFilterArr = gradeArr;
				appliedFiltersFindPanel();
			}
		}

		/*******************************************************************
		 * FUNCTION: TURN CHECKBOX CLICKED ON - OFF
		 *******************************************************************/
		private function checkWordFilter(key_wordFilter: RegExp, _title: String, _desc: String, _concept: String): Boolean {
			var goodItem: Boolean = false;
			var str: String = "" + _title + _desc + _concept;

			//key_Panel.search_txt.text
			if (("" + _title) == "Front Material" || ("" + _title) == "Back Material") {
				goodItem = false;
			} else {
				//trace("key word 2"+key_wordFilter);
				//trace(str);

				//if( key_wordFilter == null ){ goodItem = true; }					
				if (key_Panel.search_txt.text == null || key_Panel.search_txt.text == "") {
					goodItem = true;
				} else if (str.search(key_wordFilter) > -1) {
					goodItem = true;
				} else {
					goodItem = false;
				}
			}
			return goodItem;
		}

		/*******************************************************************
		 * FUNCTION: CHECK IF FILTER IS ONLINE
		 *******************************************************************/
		private function IsOnline(flag: Boolean, type: String): Boolean {
			//var goodItem:Boolean = true;
			var goodItem: Boolean = false;
			if (flag == true && type == "online") {
				goodItem = true;
			}
			//if(flag == true ){					
			//if(type == "online" ){ goodItem = true;}
			//else{goodItem = false; }					
			//goodItem = true;
			//}
			//else{ 
			//if(type == "online" ){ goodItem = false;}
			//else{goodItem = true; }					
			//}				
			return goodItem;
		}

		/*******************************************************************
		 * FUNCTION: CHECK IF GRADE FILTER
		 *******************************************************************/
		private function checkGradeFilter(grade: String): Boolean {
			//trace("------------------------------------------------------------filter run------------------------------------------------");
			var goodItem: Boolean = false;
			//trace("grade "+grade);
			for (var i: uint = 0; i < key_gradeFilterArr.length; i++) {
				//trace(key_gradeFilterArr[i]);
				var dfront;
				var dfront2;
				if (grade != null) {
					dfront = key_gradeFilterArr[i].charAt(0);
					if (dfront == "K") {
						dfront = 0;
					}
					dfront = Number(dfront);
					//trace("dfront  "+dfront);
					dfront2 = Number(grade.charAt(0));
					//trace("dfront2  "+dfront2);
				} else {
					dfront = 99;
					dfront2 = 1;
				}
				var drear1c;
				//trace(key_gradeFilterArr[i].length);
				if (key_gradeFilterArr[i].length > 3) {
					var drear1a = key_gradeFilterArr[i].length;
					drear1c = Number(key_gradeFilterArr[i].slice((drear1a) - 2));
				} else if (key_gradeFilterArr[i].length < 4 && key_gradeFilterArr[i].length > 0) {
					drear1c = Number(key_gradeFilterArr[i].charAt(2));
				}
				var drear2c;
				//trace(grade.length);
				if (grade.length > 3) {
					var drear2a = grade.length;
					drear2c = Number(grade.slice((drear2a) - 2));
					//trace(Number(grade.slice((drear2a)-2)));
				} else if (grade.length < 4 && grade.length > 0) {
					drear2c = Number(grade.charAt(2));
				}
				//trace("dfront   "+dfront+"       dfront2    "+dfront2);
				//trace("drear1c   "+drear1c+"       drear2c    "+drear2c);
				if (dfront >= dfront2 && drear2c >= drear1c) {
					goodItem = true;
				}
				//if(dfront == dfront2 && drear2c == drear1c){
				//goodItem = true; 
				//} else if(grade == key_gradeFilterArr[0]){
				//goodItem = true; 

				//}
			}
			return goodItem;

		}
		private function checkGradeFilterFind(grade: String): Boolean {
			var goodItem: Boolean = false;
			//trace("grade "+grade);
			for (var i: uint = 0; i < find_gradeFilterArr.length; i++) {
				//trace(key_gradeFilterArr[i]);
				var dfront;
				var dfront2;
				if (grade != null) {
					dfront = find_gradeFilterArr[i].charAt(0);
					if (dfront == "K") {
						dfront = 0;
					}
					dfront = Number(dfront);
					//trace("dfront  "+dfront);
					dfront2 = Number(grade.charAt(0));
					//trace("dfront2  "+dfront2);
				} else {
					dfront = 99;
					dfront2 = 1;
				}
				var drear1c;
				//trace("key "+key_gradeFilterArr[i].length);
				//trace("find "+find_gradeFilterArr[i].length);

				if (find_gradeFilterArr[i].length > 3) {
					var drear1a = find_gradeFilterArr[i].length;
					drear1c = Number(find_gradeFilterArr[i].slice((drear1a) - 2));
				} else if (find_gradeFilterArr[i].length < 4 && find_gradeFilterArr[i].length > 0) {
					drear1c = Number(find_gradeFilterArr[i].charAt(2));
				}
				var drear2c;
				//trace(grade.length);
				if (grade.length > 3) {
					var drear2a = grade.length;
					drear2c = Number(grade.slice((drear2a) - 2));
					//trace(Number(grade.slice((drear2a)-2)));
				} else if (grade.length < 4 && grade.length > 0) {
					drear2c = Number(grade.charAt(2));
				}
				//trace("dfront   "+dfront+"       dfront2    "+dfront2);
				//trace("drear1c   "+drear1c+"       drear2c    "+drear2c);
				if (dfront >= dfront2 && drear2c >= drear1c) {
					goodItem = true;
				}
				//if(dfront == dfront2 && drear2c == drear1c){
				//goodItem = true; 
				//} else if(grade == key_gradeFilterArr[0]){
				//goodItem = true; 

				//}
			}
			return goodItem;
		}

		/*******************************************************************
		 * FUNCTION: APPLIED ALL FILTERS TO FIND LESSONS BY STANDARD
		 *******************************************************************/
		private function appliedFiltersFindPanel(): void {
			var arr: Array = new Array();
			//trace("currentFindLessonsArr filter"+currentFindLessonsArr.length);
			for (var ii: uint = 0; ii < currentFindLessonsArr.length; ii++) {
				var item: LessonItem = currentFindLessonsArr[ii];
				//trace("filter item"+item.gradelevel);
				//if( checkGradeFilterFind(item.gradelevel)  &&  IsOnline(findonline, item.type)  )						
				//if( checkGradeFilterFind(item.gradelevel)  ||  IsOnline(findonline, item.type)  )	
				if (checkGradeFilterFind(item.gradelevel) || IsOnline(findonline, item.type)) {
					arr.push(item);
				}
			}
			fsp.source = null;
			//trace("arr    "+arr.length);
			populateFind(arr);
		}
		//findonline

		/*******************************************************************
		 * FUNCTION: APPLIED ALL FILTERS TO BY KEYWORD PANEL
		 *******************************************************************/
		private function appliedFiltersKeyPanel(): void {
			var arr: Array = new Array();
			for (var ii: uint = 0; ii < lessonItemsArray.length; ii++) {
				var item: LessonItem = lessonItemsArray[ii];
				//trace(item);
				//if( checkGradeFilter(item.gradelevel)  &&  checkWordFilter(key_wordFilter, item.title, item.desc, item.concepts)  && IsOnline(online,item.type)  )																
				if (checkGradeFilter(item.gradelevel) && checkWordFilter(key_wordFilter, item.title, item.desc, item.concepts) || IsOnline(online, item.type)) {
					arr.push(item);
				}
			}
			sp.source = null;
			populateByKeywords(arr);
		}

		/*******************************************************************
		 * FUNCTION: APPLIED ALL FILTERS TO BY PUBLICATION PANEL
		 *******************************************************************/
		private function appliedFiltersPubPanel(): void {
			//trace("----------------------------------------------filter--------------------------------------------");
			var arr: Array = new Array();
			var dwcheck: Boolean = false;
			var myfilterArray: Array = new Array();
			//trace("PUB GRADE FILTER:"+pub_gradeFilterArr);
			var fstart;
			var filterArr: Array = new Array();
			//HMD 3.22.11 Revisions for publications with filtering
			//Built Filter for the items that are in the checked boxes
			for (var i: uint = 0; i < pub_gradeFilterArr.length; i++) {

				fstart = pub_gradeFilterArr[i].split("-")
				//trace("FSTART:"+fstart)
				//Put first item in Array
				var fitem
				if (fstart[0] == "K") {
					fitem = 0
				} else {
					fitem = Number(fstart[0])
				}

				//If there's no second item, add in the same which will only popoulate once
				if (fstart.length == 1) {
					fstart.push(fstart[0])
				}

				//Now pull the last item and see what in between needs to be added
				for (var ct = fitem; ct <= Number(fstart[1]); ct++) {
					//trace(ct);
					filterArr.push(ct);
				}

			}
			//trace("FILTER ITEMS:"+filterArr);

			//Go through each item to see if it falls into the filter

			for (var ii: uint = 0; ii < pubItemsArray.length; ii++) {
				var item: PublicationItem = pubItemsArray[ii];
				//trace("Item Grade Level"+item.gradelevel);
				var gl: Array = new Array();

				//var itemGrade:Array=new Array();
				var startGrade
				var endGrade

				if (item.gradelevel != null) {

					gl = item.gradelevel.split("-")

					if (gl[0] == "K") {
						startGrade = 0
					} else {
						startGrade = Number(gl[0])
					}

					if (gl.length > 0) {
						endGrade = Number(gl[1])
					} else {
						endGrade = startGrade;
					}

				} else {
					startGrade = 0
					endGrade = 99
				}

				//Now that we have the array that contains which grades are avaialble in the filter and info to tell us the starting and stopping grades, we can now look through and see what matches can be found

				//First thing - see if it already exists
				var found = false;
				var isMatch: Boolean = false;
				for (var iiii: int = 0; iiii <= alreadyfound.length; iiii++) {
					//trace("iii "+iii);
					//trace("alreadyfound.length"+alreadyfound.length);
					//trace("alreadyfound"+alreadyfound);
					//trace("alreadyfound[iii]"+alreadyfound[0]);
					//trace("item.id  "+item.pid);
					if (alreadyfound[iiii] == item.pid) {
						//trace("Already in there");
						found = true;
					}
				}

				if (!found) {
					//search to see if it exists
					//trace (_testArray.indexOf(7));
					for (ct = startGrade; ct <= endGrade; ct++) {
						if (filterArr.indexOf(ct) != -1) {
							//trace("Found a match");
							isMatch = true
						}
					}

				}

				if (isMatch && !found) {
					//Now to add it in if isMatch is still true
					var dtemp: String = item.pid;
					//trace(dtemp);
					alreadyfound.push(dtemp);
					arr.push({
						Image: item.img,
						Id: item.pid,
						Title: item.ptitle,
						Description: item.desc,
						Grade: item.gradelevel
					});
				}

			}

			/*
			//Older code below
			for(var i:uint= 0; i < pub_gradeFilterArr.length; i++){
				
					for(var ii:uint = 0; ii < pubItemsArray.length; ii++){
						var item:PublicationItem = pubItemsArray[ii];
						//trace(item);
						
						var dfront;
						var dfront2;
						trace("Item Grade Level"+item.gradelevel);
						if (item.gradelevel !=null){
							//Show starting grade level
							dfront = pub_gradeFilterArr[i].charAt(0);
							if (dfront == "K"){
								dfront = 0;
							}
							dfront = Number(dfront);
							//trace("dfront  "+dfront);
							
							//show ending grade level
							dfront2 = item.gradelevel.charAt(0);
							if (dfront2 == "K"){
								dfront2 = 0;
							}
							dfront2 = Number(dfront2);
							//trace("dfront2  "+dfront2);
							trace("Grade range:"+dfront+" : "+dfront2);
							
						} else {
							dfront = 99;
							dfront2 = 1;
							trace("Grade range in Filter:"+dfront+" : "+dfront2);
						}
						
						
						var drear1c;
						//trace(pub_gradeFilterArr[i].length);
						if (pub_gradeFilterArr[i].length > 3){
							var drear1a = pub_gradeFilterArr[i].length;
							drear1c = Number(pub_gradeFilterArr[i].slice((drear1a)-2));
						} else if (pub_gradeFilterArr[i].length < 4 && pub_gradeFilterArr[i].length > 0){
							drear1c = Number(pub_gradeFilterArr[i].charAt(2));
						}
						
						
						var drear2c;
						//trace(item.gradelevel.length);
						if (item.gradelevel.length > 3){
							var drear2a = item.gradelevel.length;
							drear2c = Number(item.gradelevel.slice((drear2a)-2));
							//trace(Number(item.gradelevel.slice((drear2a)-2)));
						} else if (item.gradelevel.length < 4 && item.gradelevel.length > 0){
							drear2c = Number(item.gradelevel.charAt(2));
						}
						trace("Grade range of this item:"+drear1c+" : "+drear2c);
						
						for(var iii:int = 0; iii <= alreadyfound.length; iii++){
							//trace("iii "+iii);
							//trace("alreadyfound.length"+alreadyfound.length);
							//trace("alreadyfound"+alreadyfound);
							//trace("alreadyfound[iii]"+alreadyfound[0]);
							//trace("item.id  "+item.pid);
							if (alreadyfound[iii]==item.pid){
								trace("Already in there");
								dwcheck=true;
							}
						}
						
						//trace(dtemp);
						//Here is the check
						//dfront is the starting grade of the item
						//dfront2 is the ending grade of the item
						//drear1c is the starting grade of the item
						//drear2c is the ending grade of the item
						
						//if the item starting grade is >=filter start and ending grade is less <==filter end
						
						if(!dwcheck){
							//if(dfront >= dfront2 && drear2c >= drear1c && dwcheck!= true){
							if(drear1c >= dfront && drear2c <= dfront2 && dwcheck!= true){
								var dtemp:String = item.pid;
								//trace(dtemp);
								alreadyfound.push(dtemp);
								arr.push( { Image:item.img, Id:item.pid, Title:item.ptitle, Description:item.desc, Grade:item.gradelevel } );
								trace("------------------------");
								trace("Adding:"+item.ptitle);
								trace("------------------------");
							
							}
						}
						
					}
			}
			//End of filter
			*/
			psp.source = null;
			populateByPub(arr);
		}

		/*******************************************************************
		 * FUNCTION: APPLIED ALL FILTERS TO BY PUBLICATION PANEL
		 *******************************************************************/
		private function clearSearch(evt: MouseEvent): void {
			key_wordFilter = null;
			//trace("clear did happen?");
			key_Panel.search_txt.text = "";
			//trace("key_chkboxArr.length       "+key_chkboxArr.length);
			for (var i: uint = 0; i < (key_chkboxArr.length); i++) {
				key_chkboxArr[i].On = true;
			}
			//key_chkboxArr[4].On = true; //online lessons are out by default
			displayCheckboxStatus("key", key_chkboxArr);
			sp.source = null;
			tableByKeywords();
		}


		/*******************************************************************
		 * FUNCTION: CHECK IF THE LESSON IS ONLINE BASED IN THE ID
		 *******************************************************************/
		private function isLessonOnline(idstr: String): String {
			var onlineurl: String;

			for (var i: uint = 0; i < lessonItemsArray.length; i++) {
				var item: LessonItem = lessonItemsArray[i];
				if ((item.type == "online") && (item.id == idstr)) {
					onlineurl = item.pdf_url;
				} //in online Lessons is an web url
				else if ((item.type == "print") && (item.id == idstr)) {
					onlineurl = "";
				}
			}
			return onlineurl;
		}



		/*******************************************************************
		 * FUNCTION: LOAD XML FOR MAP TOOLTIP
		 *******************************************************************/
		private function loadXMLtooltips(stream): void {
			dwpassTips = stream;
			
			var xmlfullpath = Object(parent).getDpath();
			loadXMLtooltipsXML(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + "usmap-econ.xml");
			
			//2019-07-11 NOLOAD
			/*
			//trace("dwpasspub "+dwpasspub);
			trace("dwpassstate " + dwpassTips);
			trace("$streamurl " + $streamurl + dwpassTips);
			var streamtemp = $streamurl + dwpassTips
			
			var TIPSLoadertemp: URLLoader = new URLLoader();
			TIPSLoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerTIPS);
			TIPSLoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
			var TIPSUrltemp: URLRequest = new URLRequest(streamtemp);
			//pubsLoadertemp.addEventListener(Event.COMPLETE,pubsLoaded);
			TIPSLoadertemp.load(TIPSUrltemp);
			*/
		
		}
		private function httpStatusHandlerTIPS(event: HTTPStatusEvent): void {
			//trace("httpStatusHandler: -----------------------------------" + event);
			//trace("status: " + event.status);
			if (event.status == 0) {
				internetcontext = "Unable to locate internet connection";

				var xmlfullpath = Object(parent).getDpath();
				loadXMLtooltipsXML(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + "usmap-econ.xml");
			} else {
				loadXMLtooltipsXML($streamurl + "usmap-econ.xml");
			}
			//loadLibraryFinal(MainConstants.XMLPATH + dwpasspub);
		}
		private function ioErrorHandler(event: IOErrorEvent): void {
			trace("ioErrorHandler: " + event);
		}
		private function loadXMLtooltipsXML(stream): void {
			var url: URLRequest = new URLRequest(stream);
			//trace("xmlTooltipPath "+stream);
			var loader: URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, loadToolTips);
			loader.load(url);
			function loadToolTips(evt: Event): void {
				var _xml: XML = new XML(loader.data);
				tooltipXmlList = new XMLList(_xml.tooltips.tooltip);
				//trace(tooltipXmlList);
			}

		}

		/*******************************************************************
		 * FUNCTION: GET TOOLTIP FOR THE USA MAP STATES
		 *******************************************************************/
		private function getTooltip(acron: String): String {
			var tip: String = "";
			if (tooltipXmlList.length() > 0) {
				var item: XML;
				for each(item in tooltipXmlList) {
					if (item.@id == acron) {
						tip = "" + item;
					}
				}

			}
			return tip;
		}


		/*******************************************************************
		 * FUNCTIONS:  SET UP ALL BUTTONS AND TEXTFIELDS
		 *******************************************************************/
		private function setup(): void {
			this.tabStd_mc.buttonMode = true;
			this.tabStd_mc.mouseChildren = false;
			this.tabStd_mc.useHandCursor = true;
			//this.loadingmc_clip.gotoAndStop(2);
			this.tabPub_mc.buttonMode = true;
			this.tabPub_mc.mouseChildren = false;
			this.tabPub_mc.useHandCursor = true;

			this.tabKeyword_mc.buttonMode = true;
			this.tabKeyword_mc.mouseChildren = false;
			this.tabKeyword_mc.useHandCursor = true;

			this.tabStd_mc.addEventListener(MouseEvent.CLICK, standardSearch);
			this.tabPub_mc.addEventListener(MouseEvent.CLICK, byPubSearch);
			this.tabKeyword_mc.addEventListener(MouseEvent.CLICK, byKeywordSearch);
			tabKeyword_mc.gotoAndStop(2);
			tabPub_mc.gotoAndStop(2);
			this.close_button.buttonMode = true;
			this.close_button.mouseChildren = false;
			this.close_button.useHandCursor = true;

			/*this.about_button.buttonMode = true;
			this.about_button.mouseChildren = false; 
			this.about_button.useHandCursor = true; 						
			*/
			this.close_button.addEventListener(MouseEvent.MOUSE_OVER, onCloseOver);
			this.close_button.addEventListener(MouseEvent.MOUSE_OUT, onCloseOut);
			this.close_button.addEventListener(MouseEvent.CLICK, onCloseClick);

			//this.about_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm); 
			this.about2_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm);

			this.nav_back_button.addEventListener(MouseEvent.MOUSE_OVER, onNavBackOver);
			this.nav_back_button.addEventListener(MouseEvent.MOUSE_OUT, onNavBackOut);
			this.nav_back_button.addEventListener(MouseEvent.CLICK, gotoLastFrm);

			this.nav_home_button.addEventListener(MouseEvent.MOUSE_OVER, onNavHomeOver);
			this.nav_home_button.addEventListener(MouseEvent.MOUSE_OUT, onNavHomeOut);
			this.nav_home_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoHomeFrm);

			this.nav_concepts_button.addEventListener(MouseEvent.MOUSE_OVER, onNavConceptsOver);
			this.nav_concepts_button.addEventListener(MouseEvent.MOUSE_OUT, onNavConceptsOut);
			this.nav_concepts_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoConceptsFrm);

			this.nav_lessons_button.addEventListener(MouseEvent.MOUSE_OVER, onNavLessonsOver);
			this.nav_lessons_button.addEventListener(MouseEvent.MOUSE_OUT, onNavLessonsOut);
			this.nav_lessons_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoSearchFrm);

			//this.pagejump_btn_3.addEventListener(MouseEvent.MOUSE_DOWN, gotoLessonsFrm); //(frame 3)
		}


		/*******************************************************************
		 * FUNCTIONS:  BUTTONS ROLL OVER & OUT
		 *******************************************************************/
		private function onCloseOver(evt: MouseEvent): void {
			close_button.gotoAndStop(2);
		}
		private function onCloseOut(evt: MouseEvent): void {
			close_button.gotoAndStop(1);
		}
		private function onNavBackOver(evt: MouseEvent): void {
			back_icon_roll.gotoAndStop(2);
		}
		private function onNavBackOut(evt: MouseEvent): void {
			back_icon_roll.gotoAndStop(1);
		}
		private function onNavHomeOver(evt: MouseEvent): void {
			house_mc.gotoAndStop(2);
		}
		private function onNavHomeOut(evt: MouseEvent): void {
			house_mc.gotoAndStop(1);
		}
		private function onNavConceptsOver(evt: MouseEvent): void {
			nav_concepts_roll.gotoAndStop(2);
		}
		private function onNavConceptsOut(evt: MouseEvent): void {
			nav_concepts_roll.gotoAndStop(1);
		}
		private function onNavLessonsOver(evt: MouseEvent): void {
			nav_lessons_roll.gotoAndStop(2);
		}
		private function onNavLessonsOut(evt: MouseEvent): void {
			nav_lessons_roll.gotoAndStop(1);
		}

	} // Main class

} //end package

/*
<lessons>
<lesson type="print" id="65756" publication="95" lang="en" display="true">
			<title><![CDATA[Lesson 2 - Why Do Free Goods Disappear Quickly?]]></title>
			<desc><![CDATA[The teacher conducts a class discussion focused on how people tend to take better care of things they own and why they may be careless with things they do not own.]]></desc>
			<concepts><![CDATA[incentives,private property,property rights,science,environmental economics,1-56183-574-9,]]></concepts>
			<gradedisplay>6-8</gradedisplay>
			<gradelevel>6-8</gradelevel>
			<url><![CDATA[1-56183-574-9_02.pdf]]></url>
		</lesson>
		<lesson type="print" id="65757" publication="95" lang="en" display="true">
			<title><![CDATA[Lesson 3 - Why Do We Have So Few Whales and So Many Chickens?]]></title>
			<desc><![CDATA[The students participate in a classroom simulation that demonstrates the tragedy of the commons. Next, the simulation is altered by an introduction of property rights, and the simulation outcome changes. Then the students solve th...]]></desc>
			<concepts><![CDATA[choice,incentives,property rights,decision making/cost-benefit analysis,property rights,science,environmental economics,1-56183-574-9,]]></concepts>
			<gradedisplay>6-8</gradedisplay>
			<gradelevel>6-8</gradelevel>
			<url><![CDATA[1-56183-574-9_03.pdf]]></url>
		</lesson>
*/