/******************************************************************************
*	client.js
*
*	Contains application client-side script for the IFEBP Web.
*
******************************************************************************/

// ControlKeyPress(field, e, btnId)
//	Took basic functionality of the old method, but tried to 
//	better handle the scripting DOM.
function IFEBPKeyPress(field, e, btnId)
{
	var keycode;
	var btn;

	if (!window.event && !e)	// just exit here
		return true;

	if (window.event)	// ie-type event capable
		keycode = window.event.keyCode;
	else
		keycode = e.which;

	if (keycode == 13)
	{
		// this is how we check for newer browser...
		if (document.getElementById)
		{
			btn = document.getElementById(btnId);

			if (btn)
			{
				btn.click();
				return false;
			}
		}
		else
		{
			// if we care about ns4, then change
			// this else clause to handle it.
		}
	}

	return true;
}
//added by nick o. 8/25/06
function displayElement(divName,styleType){
	if (document.getElementById)// this is the way the standards work
	{var docElement = document.getElementById(divName).style;}
	
	else if (document.all)// this is the way old msie versions work
	{var docElement = document.all[divName].style;}
	
	else if (document.layers)// this is the way nn4 works
	{var docElement = document.layers[divName].style;}

	docElement.display = docElement.display? "":"";
	docElement.display = docElement.display? "":styleType;
}

//added by nick o. 11/27/2007
function writeSessionCookie (codeNumber, codeValue) {
    document.cookie = codeNumber + "=" + codeValue + ";";
}

function getSessionCookieValue (LabelName){
		var WholeCookie = document.cookie;
		var LabelStart =  WholeCookie.indexOf(LabelName);
		var TheCodeStart = WholeCookie.indexOf("=",LabelStart);
		var TheCodeEnd = WholeCookie.indexOf(";",LabelStart);
		return WholeCookie.substring(TheCodeStart+1,TheCodeEnd);
}
//added by nick o. 3/27/07 to check for Pop-up Blocker
function CheckForPopUpBlocker(){
	var TestPopUpWindow = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
	if((TestPopUpWindow == null) || (TestPopUpWindow == "undefined")){
		alert('We have detected that you are using popup blocking software. Please disable before purchasing a course.');
	}
	else {
		TestPopUpWindow.close();
	}
}
//End Check for Pop-up Blocker

function popUp(URL)
{
	day=new Date();
	id=day.getTime();
	eval("page"+id+"=window.open(URL,'"+id+"');");
}

//Added by nicko 2/21/2007 to allow user to select bundle option and update Registration Button UPDATED 11/20/2007 nfo
//ItemID arrays
//Each course listed should contain in this order (Course Only PLC#, Course With CE PLC#, course type, Member Price, Non-member Price, title )
var EL01items = new Array("8582", "576", "t4", "160", "200", "HIPAA Security Rule Basics (EL01)"); 
var EL02items = new Array("8578", "570", "t4", "160", "200", "HSAs and HRAs (EL02)"); 
var EL03items = new Array("8577", "582", "t4", "160", "200", "Introduction to Health Care <BR>and Group Benefit Plans (EL03)"); 
//Removed per B.S. 5/14/2008 by Nick O.// var EL04items = new Array("8580", "579", "t4", "160", "200", "Introduction to Retirement Plans (EL04)"); 
var EL05items = new Array("8576", "573", "t4", "160", "200", "Introduction to Compensation (EL05)"); 
var EL06items = new Array("8579", "591", "t4", "160", "200", "Medicare Part D (EL06)"); 
var EL07items = new Array("8663", "565", "t4", "160", "200", "COBRA (EL07)"); 
var EL08items = new Array("8664", "588", "t4", "160", "200", "Section 125 Plans (EL08)"); 
var EL09items = new Array("9268", "594", "t2", "80", "100", "Overview of Retirement Plans (EL09)"); 
var EL10items = new Array("9269", "586", "t2", "80", "100", "Defined Contribution Plans (EL10)"); 
var EL11items = new Array("9270", "567", "t2", "80", "100", "Defined Benefit Plans (EL11)"); 
var EL12items = new Array("9271", "772", "t4", "160", "200", "Introduction to Human Resources Management (EL12)"); 
var EL13items = new Array("9315", "820", "t3", "120", "150", "ERISA (EL13)"); 
var EL14items = new Array("9343", "1388", "t3", "120", "150", "USERRA (EL14)");
var EL15items = new Array("9368", "1944", "t4", "160", "200", "401(k) Plans (EL15)"); 
var EL16items = new Array("9378", "2344", "t3", "120", "150", "Ethics for Insurance Agents (EL16)");
var EL17items = new Array("9433", "2406", "t2", "80", "100", "FMLA (EL17)");
var EL18items = new Array("9369", "2415", "t4", "160", "200", "Vendor Management (EL18)");
var EL19items = new Array("9382", "2446", "t2", "80", "100", "Short and Long Term Disability (EL19)");
var EL20items = new Array("9441", "2453", "t2", "80", "100", "Life and Accidental Death and Dismemberment (EL20)");
var EL21items = new Array("9472", "2466", "t3", "120", "150", "Consumer Driven Health Care (EL21)");
var EL22items = new Array("9449", "2484", "t3", "120", "150", "Prescription Drugs (EL22)");
var EL23items = new Array("9468", "2489", "t3", "120", "150", "Wellness and Disease Management (EL23)");
var EL24items = new Array("9494", "2501", "t1", "40", "50", "Fiduciary Responsibility (EL24)");

