/* MCMC Javascript File */

/* Function to assign a stylesheet based on what browser they are using */
function initPage(step)
{
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	
	document.write('<link rel="stylesheet" type="text/css" href="');
	for(var i = 0; i < step; i++)
	{
		document.write('../');
	}
	if(browser == 'Microsoft Internet Explorer')
	{
		document.write('CSS/MCMC_CSSIE.css" />');
		
	}
	else
	{
		document.write('CSS/MCMC_CSSFF.css" />');
		
	}
	
	if(step >= 0)
	{
		document.write('<link rel="stylesheet" type="text/css" href="');
		for(var n = 0; n < step; n++)
		{
			document.write('../');
		}
		if(browser == 'Microsoft Internet Explorer')
		{
			document.write('CSS/IEstylesheet.css" />');
		}
		else
		{
			document.write('CSS/FFstylesheet.css" />');
		}
	}
}

var menu = null;


/* Shows a child Menu underneath a parent menu */
function showMenu(parent, child)
{
	if (child)
	{
		child.style.display = 'block';
		child.style.pixelLeft = getPosition(parent, "Left");
		child.style.pixelTop = getPosition(parent, "Top") + parent.offsetHeight;
		
	}
	
	if ((child != menu) && (menu))
	{
		menu.style.display = 'none';
	}

	menu = child;
	
}

/* Returns position of where the Child should be displayed */
function getPosition(parent, direction)
{
	var position = 0;
	
	while (parent != null)
	{
		position += parent["offset" + direction];
		parent = parent.offsetParent;
	}
	
	return position;


}

/* Swaps Divs to shown or hidden and changes Active Links */
function swap(id1, id2, id3, id4,id5,id6)
{
	var obj1 = document.getElementById(id1);
	var obj2 = document.getElementById(id2);
	var obj3 = document.getElementById(id3);
	
	obj1.className = 'OUTBOXNAVA';
	obj2.className = 'OUTBOXNAV';
	obj3.className = 'OUTBOXNAV';
	
	var obj4 = document.getElementById(id4);
	var obj5 = document.getElementById(id5);
	var obj6 = document.getElementById(id6);
	
	obj4.style.display = 'block';
	obj5.style.display = 'none';
	obj6.style.display = 'none';

}

/* Function that hides the header id (argument 1) and shows the content id (argument 2) */
function showFullNews(id1, id2)
{
	var header = document.getElementById(id1);
	header.style.display = 'none';
	
	var content = document.getElementById(id2);
	content.style.display = "";
}

/* Function to show ALL tbodies */
function tbodyShow()
{

	var elements = document.getElementsByTagName('tbody');
	
	for(var i = 0; i < elements.length; i++)
	{
		elements[i].style.display = "";
	}
	
}

/* Function to hide ALL tbodies in the physician's Table*/
function tbodyHide()
{
	var els = new Array('Cardiology', 'Dentistry','Emergency Medicine','Family Practice','Internal Medicine','Neurology','Optometrist','Orthopedics','Otolaryngology','Pathology','Prenatal Care','Pulmonology','Radiology','Surgery','Urology');

	for ( var i = 0; i < els.length; i++)
	{
		var obj = document.getElementById(els[i]);
		obj.style.display = 'none';
	}
}

function hideSubs() {
	sm = getElementsByClass('sMenu');
	
	for(var i = 0; i < sm.length; i++) {
		sm[i].style.display = 'none';
	}
	
}

function hideNavs() {
	navs = getElementsByClass('shown');
	
	for(var i = 0; i < navs.length; i++) {
		navs[i].className = '';
	}
}

function startTimer()
{
	$(".sMenu").everyTime(1000, "hide", function(){
		$(this).hide();
	});
	$(".menu-head").everyTime(1000, "menu-hide", function(){
		hideNavs();
	});
}

function stopTimer()
{
	$(".sMenu").stopTime("hide");
	$(".menu-head").stopTime("menu-hide");
}
