<!--//--><![CDATA[//><!--

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
} 

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
} 

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

function validateSearch(myForm) {
	if(myForm.zoom_query.value == "") {
		alert("Please enter a search phrase");
		return false;
	} else {
		return true;
	}
}

function changeTextSize(textSize) {
	document.body.className = 'site ' + textSize;
	window.frames[0].document.body.className = 'site ' + textSize;
	return false;
}

function printPage() {
	window.print();
	return false;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function bookmarkPage(title){
	if (navigator.appName=='Microsoft Internet Explorer')
		window.external.AddFavorite("http://www.spoce.com", title);
	else
		alert("Please hit CTRL+D to add a bookmark to this site");
	return false;
}

function addOnloads() {
	var sfEls = document.getElementById("accessButtons").getElementsByTagName("a");
	for (var i=0; i<sfEls.length; i++) {
		if(sfEls[i].id == "printToolbar") {
			sfEls[i].onclick=function() {
				return printPage();
			}		
		}
		if(sfEls[i].id == "bookmarkToolbar") {
			sfEls[i].onclick=function() {
				return bookmarkPage(document.title);
			}		
		}
		if(sfEls[i].id == "smallTxtToolbar") {
			sfEls[i].onclick=function() {
				return changeTextSize('smallText');
			}		
		}
		if(sfEls[i].id == "mediumTxtToolbar") {
			sfEls[i].onclick=function() {
				return changeTextSize('mediumText');
			}		
		}
		if(sfEls[i].id == "largeTxtToolbar") {
			sfEls[i].onclick=function() {
				return changeTextSize('largeText');
			}		
		}		
	}
}

window.onload = function() {
	addOnloads();
}

window.onunload = function(e) {
	var textSize = document.body.className.split(' ')[1];
	createCookie('style', textSize, 365);
}
//--><!]]>