//Begin ET courses
var ET11items = new Array("9408", "2400", "av", "40", "50", "Working towards Healthier Employees - Smoking Cessation and Obesity (ET11)"); 
var ET14items = new Array("9404", "2380", "av", "40", "50", "Health, Economic, & Legal Components of Worksite Wellness Programs (ET14)"); 
var ET16items = new Array("9356", "2382", "av", "40", "50", "Strategic Benefits through Employee Involvement (ET16)"); 
var ET18items = new Array("9354", "2403", "av", "40", "50", "Update on HIPAA Privacy and Security (ET18)"); 
var ET19items = new Array("9353", "2402", "av", "40", "50", "Trends and Challenges in Administering FMLA (ET19)"); 
var ET21items = new Array("9409", "2397", "av", "40", "50", "401(k) Fee Reasonableness and Transparency (ET21)"); //
var ET22items = new Array("9350", "2386", "av", "40", "50", "Smoking Cessation and Other Wellness Programs:  Design and Compliance (ET22)"); 
var ET23items = new Array("9349", "2387", "av", "40", "50", "Value-Based Health Insurance Design:  Bridging the Divide <br>between Quality and Cost Containment (ET23)"); 
var ET24items = new Array("9348", "2392", "av", "40", "50", "Phased Retirement Status Update (ET24)"); 
var ET27items = new Array("9407", "2388", "av", "40", "50", "The Eight Benefits Conversations:  Recalibrating Health and Welfare (ET27)"); 
var ET29items = new Array("9381", "2395", "av", "40", "50", "Dependent Eligibility: Consider this Before your Next Open Enrollment (ET29)"); 
var ET30items = new Array("9450", "2458", "av", "40", "50", "Specialty Medication Coverage: Plan Design Decisions (ET30)"); 
var ET31items = new Array("9444", "2447", "av", "40", "50", "HIPAA Revisited (ET31)");
var ET32items = new Array("9442", "9443", "av", "40", "50", "Using Captives in Employee Benefits (ET32)");
var ET33items = new Array("9429", "2443", "av", "40", "50", "Using VEBAs to Manage Retiree Medical Liabilities (ET33)"); 
var ET36items = new Array("9446", "2452", "av", "40", "50", "FMLA: Fundamentals and More (ET36)"); 
var ET39items = new Array("9454", "2479", "av", "40", "50", "Choosing a Target Date (Lifecycle) Fund Family (ET39)");
var ET41items = new Array("9463", "2464", "av", "40", "50", "The Business Case for Employee Health and Wellbeing (ET41)");
var ET43items = new Array("9476", "2472", "av", "40", "50", "FMLA Update: Military Family Leave and <br>the New Proposed FMLA Regulations (ET43)");
var ET44items = new Array("9474", "2480", "av", "40", "50", "Wellness Programs and HIPAA Compliance: <br>Whats New - Whats Working in Practice (ET44)");
var ET45items = new Array("9452", "2482", "av", "40", "50", "New Technology for HR Service Delivery and Communication (ET45)");
var ET46items = new Array("9484", "2487", "av", "40", "50", "401(k) Fees in the Spotlight (ET46)");
var ET48items = new Array("9489", "2493", "av", "40", "50", "Its Time to Take Another Look at HIPAA Security (ET48)");
var ET49items = new Array("9492", "2495", "av", "40", "50", "Account-Based Health Plans: What Works, What Doesnt and Why (ET49)");
var ET50items = new Array("9495", "2497", "av", "40", "50", "HIPAA Privacy Refresher (ET50)");
var ET52items = new Array("9498", "2499", "av", "40", "50", "Update on Recent HSA Guidance (ET52)");

