if (document.getElementById && document.getElementsByTagName && document.createElement) {
	// read the cookie to get the proper font family, set to default Verdana if a first timer
	ff = readCookie('fontFamily');
	if (ff=='') ff='Verdana, Arial, Helvetica, sans-serif';

	// read the cookie to get the proper font size, set to default 12 if a first timer
	fs = parseInt(readCookie('fontSize'));
	if (!fs>0) fs=12;

	// set the appropriate font sizes for the relevant HTML elements
	// any other elements that you want to have a changeable font size must be added to this list
	// in the form "element_fs" and then also added to the setSizes and changeType functions
	var body_fs;

	setSizes();

	//De style switcher:
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);

	// lets write out styles with the changeable values that we get from the cookies
	// and the random rgb values. This will make the page display
	document.writeln('<style type="text/css">');
	document.writeln('body{font-size:'+body_fs+'px;}');
	document.writeln('body{font-family:'+ff+';}');
	document.writeln('<\/style>');
	}

// called from body onload
function init() {
	changeType();
	}
	
// this changes the sizes of the various elements relative to the fs
function setSizes() {
	body_fs = fs
}

function changeType() {
	if (!document.getElementsByTagName) {return false;} // unclean! unclean!
	// because NS6 seems to freak out on abs. positionined divs
	// when you change a style property of the body, we have to
	// set the fontFamily and fontSize on div elements and not the body
	setStyleByTag('div','fontFamily',ff);
	setStyleByTag('div','fontSize',body_fs+'px');
	
	// store these values in cookies for subsequent page loads
	writeCookie('fontSize',fs);
	writeCookie('fontFamily',ff);
	}

// funcion que llama el boton A+
function increaseSize() {
	if(body_fs<16){
	    fs+=1; setSizes(); changeType();
	}    
}

function increaseSize(n) {
	if(body_fs<16){
	    if (n==1){
			fs=10; setSizes(); changeType();
		}
	    if (n==2){
			fs=11; setSizes(); changeType();
		}
	    if (n==3){
			fs=12; setSizes(); changeType();
		}
	}    
}

// funcion que llama el boton A- 
function decreaseSize() {
	if (body_fs>10) {
	     fs-=1; setSizes(); changeType();
	}
}


// cookie functions modified from code found at Alexei Kourbatov's javascripter.net/faq/
function writeCookie(cookieName,cookieValue) {
	var today = new Date();
	var expire = new Date();
	expire.setTime(today.getTime() + 3600000*24*3000);
	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
	}
	
function readCookie(cookieName) {
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="") return ""; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
	}

// thanks to randomwalks.com for this code
function targetLinks(boNew) {
	if (boNew) 
		where = "_blank";
	else
		where = "_self";
	for (var i=0; i<=(document.links.length-1); i++) {
		document.links[i].target = where;
	}
}

// These 2 setstyle functions were modified from code by Steven Champeon found at
// http://developer.apple.com/internet/_javascript/styles.html

// setStyleByTag: given an element type, style property and value
// args:
//  e - element type or id
//  p - property
//  v - value
function setStyleByTag(e, p, v) {
	var elements = document.getElementsByTagName(e);
	for(var i = 0; i < elements.length; i++) {
		elements.item(i).style[p] = v;
	}
}


/*StyleSwitcher*/

function setActiveStyleSheet(title) {
	var a;
	for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
	if (getActiveStyleSheet() == null) {
		title = getPreferredStyleSheet();
		if (title != null) setActiveStyleSheet(title, true);
	}
	writeCookie("style",title);
}

function getActiveStyleSheet() {
	var a;
	for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getPreferredStyleSheet() {
	var a;
	for (var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) return a.getAttribute("title");
	}
	return null;
}


function start(e) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
}

