
function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style = document.getElementById(whichLayer).style;
		style.display = style.display? "":"none";
	}
}
function hideLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style = document.getElementById(whichLayer).style;
		style.display = "none";
	}
}
function showLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style = document.getElementById(whichLayer).style;
		style.display = "";
	}
}

var subNav = false;
var subSubNav = false;
function hideSubNav(whichLayer)
{
	var t=setTimeout("hideSubNavPriv('"+whichLayer+"')",120);
}

function hideSubNavPriv(whichLayer)
{
	if(subNav)
	{
		
	}
	else
	{
		hideLayer(whichLayer);
	}
}
function hideSubSubNav(whichLayer)
{
	var t=setTimeout("hideSubSubNavPriv('"+whichLayer+"')",120);
}

function hideSubSubNavPriv(whichLayer)
{
	if(subSubNav)
	{
		
	}
	else
	{
		hideLayer(whichLayer);
	}
}

function getWindowWidth() {
	var windowWidth=0;
	if (typeof(window.innerWidth)=='number') {
		windowWidth=window.innerWidth;
	}
	else {
	if (document.documentElement&&document.documentElement.clientWidth) {
			windowWidth=
			document.documentElement.clientWidth;
		}
		else {
			if (document.body&&document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function setFooter() {
	if (document.getElementById) {
		var windowWidth=getWindowWidth();
		if (windowWidth>0) {
			var footerElement=document.getElementById('footer');
			var footerWidth=footerElement.offsetWidth;
			if (windowWidth/2.0-footerWidth/2.0>=0) {
				footerElement.style.left=(windowWidth/2.0-(footerWidth/2.0))+'px';
			}
			else {
			}
		}
	}
}

function insAtC(myField, myValue) {
	//IE support
	if (document.selection) 
	{
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
		} 
	else 
	{
		myField.value += myValue;
	}
}

function calP(template,day,hour)
{
    new Ajax.Updater('rbb','/schedules/new_schedule_element/'+template+'?day='+day+'&hour='+hour, {asynchronous:true, evalScripts:true, onComplete:function(request){RedBox.addHiddenContent('rbb'); }, onLoading:function(request){RedBox.loading(); }}); 
}