function ShowTab(sTabLayers,sTabs,sImageNameBases,iIndex)
{	
	var aTabLayers = sTabLayers.split(",");
	var aTabs = sTabs.split(",");
	var aImageNameBases = sImageNameBases.split(",");
	var i = 0;
	
	for(i=0;i<aTabLayers.length;i++)
	{
		try {
		//turn off all tab sections
		document.getElementById(aTabLayers[i]).style.display = "none";
		//turn off all tabs themselves
		document.getElementById(aTabs[i]).src = "http://i.d.com.com/i/mdl/global/2006/pages/" + aImageNameBases[i] + "_off.gif";
		} catch(e){
		//couldn't find tab or layer
		}
	}
	
	//display the correct tab section and tab image (according to the arguments passed in to this function)
	var sSectionDivId = aTabLayers[iIndex];
	var sTabImageId = aTabs[iIndex];	
	document.getElementById(sSectionDivId).style.display = "block";					
	document.getElementById(sTabImageId).src = "http://i.d.com.com/i/mdl/global/2006/pages/" + aImageNameBases[iIndex] + "_on.gif";
}
				

				
function MouseOverTab(sTabs, sImageNameBases, iIndex)
{
	var aTabs = sTabs.split(",");
	var aImageNameBases = sImageNameBases.split(",")	
	var sTabId = aTabs[iIndex];
	var sTabName = aImageNameBases[iIndex];

	var sImage = document.getElementById(sTabId).src;
	sImage = sImage.substring(sImage.length-6,sImage.length-4)				
	if (sImage != "on")
	{
		document.getElementById(sTabId).src = "http://i.d.com.com/i/mdl/global/2006/pages/" + sTabName + "_over.gif";
	}						
}

function MouseOutTab(sTabs, sImageNameBases, iIndex)
{

	var aTabs = sTabs.split(",");
	var aImageNameBases = sImageNameBases.split(",")	
	var sTabId = aTabs[iIndex];
	var sTabName = aImageNameBases[iIndex];
	
	var sImage = document.getElementById(sTabId).src;
	sImage = sImage.substring(sImage.length-6,sImage.length-4)					
	if (sImage != "on")
	{
		document.getElementById(sTabId).src = "http://i.d.com.com/i/mdl/global/2006/pages/" + sTabName + "_off.gif";
	}					
}

 
							
//imgExpandCollapse[1..n]  for expand/coll images
//tablayer-result-1          for divs

function ExpandCollapse(sDivIndex)
{
	if (document.getElementById("tablayer-result-" + sDivIndex).style.display == "block")
	{
		document.getElementById("tablayer-result-" + sDivIndex).style.display = "none";
		document.getElementById("imgExpandCollapse" + sDivIndex).src = "http://i.d.com.com/i/mdl/global/2006/pages/icon_expand.gif";
	}
	else
	{
		document.getElementById("tablayer-result-" + sDivIndex).style.display = "block";
		document.getElementById("imgExpandCollapse" + sDivIndex).src = "http://i.d.com.com/i/mdl/global/2006/pages/icon_condense.gif";
	}									
}	

function ExpandAll()
{			


	var imgExpandAll = document.getElementById("imgExpandAll");	
	var sDivState = "";

	if (imgExpandAll.src.indexOf("condense_all") > 0)
	{
		document.getElementById("imgExpandAll").src ="http://i.d.com.com/i/mdl/global/2006/pages/icon_expand_all.gif";
		sDivState = "none"
		sExpandOrCollapse = "expand";
	}
	else
	{
		document.getElementById("imgExpandAll").src ="http://i.d.com.com/i/mdl/global/2006/pages/icon_condense_all.gif";			
		sDivState = "block"
		sExpandOrCollapse = "condense";
	}
	for (i=1;i<=15;i++)
	{
		document.getElementById("tablayer-result-" + i).style.display = sDivState;
		document.getElementById("imgExpandCollapse" + i).src = "http://i.d.com.com/i/mdl/global/2006/pages/icon_" + sExpandOrCollapse + ".gif";
	}

}	

