// JScript source code
	function loadit(gopage) {
		if (opener == undefined || opener == "undefined") {
			this.location = gopage
		} else {
			tmp1 = this.location.href;
			opener.location.href=gopage;
			this.location.href=tmp1;
		}
	}

	function setQTSearchFocus() {
		document.qtsearch.ticker.focus();
	}

	function openPlayerSelection(windowURL) {
	   playerSelectWin = window.open(windowURL,'playerSelectWin','toolbar=no,titlebar=no,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=312,height=480,top=20,left=10');
    }

	function openUnivWin(windowName) {
	if ((navigator.appVersion.indexOf("Mac") != -1)) {
		newWindow = window.open(windowName, 'newWindow','toolbar=no,location=no,menubar=no,width=475,height=550,scrollbars=yes,resizable=no');
	} else {
		newWindow = window.open(windowName, 'newWindow','toolbar=no,location=no,menubar=no,width=493,height=550,scrollbars=yes,resizable=no');
	}}

	function openwin(windowName, width, height) {  
	    newWindow = window.open(windowName, 'newWindow','width='+width+',height='+height+',scrollbars=yes,top=10, left=10');  
	} 
	
	function winOpen(url,width,height) {
	    //Incoming width and height are formatted for IE on windows platform.		
		if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.appName == "Microsoft Internet Explorer")) {
		    height = height * .892;
			window.open(url,'macie','menubar=no,resizable=yes,status=no,scrollbars=yes,width='+width+',height='+height); }
		if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.appName == "Netscape")) {
		    height = height * .941;
			window.open(url,'macNN','menubar=no,resizable=yes,status=no,scrollbars=yes,width='+width+',height='+height); }		
		if ((navigator.appVersion.indexOf("Win") != -1) && (navigator.appName == "Netscape")) {
		    height = height * 1.059;
			window.open(url,'NN','menubar=no,resizable=yes,status=no,scrollbars=yes,width='+width+',height='+height); }
		if ((navigator.appVersion.indexOf("Win") != -1) && (navigator.appName == "Microsoft Internet Explorer")) {
			window.open(url,'IE','menubar=no,resizable=yes,scrollbars=yes,width='+width+',height='+height); }	
	}
	 
	function getSelectedButton(buttonGroup) { 
		for (var i = 0; i < buttonGroup.length; i++) {			
			if(buttonGroup[i].checked) {
				return buttonGroup[i].value;
			}   
		}
		return 0;
	}            

   function openQuizAnswer(quesId, colId) {
     var answer = getSelectedButton(document.quizAnswer.userAnswer);
       if (answer == 0) {
          alert("Please answer the question.");
          return false;
       }
	 var destURL = "/articlenet/quiz_answer.aspx?quesId=" + quesId + "&answer=" + answer + "&colId=" + colId;	 
	 newWindow = window.open(destURL, 'newWindow','toolbar=no,menubar=no,width=411,height=245,scrollbars=yes,resizable=no');
     return false;
   }

	var browser_type=navigator.appName
	function popUpAndRedirect(windowName) {
		history.go(-1);
		if (browser_type=="Microsoft Internet Explorer") {
			newWindow = window.open(windowName, 'myWindow','toolbar=no,location=no,menubar=no,width=475,height=550,scrollbars=no,resizable=no');
		} else {
			newWindow = window.open(windowName, 'myWindow','toolbar=no,location=no,menubar=no,width=475,height=550,top=0,left=0,scrollbars=no,resizable=no');
		}		
	}
	
function srchTerm()
{
	sSearchType = document.searchForm.SrchType.value;

	if (sSearchType == "search") {
		document.searchForm.SrchTerm.value = document.searchForm.sSrchTerm.value;
  	document.searchForm.action = "http://search.morningstar.com/MstarSrch/MstarSrch2.aspx?topnav=search";
  	document.searchForm.submit();
	} else {
		document.searchForm.action = "http://quote.morningstar.com/switch.html?ticker="+document.searchForm.sSrchTerm.value;
		document.searchForm.submit();
  }
}

function setSearchType(sSearchType)
{
	document.searchForm.SrchType.value = sSearchType;
}

function ClearSearchBox()
{
	var text = document.searchForm.sSrchTerm.value;
	if (text == "Enter ticker, name or topic")
		document.searchForm.sSrchTerm.value = "";
}

function setContent(url, symbol)
{
	var xmlhttp=getXMLHTTP();
	xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) 
			{		
				if (xmlhttp.status == 200) {
					try{	
						document.getElementById(symbol).innerHTML =xmlhttp.responseText;	
					}catch (e){
					}
				}
			}
		}
	xmlhttp.open("GET",url,true);		
	xmlhttp.send(null);
}
function setPopArticle(filepath, symbol)
{
	var url = "/articleProxy/GetPopArticle.aspx?filepath=" +filepath;
	setContent(url, symbol);
}
function setRelatedNews(tickers, symbol)
{
	var url = "/articleProxy/GetRelatedNews.aspx?ticker=" +tickers;
	setContent(url, symbol);
}
function setRelatedArticle(keyword, symbol)
{
	var url = "/articleProxy/GetRelatedArticle.aspx?keyword=" +keyword;
	setContent(url, symbol);
}
function setButton(id, symbol)
{ 
	var url = "/articleProxy/GetArticleButton.aspx?id=" +id;
	setContent(url, symbol);
}
function openDelicious(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(title, 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 turnonDate(weekid,rptDate,symbol) 
{ 
  for (var i=1;i<=6;i++)
    {
   //  document.getElementById("Tabmenu" + i).className="sdir";
          document.getElementById("Week" + i).style.display = "none";

     }
   // document.getElementById("Tab" + id).className="sdirOn";
    document.getElementById(weekid).style.display = "block";
    
    setEarnings(weekid+"Dt1",rptDate, symbol);

}
function setEarnings(dtid,rptDate, symbol)
{  
    var weekid=dtid.substring(0,5);
 
    for (var i=1;i<6;i++)
    {
          document.getElementById(weekid+"Dt" + i).className="col2";
    }
    document.getElementById(dtid).className="days_today";
    document.getElementById(dtid).href="";
	var url = "GetEarningsCalendar.aspx?rptDate=" +rptDate;
	setContent(url, symbol);
}

 window.onload = function ()
{   
    var myDate = new Date();
    for ( var i=1;i<6;i++)
    {
        if (myDate.getDay()==i)
        {  
          if (document.getElementById("Week5Dt"+ i) != null )
           {
	        document.getElementById("Week5Dt"+ i).className="days_today";
	        }
	    }
    }	
    if (myDate.getDay()==6 || myDate.getDay()==7)
    {   if (document.getElementById("Week5Dt1") != null )
	       document.getElementById("Week5Dt1").className="days_today";
    }
};