var AllPLCdivs = new Array("EL01", "EL02", "EL03", "EL05", "EL06", "EL07", "EL08", "EL09", "EL10", "EL11", "EL12", "EL13", "EL14", "EL15", "EL16", "EL17", "EL18", "EL19", "EL20", "EL21", "EL22", "EL23", "EL24", "ET11", "ET14", "ET16", "ET18", "ET19", "ET21", "ET22", "ET23", "ET24", "ET27", "ET29", "ET30", "ET31", "ET32", "ET33", "ET36", "ET39", "ET41", "ET43","ET44","ET45","ET46", "ET48", "ET49", "ET50", "ET52");

//generates "Register Now" HTML on all Sell pages
function displaySingleCourseCat(UCwindowURL) {
	if(UCwindowURL.indexOf("SELL_")!=-1){
		var CourseIDstart = UCwindowURL.indexOf("_");
		var CourseIDend = UCwindowURL.indexOf(".ASPX");
		var TheCourseID = UCwindowURL.substring(CourseIDstart+1,CourseIDend);
		
		var PLCContainerDiv = document.getElementById("singleCourse");
		//var allDivs=document.forms['pageBuilder'].all.tags("DIV"); //This uses the old ie4 way
		//for (y=0; y<allDivs.length; y++){
			//if (allDivs[y].id == "singleCourse"){	
				var ItemIDarray = eval(TheCourseID + "items");
				var OpenTags = "<Fieldset><Legend>Register Online</Legend><UL><LI class="+ItemIDarray[2]+">"+ItemIDarray[5]+" <a href='Demo_Courses.aspx' style='white-space:nowrap;'>Demo a Course</a><DIV class=PLC>";
				var RadioButtons = "";//"<INPUT onclick=\"javascript:displayItemPCL('"+TheCourseID+"','"+ItemIDarray[0]+"');\" type=radio CHECKED name=BundleOpt>Course Only</INPUT><INPUT onclick=\"javascript:displayItemPCL('"+TheCourseID+"','"+ItemIDarray[1]+"');\" type=radio name=BundleOpt>Course with CE Credit</INPUT><BR>";
				var Pricing = "";//"<SPAN class=price><B>Member:</B> $"+ItemIDarray[3]+" <B>Non-member:</B> $"+ItemIDarray[4]+"</SPAN>"; 
				var BluePLC = "";//"<DIV class=BluePLC id=itemID"+ItemIDarray[0]+" onclick=javascript:CheckForPopUpBlocker();>"+PLCContainerDiv.innerHTML+"</DIV>";
				var FauxPLC = "<DIV><SPAN class='callout'>We are currently upgrading our system.</span><br/>If you would like to purchase a course during this time,<br/>please contact us at<a href='mailto:elearning@ifebp.org'>elearning@ifebp.org</a>";//"<DIV class=fauxPLC id=itemID"+ItemIDarray[1]+" onclick=javascript:CheckForPopUpBlocker();><A href=\"CE_"+TheCourseID+".aspx\"><IMG src=\"images/PurchaseNow.gif\" border=0></A></DIV>";
				var CloseTags = "</DIV></LI></UL></Fieldset>";
				PLCContainerDiv.innerHTML = OpenTags + RadioButtons + Pricing + BluePLC + FauxPLC + CloseTags;
			//}
		//}
	}
}

