// Fix Netscape resize bug

if(!window.saveInnerWidth) {
  window.onresize = resizeIt;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

function resizeIt() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.location.reload();
    }
}
// END Fix Netscape resize bug

function stylemastertable()
{
	//alert(screen.height)
	//alert(window.innerHeight)
	//alert(document.body.offsetHeight)
	//alert(document.body.scrollHeight)
	if (window.innerHeight)
	{
		if (document.body.scrollHeight <= window.innerHeight)
		{
			document.body.scroll="no";
		}
	}
	else
	{
		if (document.body.scrollHeight <= document.body.offsetHeight)
		{
			document.body.scroll="no";
		}
	}
	/*if (screen.width>1000)
	{
		for (kz=0; kz<document.getElementsByTagName("table").length; kz++)
		{
			if (document.getElementsByTagName("table")[kz].className=="bkgpage")
			{
				document.getElementsByTagName("table")[kz].className="bkgpageadri"
			}
		}
	}*/
}
function stylemastertablehome()
{
	if (window.innerHeight)
	{
		if (document.body.scrollHeight <= window.innerHeight)
		{
			document.body.scroll="no";
		}
	}
	else
	{
		if (document.body.scrollHeight <= document.body.offsetHeight)
		{
			document.body.scroll="no";
		}
	}
	/*if (screen.width>1000)
	{
		for (kz=0; kz<document.getElementsByTagName("table").length; kz++)
		{
			if (document.getElementsByTagName("table")[kz].className=="bkgpagehome")
			{
				document.getElementsByTagName("table")[kz].className="bkgpageadrihome"
			}
		}
	}*/
}
// Browser Sniffer

function check() {
// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav5, is_nav5up, 
//     is_nav6, is_nav6up, is_ie3, is_ie4, is_ie4up, is_ie5up, is_ie6...

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***

    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
       is_major = parseInt(is_minor);
    }

    var is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    var is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    var is_gecko = ((navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
    var is_gver  = 0;
    if (is_gecko) is_gver=navigator.productSub;

    var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                    (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                    (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                    (is_gecko) && 
                    ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Firefox")));
    if (is_moz) {
       var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
       if(!(is_moz_ver)) {
           is_moz_ver = agt.indexOf('rv:');
           is_moz_ver = agt.substring(is_moz_ver+3);
           is_paren   = is_moz_ver.indexOf(')');
           is_moz_ver = is_moz_ver.substring(0,is_paren);
       }
       is_minor = is_moz_ver;
       is_major = parseInt(is_moz_ver);
    }

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
                && (!(is_moz)));

    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    // Changed this to use navigator.vendor/vendorSub - dmr 060502   
    // var nav6Pos = agt.indexOf('netscape6');
    // if (nav6Pos !=-1) {
    if ((navigator.vendor)&&
        ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
        (is_nav)) {
       is_major = parseInt(navigator.vendorSub);
       // here we need is_minor as a valid float for testing. We'll
       // revert to the actual content before printing the result. 
       is_minor = parseFloat(navigator.vendorSub);
    }

    var is_opera = (agt.indexOf("opera") != -1);

    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && is_minor >= 4);  // changed to is_minor for
                                                // consistency - dmr, 011001
    var is_nav6   = (is_nav && is_major==6);    // new 010118 mhp
    var is_nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

    var is_nav5   = (is_nav && is_major == 5 && !is_nav6); // checked for ns6
    var is_nav5up = (is_nav && is_minor >= 5);

    var is_nav7   = (is_nav && is_major == 7);
    var is_nav7up = (is_nav && is_minor >= 7);

    var is_ie   = ((iePos!=-1) && (!is_opera));
    var is_ie3  = (is_ie && (is_major < 4));

    var is_ie4   = (is_ie && is_major == 4);
    var is_ie4up = (is_ie && is_minor >= 4);
    var is_ie5   = (is_ie && is_major == 5);
    var is_ie5up = (is_ie && is_minor >= 5);
    
    var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1)); // 020128 new - abk
    var is_ie5_5up =(is_ie && is_minor >= 5.5);                // 020128 new - abk
	
    var is_ie6   = (is_ie && is_major == 6);
    var is_ie6up = (is_ie && is_minor >= 6);

    var is_oldNS = (is_nav && is_minor < 6);
    var is_oldMSIE = (is_ie && is_minor < 5);
    var css_alt = (is_oldNS || is_oldMSIE || is_opera);

  return css_alt    
}

