//
// http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1950641247
//
function recorrerTag(tag,theProp,theValue){ // tag es un Node
	if(tag.nodeType==1){ // Element
		eval("tag."+theProp+"="+theValue);
		tag = tag.firstChild;
		while(tag){
			recorrerTag(tag,theProp,theValue);
			tag = tag.nextSibling;
		}
	}
	else if(tag.nodeType==3){ // Text
		//alert(tag.nodeValue);
	}
}

function recorrerTags(name,idbeginning,theProp,theValue){
	var bodys = document.getElementsByTagName('body');
	var spans = bodys.item(0).getElementsByTagName(name);
	for(i=0;i<spans.length;i++){
		// si el nombre del span comienza por contentText, lo proceso
		var span = spans.item(i);
		if(span.nodeType == 1){
			var attrs = span.attributes;
			if(attrs.getNamedItem('id').nodeValue.indexOf(idbeginning) == 0){
				recorrerTag(span,theProp,theValue);
			}
		}
	}
}

// FONT SIZE MANAGEMENT
function LoadActualFontSize() {
	tempArray = document.cookie.split(";");
	for (tA = 0; tA < tempArray.length; tA++){
		if (tempArray[tA].indexOf('fontSize') > -1){
			fontSizeValue = tempArray[tA].split("=")
			ACTUAL_FONTSIZE = parseInt(fontSizeValue[1]);
		}
	}
}
function SaveActualFontSize() {
	var expire = new Date ();
	expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
	expire = expire.toGMTString();
	document.cookie="fontSize="+ACTUAL_FONTSIZE+"; path=/; expires="+expire;
}
function BiggerText() {
	ACTUAL_FONTSIZE = ACTUAL_FONTSIZE+1;
	
	if (ACTUAL_FONTSIZE > LARGEST_FONTSIZE) { ACTUAL_FONTSIZE = LARGEST_FONTSIZE }
	recorrerTags('span','contentText','style.fontSize',ACTUAL_FONTSIZE);
	SaveActualFontSize();
}
function SmallerText() {
	ACTUAL_FONTSIZE = ACTUAL_FONTSIZE-1
	if (ACTUAL_FONTSIZE < SMALLEST_FONTSIZE) { ACTUAL_FONTSIZE = SMALLEST_FONTSIZE }
	recorrerTags('span','contentText','style.fontSize',ACTUAL_FONTSIZE);
	SaveActualFontSize();
}
ACTUAL_FONTSIZE = 12;
SMALLEST_FONTSIZE = 9;
LARGEST_FONTSIZE = 18;