//generates "Purchase Now" button options for the Topic Catalog Course divs
function displayFullCourseCat() {
	//var allDivs=document.forms['pageBuilder'].all.tags("DIV");//This uses the old ie4 way
	var PLCContainerDiv;
	for (y=0; y<AllPLCdivs.length; y++){
		//if (allDivs[y].name == "ElearningCourse"){ 
			PLCContainerDiv = document.getElementById(AllPLCdivs[y]);
			var TheCourseID = AllPLCdivs[y];
			var ItemIDarray = eval(TheCourseID + "items");
			var OpenTags = "<LI class="+ItemIDarray[2]+"><A href='Sell_"+TheCourseID+".aspx'>"+ItemIDarray[5]+"</A><DIV class=PLC>";
			var RadioButtons = "<INPUT onclick=\"javascript:displayItemPCL('"+TheCourseID+"','"+ItemIDarray[0]+"');\" type=radio CHECKED name="+TheCourseID+">Course Only</INPUT><INPUT onclick=\"javascript:displayItemPCL('"+TheCourseID+"','"+ItemIDarray[1]+"');\" type=radio name="+TheCourseID+">Course with CE Credit</INPUT><BR>";
			var Pricing = "<SPAN class=price><B>Member:</B> $"+ItemIDarray[3]+" <B>Non-member:</B> $"+ItemIDarray[4]+"</SPAN>"; 
			var BluePLC = "<DIV class=BluePLC id=itemID"+ItemIDarray[0]+" onclick=javascript:CheckForPopUpBlocker();>"+PLCContainerDiv.innerHTML+"</DIV>";
			var FauxPLC = "<DIV class=fauxPLC id=itemID"+ItemIDarray[1]+" onclick=javascript:CheckForPopUpBlocker();><A href=\"CE_"+TheCourseID+".aspx\"><IMG src=\"images/PurchaseNow.gif\" border=0></A></DIV>";
			var CloseTags = "</DIV></LI>";
			PLCContainerDiv.innerHTML = OpenTags + RadioButtons + Pricing + BluePLC + FauxPLC + CloseTags;
		//}
	}
}

//Displays the bundle option purchase link based on the radio button selection
function displayItemPCL(courseNumber,SelectedItemID) {
	var ItemIDarray = eval(courseNumber + "items");
	for (var x = 0; x < 2; x++){
		//Hide all PCLs for this course
		var PCLdivName = "itemID" + ItemIDarray[x];
		displayElement(PCLdivName,'none');
	}
	//Show selected PCL for this course
	PCLdivName = "itemID" + SelectedItemID;
	displayElement(PCLdivName,'block');
}

var TopicCatalogArray = new Array("healthCourses", "pensionCourses", "compCourses", "generalCourses");

function displayTopicCatalog(TopicSelected) {
	for (var tca = 0; tca < TopicCatalogArray.length; tca++){
		//Hide all Catalogs
		displayElement(TopicCatalogArray[tca],'none');
	}
	//Show selected catalog
	displayElement(TopicSelected,'block');
	writeSessionCookie ("PreviousTopicSelected", TopicSelected);
	for (var i=0;i<document.forms['pageBuilder'].SelectTopic.options.length;i++) {
    	if (document.forms['pageBuilder'].SelectTopic.options[i].value == TopicSelected){
	        document.forms['pageBuilder'].SelectTopic.options[i].selected = true;
			writeSessionCookie ("PreviousTopicOption", i);
		}
	}
}

function getPreviousTopicSelected(windowURL) {
	//Look for cookie value if topic was previously selected
	var CookieTopicOption = getSessionCookieValue ("PreviousTopicOption");
	//Check for topic passed in URL
	if(windowURL.indexOf("?PTS=")!=-1){
		var TheTopicStart = windowURL.indexOf("=");
		var TopicSelected = windowURL.substring(TheTopicStart+1,windowURL.length);
		displayTopicCatalog(TopicSelected)
		return;
	}else if (TopicCatalogArray[CookieTopicOption] != null){
		var CookieTopic = TopicCatalogArray[CookieTopicOption]
		displayTopicCatalog(CookieTopic);
		return; 
	}else{
		var DefaultTopic = "healthCourses";
		displayTopicCatalog(DefaultTopic);
	}
}

//added by nick o. 12/7/06 for use on custom catalog page 
//updated by nick o. 11/20/2007 (Removed ALL discount pricing changes code)

