<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

sfHover = function() {
	var sfEls = document.getElementById("nav").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);

/*===============================================================================
'
'	Useage:	Code to set and read cookies for athentication on the Saperstein web site.
'
'	Author:	 , 
'
'	Functionality:
' 	1) 
' 	2) 
' 	3) 
' 	4) 	
'
' 	Notes:
' 	1) tested on 
' 	2) requires 
' 	3) change the $degug value to 1 to enable debug messages
'
'===============================================================================
'
' 	v1.0 -- , 2/22/2007
'
'==============================================================================*/

// This function gets values from the refernced cookie.
function getCookie (name) {

    var dc = document.cookie;

    var cookieArray = dc.split(";");

 

    for(i=0; i<cookieArray.length; i++)

       {

              equals=cookieArray[i].indexOf("=")

              if (equals != -1)

              {

                     labelName = cookieArray[i].substring(0, equals)

                     

                     // remove any preceding space

                     if(labelName.indexOf(" ") == 0)

                     {

                           labelName = labelName.substring(1, labelName.length)

                     }

                     

                     if(labelName == name)

                     {

                           cookieLen=cookieArray[i].length

                           value=cookieArray[i].substring(equals+1, cookieLen)

                           return value

                           var e = document.getElementById(value);

                           e.style.display = 'block';

                           e.style.visibility = 'visible';

                           document.getElementById('mnu'+value).style.backgroundColor='#005E9E';

                     }

              }

       }

}

 

function delCookie (NameOfCookie)

{

 

// The function simply checks to see if the cookie is set.

// If so, the expiration date is set to Jan. 1st 1970.

 

if (getCookie(NameOfCookie)) {

document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";

}

}

       

function setCookie(name, value, expires) {

document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());

}

 

// Now, make the new Date object and set it 30 days ahead: This keeps the cookie for 30 days.

var exp = new Date();     //set new date object

exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * -1));     //set it 30 days ahead 
//-->

// Preload clientMenu images
        if (document.images) {
			var calImageOn = new Image(328, 150);
			calImageOn.src = '../img/client_buttons_on_01.gif';
			var calImageOff = new Image(328, 150);
			calImageOff.src = '../img/client_buttons_off_01.gif';
			var bookImageOn = new Image(328, 150);
			bookImageOn.src = '../img/client_buttons_on_02.gif';
			var bookImageOff = new Image(328, 150);
			bookImageOff.src = '../img/client_buttons_off_02.gif';
		}

/* 
	This function checks to see if the "loggedin" cookie exists.
*	If "loggedin" exists, it replaces the login form from the page header with a logout button,
*	adds the submenu with "calendar" and "books" links, and changes the info text to image links for "calendar" and "books".
*/

function toggleLogin()
{

//	Get name of current file to see what we should display if logged in
	var URL = unescape(location.href)	// get current URL in plain ASCII
	var xstart = URL.lastIndexOf("/") + 1
	var xend = URL.length
	var hereName = URL.substring(xstart,xend)
//	var herePath = URL.substring(0,xstart)
//	alert("The name of the current file is: " + hereName + " and the path is: " + herePath)
	
	
    if (getCookie('loggedin')) {
//	Replace the login form with a logout button
        var el = document.getElementById('login');
        el.innerHTML = "<table style='padding-top: 5px; width: 100px' align='right' cellpadding='0' cellspacing='0'>";
        el.innerHTML += "<tbody>";
        el.innerHTML += "<tr>";
        el.innerHTML += "<form name='login' id='logout' method='post'>";
        el.innerHTML += "<td>";
        el.innerHTML += "</td>";
        el.innerHTML += "<td>";
        el.innerHTML += "<br></td>";
        el.innerHTML += "<td>";
        el.innerHTML += "</td>";
        el.innerHTML += "<td>";
        el.innerHTML += "<input value='logout' type='submit' onClick='siteLogout();'>&nbsp;";
        el.innerHTML += "</td>";
        el.innerHTML += "</tr>";
        el.innerHTML += "</form>";
        el.innerHTML += "</tbody></table>";

//	Create the "calendar" and "books" submenu bar
        var clientMenu = document.createElement('div');
        clientMenu.setAttribute('id', 'clientmenu');
        clientMenu.style.zIndex='0';
        clientMenu.innerHTML = "&nbsp;&nbsp;&nbsp;<a href='calendar.aspx'>Calendar</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href='order.aspx'>Books</a>";       
        var elm = document.getElementById('menu');
        elm.appendChild(clientMenu);
        var clm = document.getElementById('clientmenu');
        clm.style.width='99%';
        
//	Change the main info text to image links for "calendar" and "books"
		if (document.getElementById('mainInfo') != null) {
        var elPics = document.getElementById('mainInfo');
			elPics.style.height = "300px";
			elPics.style.width = "328px";
			elPics.style.paddingLeft = "0px";
			elPics.style.paddingRight = "0px";
			elPics.style.paddingTop = "0px";
			elPics.innerHTML = "<a href='calendar.aspx' onmouseover='lightup(\"calImage\")' onmouseout='turnOff(\"calImage\")'><img name='calImage' src='../img/client_buttons_off_01.gif' border='0' /></a>";
			elPics.innerHTML += "<a href='order.aspx' onmouseover='lightup(\"bookImage\")' onmouseout='turnOff(\"bookImage\")'><img name='bookImage' src='../img/client_buttons_off_02.gif' border='0' /></a>";
        }
    }
}

// Self-explanatory, but this function deletes the "loggedin" cookie, then reloads the page to its original layout
function siteLogout()
{
    delCookie('loggedin');
    delCookie('currPage');
    document.location.reload();
}

//	This function swaps the gray-background image links for white ones...
function lightup(imgName)
{
	if (document.images)
	{
		var imgOn = eval(imgName + "On.src");
		document[imgName].src = imgOn;
	}
}

//	This function changes the image links back to their original state
function turnOff(imgName)
{
	if (document.images)
	{
		var imgOff = eval(imgName + "Off.src");
		document[imgName].src = imgOff;
	}
}