function initMenu()
{
	FixDropdownForIE("menuList");
}

function FixDropdownForIE(ulTagID)
{
	if (document.all && document.getElementById)
	{
		navRoot = document.getElementById(ulTagID);
		if (navRoot != null)
		{
			for (i=0; i < navRoot.childNodes.length; i++)
			{
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI")
				{
					node.onmouseover=function()
					{
						this.className+=" over";
						var obj = document.mainform.elements;
						for (var j=0; j< obj.length; j++)
						 {
						 	if ((obj[j].type =="select-one") && (obj[j].name != "CCOWebBody:CCOWebHeader:ddlTopics"))
						 	{
						 		obj[j].style.visibility = "hidden";
						 	}
						 }
					}
					node.onmouseout=function()
					{
						this.className=this.className.replace(" over", "");
						var obj = document.mainform.elements;
						for (var j=0; j< obj.length; j++)
						 {
						 	if (obj[j].type =="select-one")
						 	{
						 		obj[j].style.visibility = "visible";
						 	}
						 }
					}
				}
			}
		}
	}
}

function fixParentHeight(parentID)
{

	if (document.getElementById) 
	{
		var node = document.getElementById(parentID);
		var hgt = 0;
		for (var i=0; i < node.childNodes.length; i++) {
			var child = node.childNodes[i];
			if (child.nodeName=="DIV") 
			{
				if ((child.offsetHeight+child.offsetTop) > hgt) hgt = (child.offsetHeight + child.offsetTop);
			}
		}
		node.style.height = hgt + "px";
		return true;
	}
}

// to be overwritten in a page if it needs to do some special init handling
function preInit() {};
function postInit() { };

function init()
{
	preInit();
	initMenu();
	fixParentHeight("mainContent");
	postInit();
}


function openExternalLink(url)
{
	alert("You are now leaving this CME activity and visiting an external site. The faculty, the accrediting body, and Clinical Care Options, LLC are not responsible for the accuracy or objectivity of the content of the site you are about to visit. Click 'OK' to continue to the external site.");
	var d = new Date();
	var millis = Math.floor(d.getTime());
	var w;

	
	var title = "external" + millis;


	w = window.open(url, title);
	

	if (w)
		w.focus();
	else // blocked!
		alert('Message from Clinical Care Options:\n' +
				'\n' +
				'The item you clicked on cannot be displayed - most likely\n' +
				'because you are blocking popup windows for this site.\n' +
				'\n' +
				'Try clicking on the item again. If that doesn\'t work, you\n' +
				'will need to disable popup blocking to see the item.\n');
}

function openForgotPasswordDialog()
{
	CCOWindowOpen("/x/Forgot%20Password.aspx","forgotpassword","width=300,height=300");
}

function popCertificate(guid)
{
	CCOWindowOpen("/x/Certificate.aspx?ID="+guid,"certificate","height=680,width=650,status,scrollbars,toolbar");
}

function openPrintVersion()
{
	var url = window.location.href;
	if (url.indexOf("?") > -1)
	{
		url += "&lg=print";
	}
	else
	{
		url += "?lg=print";
	}
	CCOWindowOpen(url,"print","width=600, height=575, resizable, scrollbars");
}

function showMakeHomepageMsg(idx)
{
	var msg = "";
	switch(idx)
	{
		case "ok":
			msg = "You have successfully made this your default home page.";
			break;
		case "anon":
			msg = "You must be logged in to take advantage of this feature.";
			break;
		case "error":
			msg = "An error occurred when trying to save your default home page.";
			break;
	}
	
	alert(msg);
}

function popPage(path)
{
	var nURL = escape(path);
	if (path.indexOf(".aspx") == -1)
	{
		nURL = "/layouts/CCO.Print.aspx?path=" + nURL;
		nURL += "&p=1";
	}
	

	var d = new Date();
	var millis = Math.floor(d.getTime());
	var w;
	
	var title = "print" + millis;
	w = window.open(nURL, title, "width=600, height=575, resizable, scrollbars=1");
	

	if (w)
		w.focus();
	else // blocked!
		alert('Message from Clinical Care Options:\n' +
				'\n' +
				'The item you clicked on cannot be displayed - most likely\n' +
				'because you are blocking popup windows for this site.\n' +
				'\n' +
				'Try clicking on the item again. If that doesn\'t work, you\n' +
				'will need to disable popup blocking to see the item.\n');
}