// Seleziona CSS per MSIE < 5 o per Netscape < 6
function selectcss(ambient,punti) {

  var stile = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/main_IE";
  var stile2 = "";
	if (ambient == "hp") {
    var stile2 = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/hp_IE.css'>";
  } else if (ambient == "ax") {
    var stile2 = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/ax_IE.css'>";
  } else if (ambient == "res") {
    var stile2 = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/res_IE.css'>";
  }
  
	if (check())  { //Netscape<6, IE<5, Opera 
    var stile = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/main_NS";
  	if (ambient == "hp") {
      var stile2 = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/hp_NS.css'>";
    } else if (ambient == "ax") {
      var stile2 = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/ax_NS.css'>";
    } else if (ambient == "res") {
      var stile2 = "<LINK REL=STYLESHEET TYPE='text/css' HREF='"+punti+"css/res_NS.css'>";
    }
  }

if (screen.width>1000 && stile.indexOf("css")!=-1) stile +="bis";
//if (screen.width>1000 && stile2.indexOf("css")!=-1) stile2 +="bis";

if (stile.indexOf("css")!=-1) stile +=".css'>";
//if (stile2.indexOf("css")!=-1) stile2 +=".css'>";
//alert(stile+"\r\n"+stile2)
  document.write(stile);
  document.write(stile2);
  
  return 
}


// Browser Utilities

var gAgent = window.navigator.userAgent;
var gAgentVers = parseInt(gAgent.charAt(gAgent.indexOf("/")+1),10);

function is_explorer()
{
	return gAgent.indexOf("MSIE") > 0;
}

// Rollover generico
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Rollover Utilities
// Almeno un elemento grafico, anche fittizzio, deve chiamarsi rollover0 altrimenti non carica le immagini!!!!
var gRollovers = new Object();
var NavMenu = new Object();
var gRolloversPath = "*";

function find_element(name,layer)
{	
	if (gAgentVers < 4) return document[name];
	var currentLayer = layer ? layer.document : document;
	var element = currentLayer[name];
	if (!element)
	{
		for (var i=0;i<currentLayer.layers.length;i++)
		{
			element = find_element(name,currentLayer.layers[i]);
			if (element) return element;
		}
	}
	return element;
}



function set_rollovers_path()
{
	gRolloversPath = '';
	if (document.images)
	{
		var img = (!is_explorer()) ? find_element('rollover0',0) : document['rollover0'];
		if (img)
		{
			var src = img.src
			var lastOffset = src.lastIndexOf('/');
			if (lastOffset != -1)
			{
				gRolloversPath = src.substr(0,lastOffset+1);
			}
		}
	}
}



function load_rollover(button)
{
	if (document.images && button.charAt(0) != '_' && button.substr(0,8) != 'rollover')
	{
		gRollovers[button] = new Object();
		gRollovers[button][0] = new Image();
		gRollovers[button][0].src = gRolloversPath + button + '_norm.gif';
		gRollovers[button][1] = new Image();
		gRollovers[button][1].src = gRolloversPath + button + '_over.gif';
	}
}



function load_all_rollovers()
{
	set_rollovers_path();
	if (document.images && gRolloversPath != '*')
		{
		var numImages = document.images.length;
		if (numImages > 0)
		{
			for (var i=0;i<numImages;i++)
			{
				if (document.images[i])
				{
					if (document.images[i].name) load_rollover(document.images[i].name);
				}
			}
		}
		
  	for (var i=0;i<5;i++)
		{
  		NavMenu['pointer' + i + '_up'] = new Image();
  		NavMenu['pointer' + i + '_up'].src = gRolloversPath + 'pointer' + i + '_up.gif';
  		NavMenu['pointer' + i + '_dn'] = new Image();
  		NavMenu['pointer' + i + '_dn'].src = gRolloversPath + 'pointer' + i + '_dn.gif';
  		NavMenu['hp_pointer' + i + '_dn'] = new Image();
  		NavMenu['hp_pointer' + i + '_dn'].src = gRolloversPath + 'hp_pointer' + i + '_dn.gif';
		}
		NavMenu['pointerax_up'] = new Image();
		NavMenu['pointerax_up'].src = gRolloversPath + 'pointerax_up.gif';
		NavMenu['hp_pointer_ax'] = new Image();
		NavMenu['hp_pointer_ax'].src = gRolloversPath + 'hp_pointer_ax.gif';
		}
}



function rollover(button,state)
{
	if (document.images && gRolloversPath != '*')
	{
		if (gRollovers[button])
		{
			var img = (!is_explorer()) ? find_element(button,0) : document[button];
			if (img) img.src = gRollovers[button][state].src;
			return true;
		}
	}
	return false;
}



function rollover_button(button,state)
{
	if (document.images && gRolloversPath != '*')
	{
		if (gRollovers[button])
		{
			var img = (!is_explorer()) ? find_element(button,0) : document[button];
			if (img) img.src = gRollovers[button][state].src;
			return true;
		}
	}
	return false;
}



