/*
Menu for Internal Purposes Only
*** Delete this code before launch
====================================================================*/
/*
pages = new Array(
	'=== Select a Template ===','#',
	'Home','index.html',
	'Subpage 2 Column','subpage_2col_NEW.html',
	'Subpage 3 Column - Landing Page Example','subpage_3col_NEW.html',
	'Subpage showing For Companies colors','subpage_2col_forCompanies.html',
	'','#',
	'* Locations','locations.html',
	'* Health Tools','healthTools.html',
	'* Contact','contact.html',
	'* News Room','newsroom.html',
	'* Testimonials','testimonials.html',
	'* Campus Map','campusMap.html',
	'* History','history.html',
	'* Careers','careers.html',
	'* Guest Rooms','guestRooms.html',
	'* Meeting Spaces','meetingSpaces.html',
	'* Health Tips/Recipes','healthTips.html'
)
function insiteMenu(){
	var container = document.createElement("div");
		container.setAttribute("style","display:block; width:100%; z-index:100; position:absolute; left:0; top:0; text-align:center;");
	var list = document.createElement("select");
		list.setAttribute("id","insiteSelect");
		list.setAttribute("onchange","location.href=this.options[this.selectedIndex].value");
		list.setAttribute("style","background:#369; color:#fff; border:1px solid #369;");
	for (i=0; i<pages.length;i+=2){
		// Get current page
		var page = location.href;
		page = page.substring(page.lastIndexOf("/")+1)
		// Build Options
		var title = pages[i];
		var href = pages[i+1];
		var list_item = document.createElement("option");
		var newLink = document.createElement("a");
			newLink.setAttribute("href",href)
		list_item.setAttribute("value",newLink);
		if(href == page) {
			list_item.setAttribute("selected",true);
		}
		var list_item_text = document.createTextNode(title);
		list_item.appendChild(list_item_text);
		list.appendChild(list_item);
	}
	container.appendChild(list);
	var outer = document.getElementById("outer-header");
	outer.parentNode.insertBefore(container,outer)
}
addLoadEvent(insiteMenu);
*/
/* 
Text Size Change toggle
====================================================================*/
function changeTextSize(){
	if(!document.getElementById) return;
	if(!document.getElementById('textsizeLink')) return;
	
	document.getElementById('textsizeLink').onclick = function(){
		cur = getActiveStyleSheet();
		if(cur != "largeFont"){
			setActiveStyleSheet('largeFont');
		}
		else {
			setActiveStyleSheet('default');
		}
	}
}
addLoadEvent(changeTextSize);

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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;
}

/*window.onload = function(e) {*/
function cookieSetup(){
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
addLoadEvent(cookieSetup);

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



/* 
Adds functions to onload event
====================================================================*/
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){window.onload = func;}
	else{window.onload = function(){oldonload(); func();}}
}