function Expand()
{
	
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=838,height=628');");
}



var iCurrentPage = 1;
								    
function PreviousPicks()

{

            if (iCurrentPage > 1)

            {

                        iCurrentPage--;

                        PaintAngiePickNavNumbers();                                                                                                     

            }

            PaintAngiePickNavNumbers();

}



function NextPicks()
{
	//debugger;
	if (iCurrentPage < 3) 
	{
		iCurrentPage++;
		PaintAngiePickNavNumbers();    
	}
	
}

function PicksByNumber(iPageNumber)
{
	iCurrentPage = iPageNumber;
	PaintAngiePickNavNumbers();
}


function PaintAngiePickNavNumbers()
{	
   // debugger;		
	for (i=1;i<=3;i++)
	{
		var imgPick = document.getElementById("imgAngiePick" + i);
		var divPick = document.getElementById("tablayer-ep-" + i);
		
		
		
		if (i == iCurrentPage)
		{
			imgPick.src = "http://i.d.com.com/i/mdl/global/2006/pages/toolbar_" + i + "_on.gif"; 
			divPick.style.display = "block";  
		}
		else
		{
		   imgPick.src = "http://i.d.com.com/i/mdl/global/2006/pages/toolbar_" + i + "_off.gif";                                               								            
		   divPick.style.display = "none";
		}					     
	}								            								        
}

var sLastOpenDiv = "";
/* Toggle is duplicated here to fix a namespace conflict with prototype. the Toggle function should be removed once the watchlist functionality, which includes prototype, is deployed and all elements are precached */
function Toggle(sId)

{
	if (document.getElementById(sId).style.display == "block")
	{
		document.getElementById(sId).style.display = "none";
	}
	else
	{
		document.getElementById(sId).style.display = "block";
		if(sLastOpenDiv != "" && sLastOpenDiv != sId)
		{
			document.getElementById(sLastOpenDiv).style.display = "none";
		}
		sLastOpenDiv = sId;
	}
}
function mdlToggle(sId)

{
	if (document.getElementById(sId).style.display == "block")
	{
		document.getElementById(sId).style.display = "none";
	}
	else
	{
		document.getElementById(sId).style.display = "block";
		if(sLastOpenDiv != "" && sLastOpenDiv != sId)
		{
			document.getElementById(sLastOpenDiv).style.display = "none";
		}
		sLastOpenDiv = sId;
	}
}