function rollover_image(button,imageName,imageStatus)
{
	if (document.images && gRolloversPath != '*')
	{
		var img = (!is_explorer()) ? find_element(button,0) : document[button];
		if (img)
		{
			if (NavMenu[imageName])
			{
				img.src = NavMenu[imageName].src;
			}
			else
			{
				img.src = gRolloversPath + imageName + '.gif';
			}
    	if (!imageStatus) 
    	{
        window.status=defaultStatus;
			}
			else
			{
        window.status=imageStatus;
			}
			return true;
		}
	}
	return false;
}

// End Rollover Utilities------

var wlev = 0

function objwspec (theUrl,WinName,WinFeat,StatusMsg) {
        this.theUrl=theUrl
        this.WinName=WinName
        this.WinFeat=WinFeat
        this.StatusMsg=StatusMsg
}

function winPopUp(wname,wstring) { /* Finestre Pop Up */

  // ww = window.width      --> -1 : full-width
  // wh = window.height         -1 : full-height
  //
  // wx = window.x.position -->  l : left
  //                             r : right
  //                             c : center
  //                        number : coordinate
  //
  // wy = window.y.position -->  t : top
  //                             b : bottom
  //                             c : center
  //                        number : coordinate

  var wscroll = "yes"
  var wmbar   = "no"
  var wresize = "no"
  var wlocat  = "no"
  var wstatus = "no"
  var wtbar   = "no"

  if (wname == "calendario") {
      var ww   = 500
      var wh   = 550
      var wx   = "c"
      var wy   = "c"
  }

  if (wname == "news") {
      var ww   = 500
      var wh   = 550
      var wx   = "c"
      var wy   = "c"
  }

  if (wname == "credits") {
      var ww   = 400
      var wh   = 600
      var wx   = "c"
      var wy   = "c"
      wscroll  = "no"
  }
  
  if (wname == "chisiamo") {
      var ww   = 650
      var wh   = 350
      var wx   = "c"
      var wy   = "c"
      wscroll  = "no"
  }
  
  if (wname == "ABIFormazione") {
      var ww   = 500
      var wh   = 500
      var wx   = "c"
      var wy   = "c"

  }
  if (wname == "contatti") {
      //var ww   = 600
	  var ww   = 400
      //var wh   = 250
	  var wh   = 600
      var wx   = "c"
      var wy   = "c"
      //wscroll  = "no"
  }
  
  if (wname == "finanziata") {
      var ww   = 650
      var wh   = 350
      var wx   = "c"
      var wy   = "c"
      wscroll  = "no"
  }
  var wleft   = 0
  var wtop    = 0
  var wwidth  = ((ww == -1) ? screen.width : ww);
  var wheight = ((wh == -1) ? screen.height : wh);
  
  if (wx > -1 )   { wleft = wx }
  if (wx == "l" ) { wleft = 0 }
  if (wx == "r" ) { wleft = (screen.width - wwidth) }
  if (wx == "c" ) { wleft = (screen.width - wwidth)/2 }
  if (wy > -1 )   { wtop = wy }
  if (wy == "t" ) { wtop = 0 }
  if (wy == "b" ) { wtop = (screen.height - wheight) }
  if (wy == "c" ) { wtop = (screen.height - wheight)/2 }
 
  var wfeat  = 'scrollbars=' + wscroll + ',';
      wfeat += 'menubar=' + wmbar + ',';
      wfeat += 'resizable=' + wresize + ',';
      wfeat += 'location=' + wlocat + ',';
      wfeat += 'status=' + wstatus + ',';
      wfeat += 'toolbar=' + wtbar + ',';
      wfeat += 'width=' + wwidth + ',';
      wfeat += 'height=' + wheight + ',';
      wfeat += 'left=' + wleft + ',';
      wfeat += 'top=' + wtop;
      
  wspec = new objwspec(wstring, wname, wfeat);
  wWin = window.open(wspec.theUrl,wspec.WinName,wspec.WinFeat);
  //wWin.resizeTo(wwidth,wheight);
  //wWin.window.focus();
  wWin.focus();
}

// Finestra Pop Up Area Riservata
function openResarea(wname,wstring) { 

  var wwidth  = screen.width;
  var wheight = screen.height;
  var wleft   = 0;
  var wtop    = 0;
  var wmbar   = "yes";
  var wresize = "yes";
  var wlocat  = "yes";
  var wstatus = "yes";
  var wtbar   = "yes";
  var wscroll = "yes";

  var wfeat  = 'scrollbars=' + wscroll + ',';
      wfeat += 'menubar=' + wmbar + ',';
      wfeat += 'resizable=' + wresize + ',';
      wfeat += 'location=' + wlocat + ',';
      wfeat += 'status=' + wstatus + ',';
      wfeat += 'toolbar=' + wtbar + ',';
      wfeat += 'width=' + wwidth + ',';
      wfeat += 'height=' + wheight + ',';
      wfeat += 'left=' + wleft + ',';
      wfeat += 'top=' + wtop;
      
  wspec = new objwspec("", wname, wfeat);

  wRes = window.open(wspec.theUrl,wspec.WinName,wspec.WinFeat);
  wRes.resizeTo(wwidth,wheight); 
  if (!wRes.document.title) {
      wRes.location.href = wstring;
  }
  if (!wRes.opener) wRes.opener = self;
  wRes.window.focus();
}

