document.onmousedown=cancelRightClick;
document.onmouseup=cancelRightClick;
document.oncontextmenu=cancelRightClick;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=cancelRightClick;
window.onmouseup=cancelRightClick;
document.onkeydown = cancelRefresh;

var choosen = false;

function cancelRefresh() {
  // keycode for F5 function
  if (window.event && window.event.keyCode == 116) {
    window.event.keyCode = 8;
  }
  // keycode for backspace
  if (window.event && window.event.keyCode == 8) {
    // cancel the backspace
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false;
  }
}


// ===================== SCRIPTS FOR THE COURSE ARTICLE PAGE ==================
var currLevel = null;
var oTimer;
function ddShowLevel(newLevel) {
   ddHideLevel();
   if (document.getElementById(newLevel)) {
	   document.getElementById(newLevel).style.display = "block";
	   currLevel = newLevel;
   }
}

function ddHideLevel() {
   if (currLevel) document.getElementById(currLevel).style.display = "none";
   currLevel = null;
}

function ddHideLevel2() {
   if (currLevel) document.getElementById(currLevel).style.display = "none";
   currLevel = null;
}

function ddStartHideTimer() {
   if (currLevel) oTimer = setTimeout("ddHideLevel(currLevel)",1000);
}

function ddStopHideTimer() {
   clearTimeout(oTimer);
}

// ===================== SCRIPTS FOR THE COURSE CATALOG PAGE ==================
   var currLevel = "L100"  
   var currProg = "P100"
   var currImg = "img100"
  

   function doShowHideLevel(newProg, newLevel, newImg) {
      document.getElementById(currLevel).style.display = "none";     
      document.getElementById(currProg).className = "CourseLevel";     

      document.getElementById(newLevel).style.display = "block";     
      document.getElementById(newProg).className = "CourseLevelCurr";
       
      document.getElementById(currImg).src="http://im.morningstar.com/im/classroom/100_0.gif";         
      document.getElementById(newImg).src="http://im.morningstar.com/im/classroom/100_1.gif"; 
                      
      currProg = newProg;
      currLevel = newLevel;
      currImg = newImg;
   }
   
   function getProgress(newPro)
   {
      document.getElementById("levelProg").innerHTML=newPro; 
   }
      

// ===================== SCRIPTS FOR THE COURSE QUIZ PAGE ======================

   function showAnswer(oDiv) {
   	         	
      if (!choosen) {
         //document.getElementById('question').style.display = "none";
      	 //disable answers after first selection
      	 document.getElementById("question").disabled = true;
         document.getElementById(oDiv).style.display = "block";
         document.getElementById("continue").style.display = "block";
         choosen = true;
      } else {
         alert("You have already choosen your answer. Please click continue to view the next question.")
      }

   }

   function SubmitQuiz() {
	document.getElementById("question").disabled = false;
	document.getElementById("quiz").submit();
   }


   function openwin(windowName,width,height) {
       newWindow = window.open(windowName, 'newWindow','toolbar=no,location=no,menubar=no,width='+width+',height='+height+',scrollbars=yes,resizable=no');
   }



   function loadit(gopage) {
   	var reg = new RegExp(".pdf", "i");
   	if (!reg.exec(gopage)) {
	   	if (opener == undefined || opener == "undefined" || window.opener.closed) {
	   		this.location = gopage
	   	} else {
	   		tmp1 = this.location.href;
	   		opener.location.href=gopage;
	   		this.location.href=tmp1;
	   	}
   	}
   	else {
   		openwin(gopage, 800, 800)
   	}
   	
   }
 		
   		
   		
   function footeropenwin(windowName,width,height) {
       newWindow = window.open(windowName, 'newWindow','toolbar=no,location=no,menubar=no,width='+width+',height='+height+',scrollbars=yes,resizable=no');
   }

   function cancelRightClick(e) {
      if (navigator.appName == 'Netscape' &&
         (e.which == 3 || e.which == 2))
      {
         return false;
      }
      else if (navigator.appName == 'Microsoft Internet Explorer' &&
         (event.button == 2 || event.button == 3)) {
         alert("You cannot navigate through the Interactive Classroom using \nright mouse clicks. Please use the links provided on screen.");
         return false;
      }
      return true;
   }

