<!--

// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

var HOST = 'livadas.com';
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
	
function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	}

	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

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(sName) {
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

// shows which style sheet is currently selected within group of radio buttons or select menu 
function indicateSelected(element){
	var i
	//if element is a radio button or select menu
	if (title!=null && (element.type==undefined || element.type=="select-one")){ 
		var element=(element.type=="select-one") ? element.options : element
		for (i=0; i<element.length; i++){
			//if match found between form element value and cookie value
			if (element[i].value==title){ 
				//if this is a select menu
				if (element[i].tagName=="OPTION") 
				element[i].selected=true
				//else if it's a radio button
				else 
				element[i].checked=true
				break
			}
		}
	}
}

window.onload = function(e) {
	var formref=document.getElementById("cssform")
	setActiveStyleSheet(title);
	indicateSelected(formref.cssselect)
}

window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}


// BEGIN FONT SELECTOR FUNCTIONS

var fontsize = readCookie("fontsize");
if (!fontsize) {
	var fontsize = .66;
}

function changeFontSize (fontsize) {
	createCookie("fontsize", fontsize, 365);
	self.location.href = self.location.href;
}

document.write('<style type="text/css">');
document.write('body#livadas {font-size:'+fontsize+'em;}');
document.write('<\/style>');