var validCodes = new Array("DMnull", "DMWAH1", "DMEBC1", "DMEBN1", "DMEBA1", "DMMHB1", "DMNAHU", "DMSHRM", "DMCUP1");
var CurrentCatalog = validCodes[0];
var curDAcodeNumber = 0;

function UpdateCatalog (DAcodeNumber){
	//alert(DAdiscounts[DAcodeNumber]+", "+validCodes[DAcodeNumber]+", "+CurrentDiscount);
	if (DAcodeNumber != curDAcodeNumber){
		displayElement(CurrentCatalog,'none');
		displayElement(validCodes[DAcodeNumber],'block');
		CurrentCatalog = validCodes[DAcodeNumber];
		curDAcodeNumber = DAcodeNumber;
	}
	if (CurrentCatalog == "DMSHRM") {
		var justTheCatalog = document.getElementById("fullCatalog");
		var allCourses = justTheCatalog.getElementsByTagName("li");
		for (var i=0; i<allCourses.length; i++){
			if (allCourses[i].className != "av"){
				allCourses[i].style.display = "none";
			}
		}
		displayElement('quickLinks','none');
		displayElement('BeginPageLayout1_RelatedLinks1_relatedLinks','none');
		displayElement('courseLegend','none');
	}
}

function getCouponCodeValue(windowURL) {
	//Check for code passed in URL
	if(windowURL.indexOf("?DM")!=-1){
		var TheCodeStart = windowURL.indexOf("?");
		var TheCode = windowURL.substring(TheCodeStart+1,windowURL.length);
		for (var x = 0; x <= validCodes.length; x++){
			if (TheCode==validCodes[x]){
				UpdateCatalog(x);
				writeSessionCookie ("TheCodeArrayNumber", x);
				writeSessionCookie ("DAcode", TheCode);
			}
		}
	return;
	}else{//Look for cookie if on the Catalog page
	var DMCodeArrayNumber = getSessionCookieValue ("TheCodeArrayNumber");
	if (validCodes[DMCodeArrayNumber] != null){UpdateCatalog(DMCodeArrayNumber);}
	return;
	}
}

//END custom catalog code

//Special onLoad functions for learner portal added by nicko 3/5/2007
function pageLoad(){
	var windowURL = unescape(window.location);
	var UCwindowURL = windowURL.toUpperCase();
	//Resets the Form Fields for the Custom Catalog and the CE Pages
	if (UCwindowURL.indexOf("CATALOG_CUSTOM")!=-1||UCwindowURL.indexOf("CE_")!=-1){document.forms['pageBuilder'].reset();}
	//Special for the Custom Catalog Pages
	if (UCwindowURL.indexOf("CATALOG_CUSTOM")!=-1){displayFullCourseCat(); getPreviousTopicSelected(windowURL); getCouponCodeValue(windowURL); }//
	if (UCwindowURL.indexOf("SELL_")!=-1){displaySingleCourseCat(UCwindowURL);}
	if (UCwindowURL.indexOf("CUSTOMTEST")!=-1){ displayFullCourseCat(); }
}

// swamp image script
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// end swap image script

// begin printer friendly script
function PrintablePage() {
	if (window.location.href.indexOf('PF=1')>0) {
		document.write('<link rel="stylesheet" type"text/css" href="//www.ifebp.org/IFEBP/common/styles/print.css">');
	}
}
// end printer friendly script

// Added 2/1/07 Dan Wagner, LearnSomething
var licNum
var licProf
var licState
// End Added 2/1/07 Dan Wagner, LearnSomething

// Added by Nick Olig, IFEBP 9/17/2007 for CEC Processing on enrollment to replace Dan Wagner's solution
function setSessionVariables() { //v1.00
	var xmlhttp
	var URL
	
	if (window.XMLHttpRequest) 
		{
		//IE and Firefox use this 
		xmlhttp = new XMLHttpRequest();
		}
	else if (window.ActiveXObject) 
		{
		xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
		}

	if (xmlhttp != null) 
		{
		URL = '/UpdateSessionState.aspx?CECLicNum=' + licNum + '&CECProfession='+ licProf + '&CECState=' + licState
		//alert(URL); //Used for testing purposes
		xmlhttp.open('GET', URL, true);
		xmlhttp.send(null);
		}
	else 
		{
		alert('Your browser does not support XMLHTTP.');
		}
}

