<!--

var _MIN_FONT_HEIGHT_   =  8;
var _MAX_FONT_HEIGHT_   = 24;
var _DELTA_FONT_HEIGHT_ =  2;
var _STD_FONT_HEIGHT_   = 10;

var __WAI_currentFontHeight__ = _STD_FONT_HEIGHT_;
var __WAI_currentStyleSheet__ = "grafica";


function WAI_getStyleSheetParentElement(oStyleSheet)
{
	return document.all ? oStyleSheet.owningElement : oStyleSheet.ownerNode;
}

function WAI_getStyleSheetRules(oStyleSheet)
{
	return document.all ? oStyleSheet.rules : oStyleSheet.cssRules;
}

function WAI_setStyleData(oStyleData)
{
	var oStyleSheets = document.styleSheets;

	var oStyleSheet, oRule, iNewHeight, oRule1 = null, oRule2 = null;
	for(var i = 0; i < oStyleSheets.length; i++)
	{
		oStyleSheet = oStyleSheets.item(i);
		if(WAI_getStyleSheetParentElement(oStyleSheet).tagName.toLowerCase() != 'link')
			continue;
			
		var bLoop = true;
		var oRules = WAI_getStyleSheetRules(oStyleSheet);
		for(var n = 0; bLoop && n < oRules.length; n++)
		{
			oRule = oRules.item(n);
			
			switch(oStyleData.action)
			{
/*
				case "replace":
					if(oRule.selectorText == oStyleData.find)		oRule1 = oRule;
					if(oRule.selectorText == oStyleData.replace)	oRule2 = oRule;
					
					if(oRule1 != null && oRule2 != null)
					{
						WAI_replaceStyleSheet(oRule1.style, oRule2.style);
						bLoop = false;
					}
					break;
*/
				case "fontHeight":
					oRule = oRule.style;
					if(oRule.fontSize != null && oRule.fontSize != "")
					{
						if(oStyleData.delta)
						{
							iNewHeight = parseFloat(oRule.fontSize) + oStyleData.delta;
							if(iNewHeight > _MIN_FONT_HEIGHT_ && iNewHeight <= _MAX_FONT_HEIGHT_)
							{
								oRule.fontSize = iNewHeight + "px";
								__WAI_currentFontHeight__ = iNewHeight;
							}
						}
						else // if(oStyleData.height)
						{
							oRule.fontSize = oStyleData.height + "px";
							__WAI_currentFontHeight__ = oStyleData.height;
						}
					}
					
					break;
			}
		}
	}

	saveToCookie("WAIfh",  __WAI_currentFontHeight__);
}
/*
function WAI_replaceStyleSheet(oStyleFind, oStyleReplace)
{
	var sProperties = ["backgroundColor", "color"];
	
	for(var i in sProperties)
	{
		sPropName  = sProperties[i];
		sPropValue = eval("oStyleReplace." + sPropName);
		eval("oStyleFind." + sPropName + "=sPropValue;");
	}
}
*/
/********************************************************************************************\
	funzioni presenti nelle pagine
\********************************************************************************************/

function WAI_aumentaFont()
{
	WAI_setStyleData({action:"fontHeight",delta:_DELTA_FONT_HEIGHT_});
}

function WAI_diminuisciFont()
{
	document.body.style.fontSize = (parseFloat(document.body.style.fontSize) - _DELTA_FONT_HEIGHT_) + "px";
	WAI_setStyleData({action:"fontHeight",delta:-_DELTA_FONT_HEIGHT_});
}

function WAI_standardFont()
{
	document.body.style.fontSize = _STD_FONT_HEIGHT_ + "px";
	WAI_setStyleData({action:"fontHeight",height:_STD_FONT_HEIGHT_});
}

function WAI_setLayout(sStyleSheetTitle, sTagName)
{
	var oColl = document.getElementsByTagName(sTagName)
	for(var i = 0; i < oColl.length; i++)
	{
		var oEl = oColl[i];

		if(oEl.style.prevStyle)
			oEl.style.cssText = oEl.style.prevStyle;

		if(/^solotesto$|^altocontrasto$/i.test(sStyleSheetTitle))
		{
			oEl.style.prevStyle = oEl.style.cssText;

			oEl.style.backgroundImage = "";

			if(sStyleSheetTitle == "altocontrasto" && !/^intestazione_pagina$|^menu_pagina$|^corpo_pagina$/i.test(oEl.className))

			{
				oEl.style.backgroundColor = "";
				oEl.style.border          = "none";
			}
		}
	}
}

