// Initialize global variables

var courseList = new Array();
courseList["ACE1000"] = "ACE1000-10";
courseList["ACE1000-08"] = "ACE1000-10";
//courseList["ACE1000CME-10"] = "ACE1000CME-10";
courseList["ACE1000DTH"] = "HIDE";
courseList["ACE1000LP-08"] = "ACE1000-10";
courseList["ACECMELP-10"] = "ACE1000-10";
courseList["ACE2000"] = "ACE2000-10";
//courseList["ACE2000CME-10"] = "ACE2000-10";
//courseList["ACE2000CMELP-10"] = "ACE2000-10";
courseList["ACE2000LP"] = "ACE2000-10";
courseList["ACE3000"] = "ACE3000-11";
courseList["ACE3000-08"] = "ACE3000-11";
courseList["ACE3000LP-08"] = "ACE3000-11";
courseList["ACE3001"] = "ACE3001-11";
courseList["ACE3001-08"] = "ACE3001-11";
courseList["ACE3001-09"] = "ACE3001-11";
courseList["ACE3001LP-09"] = "ACE3001-11";
courseList["ACE3004"] = "ACE3004-11";
courseList["ACE3004-09"] = "ACE3004-11";
courseList["ACE3004LP-09"] = "ACE3004-11";
courseList["ACE4000"] = "ACE4000-09";
courseList["ACE4010"] = "ACE4010-10";
courseList["ACE4010LP"] = "ACE4010-10";
courseList["ACE4020"] = "ACE4020-10";
courseList["ACE5000"] = "ACE5000-09";
courseList["ACE5000-09"] = "ACE5000-11";
courseList["ACE5010"] = "ACE5010-09";
courseList["ACE5010-09OLD"] = "ACE5010-09";
courseList["ACE6002"] = "ACE6002-10";
courseList["ACE6002LP"] = "ACE6002-10";
courseList["ACE6003"] = "ACE6003-10";
courseList["ACE6003LP"] = "ACE6003-10";
courseList["ACE8000"] = "ACE8000-11";
courseList["ACE8000LP"] = "ACE8000-11";
courseList["ACE1002-CORNELL"] = "HIDE";
courseList["ACE1002-CORNELL-08"] = "HIDE";
courseList["ACE1001"] = "ROOT";
courseList["ACE1001-08"] = "ROOT";
courseList["ACE1002-MTSINAI"] = "HIDE";
courseList["ACE2001"] = "ROOT";
courseList["ACE2004"] = "ROOT";
courseList["ACE2005"] = "ROOT";
courseList["ACE3002"] = "ROOT";
courseList["ACE3003"] = "ROOT";
courseList["ACE3003-09"] = "ROOT";
courseList["ACE3005"] = "ROOT";
courseList["ACE3005-09"] = "ROOT";
courseList["ACE4001"] = "ROOT";
courseList["ACE4011"] = "ROOT";
courseList["ACE4021"] = "ROOT";
courseList["ACE5001"] = "ROOT";
courseList["ACE5011"] = "ROOT";
courseList["ACE7002"] = "ROOT";
courseList["ACE8001"] = "ROOT";

var CWindow;

function CloseWindows(){
	if (CWindow) {
        if (CWindow.closed==0) {
            CWindow.close();
        }
    }
}

function getToken()
{
	var regex = new RegExp(".*accesscontinuingeducation.com\/([^\/]*)(\/.*)?");
	//var regex = new RegExp(".*localhost:81\/([^\/]*)(\/.*)?");
	var location = ""+window.location;
	return location.replace(regex,"$1");
	
}

function getCourseInfo()
{
	var token = getToken().toUpperCase();
	var message = "";
	
	
	
	if( token.length > 0 )
	{
		
		if( courseList[token] != null )
		{
			
			switch(courseList[token]) 
			{
				case "ROOT" : 
					var redirectURL = "http://accesscontinuingeducation.com/";
					message = "<div style='font-weight:bold; color:#F00; background:#FFF; border: none; background:#FFF; width:799;' ><br/><strong>Alert! This course is no longer offered!<strong> <a href=\""+redirectURL+"\">Click here to return to the home page</a>.<br/><br/></div>";				
					break;
				case "HIDE" :
					message = "";				
					break;										
				default:
					var redirectURL = "http://accesscontinuingeducation.com/"+courseList[token]+"/course.cfm";
					message = "<div style='font-weight:bold; color:#F00; background:#FFF; border: none; background:#FFF; width:799;' ><br/><strong>Alert! This course is outdated!<strong> <a href=\""+redirectURL+"\">Click here for the most recent version</a>.<br/><br/></div>";
					break;
			}
		}
		else
		{
			var courseURL = "http://accesscontinuingeducation.com/"+getToken()+"/course.cfm";
			var homeURL = "http://accesscontinuingeducation.com/";
			message = "<div style='font-weight:bold; color:#F00; background:#FFF; border: none; background:#FFF; width:799;' ><br/>This page is part of an online course provided by <a href=\""+homeURL+"\">Access Continuing Education, Inc.</a>.<br /> Need more information about this course, or how to purchase the test? <br /> <a href=\""+courseURL+"\">Visit this course's home page</a>.<br/><br/></div>";
		}
	}
	
	return message;
}