function GoCostAnalyzer()
{
	document.CostInput.submit();
}
function GoFundSelector(i)
{
	ClearFundSelectorForm();
	if(i==1)
	{
		document.FundSelector.previousview.value = "Portfolio"
		document.FundSelector.currview.value = "Portfolio"
		document.FundSelector.groupname.value = "Domestic Stock"
		document.FundSelector.catname.value = "11"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.turnover.value = "25"
		document.FundSelector.currsort.value = "turnover"
		document.FundSelector.previoussort.value = "turnover"
		document.FundSelector.pageno.value = "0"
		document.FundSelector.currby.value = "0"
		document.FundSelector.submit();
	}
	else if(i==2)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "Domestic Stock"
		document.FundSelector.catname.value = "Domestic Hybrid"
		document.FundSelector.expratio.value = "catavg"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.currsort.value = "expratio"
		document.FundSelector.previoussort.value = "expratio"
		document.FundSelector.pageno.value = "0"
		document.FundSelector.currby.value = "0"
		document.FundSelector.submit();
	}
	else if(i==3)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "Domestic Stock"
		document.FundSelector.catname.value = "Real Estate"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.submit();
	}
	else if(i==4)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "International Stock"
		document.FundSelector.catname.value = "Foreign"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.mmc.value = "-1000"
		document.FundSelector.submit();
	}
	else if(i==5)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "International Stock"
		document.FundSelector.catname.value = "Foreign"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.mmc.value = "+10000"
		document.FundSelector.submit();
	}
	else if(i==6)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "International Stock"
		document.FundSelector.catname.value = "Precious Metals"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.submit();
	}
	else if(i==7)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "Domestic Stock"
		document.FundSelector.catname.value = "Convertible Bond"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.submit();
	}
	else if(i==8)
	{
		document.FundSelector.previousview.value = "Snapshot"
		document.FundSelector.currview.value = "Snapshot"
		document.FundSelector.groupname.value = "Taxable Bond"
		document.FundSelector.catname.value = "High-Yield"
		document.FundSelector.catrating4.value = "1"
		document.FundSelector.catrating5.value = "1"
		document.FundSelector.submit();
	}

}
function GoStockSelector(i)
{
	ClearStockSelectorForm();
	if(i==1)
	{
		document.StockSelector.previousview.value = "Snapshot"
		document.StockSelector.currview.value = "Snapshot"
		document.StockSelector.curmktcap.value = "250"
		document.StockSelector.currsort.value = "curmktcap"
		document.StockSelector.previoussort.value = "curmktcap"
		document.StockSelector.pageno.value = "0"
		document.StockSelector.currby.value = "0"
		document.StockSelector.submit();
	}
}

function ClearStockSelectorForm()
{
	document.StockSelector.reset();
}
function ClearFundSelectorForm()
{
	//alert(document.FundSelector);
	document.FundSelector.reset();
}
function openDelicious()
{
	var title;
	var bookMarkTitle = document.getElementById("bookMark_Title");
	if (bookMarkTitle != null)
	{
		title = bookMarkTitle.value;
	}
	else
	{
		title = document.title;
	}
    window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href) + '&title=' + title,'delicious','toolbar=0,scrollbars=yes, resizable=yes, width=700,height=400');
}

function openDigg()
{
	var title;
	var bodytext;
	var elem = document.getElementById("bookMark_Title");
	if (elem != null)
	{
		title = elem.value;
	}
	else
	{
		title = document.title;
	}
	
	elem = document.getElementById("bookMark_Body");
	if (elem != null)
	{
		bodytext = elem.value;
	}
	else
	{
		bodytext = "";
	}
	
    window.open('http://www.digg.com/submit?phase=2&url=' + encodeURIComponent(location.href) + '&title=' + title + '&bodytext=' + bodytext + '&topic=business_finance', 'digg','toolbar=no, scrollbars=yes,resizable=yes');
}
/*
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_preloadImages() { //v3.0
  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_findObj(n, d) { //v3.0
  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); 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];}
}
*/