function WAI_activateStyleSheet(sStyleSheetTitle, bForce)
{
	saveToCookie("WAIcss", sStyleSheetTitle);

	if(!bForce && sStyleSheetTitle == "grafica")
	{
		window.location.reload();
		return;
	}

	var oStyleSheets = document.getElementsByTagName("link");

	var oStyleSheet;
	for(var i = 0; i < oStyleSheets.length; i++)
	{
		oStyleSheet = oStyleSheets.item(i);
		if(oStyleSheet.getAttribute("rel").indexOf("alternate") == -1)
			continue;
		
		oStyleSheet.disabled = true;
		oStyleSheet.disabled = oStyleSheet.getAttribute("title").toLowerCase() != sStyleSheetTitle.toLowerCase();

		if(!oStyleSheet.disabled)
			__WAI_currentStyleSheet__ = sStyleSheetTitle;
	}


	WAI_setLayout(sStyleSheetTitle, "table");
	WAI_setLayout(sStyleSheetTitle, "tr");
	WAI_setLayout(sStyleSheetTitle, "td");

	WAI_replaceImgLink();
}

function WAI_replaceImgLink()
{
	var oParent, oParentAllowed = /^a$/i;

	var oColl = document.getElementsByTagName("img");
	for(var i = oColl.length - 1; i >= 0; i--)
	{
		oParent = oColl[i].parentNode;
		if(oParent && oParentAllowed.test(oParent.tagName))
			oParent.innerHTML = "<span class='testoverde'>[" + oColl[i].alt + "]</span><br />";
	}
}

/*
function WAI_getActivateStyleSheet()
{	

	var oStyleSheets = document.getElementsByTagName("link");

	var oStyleSheet;
	for(var i = 0; i < oStyleSheets.length; i++)
	{
		oStyleSheet = oStyleSheets.item(i);
		if(oStyleSheet.getAttribute("rel").indexOf("alternate") == -1)
			continue;
		
		if(!oStyleSheet.disabled)
			return oStyleSheet.getAttribute("title");
	}
	
	return "";
}
*/


function WGI_saveCfg()
{
//	saveToCookie("WAIcss", __WAI_currentStyleSheet__);
//	saveToCookie("WAIfh",  __WAI_currentFontHeight__);
}
	
function WGI_loadCfg()
{
	try
	{
		__WAI_currentStyleSheet__ = getFromCookie("WAIcss", __WAI_currentStyleSheet__);
		__WAI_currentFontHeight__ = parseFloat(getFromCookie("WAIfh", "" + __WAI_currentFontHeight__));

		if(__WAI_currentStyleSheet__ == "grafica")
		{
			WAI_setStyleData({action:"fontHeight",height:__WAI_currentFontHeight__});
			WAI_activateStyleSheet(__WAI_currentStyleSheet__, true);
		}
	}
	catch(e)
	{
alert(e.message);
	}
}


function WGI_restoreLayoutDocument()
{
	try
	{
		document.body.style.fontSize = __WAI_currentFontHeight__ + "px";

		if(__WAI_currentStyleSheet__ != "grafica")
		{
			if(__WAI_currentFontHeight__ != _STD_FONT_HEIGHT_)
				WAI_setStyleData({action:"fontHeight",height:__WAI_currentFontHeight__});

			WAI_activateStyleSheet(__WAI_currentStyleSheet__);
		}

		document.body.style.visibility = "visible";
	}
	catch(e)
	{
		alert(e.message);
	}
}

function WGI_keypress(oEvent)
{
	var bConsumed = false;

	if(oEvent.altKey)
	{
		switch(oEvent.keyCode - 48)
		{
			case 1:	// ALT + 1
				window.location = 'home.xml';
				bConsumed = true;
				break;

			case 2:	// ALT + 2
				window.location = '../it/home.xml';
				bConsumed = true;
				break;

			case 3:	// ALT + 3
				window.location = '../de/home.xml';
				bConsumed = true;
				break;

			case 5:	// ALT + 5
				WAI_standardFont()
				bConsumed = true;
				break;

			case 6:	// ALT + 6
				WAI_aumentaFont()
				bConsumed = true;
				break;

			case 7:	// ALT + 7
				WAI_diminuisciFont()
				bConsumed = true;
				break;

			case 8:	// ALT + 8
				WAI_activateStyleSheet('altocontrasto');
				bConsumed = true;
				break;

			case 9:	// ALT + 9
				WAI_activateStyleSheet('solotesto');
				bConsumed = true;
				break;

			case 0:	// ALT + 0
				WAI_activateStyleSheet('grafica');
				bConsumed = true;
				break;
		}
	}

	if(bConsumed)
		CrossBrowser.stopEvent(oEvent);
}

CrossBrowser.addEvent(document, "keydown", WGI_keypress);
CrossBrowser.addEvent(document, "unload",  WGI_saveCfg);
CrossBrowser.addEvent(window,   "load",    WGI_restoreLayoutDocument);

WGI_loadCfg();
-->