// This function opens a centered popup window.  If a window of the same name is already opened, the function closes the open window before opening a new one.  This ensures the window is always sized correctly.

function LaunchWindow(page) {
CloseWindows();	
CWindow = window.open(page,'CWindow','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}

TopLinks="<div id='header' style='background:#242f69; width:800px; margin:0px; padding:0px;'><div id='header-inside' style='background:#242f69 url(/images/build/banner_bg.png) no-repeat; height:224px; margin:0px; padding:0px;'><ul id='top-nav' style='float: right; width: 260px; height: 16px; font-size: .8em; color: #ffffff; list-style: none; margin:20px 0 0 0;'><li style='float: left; padding: 0 4px 0 4px; font-size:13px;'><a href='javascript:LaunchWindow(\"/register/register.cfm\");' style='color: #ffffff; text-decoration: none;'>Register</a></li><li class='wbullet' style='float: left; padding: 0 4px 0 4px; margin-top:2px; font-size:13px;'><img src='/images/build/bullet-white.jpg' alt='' /></li><li style='float: left; padding: 0 4px 0 4px; font-size:13px;'><a href='javascript:LaunchWindow(\"/login/login.cfm\");' style='color: #ffffff; text-decoration: none;'>Login</a></li><li class='wbullet' style='float: left; padding: 0 4px 0 4px; font-size:13px; margin-top:2px;'><img src='/images/build/bullet-white.jpg' alt='' /></li><li style='float: left; padding: 0 4px 0 4px; font-size:13px;'><a href='javascript:LaunchWindow(\"/register/register.cfm\");' style='color: #ffffff; text-decoration: none;'>My&nbsp;Access&nbsp;Records</a></li></ul><div id='access-logo' style='width: 217px; float:left; margin:0 0 0 200px; padding:0;'><a href='/index.cfm'><img src='/images/build/logo-access-continuing-education.png' alt='Access Continuing Education' style='border:none; margin-top:90px; padding:0;' /></a></div><ul id='main-nav' style='float: left;  width:1000px; list-style: none; padding: 0 40px 0 180px; margin:10px 0 0 0;'><li class='less-padding' style='float: left; list-style: none; font-size: 16px; padding: 7px 0 0 18px; padding-left: 10px;'><a href='javascript:LaunchWindow(\"/index.cfm\");' style='color: #FFFFFF; text-decoration: none;'>Home</a></li><li style='float: left; list-style: none; font-size: 16px; padding: 7px 0 0 18px;'><a href='javascript:LaunchWindow(\"/about/about.cfm\");' style='color: #FFFFFF; text-decoration: none;'>About Us</a></li><li style='float: left; list-style: none; font-size: 16px; padding: 7px 0 0 18px;'><a href='javascript:LaunchWindow(\"/about/use.cfm\");' style='color: #FFFFFF; text-decoration: none;'>FAQs</a></li><li style='float: left; list-style: none; font-size: 16px; padding: 7px 0 0 18px;'><a href='javascript:LaunchWindow(\"/login/organizational-access-billing.cfm\");' style='color: #FFFFFF; text-decoration: none;'>Organizational Access/Billing</a></li><li style='float: left; list-style: none; font-size: 16px; padding: 7px 0 0 18px;'><a href='javascript:LaunchWindow(\"/provider/status.cfm\");' style='color: #FFFFFF; text-decoration: none;'>Advisors</a></li><li style='float: left; list-style: none; font-size: 16px; padding: 7px 0 0 18px;'><a href='javascript:LaunchWindow(\"/contact/contact.cfm\");' style='color: #FFFFFF; text-decoration: none;'>Contact Us</a></li></ul></div>"+getCourseInfo()+"</div>";

