// 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


// 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")));
    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(level) {

	if (level == "root") {
    var styleMSIE = "<LINK REL=STYLESHEET TYPE='text/css' HREF='styleIE.css'>";
    var styleNS   = "<LINK REL=STYLESHEET TYPE='text/css' HREF='styleNS.css'>";
  } else {
    var styleMSIE = "<LINK REL=STYLESHEET TYPE='text/css' HREF='../styleIE.css'>";
    var styleNS   = "<LINK REL=STYLESHEET TYPE='text/css' HREF='../styleNS.css'>";
  }

	if (check())  {
    return styleNS
  } else {
    return styleMSIE
  }  
}



// Rollover JavaScript functions relies on image replacement feature of JavaScript 1.1

function version() {
	var vs = navigator.appVersion
	var ndx = navigator.appVersion.lastIndexOf('(');
	if (ndx>=0) vs = vs.substring(0,ndx);
	return parseFloat(vs)
}

var iversion = version();

function rollon(imgName,imgFile,imgStatus) {
	if (3 <= iversion && imgName!='') {
        document[imgName].src = getBaseUrl(document[imgName].src)+imgFile+".gif";
        window.status=imgStatus;
    }
}

function rolloff(imgName,imgFile) {
	if (3 <= iversion && imgName!='') {
        document[imgName].src = getBaseUrl(document[imgName].src)+imgFile+".gif";
        window.status=defaultStatus;
    }
}

function getBaseUrl(imgSrc) {
	var ndx = imgSrc.lastIndexOf('/');
	if (ndx>=0) return imgSrc.substring(0,ndx+1);
	else return '';
}


// Window functions

var wlev = 0

function objwspec (theUrl,WinName,WinFeat,StatusMsg) {
        this.theUrl=theUrl
        this.WinName=WinName
        this.WinFeat=WinFeat
        this.StatusMsg=StatusMsg
}


function popupAx(wname,wlev) { /* Finestre accessori */

  // 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 wpath = (wlev == 1) ? "" : "../"; 
  var wscroll = "no"
  var wmbar   = "no"
  var wresize = "no"
  var wlocat  = "no"
  var wstatus = "no"
  var wtbar   = "no"

  if (wname == "AFcontatti") {
      var wfile="info_contatti/contatti.htm"
      var ww   = 630
      var wh   = 560
      var wx   = "c"
      var wy   = "c"
      wscroll  = "yes"
  }

  if (wname == "AFinfo") {
      var wfile="info_contatti/info.htm"
      var ww   = 600
      var wh   = 540
      var wx   = "c"
      var wy   = "c"
      wscroll  = "yes"
  }
  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(wpath + wfile, wname, wfeat);

  wWin = window.open(wspec.theUrl,wspec.WinName,wspec.WinFeat);
  wWin.resizeTo(wwidth,wheight); 
  wWin.window.focus();
}

function popupLic(idCourse) { /* Finestra pacchetti di licenze */

  if (idCourse != null) {
    
      var wwidth  = 400
      var wheight = 585
      var wleft   = ((screen.width - wwidth)/2);
      var wtop    = ((screen.height - wheight)/2);
      var wfeat  = 'scrollbars=no,menubar=no,resizable=no,location=no,status=no,toolbar=no,width=' + wwidth + ',';
          wfeat += 'height=' + wheight + ',';
          wfeat += 'left=' + wleft + ',';
          wfeat += 'top=' + wtop;
      
      wspec= new objwspec("licence.htm?" + idCourse, idCourse, wfeat);
      wWin = window.open(wspec.theUrl,wspec.WinName,wspec.WinFeat);
      wWin.resizeTo(wwidth,wheight); 
      wWin.window.focus();
      }
}


function apriGloss() { /* GLOSSARIO */
  	window.open("glossary/framegloss.htm","glossWindow","height=550,width=750,top=0,left=0,status=yes,resizable=no,toolbar=no") 
}