function launchCourse(url)
{
   alert(url);
	if(url=='')
    {
        for(i=0; i<document.form1.elements.length; i++)
        {
            if(document.form1.elements[i].type == "radio")
            {
                if(document.form1.elements[i].checked)
                {
                    url=document.form1.elements[i].value;
                    break;
                }
            }
        }
    }
    alert(url);
    wOpen = window.open("jsp/mycourses/launch_course.jsp?COURSE=" + url, 'launchCourse', 'width=796 height=535,top=0,left=0,resizable=yes status=0,menubar=no,scrollbar=no');
}

function getCertificate(courseId, courseName, courseHours, whetherToGenerate)
{
    window.open("/acsmweb/html/blank.html","Certificate","width=700,height=500,top=25, left=50,location=0,directories=no,status=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes");
    document.form1.OPERATION.value="SHOW_CERTIFICATE";
    document.form1.COURSEID.value=courseId;
    document.form1.COURSENAME.value=courseName;
    document.form1.COURSEHOURS.value=courseHours;
    document.form1.PROCESS_TYPE.value=whetherToGenerate;
    document.form1.action="evaluation.do";
    document.form1.target="Certificate";
    document.form1.submit();
}
function setOperation(operation)
{
    document.form1.OPERATION.value=operation;
    document.form1.submit();
}

function setHeaderOperation(operation)
{
    document.header.OPERATION.value=operation;
	document.header.action="usermanagement.do";
    document.header.submit();
}

function getPortalHome()
{
    document.form1.OPERATION.value="GET_LOGIN_PAGE";
    document.form1.submit();
}

function getHome()
{
    document.header.OPERATION.value="GET_HOME";
    document.header.action="usermanagement.do";
    document.header.submit();
}
function getAdminHome()
{
    document.header.OPERATION.value="GET_ADMIN_HOME";
    document.header.action="usermanagement.do";
    document.header.submit();
}

function getCMEHome()
{
	document.header.OPERATION.value="GET_CME_HOME";
	document.header.action="assetmanagement.do";
	document.header.submit();
}

function getAssetToolHome()
{
	//alert("Test");
	document.frmtool.OPERATION.value = "GET_ASSET_TOOL_HOME";
	document.frmtool.action = "assetmanagement.do";
	document.frmtool.submit();
}
function getAddComment()
{
	document.header.OPERATION.value = "GET_ADD_COMMENT_PAGE";
	document.header.action = "assetmanagement.do";
	document.header.submit();
}

function getDeleteComment()
{
	document.header.OPERATION.value = "GET_DELETE_COMMENTS_PAGE";
	document.header.action = "assetmanagement.do";
	document.header.submit();
}

function getAddDiscount()
{
	document.header.OPERATION.value = "GET_ADD_DISCOUNT_PAGE";
	document.header.action = "assetmanagement.do";
	document.header.submit();
}

function getEditListDiscount()
{
	document.header.OPERATION.value = "GET_EDIT_LIST_DISCOUNT_PAGE";
	document.header.action = "assetmanagement.do";
	document.header.submit();
}

function getAdminReports()
{
    document.header.OPERATION.value="";
    document.header.action="reports.do";
    document.header.submit();
}
function getAdminCourseHome()
{
    document.header.OPERATION.value="GET_COURSE_ADMIN_PAGE";
    document.header.action="importCourse.do";
    document.header.submit();
}
function getInstallPTestPage()
{
    document.header.OPERATION.value="IMPORT_PTEST_PAGE";
    document.header.action="importPTest.do";
    document.header.submit();
}

function getAuthHome()
{
	document.header.OPERATION.value = "GET_AUTH_TOOL_HOME";
	document.header.action = "importPTest.do";
	document.header.submit();
}
// Quiz starts Here
function getQuizHome()
{
	document.header.OPERATION.value = "GET_QUIZ_TOOL_HOME";
	document.header.action = "assetmanagement.do";
	document.header.submit();
}
//quiz ends Here
function getCreatePracticeTest()
{
	document.header.OPERATION.value="GET_CREATE_PRACTICE_TEST";
    document.header.action="importPTest.do";
	document.header.submit();
}

function getCourseCatalogHome()
{
    document.header.OPERATION.value="GET_PRACTICE_TESTLIST";
    document.header.action="practiceTest.do";
    document.header.submit();
}