sfHover = function() {
	var sfEls = document.getElementById("dropdowns");
	if (sfEls) {
		sfEls = sfEls.getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function ShowLogin(){
	var loginLinksLayer = 'loginLinks';
	var loginFieldsLayer = 'loginFields';
	if (document.getElementById(loginLinksLayer).style.display == "block") {
		document.getElementById(loginLinksLayer).style.display =="none";
		document.getElementById(loginFieldsLayer).style.display =="block";
	}
}
function toggleShowLogin()
{
    var loginLinksLayer = 'uloginOut';
    var loginFieldsLayer = 'uloginForm';

    if (document.getElementById(loginLinksLayer).style.display == "block") {
        document.getElementById(loginLinksLayer).style.display = "none";
        document.getElementById(loginFieldsLayer).style.display = "block";
    } else {
        document.getElementById(loginLinksLayer).style.display = "block";
        document.getElementById(loginFieldsLayer).style.display = "none";
    }
}
function goToSeeBenefitsUrl() {
    window.location = 'http://' + location.host + '/1320-1_32-142.html?tag=mhd_why&path=' + urlEncode(location.href);
}
function goToForgotPasswordUrl() {
    window.location = 'http://' + location.host + '/1328-1_32-142.html?tag=mhd_fg&path=' + urlEncode(location.href);
}
function urlEncode(path) {
    if (path.indexOf('%') > -1) {
        return path;
    } else {
        return escape(path);
    }
}

// new mouseover stars for MDL

			function ratingsOver2 (id, rating) {
				star_obj = document["stars_" + id];
				nms_obj = document["nms_" + id];
				if (rating > 0) {
					nms_obj.src="/i/mdl/global/nms_off_bug_trans.gif";
					star_obj.src="/i/dl/global/stars_myreviews_" + rating + ".gif";
				} else if (rating == 0) {
					nms_obj.src="/i/mdl/global/nms_on_bug_trans.gif";
					star_obj.src="/i/dl/global/stars_myreviews_0.gif";
				} else {
					nms_obj.src="/i/mdl/global/nms_off_bug_trans.gif";
					star_obj.src="/i/dl/global/stars_myreviews_0.gif";
				}
			}
			function ratingsOut2 (id) {
				star_obj = document["stars_" + id];;
				nms_obj = document["nms_" + id];
				if (currentRating == -1) {
					star_obj.src = "/i/dl/global/stars_myreviews_0.gif";
					nms_obj.src = "/i/mdl/global/nms_off_bug_trans.gif";
				} else if (currentRating > 0) {
					star_obj.src = "/i/dl/global/stars_myreviews_" + currentRating + ".gif";
					nms_obj.src = "/i/mdl/global/nms_off_bug_trans.gif";
				} else if (currentRating == 0) {
					star_obj.src = "/i/dl/global/stars_myreviews_0.gif";
					nms_obj.src = "/i/mdl/global/nms_on_bug_trans.gif";
				}
			} 



function rateObj2 (id, rating) {
	setRating(id, rating);
	currentRating = rating;
}
				
function setRatingdl2(id, score) {
  document.getElementById("rating_" + id).value = score;
  document.getElementById("stars_" + id).src = '/i/dl/global/stars_myreviews_' + score + '.gif';
}

//calls the icon legend - soon to be removed
function callIconOver () {
	if (showPopUps != null && (showPopUps=="true" || showPopUps==true)) {
		overlib("<div class='iconLegend'><img src='http://i.d.com.com/i/mdl/global/2006/icon_legend.gif' width='160' height='138'></div>", VCENTER, RIGHT, TEXTSIZE, "10px", SHADOW, DELAY, 500, WIDTH, "5");
	}
}

//calls the icon legend
function callIconOver2 () {
	if (showPopUps != null && (showPopUps=="true" || showPopUps==true)) {
		overlib('<div class=\"iconLegend\"><img src=\"http://i.d.com.com/i/mdl/global/2006/icon_legend.gif\" width=\"160\" height=\"138\"></div>', TEXTSIZE, '10px', WIDTH, 5, FGCOLOR, '#FFFFFF', BGCOLOR, '#666666', DELAY, 500, CENTER, OFFSETY, -60);
	}
}

// Clears the icon legend
function nd2(time){
if(!(OLloaded&&OLgateOK))return;
if((OLexclusivePI)&&OLisExclusive())return true;
if(time&&!o3_delay){
if(o3_timerid>0)clearTimeout(o3_timerid);
o3_timerid=setTimeout("cClick()",(o3_timeout=time));
}else{
if(o3_removecounter>=1)o3_showingsticky=0;
if(o3_showingsticky==0){
o3_allowmove=0;
if(over)hideObject(over);
}else{
o3_removecounter++;}}
return true;
}


// randomization stuff
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
};

function rand(number) {
	return Math.ceil(rnd()*number);
};

function isArray(a) {
	return isObject(a) && a.constructor == Array;
}

function isObject(a) {
	return (a && typeof a == 'object') || isFunction(a);
}

function isFunction(a) {
	return typeof a == 'function';
}


// misc

function getRadioValueMDL(submitFormName, fieldName) {
    var radioValue = "";
    var radioField =  document.forms[submitFormName][fieldName];
    for (var i=0; i < radioField.length; i++) {
        if (radioField[i].checked) {
            radioValue = radioField[i].value;
       }
    }
    return radioValue;
}