function closeWindow() { 
  self.close();
}



// GET ACROBAT READER
function doAcrobat() {
  var s = ""
  s += "<table width=100% cellspacing=5 cellpadding=0 border=0>";
  s += "<tr>";
  s += "<td align=center><br><br><A HREF=\"http://www.adobe.com/products/acrobat/readstep.html\" target='_blank'><IMG SRC='images/getacro.gif' BORDER=0 HEIGHT=31 WIDTH=88><br></A></td>";
  s += "</tr>";
  s += "<tr>";
  s += "<td align=center class='funx'>";
  s += "Scarica qui la<br>versione aggiornata di<br>Adobe Acrobat Reader<br>";
  s += "</td>";
  s += "</tr>";
  s += "</table>";

  return s
}  

// Privacy
function privacy() {

	var prvpage = ""
  prvpage += "<TR><TD width=100% align=center valign=top>";
  prvpage += "<table cellspacing=0 cellpadding=0 border=0>";
  prvpage += "<tr><td align=center class='txt'>In relazione alla normativa vigente in tema di tutela della privacy di cui alla Legge N° 675/1996, i dati concessi verranno trattati conformemente alle disposizioni a fini statistici e per uso interno da ABISERVIZI S.p.A. – Divisione ABIFORMAZIONE, e non verranno ceduti a terzi.<br><br></td></tr>";
  prvpage += "</table>";
  prvpage += "</TD></TR>";

  return prvpage
}  

// Go back
function goback(amb,punti) {

  if ( !amb ) { amb = 0 }

 	var goback = ""
  goback += "<tr><td align=right valign=top class='funx'><br>";
  goback += "<table cellspacing=0 cellpadding=0 border=0>";
  goback += "<tr>";
  goback += "<td><img src='"+punti+"images/pointer0_up.gif' width=12 height=8 alt='' name='back99'></td>";
  goback += "<td class='funx'><a href=\"javascript:history.go(-1)\" onMouseOver=\"return rollover_image('back99','pointer" + amb + "_up',msgStatus[3])\" onMouseOut=\"return rollover_image('back99','pointer0_up')\">Back</a></td>";
  goback += "</tr>";
  goback += "</table>";
  goback += "</td></tr>";

  return goback
}  

// Go top page
function gotop(amb,num,punti) {

  if ( !num ) { num = '' }
  if ( !amb ) { amb = 0 }

 	var gotop = ""
  gotop += "<tr><td width=100% align=right valign=top>";
  gotop += "<table cellspacing=0 cellpadding=0 border=0>";
  gotop += "<tr><td class='spacetop' colspan=2><br></td></tr>";
  gotop += "<tr>";
 	gotop += "<td><img src='"+punti+"images/pointer0_up.gif' width=12 height=8 alt='' name='top" + num + "'></td>";
 	gotop += "<td class='funx'><a href=\"#\" onMouseOver=\"return rollover_image('top" + num + "','pointer" + amb + "_up',msgStatus[2])\" onMouseOut=\"return rollover_image('top" + num + "','pointer0_up')\">Top</a></td>";
  // 	gotop += "<td class='funx'><a href=\"" + location.pathname + "#\" onMouseOver=\"return rollover_image('top" + num + "','pointer" + amb + "_up',msgStatus[2])\" onMouseOut=\"return rollover_image('top" + num + "','pointer0_up')\">Top</a></td>";
 	gotop += "</tr>";
 	gotop += "</table>";
 	gotop += "</td></tr>";

  return gotop
}  

// Bottom page
function bottompage() {

	var botpage = ""
  botpage += "<TR><TD width=100% align=center valign=bottom colspan=5>";
  botpage += "<table cellspacing=0 cellpadding=0 border=0>";
  botpage += "<tr><td align=center class='cright'><br>Copyright © 2009 ABISERVIZI SpA. Tutti i diritti riservati.<br>E\' proibita la riproduzione, anche parziale, in qualsiasi forma senza espresso permesso scritto di ABISERVIZI SpA.</td></tr>";
  botpage += "</table>";
  botpage += "</TD></TR>";

  return botpage
}  

// Sostituisce icona se non è presente per quel tipo file
function checkImage(img,punti) {
    img.src = punti+"CMS/uploads/icone/tmp.gif";
}

// Cancel keystroke
function nokeystroke()
{
    window.event.returnValue = false;
}
//scritp di tracking per Google Analytics

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-8970471-1");
pageTracker._trackPageview();
} 
catch(err) {}
