function setFontSize(value) {
theStyle = null;
if (value == "small") theStyle = "90%";
if (value == "medium") theStyle = "100%";
if (value == "large") theStyle = "110%";
if (theStyle) 
document.getElementsByTagName("body")[0].style.fontSize = theStyle;
} 
function vai_alla_pag(numpag)
{
	if ((numpag != 0) && (numpag != '') && (numpag))
	{
		var addr = document.location.href.split("/");
		var addr2 = addr[addr.length - 1];
		var ext   = addr2.split(".")[1];
		
		addr2 = strReverse(addr2);

		if (addr2.search(/-/g) > 0)
		{
			addr2 = addr2.substr(addr2.search(/-/g));
		}
		addr2 = strReverse(addr2) + numpag + "." + ext;
		
		document.location.href = addr2;
	}
}

function newWindow(address, width, height)
{
	window.open(address,"",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + width + ', height=' + height);
}

function strReverse(strToReverse)
{
	var strRev = new String;
	var i = strToReverse.length;
	
	while (i--)
		strRev += strToReverse.charAt(i);
	
	return strRev;
}

function imgZoom(path_img)
{
	window.open("/Zoom.asp?img=" + path_img,"",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
}

/*    Function        :DCgetCSS
**    Paramters       :oD     = document object
**                     szCSS  = string name of style class
**   (LA POTENZA E' NULLA SENZA CONTROLLO)
*/
function DCgetCSS(oD,szCSS)
{
	if((typeof oD.styleSheets)!='undefined')
	{
		for(xx=oD.styleSheets.length-1; xx>=0; xx--)
		{
			if(typeof oD.styleSheets[xx].cssRules !="undefined")
			{
				if(oD.styleSheets[xx].cssRules.item(szCSS))
				{
					return oD.styleSheets[xx].cssRules.item(szCSS).style;
				}
			}
			else
			{
				if((typeof oD.styleSheets[xx].rules)!='undefined')
				{
					if(oD.styleSheets[xx].rules.length)
					{
						for (ii=0; ii<oD.styleSheets[xx].rules.length; ii++)
						{
							if (oD.styleSheets[xx].rules[ii].selectorText == szCSS)
							{
								return oD.styleSheets[xx].rules.item(ii).style;
							}
						}
					}
				}
			}
		}
	}
	
	if(oD.classes)
	if(oD.classes[szCSS])return oD.classes[szCSS].all;
 
	alert("Impossibile accedere a " + szCSS)
	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;
}

function setCss(nomecss) {
try{
	var body = document.getElementsByTagName('body')[0];
	var css = "stile.css"; // default

	if (nomecss == 'N') css = "";
	if (nomecss == 'ST') 
	{
		css = "erap.css";
	}
	if (nomecss == 'AC') 
	{
		css = "erap_contrasto.css";
	
	}
	document.styleSheets[0].href='../css/' + css;
	createCookie('85',nomecss,365);
}
catch(e){}
}

window.onload = function() {
	size = readCookie('80');
	setFontSize(size);
	css=readCookie('70');
	setCss(css);
}