function logOff()
{
    document.header.OPERATION.value="LOGOFF";
    document.header.action="usermanagement.do";
    document.header.submit();
}
function goReportList()
{
    document.header.action="reports.do";
    document.header.submit();
}
function getMyCourses()
{
    document.header.OPERATION.value="GET_MY_COURSE_LIST";
    document.header.action="courses.do";
    document.header.submit();
}
function getCourseCatalog()
{
    document.header.OPERATION.value="GET_UNSUBSCRIBED_COURSES";
    document.header.action="courses.do";
    document.header.submit();
}
function callFAQs()
{
    document.header.OPERATION.value="MANAGEFAQLIST";
    document.header.action="faq.do";
    document.header.submit();
}

function callContactUs()
{
    document.header.OPERATION.value="GET_CONTACTUS";
    document.header.action="usermanagement.do";
    document.header.submit();
  
}
function callPolicy()
{
    document.header.OPERATION.value="GET_POLICY";
    document.header.action="usermanagement.do";
    document.header.submit();

 
}
function callTerms()
{
    document.header.OPERATION.value="GET_TERMS";
    document.header.action="usermanagement.do";
    document.header.submit();
}

function callAboutUs()
{
    document.header.OPERATION.value="GET_ABOUT_US";
    document.header.action="usermanagement.do";
    document.header.submit();
}

function callDisclaimer()
{
    document.header.OPERATION.value="GET_DISCLAIMER";
    document.header.action="usermanagement.do";
    document.header.submit();
 
}

function NoPracticeTestMessage()
{
    alert('You will need to login to access the Practice Tests.');
}

function NoAssetMessage()
{
    alert('You will need to login to view the Asset.');
}

function openErrorwin()
{
    mywin=window.open("jsp/common/displayerror.jsp","hrblock_errorwindow","width=400,height=221,scrollbars,top=0,left=0,screenX=0,screenY=0"); 
}

function trimString (str)
{
    str = this != window? this : str;
    return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function MM_preloadImages() 
{
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() 
{
    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)
{
    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()
{
    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];}
}

function getAdminLinksHome() {
	 document.header.OPERATION.value = "MANAGELINKSLIST";
     document.header.action = "managelink.do";
     document.header.submit();
}

function rightClickDisable(go)
{
	if (document.all)
	{
		if (event.button == 2 || event.button==3) 
		{
		alert("ACSM Learning Portal\nThe Mouse Right click functionality has been disabled.");
		return false;
		}
		else
		{
			documentState = document.readyState;
			if (documentState == "loaded" || documentState == "complete")
			{
				//alert(documentState);		
			}
			else
			{
				alert("ACSM Learning Portal\nPlease wait for the page elements to download.");								
			}
		}
	}
	
}

 document.onmousedown=rightClickDisable;

function keyDown(e)
{
	
	if (navigator.appName == "Netscape")
            var ieKey = e.which;
	else
            var ieKey = event.keyCode;

	if((ieKey==37 && event.srcElement.type != "text" && event.srcElement.type != "textarea") || (ieKey==8 && event.srcElement.type != "text" && event.srcElement.type != "textarea") || (ieKey==39 && event.srcElement.type != "text" && event.srcElement.type != "textarea")|| ((window.event.ctrlKey || window.event.keyCode == 17) && window.event.keyCode == 80)|| (ieKey==17 && ieKey==80 && event.srcElement.type != "text" && event.srcElement.type != "textarea"))
	{
		window.event.keyCode = 506;
	}
	/*if(window.event && window.event.keyCode == 506)
    { 
		//alert("506 1");
		alert('ACSM Learning Portal\nThe use of special keys has been disabled.');
		return false;
    }*/

	if((ieKey==116 && event.srcElement.type != "text" && event.srcElement.type != "textarea") || ieKey==93 || (ieKey==17 && ieKey==82 && event.srcElement.type != "text" && event.srcElement.type != "textarea") || ((window.event.ctrlKey || window.event.keyCode == 17) && window.event.keyCode == 82))
	{
	    window.event.keyCode = 505;
	}
	if(window.event && window.event.keyCode == 505)
	{ 
		alert('ACSM Learning Portal\nThe Refresh function has been disabled.');
		return false;
	}
}

if (navigator.appName == "Netscape")
    document.captureEvents(Event.KEYPRESS)

document.onkeydown = keyDown;