function createCookie(name,value,days) { //v1.00
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function SaveCEvalues() {//v1.01
	var cookieValue
	//alert("LicNum: " + licNum + "\n LicState: " + licState + "\n LicProf: " + licProf); //Used for testing purposes
	setSessionVariables()
	cookieValue="CECLicNum=" + licNum + "&CECProfession=" + licProf + "&CECState=" + licState + ""
	createCookie('CECs', cookieValue, '')
}

function CEvaluesOnChange() {
	var form = document.getElementById("pageBuilder")

	licProf = form.licenseProfession.value;
	licState = form.licenseState.value;
	licNum = form.licenseNumber.value;
		
	if (licNum==null||licNum==""||licState==null||licState=="")
	{
		displayElement ('Grey_PurchaseLinkControl','block');
		displayElement ('PurchaseLinkControl','none');
	}else{
		displayElement ('Grey_PurchaseLinkControl','none');
		displayElement ('PurchaseLinkControl','block');
		SaveCEvalues();
	}
}

function HighlightRequiredFields(color) {
	var form = document.getElementById("pageBuilder");
	if (color==null||color=="") {color="yellow";}
	if (color=="yellow") {alert("Please fill in all required field(s).");}
	form.licenseProfession.style.backgroundColor=color;
	form.licenseState.style.backgroundColor=color;
	form.licenseNumber.style.backgroundColor=color;
}
//End CEC Processing on enrollment

// Added by Nick Olig, IFEBP 8/20/2007 for CEC Processing of SHRM redesignation credit
function displayCEinfo() {//v1.01
	var form = document.getElementById("pageBuilder");

	licProf = form.licenseProfession.value;
	
	HighlightRequiredFields("White");//reset required field background color
	
	if ((licProf == "INS") || (licProf == "OTH"))
		{
			displayElement ('shrmCEinfo','none');
			displayElement ('insCEinfo','block');
			CreateStateOptions();//Populates License State drop down menu
			CEvaluesOnChange();//Check CE Values
		}
	else if ((licProf == "PHR") || (licProf == "SPHR") || (licProf == "GPHR"))
		{
			displayElement ('insCEinfo','none');
			displayElement ('shrmCEinfo','block');
			displayElement ('Grey_PurchaseLinkControl','none');
			displayElement ('PurchaseLinkControl','block'); //display or "enable" purchase link control
			form.licenseState.value = ""; //Reset CE Value. 
			licState = ""; //No value needed for HRCI designations
			form.licenseNumber.value = ""; //Reset CE Value. 
			licNum = ""; //No value needed for HRCI designations
			SaveCEvalues(); //write CE Values to Session Variables and Cookie
		}
	else 
		{
			displayElement ('insCEinfo','none');
			displayElement ('shrmCEinfo','none');
		}
	
}
// END Added by Nick Olig, IFEBP 8/20/2007 for CEC Processing of SHRM redesignation credit

//Added by Nick Olig, IFEBP 9/18/2007 for CEC State Options
function CreateStateOptions () {
	//Only ALL approved States. Common "non approved" states are FL, NC, NY
	var ALLstateAbbrv = new Array("AK","AL","AR","AZ","CA","CO","CT","DC","DE","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","ND","NE","NH","NJ","NM","NV","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY");//In alpha order

	//Excluded states by course. Course Number must be in ALL CAPS and match CE page name. Updated 11/26/2007 nfo
	var ExSt_EL01 = new Array ("RI"); //updated 4-22-08
	var ExSt_EL02 = new Array ("MT","RI"); //updated 4-22-08
	var ExSt_EL03 = new Array ("RI"); //updated 4-22-08
	//Removed per B.S. 5/14/2008 by Nick O.// var ExSt_EL04 = new Array ("RI"); //updated 4-22-08
	var ExSt_EL05 = new Array ("DE","ID","ME","MA","MO","MT","NE","RI","TX"); //updated 4-22-08
	var ExSt_EL06 = new Array ("RI"); //updated 4-22-08
	var ExSt_EL07 = new Array ("none"); //updated 4-22-08 //Use "none" instead of "" when no states are excluded so that the first state option ("") remains intact
	var ExSt_EL08 = new Array ("CO","RI"); //updated 4-22-08
	var ExSt_EL09 = new Array ("LA","RI"); //updated 4-22-08
	var ExSt_EL10 = new Array ("MT","RI"); //updated 4-22-08
	var ExSt_EL11 = new Array ("RI"); //updated 4-22-08
	var ExSt_EL12 = new Array ("na"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL13 = new Array ("AL","IN","MN","NV","NM","SD","UT","WY"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL14 = new Array ("AL","DE","IN","MN","NV","NM","SD","TN","UT","WY"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL15 = new Array ("na"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL16 = new Array ("AL","DE","IN","MN","NV","NM","SC","SD","TN","UT","WY"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL17 = new Array ("IN","MN","NM","SD","TN","TX","UT","WY"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL18 = new Array ("IN","MN","NM","SD","TN","TX","UT","WY"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL19 = new Array ("AK","CT","DC","ID","IN","KY","LA","MA","MN","MO","MT","ND","NE","NM","OK","OR","RI","SD","UT","WY"); //updated 08-14-08 
	var ExSt_EL20 = new Array ("na"); //updated 4-22-08 //CE is NOT available
	var ExSt_EL21 = new Array ("na"); //updated 4-22-08 //CE is NOT available
	
	//Determine the Course Name from the CE Page
	var windowURL = unescape(window.location);
	var UCwindowURL = windowURL.toUpperCase();
	var CECourseName = UCwindowURL.substring(UCwindowURL.indexOf('CE_')+3,UCwindowURL.indexOf('.ASPX'));
	
	var thisCourseExStArray = eval("ExSt_"+CECourseName);//Use the Course Name to get the Excluded States Array
	var thisCourseExStString = thisCourseExStArray.join();//Convert the Array to a String
	
	if (thisCourseExStString != "na"){ //make sure CE is available
			//Find the Form Field
		var form = document.getElementById("pageBuilder");
		//initialize State Options
		var StateOptions = "<OPTION selected></OPTION>";
		
		for (theST=0; theST<ALLstateAbbrv.length; theST++) {
			//Filter resultes with the Excluded States String
			if (thisCourseExStString.indexOf(ALLstateAbbrv[theST])<0){
				StateOptions = StateOptions + "<OPTION value="+ALLstateAbbrv[theST]+">"+ALLstateAbbrv[theST]+"</OPTION>";
			}
		}
		
		//update innerHTML of State Selections Span Tag
		var StateSelectionHTML="<SELECT id=licstate onchange=javascript:CEvaluesOnChange(); name=licenseState>"+StateOptions+"</SELECT> *";
		document.getElementById("StateSelection").innerHTML=StateSelectionHTML;
		
	}else if (thisCourseExStString == "na"){ // If CE is NOT available
		//update innerHTML of State Selections Span Tag
		var StateSelectionHTML="<SELECT id=licstate name=licenseState><OPTION selected></OPTION></SELECT> *<BR><SPAN class=callout>CE Credit is not available at this time</SPAN>";
		document.getElementById("StateSelection").innerHTML=StateSelectionHTML;
	}
	
}
//End CEC State Options

//Course Description Links Function added by Nick Olig on 11/1/2007
function DisplayDescriptionWindow (CourseDescriptionNumber) {
	window.open('/shared/courseDescription.aspx?courseID='+CourseDescriptionNumber+'&clientID=471&URL=http://elearning.ifebp.org/elearning', 'description', 'resizable, scrollbars, width=500, height=400').focus();
	void('');
	return;
}
//End Course Description Links Function

//Purchase Token qty field added by Nick Olig on 10/11/2007 to test- copied to live 10/29/07 bp

var PreviousSelection = 1; //Default selected option for token quantity

function displayTokenPCL () {
	var form = document.getElementById("pageBuilder");
	var SelectedNumberOfTokens = form.qtyToken.value;
	displayElement (PreviousSelection, 'none');
	displayElement (SelectedNumberOfTokens,'block');
	PreviousSelection = SelectedNumberOfTokens;
}
//End Purchase Token qty field